From 9974423e2bdc474bb53cd9e3eb546ce7348634e5 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 18 Jun 2015 20:28:40 +0300 Subject: [PATCH 001/450] Disable performance time counters by default --- .../cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 1 + .../src/org/jetbrains/kotlin/util/PerformanceCounter.kt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 5c6fde64d83..e3562a67f17 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -61,6 +61,7 @@ public open class K2JVMCompiler : CLICompiler() { PathUtil.getKotlinPathsForCompiler() messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Using Kotlin home directory " + paths.getHomePath(), CompilerMessageLocation.NO_LOCATION) + PerformanceCounter.setTimeCounterEnabled(arguments.reportPerf); val configuration = CompilerConfiguration() configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageSeverityCollector) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt index a48fd1b7627..32c1d8fba35 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt @@ -26,6 +26,8 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val private val enteredCounters = ThreadLocal>() + private var enabled = false + init { threadMxBean.setThreadCpuTimeEnabled(true) } @@ -52,6 +54,10 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val } countersCopy.forEach { it.report(consumer) } } + + public fun setTimeCounterEnabled(enable: Boolean) { + enabled = enable + } } private var count: Int = 0 @@ -69,6 +75,8 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val public fun time(block: () -> T): T { count++ + if (!enabled) return block() + val needTime = !reenterable || enterCounter(this) val startTime = currentThreadCpuTime() try { From d830729ddbdf03db1bfd192bf8a5935144c8d72c Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 18 Jun 2015 20:56:57 +0300 Subject: [PATCH 002/450] change creation of performance counters --- .../kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt | 2 +- .../jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt | 2 +- .../org/jetbrains/kotlin/resolve/calls/CallResolver.java | 4 ++-- .../src/org/jetbrains/kotlin/util/PerformanceCounter.kt | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt index b5b21ba5f29..300839c8138 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinCliJavaFileManagerImpl.kt @@ -36,7 +36,7 @@ import kotlin.properties.Delegates public class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJavaFileManager(myPsiManager), KotlinCliJavaFileManager { - private val perfCounter = PerformanceCounter("Find Java class") + private val perfCounter = PerformanceCounter.create("Find Java class") private var index: JvmDependenciesIndex by Delegates.notNull() public fun initIndex(packagesCache: JvmDependenciesIndex) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt index ea3226f0f8a..81cb027b552 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/VirtualFileKotlinClass.kt @@ -51,7 +51,7 @@ public class VirtualFileKotlinClass private constructor( companion object Factory { private val LOG = Logger.getInstance(javaClass()) - private val perfCounter = PerformanceCounter("Binary class from Kotlin file") + private val perfCounter = PerformanceCounter.create("Binary class from Kotlin file") deprecated("Use KotlinBinaryClassCache") fun create(file: VirtualFile): VirtualFileKotlinClass? { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index f0eecb9209a..385e72e4201 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -74,8 +74,8 @@ public class CallResolver { private TaskPrioritizer taskPrioritizer; private AdditionalCheckerProvider additionalCheckerProvider; - private static final PerformanceCounter callResolvePerfCounter = new PerformanceCounter("Call resolve", true); - private static final PerformanceCounter candidatePerfCounter = new PerformanceCounter("Call resolve candidate analysis", true); + private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", true); + private static final PerformanceCounter candidatePerfCounter = PerformanceCounter.Companion.create("Call resolve candidate analysis", true); @Inject public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt index 32c1d8fba35..216dd5c530d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.util import java.lang.management.ManagementFactory import java.util.concurrent.TimeUnit -public class PerformanceCounter jvmOverloads constructor (val name: String, val reenterable: Boolean = false) { +public class PerformanceCounter private constructor (val name: String, val reenterable: Boolean = false) { companion object { private val threadMxBean = ManagementFactory.getThreadMXBean() private val allCounters = arrayListOf() @@ -58,6 +58,10 @@ public class PerformanceCounter jvmOverloads constructor (val name: String, val public fun setTimeCounterEnabled(enable: Boolean) { enabled = enable } + + public jvmOverloads fun create(name: String, reentable: Boolean = false): PerformanceCounter { + return PerformanceCounter(name, reentable) + } } private var count: Int = 0 From 45a3d7ec46d4c3047878c831bb7688d487a0fb86 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 18 Jun 2015 21:18:54 +0300 Subject: [PATCH 003/450] Create performance counter with excluded counters --- .../kotlin/resolve/calls/CallResolver.java | 3 +- .../ExpressionTypingVisitorDispatcher.java | 93 +++++----- .../kotlin/util/PerformanceCounter.kt | 167 ++++++++++++++---- 3 files changed, 190 insertions(+), 73 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 385e72e4201..befe4e08b78 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -48,6 +48,7 @@ import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeSubstitutor; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; +import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher; import org.jetbrains.kotlin.types.expressions.OperatorConventions; import org.jetbrains.kotlin.util.PerformanceCounter; @@ -74,7 +75,7 @@ public class CallResolver { private TaskPrioritizer taskPrioritizer; private AdditionalCheckerProvider additionalCheckerProvider; - private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", true); + private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", ExpressionTypingVisitorDispatcher.typeInfoPerfCounter); private static final PerformanceCounter candidatePerfCounter = PerformanceCounter.Companion.create("Call resolve candidate analysis", true); @Inject diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java index 2230f498232..48a22d06915 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types.expressions; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; +import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.diagnostics.DiagnosticUtils; @@ -30,6 +31,7 @@ import org.jetbrains.kotlin.types.DeferredType; import org.jetbrains.kotlin.types.ErrorUtils; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryPackage; +import org.jetbrains.kotlin.util.PerformanceCounter; import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException; import org.jetbrains.kotlin.utils.KotlinFrontEndException; @@ -38,6 +40,8 @@ import static org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtil public class ExpressionTypingVisitorDispatcher extends JetVisitor implements ExpressionTypingInternals { + public static final PerformanceCounter typeInfoPerfCounter = PerformanceCounter.Companion.create("Type info", true); + public interface StatementVisitorProvider { ExpressionTypingVisitorForStatements get(@NotNull ExpressionTypingContext context); } @@ -161,50 +165,55 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor visitor) { - try { - JetTypeInfo recordedTypeInfo = BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext()); - if (recordedTypeInfo != null) { - return recordedTypeInfo; - } - JetTypeInfo result; - try { - result = expression.accept(visitor, context); - // Some recursive definitions (object expressions) must put their types in the cache manually: - //noinspection ConstantConditions - if (context.trace.get(BindingContext.PROCESSED, expression)) { - JetType type = context.trace.getBindingContext().getType(expression); - return result.replaceType(type); - } + private static JetTypeInfo getTypeInfo(@NotNull final JetExpression expression, final ExpressionTypingContext context, final JetVisitor visitor) { + return typeInfoPerfCounter.time(new Function0() { + @Override + public JetTypeInfo invoke() { + try { + JetTypeInfo recordedTypeInfo = BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext()); + if (recordedTypeInfo != null) { + return recordedTypeInfo; + } + JetTypeInfo result; + try { + result = expression.accept(visitor, context); + // Some recursive definitions (object expressions) must put their types in the cache manually: + //noinspection ConstantConditions + if (context.trace.get(BindingContext.PROCESSED, expression)) { + JetType type = context.trace.getBindingContext().getType(expression); + return result.replaceType(type); + } - if (result.getType() instanceof DeferredType) { - result = result.replaceType(((DeferredType) result.getType()).getDelegate()); - } - context.trace.record(BindingContext.EXPRESSION_TYPE_INFO, expression, result); - } - catch (ReenteringLazyValueComputationException e) { - context.trace.report(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM.on(expression)); - result = TypeInfoFactoryPackage.noTypeInfo(context); - } + if (result.getType() instanceof DeferredType) { + result = result.replaceType(((DeferredType) result.getType()).getDelegate()); + } + context.trace.record(BindingContext.EXPRESSION_TYPE_INFO, expression, result); + } + catch (ReenteringLazyValueComputationException e) { + context.trace.report(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM.on(expression)); + result = TypeInfoFactoryPackage.noTypeInfo(context); + } - context.trace.record(BindingContext.PROCESSED, expression); - recordScopeAndDataFlowInfo(context.replaceDataFlowInfo(result.getDataFlowInfo()), expression); - return result; - } - catch (ProcessCanceledException e) { - throw e; - } - catch (KotlinFrontEndException e) { - throw e; - } - catch (Throwable e) { - context.trace.report(Errors.EXCEPTION_FROM_ANALYZER.on(expression, e)); - logOrThrowException(expression, e); - return TypeInfoFactoryPackage.createTypeInfo( - ErrorUtils.createErrorType(e.getClass().getSimpleName() + " from analyzer"), - context - ); - } + context.trace.record(BindingContext.PROCESSED, expression); + recordScopeAndDataFlowInfo(context.replaceDataFlowInfo(result.getDataFlowInfo()), expression); + return result; + } + catch (ProcessCanceledException e) { + throw e; + } + catch (KotlinFrontEndException e) { + throw e; + } + catch (Throwable e) { + context.trace.report(Errors.EXCEPTION_FROM_ANALYZER.on(expression, e)); + logOrThrowException(expression, e); + return TypeInfoFactoryPackage.createTypeInfo( + ErrorUtils.createErrorType(e.getClass().getSimpleName() + " from analyzer"), + context + ); + } + } + }); } private static void logOrThrowException(@NotNull JetExpression expression, Throwable e) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt index 216dd5c530d..96ebd30ca8d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt @@ -17,35 +17,20 @@ package org.jetbrains.kotlin.util import java.lang.management.ManagementFactory +import java.util.* import java.util.concurrent.TimeUnit -public class PerformanceCounter private constructor (val name: String, val reenterable: Boolean = false) { +public abstract class PerformanceCounter protected constructor(val name: String) { companion object { private val threadMxBean = ManagementFactory.getThreadMXBean() private val allCounters = arrayListOf() - private val enteredCounters = ThreadLocal>() - private var enabled = false init { threadMxBean.setThreadCpuTimeEnabled(true) } - private fun enterCounter(counter: PerformanceCounter): Boolean { - var enteredCountersInThread = enteredCounters.get() - if (enteredCountersInThread == null) { - enteredCountersInThread = hashSetOf(counter) - enteredCounters.set(enteredCountersInThread) - return true - } - return enteredCountersInThread.add(counter) - } - - private fun leaveCounter(counter: PerformanceCounter) { - enteredCounters.get()?.remove(counter) - } - public fun currentThreadCpuTime(): Long = threadMxBean.getCurrentThreadUserTime() public fun report(consumer: (String) -> Unit) { @@ -59,13 +44,29 @@ public class PerformanceCounter private constructor (val name: String, val reent enabled = enable } - public jvmOverloads fun create(name: String, reentable: Boolean = false): PerformanceCounter { - return PerformanceCounter(name, reentable) + public jvmOverloads fun create(name: String, reenterable: Boolean = false): PerformanceCounter { + return if (reenterable) + ReenterableCounter(name) + else + SimpleCounter(name) + } + + public fun create(name: String, vararg excluded: PerformanceCounter): PerformanceCounter = CounterWithExclude(name, *excluded) + + protected inline fun getOrPut(threadLocal: ThreadLocal, default: () -> T) : T { + var value = threadLocal.get() + if (value == null) { + value = default() + threadLocal.set(value) + } + return value } } + protected val excludedFrom: MutableList = ArrayList() + private var count: Int = 0 - private var totalTimeNanos: Long = 0 + protected var totalTimeNanos: Long = 0 init { synchronized(allCounters) { @@ -73,27 +74,25 @@ public class PerformanceCounter private constructor (val name: String, val reent } } - public fun increment() { + public final fun increment() { count++ } - public fun time(block: () -> T): T { + public final fun time(block: () -> T): T { count++ if (!enabled) return block() - val needTime = !reenterable || enterCounter(this) - val startTime = currentThreadCpuTime() + excludedFrom.forEach { it.enterExcludedMethod() } try { - return block() + return countTime(block) } finally { - if (needTime) { - totalTimeNanos += currentThreadCpuTime() - startTime - if (reenterable) leaveCounter(this) - } + excludedFrom.forEach { it.exitExcludedMethod() } } } + protected abstract fun countTime(block: () -> T): T + public fun report(consumer: (String) -> Unit) { if (totalTimeNanos == 0L) { consumer("$name performed $count times") @@ -103,4 +102,112 @@ public class PerformanceCounter private constructor (val name: String, val reent consumer("$name performed $count times, total time $millis ms") } } -} \ No newline at end of file +} + +private class SimpleCounter(name: String): PerformanceCounter(name) { + override fun countTime(block: () -> T): T { + val startTime = PerformanceCounter.currentThreadCpuTime() + try { + return block() + } + finally { + totalTimeNanos += PerformanceCounter.currentThreadCpuTime() - startTime + } + } +} + +private class ReenterableCounter(name: String): PerformanceCounter(name) { + companion object { + private val enteredCounters = ThreadLocal>() + + private fun enterCounter(counter: ReenterableCounter) = PerformanceCounter.getOrPut(enteredCounters) { HashSet() }.add(counter) + + private fun leaveCounter(counter: ReenterableCounter) { + enteredCounters.get()?.remove(counter) + } + } + + override fun countTime(block: () -> T): T { + val startTime = PerformanceCounter.currentThreadCpuTime() + val needTime = enterCounter(this) + try { + return block() + } + finally { + if (needTime) { + totalTimeNanos += PerformanceCounter.currentThreadCpuTime() - startTime + leaveCounter(this) + } + } + } +} + +/** + * This class allows to calculate pure time for some method excluding some other methods. + * For example, we can calculate total time for CallResolver excluding time for getTypeInfo(). + * + * Main and excluded methods may be reenterable. + */ +private class CounterWithExclude(name: String, vararg excludedCounters: PerformanceCounter): PerformanceCounter(name) { + companion object { + private val counterToCallStackMapThreadLocal = ThreadLocal>() + + private fun getCallStack(counter: CounterWithExclude) + = PerformanceCounter.getOrPut(counterToCallStackMapThreadLocal) { HashMap() }.getOrPut(counter) { CallStackWithTime() } + } + + init { + excludedCounters.forEach { it.excludedFrom.add(this) } + } + + private val callStack: CallStackWithTime + get() = getCallStack(this) + + override fun countTime(block: () -> T): T { + totalTimeNanos += callStack.push(true) + try { + return block() + } + finally { + totalTimeNanos += callStack.pop(true) + } + } + + fun enterExcludedMethod() { + totalTimeNanos += callStack.push(false) + } + + fun exitExcludedMethod() { + totalTimeNanos += callStack.pop(false) + } + + private class CallStackWithTime { + private val callStack = Stack() + private var intervalStartTime: Long = 0 + + fun Stack.peekOrFalse() = if (isEmpty()) false else peek() + + private fun intervalUsefulTime(callStackUpdate: Stack.() -> Unit): Long { + val delta = if (callStack.peekOrFalse()) PerformanceCounter.currentThreadCpuTime() - intervalStartTime else 0 + callStack.callStackUpdate() + + intervalStartTime = PerformanceCounter.currentThreadCpuTime() + return delta + } + + fun push(usefulCall: Boolean): Long { + if (!isEnteredCounter() && !usefulCall) return 0 + + return intervalUsefulTime { push(usefulCall) } + } + + fun pop(usefulCall: Boolean): Long { + if (!isEnteredCounter()) return 0 + + assert(callStack.peek() == usefulCall) + return intervalUsefulTime { pop() } + } + + fun isEnteredCounter(): Boolean = !callStack.isEmpty() + } +} From 298a27951fc1fa760c8f59c2483df991faccec07 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Thu, 25 Jun 2015 16:05:18 +0300 Subject: [PATCH 004/450] Use System.nanoTime() instead threadMxBean.getCurrentThreadUserTime() --- .../compiler/KotlinToJVMBytecodeCompiler.java | 8 +++---- .../kotlin/util/PerformanceCounter.kt | 23 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java index e0908706940..b75a88baaaf 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java @@ -314,7 +314,7 @@ public class KotlinToJVMBytecodeCompiler { MessageCollector collector = environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); assert collector != null; - long analysisStart = PerformanceCounter.Companion.currentThreadCpuTime(); + long analysisStart = PerformanceCounter.Companion.currentTime(); AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(collector); analyzerWithCompilerReport.analyzeAndReport( environment.getSourceFiles(), new Function0() { @@ -334,7 +334,7 @@ public class KotlinToJVMBytecodeCompiler { } } ); - long analysisNanos = PerformanceCounter.Companion.currentThreadCpuTime() - analysisStart; + long analysisNanos = PerformanceCounter.Companion.currentTime() - analysisStart; String message = "ANALYZE: " + environment.getSourceFiles().size() + " files (" + environment.getSourceLinesOfCode() + " lines) " + (targetDescription != null ? targetDescription : "") + @@ -395,11 +395,11 @@ public class KotlinToJVMBytecodeCompiler { ); ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - long generationStart = PerformanceCounter.Companion.currentThreadCpuTime(); + long generationStart = PerformanceCounter.Companion.currentTime(); KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION); - long generationNanos = PerformanceCounter.Companion.currentThreadCpuTime() - generationStart; + long generationNanos = PerformanceCounter.Companion.currentTime() - generationStart; String desc = moduleId != null ? "module " + moduleId + " " : ""; String message = "GENERATE: " + sourceFiles.size() + " files (" + environment.countLinesOfCode(sourceFiles) + " lines) " + desc + "in " + TimeUnit.NANOSECONDS.toMillis(generationNanos) + " ms"; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt index 96ebd30ca8d..e6caf3cac18 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt @@ -20,18 +20,17 @@ import java.lang.management.ManagementFactory import java.util.* import java.util.concurrent.TimeUnit +/** + * This counter is thread-safe for initialization and usage. + * But it may calculate time and number of runs not precisely. + */ public abstract class PerformanceCounter protected constructor(val name: String) { companion object { - private val threadMxBean = ManagementFactory.getThreadMXBean() private val allCounters = arrayListOf() private var enabled = false - init { - threadMxBean.setThreadCpuTimeEnabled(true) - } - - public fun currentThreadCpuTime(): Long = threadMxBean.getCurrentThreadUserTime() + public fun currentTime(): Long = System.nanoTime() public fun report(consumer: (String) -> Unit) { val countersCopy = synchronized(allCounters) { @@ -106,12 +105,12 @@ public abstract class PerformanceCounter protected constructor(val name: String) private class SimpleCounter(name: String): PerformanceCounter(name) { override fun countTime(block: () -> T): T { - val startTime = PerformanceCounter.currentThreadCpuTime() + val startTime = PerformanceCounter.currentTime() try { return block() } finally { - totalTimeNanos += PerformanceCounter.currentThreadCpuTime() - startTime + totalTimeNanos += PerformanceCounter.currentTime() - startTime } } } @@ -128,14 +127,14 @@ private class ReenterableCounter(name: String): PerformanceCounter(name) { } override fun countTime(block: () -> T): T { - val startTime = PerformanceCounter.currentThreadCpuTime() + val startTime = PerformanceCounter.currentTime() val needTime = enterCounter(this) try { return block() } finally { if (needTime) { - totalTimeNanos += PerformanceCounter.currentThreadCpuTime() - startTime + totalTimeNanos += PerformanceCounter.currentTime() - startTime leaveCounter(this) } } @@ -188,10 +187,10 @@ private class CounterWithExclude(name: String, vararg excludedCounters: Performa fun Stack.peekOrFalse() = if (isEmpty()) false else peek() private fun intervalUsefulTime(callStackUpdate: Stack.() -> Unit): Long { - val delta = if (callStack.peekOrFalse()) PerformanceCounter.currentThreadCpuTime() - intervalStartTime else 0 + val delta = if (callStack.peekOrFalse()) PerformanceCounter.currentTime() - intervalStartTime else 0 callStack.callStackUpdate() - intervalStartTime = PerformanceCounter.currentThreadCpuTime() + intervalStartTime = PerformanceCounter.currentTime() return delta } From 2f68cc4c97fdf11b63c8515208addcc53a967e71 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 26 Jun 2015 18:02:19 +0300 Subject: [PATCH 005/450] Created reset method. --- .../kotlin/util/PerformanceCounter.kt | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt index e6caf3cac18..a0aa4e08b75 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/PerformanceCounter.kt @@ -19,6 +19,8 @@ package org.jetbrains.kotlin.util import java.lang.management.ManagementFactory import java.util.* import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicInteger +import java.util.concurrent.atomic.AtomicLong /** * This counter is thread-safe for initialization and usage. @@ -43,6 +45,14 @@ public abstract class PerformanceCounter protected constructor(val name: String) enabled = enable } + public fun resetAllCounters() { + synchronized(allCounters) { + allCounters.forEach { + it.reset() + } + } + } + public jvmOverloads fun create(name: String, reenterable: Boolean = false): PerformanceCounter { return if (reenterable) ReenterableCounter(name) @@ -65,7 +75,7 @@ public abstract class PerformanceCounter protected constructor(val name: String) protected val excludedFrom: MutableList = ArrayList() private var count: Int = 0 - protected var totalTimeNanos: Long = 0 + private var totalTimeNanos: Long = 0 init { synchronized(allCounters) { @@ -90,6 +100,15 @@ public abstract class PerformanceCounter protected constructor(val name: String) } } + public fun reset() { + count = 0 + totalTimeNanos = 0 + } + + protected final fun incrementTime(delta: Long) { + totalTimeNanos += delta + } + protected abstract fun countTime(block: () -> T): T public fun report(consumer: (String) -> Unit) { @@ -110,7 +129,7 @@ private class SimpleCounter(name: String): PerformanceCounter(name) { return block() } finally { - totalTimeNanos += PerformanceCounter.currentTime() - startTime + incrementTime(PerformanceCounter.currentTime() - startTime) } } } @@ -134,7 +153,7 @@ private class ReenterableCounter(name: String): PerformanceCounter(name) { } finally { if (needTime) { - totalTimeNanos += PerformanceCounter.currentTime() - startTime + incrementTime(PerformanceCounter.currentTime() - startTime) leaveCounter(this) } } @@ -163,21 +182,21 @@ private class CounterWithExclude(name: String, vararg excludedCounters: Performa get() = getCallStack(this) override fun countTime(block: () -> T): T { - totalTimeNanos += callStack.push(true) + incrementTime(callStack.push(true)) try { return block() } finally { - totalTimeNanos += callStack.pop(true) + incrementTime(callStack.pop(true)) } } fun enterExcludedMethod() { - totalTimeNanos += callStack.push(false) + incrementTime(callStack.push(false)) } fun exitExcludedMethod() { - totalTimeNanos += callStack.pop(false) + incrementTime(callStack.pop(false)) } private class CallStackWithTime { From 1e7b96aec0aed7eeb0bf495b94f100e55a8a2959 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Fri, 19 Jun 2015 17:28:37 +0300 Subject: [PATCH 006/450] replace ArrayList to SmartList --- .../org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java | 4 +++- .../jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java index 904b0c54e8e..fbea050b811 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.resolve.calls; import com.google.common.collect.Lists; +import com.intellij.util.SmartList; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.CallableDescriptor; @@ -116,7 +118,7 @@ public class CallResolverUtil { receiverType = typeParameter.getUpperBoundsAsType(); } } - List fakeTypeArguments = Lists.newArrayList(); + List fakeTypeArguments = ContainerUtil.newSmartList(); for (TypeProjection typeProjection : receiverType.getArguments()) { fakeTypeArguments.add(new TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE)); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java index 304b573f017..2dc4f79e5a2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTask.java @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.resolve.calls.tasks; -import com.google.common.collect.Lists; +import com.intellij.util.SmartList; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -82,7 +82,7 @@ public class ResolutionTask extends C context.expectedType, context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.symbolUsageValidator, context.additionalTypeChecker, - context.statementFilter, Lists.>newArrayList(), + context.statementFilter, new SmartList>(), context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain); } From 110d6fa7f1031732d19c031280d8e39985d2d2ec Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 26 Jun 2015 19:12:51 +0300 Subject: [PATCH 007/450] Don't load irrelevant classes by accident, if resource happens to exist Check with the containing class or package first, don't load the class if the container doesn't know about it. This also makes the workaround for case-insensitive file systems unnecessary --- .../builtins/BuiltinsPackageFragment.kt | 4 ++-- .../deserialization/ClassDeserializer.kt | 16 +++++++++++-- .../DeserializedPackageFragment.kt | 17 ++++++++------ .../ResourceLoadingClassDataFinder.kt | 23 ++++++------------- .../DeserializedClassDescriptor.kt | 8 +++++-- .../DeserializedPackageMemberScope.kt | 12 ++++++---- .../js/KotlinJavascriptPackageFragment.kt | 4 ++-- 7 files changed, 48 insertions(+), 36 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt index 4d25cb09c4d..d745744f919 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt @@ -16,12 +16,12 @@ package org.jetbrains.kotlin.builtins -import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf +import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment import org.jetbrains.kotlin.storage.StorageManager import java.io.InputStream @@ -32,7 +32,7 @@ public class BuiltinsPackageFragment( loadResource: (path: String) -> InputStream? ) : DeserializedPackageFragment(fqName, storageManager, module, BuiltInsSerializedResourcePaths, loadResource) { - protected override fun loadClassNames(fqName: FqName, packageProto: ProtoBuf.Package): Collection { + protected override fun loadClassNames(packageProto: ProtoBuf.Package): Collection { return packageProto.getExtension(BuiltInsProtoBuf.className)?.map { id -> nameResolver.getName(id) } ?: listOf() } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt index f26af6d8b5b..22e680678a8 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ClassDeserializer.kt @@ -35,12 +35,24 @@ public class ClassDeserializer(private val components: DeserializationComponents val classData = key.classData ?: components.classDataFinder.findClassData(classId) ?: return null val outerContext = if (classId.isNestedClass()) { - (deserializeClass(classId.getOuterClassId()) as? DeserializedClassDescriptor)?.c ?: return null + val outerClass = deserializeClass(classId.getOuterClassId()) as? DeserializedClassDescriptor ?: return null + + // Find the outer class first and check if he knows anything about the nested class we're looking for + if (!outerClass.hasNestedClass(classId.getShortClassName())) return null + + outerClass.c } else { val fragments = components.packageFragmentProvider.getPackageFragments(classId.getPackageFqName()) assert(fragments.size() == 1) { "There should be exactly one package: $fragments, class id is $classId" } - components.createContext(fragments.single(), classData.getNameResolver()) + + val fragment = fragments.single() + if (fragment is DeserializedPackageFragment) { + // Similarly, verify that the containing package has information about this class + if (!fragment.hasTopLevelClass(classId.getShortClassName())) return null + } + + components.createContext(fragment, classData.getNameResolver()) } return DeserializedClassDescriptor(outerContext, classData.getClassProto(), classData.getNameResolver()) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt index 2dc100d084d..2f404139dd2 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt @@ -20,12 +20,11 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.SerializedResourcePaths import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope -import org.jetbrains.kotlin.storage.NotNullLazyValue import org.jetbrains.kotlin.storage.StorageManager +import org.jetbrains.kotlin.storage.get import java.io.InputStream import javax.inject.Inject import kotlin.properties.Delegates @@ -50,16 +49,20 @@ public abstract class DeserializedPackageFragment( this.components = components } - private val memberScopeLazyValue: NotNullLazyValue = storageManager.createLazyValue { + internal val deserializedMemberScope by storageManager.createLazyValue { val packageStream = loadResourceSure(serializedResourcePaths.getPackageFilePath(fqName)) val packageProto = ProtoBuf.Package.parseFrom(packageStream, serializedResourcePaths.EXTENSION_REGISTRY) - DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(fqName, packageProto) }) + DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(packageProto) }) } - override fun getMemberScope() = memberScopeLazyValue() + override fun getMemberScope() = deserializedMemberScope - protected abstract fun loadClassNames(fqName: FqName, packageProto: ProtoBuf.Package): Collection + internal fun hasTopLevelClass(name: Name): Boolean { + return name in getMemberScope().classNames + } + + protected abstract fun loadClassNames(packageProto: ProtoBuf.Package): Collection protected fun loadResourceSure(path: String): InputStream = loadResource(path) ?: throw IllegalStateException("Resource not found in classpath: $path") -} \ No newline at end of file +} diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt index d689f211a2c..03b86ee84d5 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.serialization.deserialization -import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.serialization.ClassData @@ -30,22 +29,14 @@ public open class ResourceLoadingClassDataFinder( private val loadResource: (path: String) -> InputStream? ) : ClassDataFinder { override fun findClassData(classId: ClassId): ClassData? { - val packageFragment = packageFragmentProvider.getPackageFragments(classId.getPackageFqName()).singleOrNull() ?: return null + val packageFragment = packageFragmentProvider.getPackageFragments(classId.getPackageFqName()).singleOrNull() + as? DeserializedPackageFragment ?: return null val stream = loadResource(serializedResourcePaths.getClassMetadataPath(classId)) ?: return null - val classProto = ProtoBuf.Class.parseFrom(stream, serializedResourcePaths.EXTENSION_REGISTRY) - val nameResolver = - (packageFragment as? DeserializedPackageFragment ?: error("Not a deserialized package fragment: $packageFragment")).nameResolver - - val expectedShortName = classId.getShortClassName() - val actualShortName = nameResolver.getClassId(classProto.getFqName()).getShortClassName() - if (!actualShortName.isSpecial() && actualShortName != expectedShortName) { - // Workaround for case-insensitive file systems, - // otherwise we'd find "Collection" for "collection" etc - return null - } - - return ClassData(nameResolver, classProto) + return ClassData( + packageFragment.nameResolver, + ProtoBuf.Class.parseFrom(stream, serializedResourcePaths.EXTENSION_REGISTRY) + ) } -} \ No newline at end of file +} diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index ae5ee0bfc77..1244c3f7e11 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -139,6 +139,10 @@ public class DeserializedClassDescriptor( return supertypes } + internal fun hasNestedClass(name: Name): Boolean { + return name in nestedClasses.nestedClassNames + } + override fun toString() = "deserialized class ${getName().toString()}" // not using descriptor render to preserve laziness override fun getSource() = SourceElement.NO_SOURCE @@ -241,9 +245,9 @@ public class DeserializedClassDescriptor( } private inner class NestedClassDescriptors { - private val nestedClassNames = nestedClassNames() + internal val nestedClassNames = nestedClassNames() - val findNestedClass = c.storageManager.createMemoizedFunctionWithNullableValues { + internal val findNestedClass = c.storageManager.createMemoizedFunctionWithNullableValues { name -> if (name in nestedClassNames) { c.components.deserializeClass(classId.createNestedClassId(name)) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt index 9a98d7e8cd8..55c647defef 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedPackageMemberScope.kt @@ -16,16 +16,17 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors -import org.jetbrains.kotlin.serialization.ProtoBuf -import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.serialization.ProtoBuf +import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents import org.jetbrains.kotlin.serialization.deserialization.NameResolver +import org.jetbrains.kotlin.storage.get +import org.jetbrains.kotlin.utils.addIfNotNull public open class DeserializedPackageMemberScope( packageDescriptor: PackageFragmentDescriptor, @@ -36,7 +37,8 @@ public open class DeserializedPackageMemberScope( ) : DeserializedMemberScope(components.createContext(packageDescriptor, nameResolver), proto.getMemberList()) { private val packageFqName = packageDescriptor.fqName - private val classNames = c.storageManager.createLazyValue(classNames) + + internal val classNames by c.storageManager.createLazyValue { classNames().toSet() } override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = computeDescriptors(kindFilter, nameFilter) @@ -44,7 +46,7 @@ public open class DeserializedPackageMemberScope( override fun getClassDescriptor(name: Name) = c.components.deserializeClass(ClassId(packageFqName, name)) override fun addClassDescriptors(result: MutableCollection, nameFilter: (Name) -> Boolean) { - for (className in classNames()) { + for (className in classNames) { if (nameFilter(className)) { result.addIfNotNull(getClassDescriptor(className)) } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt index 9f71c3f853e..8c619cd1772 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt @@ -16,11 +16,11 @@ package org.jetbrains.kotlin.serialization.js -import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.ProtoBuf +import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment import org.jetbrains.kotlin.storage.StorageManager import java.io.InputStream @@ -31,7 +31,7 @@ public class KotlinJavascriptPackageFragment( loadResource: (path: String) -> InputStream? ) : DeserializedPackageFragment(fqName, storageManager, module, KotlinJavascriptSerializedResourcePaths, loadResource) { - protected override fun loadClassNames(fqName: FqName, packageProto: ProtoBuf.Package): Collection { + protected override fun loadClassNames(packageProto: ProtoBuf.Package): Collection { val classesStream = loadResourceSure(KotlinJavascriptSerializedResourcePaths.getClassesInPackageFilePath(fqName)) val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, serializedResourcePaths.EXTENSION_REGISTRY) return classesProto.getClassNameList()?.map { id -> nameResolver.getName(id) } ?: listOf() From c8439ae6fc139b3d93d535c3aad3a93c9efa2bab Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 2 Jul 2015 18:32:28 +0300 Subject: [PATCH 008/450] Minor, rename val EXTENSION_REGISTRY -> extensionRegistry --- .../kotlin/builtins/BuiltInsSerializedResourcePaths.kt | 6 +++--- .../kotlin/serialization/SerializedResourcePaths.kt | 5 ++--- .../deserialization/DeserializedPackageFragment.kt | 2 +- .../deserialization/ResourceLoadingClassDataFinder.kt | 2 +- .../serialization/js/KotlinJavascriptPackageFragment.kt | 2 +- .../js/KotlinJavascriptSerializedResourcePaths.kt | 4 ++-- .../org/jetbrains/kotlin/serialization/js/jsProtoBufUtil.kt | 4 ++-- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsSerializedResourcePaths.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsSerializedResourcePaths.kt index 8665aadb694..5531c86eb65 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsSerializedResourcePaths.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsSerializedResourcePaths.kt @@ -23,11 +23,11 @@ import org.jetbrains.kotlin.serialization.SerializedResourcePaths import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf public object BuiltInsSerializedResourcePaths : SerializedResourcePaths() { - public override val EXTENSION_REGISTRY: ExtensionRegistryLite + public override val extensionRegistry: ExtensionRegistryLite init { - EXTENSION_REGISTRY = ExtensionRegistryLite.newInstance() - BuiltInsProtoBuf.registerAllExtensions(EXTENSION_REGISTRY) + extensionRegistry = ExtensionRegistryLite.newInstance() + BuiltInsProtoBuf.registerAllExtensions(extensionRegistry) } private val CLASS_METADATA_FILE_EXTENSION = "kotlin_class" diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/SerializedResourcePaths.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/SerializedResourcePaths.kt index af3851d61ba..63c4f0d3c4c 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/SerializedResourcePaths.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/SerializedResourcePaths.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName public abstract class SerializedResourcePaths { - public abstract val EXTENSION_REGISTRY: ExtensionRegistryLite + public abstract val extensionRegistry: ExtensionRegistryLite public abstract fun getClassMetadataPath(classId: ClassId): String @@ -39,5 +39,4 @@ public abstract class SerializedResourcePaths { } public val fallbackPaths: FallbackPaths = FallbackPaths - -} \ No newline at end of file +} diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt index 2f404139dd2..765947f6dfa 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt @@ -51,7 +51,7 @@ public abstract class DeserializedPackageFragment( internal val deserializedMemberScope by storageManager.createLazyValue { val packageStream = loadResourceSure(serializedResourcePaths.getPackageFilePath(fqName)) - val packageProto = ProtoBuf.Package.parseFrom(packageStream, serializedResourcePaths.EXTENSION_REGISTRY) + val packageProto = ProtoBuf.Package.parseFrom(packageStream, serializedResourcePaths.extensionRegistry) DeserializedPackageMemberScope(this, packageProto, nameResolver, components, classNames = { loadClassNames(packageProto) }) } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt index 03b86ee84d5..a7ba2d90484 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/ResourceLoadingClassDataFinder.kt @@ -36,7 +36,7 @@ public open class ResourceLoadingClassDataFinder( return ClassData( packageFragment.nameResolver, - ProtoBuf.Class.parseFrom(stream, serializedResourcePaths.EXTENSION_REGISTRY) + ProtoBuf.Class.parseFrom(stream, serializedResourcePaths.extensionRegistry) ) } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt index 8c619cd1772..2d81434b26d 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptPackageFragment.kt @@ -33,7 +33,7 @@ public class KotlinJavascriptPackageFragment( protected override fun loadClassNames(packageProto: ProtoBuf.Package): Collection { val classesStream = loadResourceSure(KotlinJavascriptSerializedResourcePaths.getClassesInPackageFilePath(fqName)) - val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, serializedResourcePaths.EXTENSION_REGISTRY) + val classesProto = JsProtoBuf.Classes.parseFrom(classesStream, serializedResourcePaths.extensionRegistry) return classesProto.getClassNameList()?.map { id -> nameResolver.getName(id) } ?: listOf() } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializedResourcePaths.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializedResourcePaths.kt index 85d56722589..c9f26583143 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializedResourcePaths.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializedResourcePaths.kt @@ -23,10 +23,10 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.SerializedResourcePaths public object KotlinJavascriptSerializedResourcePaths : SerializedResourcePaths() { - public override val EXTENSION_REGISTRY: ExtensionRegistryLite = ExtensionRegistryLite.newInstance() + public override val extensionRegistry: ExtensionRegistryLite = ExtensionRegistryLite.newInstance() init { - JsProtoBuf.registerAllExtensions(EXTENSION_REGISTRY) + JsProtoBuf.registerAllExtensions(extensionRegistry) } private val CLASSES_FILE_EXTENSION = "kotlin_classes" diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/jsProtoBufUtil.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/jsProtoBufUtil.kt index d083e035be9..18b978f5c6f 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/jsProtoBufUtil.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/jsProtoBufUtil.kt @@ -23,13 +23,13 @@ import org.jetbrains.kotlin.serialization.deserialization.NameResolver import java.io.ByteArrayInputStream public fun ByteArray.toPackageData(nameResolver: NameResolver): PackageData { - val registry = KotlinJavascriptSerializedResourcePaths.EXTENSION_REGISTRY + val registry = KotlinJavascriptSerializedResourcePaths.extensionRegistry val packageProto = ProtoBuf.Package.parseFrom(ByteArrayInputStream(this), registry) return PackageData(nameResolver, packageProto) } public fun ByteArray.toClassData(nameResolver: NameResolver): ClassData { - val registry = KotlinJavascriptSerializedResourcePaths.EXTENSION_REGISTRY + val registry = KotlinJavascriptSerializedResourcePaths.extensionRegistry val classProto = ProtoBuf.Class.parseFrom(ByteArrayInputStream(this), registry) return ClassData(nameResolver, classProto) } From b064b947ce96a3dc5739447c4972e28c5bef382e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Jun 2015 02:03:22 +0300 Subject: [PATCH 009/450] Minor, add missing kdoc on Function's type parameter --- core/builtins/src/kotlin/Function.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/builtins/src/kotlin/Function.kt b/core/builtins/src/kotlin/Function.kt index 4002a56dabb..3234657a686 100644 --- a/core/builtins/src/kotlin/Function.kt +++ b/core/builtins/src/kotlin/Function.kt @@ -18,5 +18,7 @@ package kotlin /** * Represents a value of a functional type, such as a lambda, a function expression or a function reference. + * + * @param R return type of the function. */ public interface Function From cd847b7cb90eb150ec8438068e57cb090795645e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 25 Jun 2015 23:01:10 +0300 Subject: [PATCH 010/450] Minor, make JavaMethod#getReturnType non-null PsiMethod#getReturnType only returns null for constructors, and JavaMethod is not created for constructors (JavaConstructor is) --- .../java/structure/impl/JavaMethodImpl.java | 5 +++-- .../descriptors/LazyJavaClassMemberScope.kt | 19 ++++++++++--------- .../lazy/descriptors/LazyJavaMemberScope.kt | 5 ++--- .../load/java/structure/JavaMethod.java | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java index f3298b2e712..91927c71d3a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMethodImpl.java @@ -64,9 +64,10 @@ public class JavaMethodImpl extends JavaMemberImpl implements JavaMet } @Override - @Nullable + @NotNull public JavaType getReturnType() { PsiType psiType = getPsi().getReturnType(); - return psiType == null ? null : JavaTypeImpl.create(psiType); + assert psiType != null : "Method is not a constructor and has no return type: " + getName(); + return JavaTypeImpl.create(psiType); } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index ff353cf30bf..0d915a9c960 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -31,14 +31,20 @@ import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.lazy.child import org.jetbrains.kotlin.load.java.lazy.resolveAnnotations import org.jetbrains.kotlin.load.java.lazy.types.toAttributes -import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.load.java.structure.JavaArrayType +import org.jetbrains.kotlin.load.java.structure.JavaClass +import org.jetbrains.kotlin.load.java.structure.JavaConstructor +import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorFactory import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.utils.* +import org.jetbrains.kotlin.utils.addIfNotNull +import org.jetbrains.kotlin.utils.emptyOrSingletonList +import org.jetbrains.kotlin.utils.ifEmpty +import org.jetbrains.kotlin.utils.valuesToMap import java.util.ArrayList import java.util.Collections import java.util.LinkedHashSet @@ -204,7 +210,7 @@ public class LazyJavaClassMemberScope( assert(methodsNamedValue.size() <= 1) { "There can't be more than one method named 'value' in annotation class: $jClass" } val methodNamedValue = methodsNamedValue.firstOrNull() if (methodNamedValue != null) { - val parameterNamedValueJavaType = methodNamedValue.getAnnotationMethodReturnJavaType() + val parameterNamedValueJavaType = methodNamedValue.getReturnType() val (parameterType, varargType) = if (parameterNamedValueJavaType is JavaArrayType) Pair(c.typeResolver.transformArrayType(parameterNamedValueJavaType, attr, isVararg = true), @@ -217,18 +223,13 @@ public class LazyJavaClassMemberScope( val startIndex = if (methodNamedValue != null) 1 else 0 for ((index, method) in otherMethods.withIndex()) { - val parameterType = c.typeResolver.transformJavaType(method.getAnnotationMethodReturnJavaType(), attr) + val parameterType = c.typeResolver.transformJavaType(method.getReturnType(), attr) result.addAnnotationValueParameter(constructor, index + startIndex, method, parameterType, null) } return result } - private fun JavaMethod.getAnnotationMethodReturnJavaType(): JavaType { - assert(getValueParameters().isEmpty()) { "Annotation method can't have parameters: $this" } - return getReturnType() ?: throw AssertionError("Annotation method has no return type: $this") - } - private fun MutableList.addAnnotationValueParameter( constructor: ConstructorDescriptor, index: Int, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 556890a9074..536569cb0ae 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -153,9 +153,8 @@ public abstract class LazyJavaMemberScope( allowFlexible = !annotationMethod, isForAnnotationParameter = annotationMethod ) - val returnJavaType = method.getReturnType() ?: throw IllegalStateException("Constructor passed as method: $method") - // Annotation arguments are never null in Java - return c.typeResolver.transformJavaType(returnJavaType, returnTypeAttrs).let { + return c.typeResolver.transformJavaType(method.getReturnType(), returnTypeAttrs).let { + // Annotation arguments are never null in Java if (annotationMethod) TypeUtils.makeNotNullable(it) else it } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java index 1511b7bbc2d..def254fe374 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaMethod.java @@ -29,6 +29,6 @@ public interface JavaMethod extends JavaMember, JavaTypeParameterListOwner { boolean hasAnnotationParameterDefaultValue(); - @Nullable + @NotNull JavaType getReturnType(); } From cd61f6f96beb6656105228ebc9659b2f31ed3f51 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 12:29:10 +0300 Subject: [PATCH 011/450] Minor, dump bytecode in REPL test on demand --- .../kotlin/repl/AbstractReplInterpreterTest.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt b/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt index 2dd04c7ad8e..35ac6d94312 100644 --- a/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/repl/AbstractReplInterpreterTest.kt @@ -24,11 +24,15 @@ import org.jetbrains.kotlin.test.JetTestUtils import org.jetbrains.kotlin.test.TestJdkKind import org.junit.Assert import java.io.File +import java.io.PrintWriter import java.util.ArrayDeque import java.util.ArrayList import java.util.regex.Pattern import kotlin.text.Regex +// Switch this flag to render bytecode after each line in the REPL test. Useful for debugging verify errors or other codegen problems +private val DUMP_BYTECODE = false + private val START_PATTERN = Pattern.compile(">>>( *)(.*)$") private val INCOMPLETE_PATTERN = Pattern.compile("\\.\\.\\.( *)(.*)$") private val TRAILING_NEWLINE_REGEX = Regex("\n$") @@ -83,7 +87,12 @@ public abstract class AbstractReplInterpreterTest : UsefulTestCase() { for ((code, expected) in loadLines(File(path))) { val lineResult = repl.eval(code) - val actual = when (lineResult.getType()!!) { + + if (DUMP_BYTECODE) { + repl.dumpClasses(PrintWriter(System.out)) + } + + val actual = when (lineResult.getType()) { ReplInterpreter.LineResultType.SUCCESS -> lineResult.getValue()?.toString() ?: "" ReplInterpreter.LineResultType.ERROR -> lineResult.getErrorText() ReplInterpreter.LineResultType.INCOMPLETE -> INCOMPLETE_LINE_MESSAGE From 7dcb33fcf2585c0e3c8f3d694c04867d4462a902 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 13:05:09 +0300 Subject: [PATCH 012/450] Minor, don't store type in receiver parameter --- .../resolve/calls/tasks/dynamicCalls.kt | 60 ++++++------------- .../lazy/descriptors/LazyScriptDescriptor.kt | 5 +- .../kotlin/types/JetTypeCheckerTest.java | 1 - .../AbstractReceiverParameterDescriptor.java | 8 ++- .../LazyClassReceiverParameterDescriptor.java | 7 --- .../impl/ReceiverParameterDescriptorImpl.java | 15 +---- .../kotlin/resolve/DescriptorFactory.java | 2 +- 7 files changed, 30 insertions(+), 68 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index b46e928cab8..696cda75774 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -16,46 +16,28 @@ package org.jetbrains.kotlin.resolve.calls.tasks -import org.jetbrains.kotlin.psi.Call -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.SourceElement -import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl -import org.jetbrains.kotlin.types.DynamicType -import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.descriptors.Visibilities -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl -import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.types.JetType -import kotlin.platform.platformStatic -import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver -import org.jetbrains.kotlin.types.isDynamic -import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector -import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.resolve.BindingTrace -import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors -import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl -import org.jetbrains.kotlin.utils.Printer -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.descriptors.impl.* import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.types.expressions.OperatorConventions -import org.jetbrains.kotlin.psi.JetOperationReferenceExpression +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.DescriptorFactory -import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.psi.ValueArgument -import java.util.ArrayList -import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression -import org.jetbrains.kotlin.psi.JetPsiUtil +import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollector +import org.jetbrains.kotlin.resolve.calls.tasks.collectors.CallableDescriptorCollectors import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl +import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver +import org.jetbrains.kotlin.types.DynamicType +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.expressions.OperatorConventions +import org.jetbrains.kotlin.types.isDynamic +import org.jetbrains.kotlin.utils.Printer +import java.util.ArrayList +import kotlin.platform.platformStatic object DynamicCallableDescriptors { @@ -150,11 +132,7 @@ object DynamicCallableDescriptors { } private fun createDynamicDispatchReceiverParameter(owner: CallableDescriptor): ReceiverParameterDescriptorImpl { - return ReceiverParameterDescriptorImpl( - owner, - DynamicType, - TransientReceiver(DynamicType) - ) + return ReceiverParameterDescriptorImpl(owner, TransientReceiver(DynamicType)) } private fun createTypeParameters(owner: DeclarationDescriptor, call: Call): List = call.getTypeArguments().indices.map { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt index 4fd8535d455..bd1d1bb6fec 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ScriptDescriptor @@ -56,7 +55,7 @@ public class LazyScriptDescriptor( resolveSession.getTrace().record(BindingContext.SCRIPT, jetScript, this) } - private val implicitReceiver = ReceiverParameterDescriptorImpl(this, KotlinBuiltIns.getInstance().getAnyType(), ScriptReceiver(this)) + private val implicitReceiver = ReceiverParameterDescriptorImpl(this, ScriptReceiver(this)) override fun getThisAsReceiverParameter() = implicitReceiver @@ -81,7 +80,7 @@ public class LazyScriptDescriptor( override fun getScriptCodeDescriptor() = scriptCodeDescriptor() override fun getScopeForBodyResolution(): JetScope { - val parametersScope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.DO_NOTHING, "Parameters of " + this, implicitReceiver) + val parametersScope = WritableScopeImpl(JetScope.Empty, this, RedeclarationHandler.DO_NOTHING, "Parameters of $this", implicitReceiver) for (valueParameterDescriptor in getScriptCodeDescriptor().getValueParameters()) { parametersScope.addVariableDescriptor(valueParameterDescriptor) } diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index 7f99415756d..a00efd960a8 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -571,7 +571,6 @@ public class JetTypeCheckerTest extends JetLiteFixture { public List getImplicitReceiversHierarchy() { return Lists.newArrayList(new ReceiverParameterDescriptorImpl( getContainingDeclaration(), - thisType, new ExpressionReceiver(JetPsiFactory(getProject()).createExpression(expression), thisType) )); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java index 34e90c54d6f..2b9d78b72c2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractReceiverParameterDescriptor.java @@ -44,7 +44,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes JetType substitutedType = substitutor.substitute(getType(), Variance.INVARIANT); if (substitutedType == null) return null; - return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), substitutedType, new TransientReceiver(substitutedType)); + return new ReceiverParameterDescriptorImpl(getContainingDeclaration(), new TransientReceiver(substitutedType)); } @Override @@ -76,6 +76,12 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes return getType(); } + @NotNull + @Override + public JetType getType() { + return getValue().getType(); + } + @NotNull @Override public List getValueParameters() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyClassReceiverParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyClassReceiverParameterDescriptor.java index f7dfdb12912..eacd090d67b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyClassReceiverParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazyClassReceiverParameterDescriptor.java @@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.resolve.scopes.receivers.ClassReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.JetType; public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParameterDescriptor { private final ClassDescriptor descriptor; @@ -32,12 +31,6 @@ public class LazyClassReceiverParameterDescriptor extends AbstractReceiverParame this.receiverValue = new ClassReceiver(descriptor); } - @NotNull - @Override - public JetType getType() { - return descriptor.getDefaultType(); - } - @NotNull @Override public ReceiverValue getValue() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ReceiverParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ReceiverParameterDescriptorImpl.java index 7a32f1b54f3..cbc87e8d9e7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ReceiverParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ReceiverParameterDescriptorImpl.java @@ -19,29 +19,16 @@ package org.jetbrains.kotlin.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.JetType; public class ReceiverParameterDescriptorImpl extends AbstractReceiverParameterDescriptor { private final DeclarationDescriptor containingDeclaration; - private final JetType type; private final ReceiverValue value; - public ReceiverParameterDescriptorImpl( - @NotNull DeclarationDescriptor containingDeclaration, - @NotNull JetType type, - @NotNull ReceiverValue value - ) { + public ReceiverParameterDescriptorImpl(@NotNull DeclarationDescriptor containingDeclaration, @NotNull ReceiverValue value) { this.containingDeclaration = containingDeclaration; - this.type = type; this.value = value; } - @NotNull - @Override - public JetType getType() { - return type; - } - @NotNull @Override public ReceiverValue getValue() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java index a39f612201c..c5f382ecae9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java @@ -115,6 +115,6 @@ public class DescriptorFactory { ) { return receiverParameterType == null ? NO_RECEIVER_PARAMETER - : new ReceiverParameterDescriptorImpl(owner, receiverParameterType, new ExtensionReceiver(owner, receiverParameterType)); + : new ReceiverParameterDescriptorImpl(owner, new ExtensionReceiver(owner, receiverParameterType)); } } From fa9dfd94b068acb9766c756146708d380ead5ef8 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 15:47:21 +0300 Subject: [PATCH 013/450] Minor, add ScriptContext#toString --- .../org/jetbrains/kotlin/codegen/context/ScriptContext.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ScriptContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ScriptContext.java index 64905a5971b..9db829601c3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ScriptContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ScriptContext.java @@ -61,4 +61,9 @@ public class ScriptContext extends FieldOwnerContext { } return "script$" + (index + 1); } + + @Override + public String toString() { + return "Script: " + getContextDescriptor().getName().asString(); + } } From 48a8f535513d7a3b0d8948470c4317e946798992 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 19:05:35 +0300 Subject: [PATCH 014/450] Fix ClassCastException in SamAdapterOverridabilityCondition This was happening on the upcoming hierarchy of property getters and setters in kotlin.reflect. No test added because it's not so easy to come up with a small example, and because the fix itself is rather trivial --- .../kotlin/load/java/sam/SamAdapterOverridabilityCondition.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java index 4ee46b2ce47..6606487ef60 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java @@ -30,7 +30,7 @@ import java.util.List; public class SamAdapterOverridabilityCondition implements ExternalOverridabilityCondition { @Override public boolean isOverridable(@NotNull CallableDescriptor superDescriptor, @NotNull CallableDescriptor subDescriptor) { - if (subDescriptor instanceof PropertyDescriptor) { + if (!(subDescriptor instanceof SimpleFunctionDescriptor)) { return true; } From aa65eb105513fceee65d21fd94c15b1398a185fd Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Wed, 1 Jul 2015 20:49:20 +0300 Subject: [PATCH 015/450] More proper fix for KT-8137/EA-69470: avoiding failed assertion when searching usages of parameter of local class constructor KT-8137 AE at JetSourceNavigationHelper.convertNamedClassOrObject() on function local class with several constructor parameters #KT-8137 fixed #EA-69470 fixed --- .../jetbrains/kotlin/psi/JetConstructor.kt | 5 +++ .../jetbrains/kotlin/psi/JetParameter.java | 2 +- .../org/jetbrains/kotlin/psi/JetPsiUtil.java | 4 +-- .../kotlinPrivatePropertyUsages2.0.kt | 5 +-- .../kotlinPrivatePropertyUsages2.1.kt | 2 +- .../kotlinPrivatePropertyUsages2.results.txt | 6 +++- .../libraryUsages/_library/library/library.kt | 5 +++ .../findUsages/AbstractJetFindUsagesTest.java | 12 +++---- .../KotlinFindUsagesWithLibraryCustomTest.kt | 32 +++++++++++++++++++ 9 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetConstructor.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetConstructor.kt index 2a10bdc2bce..32336cf1b65 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetConstructor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetConstructor.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.psi import com.intellij.lang.ASTNode import com.intellij.navigation.ItemPresentationProviders import com.intellij.psi.PsiElement +import com.intellij.psi.search.SearchScope import com.intellij.util.IncorrectOperationException import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.name.Name @@ -89,4 +90,8 @@ public abstract class JetConstructor> : JetDeclarationStub ?: getValueParameterList()?.getTextOffset() ?: super.getTextOffset() } + + override fun getUseScope(): SearchScope { + return getContainingClassOrObject().getUseScope() + } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetParameter.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetParameter.java index adf8d9a5390..c02ee94de2f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetParameter.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetParameter.java @@ -182,7 +182,7 @@ public class JetParameter extends JetNamedDeclarationStub i PsiElement parent = getParent(); if (parent != null) { PsiElement grandparent = parent.getParent(); - if (grandparent instanceof JetNamedFunction) { + if (grandparent instanceof JetFunction && !(grandparent instanceof JetFunctionLiteral)) { return grandparent.getUseScope(); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java index 54ddd225259..d84168d11b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java @@ -775,9 +775,9 @@ public class JetPsiUtil { else if (declaration instanceof JetParameter) { PsiElement parent = declaration.getParent(); - // val/var parameter of primary constructor should not be considered as local + // val/var parameter of primary constructor should be considered as local according to containing class if (((JetParameter) declaration).hasValOrVar() && parent != null && parent.getParent() instanceof JetPrimaryConstructor) { - return null; + return getEnclosingElementForLocalDeclaration(((JetPrimaryConstructor) parent.getParent()).getContainingClassOrObject(), skipParameters); } else if (skipParameters && parent != null && parent.getParent() instanceof JetNamedFunction) { diff --git a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.0.kt b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.0.kt index 0043dadf521..ad25821bdad 100644 --- a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.0.kt +++ b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.0.kt @@ -6,7 +6,8 @@ public open class Server(private val foo: String = "foo") { open fun processRequest() = foo } -public class ServerEx(): Server() { - override fun processRequest() = "foo" + foo +public class ServerEx(): Server(foo = "!") { + override fun processRequest() = "foo" + foo // this reference is found as a side effect of big use scope of constructor parameter: + // if it was simple property, it wouldn't be found } diff --git a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.1.kt b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.1.kt index fc85e72876a..86c7d186022 100644 --- a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.1.kt +++ b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.1.kt @@ -2,7 +2,7 @@ import server.*; class Client { public fun foo() { - println(Server().foo) + println(Server(foo = "!").foo) ServerEx().processRequest() } } diff --git a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt index 9fddae8966e..2c7f2972fa0 100644 --- a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt +++ b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt @@ -1 +1,5 @@ -Value read (6: 33) open fun processRequest() = foo +[kotlinPrivatePropertyUsages2.0.kt] Named argument (9: 33) public class ServerEx(): Server(foo = "!") { +[kotlinPrivatePropertyUsages2.0.kt] Value read (10: 45) override fun processRequest() = "foo" + foo +[kotlinPrivatePropertyUsages2.0.kt] Value read (6: 33) open fun processRequest() = foo +[kotlinPrivatePropertyUsages2.1.kt] Named argument (5: 24) println(Server(foo = "!").foo) +[kotlinPrivatePropertyUsages2.1.kt] Value read (5: 35) println(Server(foo = "!").foo) \ No newline at end of file diff --git a/idea/testData/findUsages/libraryUsages/_library/library/library.kt b/idea/testData/findUsages/libraryUsages/_library/library/library.kt index 21ad72ec8bc..be51210073e 100644 --- a/idea/testData/findUsages/libraryUsages/_library/library/library.kt +++ b/idea/testData/findUsages/libraryUsages/_library/library/library.kt @@ -64,4 +64,9 @@ fun test() { val tt = A.T() t.bar(2) val fff = A.T::bar + + class LocalClass(val localClassProperty: Int) { + } + + LocalClass(localClassProperty = 1).localClassProperty } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/AbstractJetFindUsagesTest.java b/idea/tests/org/jetbrains/kotlin/findUsages/AbstractJetFindUsagesTest.java index fb48fb6a26b..622e0d95f9d 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/AbstractJetFindUsagesTest.java +++ b/idea/tests/org/jetbrains/kotlin/findUsages/AbstractJetFindUsagesTest.java @@ -358,11 +358,11 @@ public abstract class AbstractJetFindUsagesTest extends JetLightCodeInsightFixtu } private void findUsagesAndCheckResults( - String mainFileText, - String prefix, - String rootPath, - T caretElement, - FindUsagesOptions options + @NotNull String mainFileText, + @NotNull String prefix, + @NotNull String rootPath, + @NotNull T caretElement, + @Nullable FindUsagesOptions options ) throws ClassNotFoundException, InstantiationException, IllegalAccessException { Collection usageInfos = findUsages(caretElement, options); @@ -419,7 +419,7 @@ public abstract class AbstractJetFindUsagesTest extends JetLightCodeInsightFixtu JetTestUtils.assertEqualsToFile(new File(rootPath, prefix + "results.txt"), StringUtil.join(finalUsages, "\n")); } - private Collection findUsages(@NotNull PsiElement targetElement, @Nullable FindUsagesOptions options) { + protected Collection findUsages(@NotNull PsiElement targetElement, @Nullable FindUsagesOptions options) { Project project = getProject(); FindUsagesHandler handler = ((FindManagerImpl) FindManager.getInstance(project)).getFindUsagesManager().getFindUsagesHandler(targetElement, false); diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt new file mode 100644 index 00000000000..ad4646e403c --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/findUsages/KotlinFindUsagesWithLibraryCustomTest.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.findUsages + +import com.intellij.psi.search.FilenameIndex +import org.jetbrains.kotlin.psi.JetParameter +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import kotlin.test.assertEquals + +public class KotlinFindUsagesWithLibraryCustomTest : AbstractKotlinFindUsagesWithLibraryTest() { + public fun testFindUsagesForLocalClassProperty() { + val libraryFile = FilenameIndex.getFilesByName(getProject(), "library.kt", myFixture.getModule().getModuleWithLibrariesScope()).first() + val indexOf = libraryFile.getText().indexOf("localClassProperty") + val jetParameter = libraryFile.findElementAt(indexOf)!!.getStrictParentOfType()!! + val usages = findUsages(jetParameter.getOriginalElement(), null) + assertEquals(2, usages.size()) + } +} \ No newline at end of file From e09411f45f62f4dd423613058935e4b192458c74 Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Fri, 3 Jul 2015 13:54:52 +0300 Subject: [PATCH 016/450] convert KotlinJpsBuildTest to Kotlin: step 1: convert body --- .../kotlin/jps/build/KotlinJpsBuildTest.java | 965 ++++++++---------- 1 file changed, 440 insertions(+), 525 deletions(-) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java index b2e15a5f3bc..181a5ec8f34 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java @@ -14,662 +14,577 @@ * limitations under the License. */ -package org.jetbrains.kotlin.jps.build; +package org.jetbrains.kotlin.jps.build -import com.google.common.collect.Lists; -import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.testFramework.LightVirtualFile; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.io.ZipUtil; -import kotlin.KotlinPackage; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jps.builders.BuildResult; -import org.jetbrains.jps.builders.impl.BuildDataPathsImpl; -import org.jetbrains.jps.model.java.JpsJavaDependencyScope; -import org.jetbrains.jps.model.java.JpsJavaExtensionService; -import org.jetbrains.jps.model.module.JpsModule; -import org.jetbrains.jps.util.JpsPathUtil; -import org.jetbrains.kotlin.codegen.AsmUtil; -import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils; -import org.jetbrains.kotlin.name.FqName; -import org.jetbrains.kotlin.test.MockLibraryUtil; -import org.jetbrains.kotlin.utils.PathUtil; -import org.jetbrains.org.objectweb.asm.ClassReader; -import org.jetbrains.org.objectweb.asm.ClassVisitor; -import org.jetbrains.org.objectweb.asm.MethodVisitor; -import org.jetbrains.org.objectweb.asm.Opcodes; +import com.google.common.collect.Lists +import com.intellij.openapi.util.Condition +import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtilRt +import com.intellij.testFramework.LightVirtualFile +import com.intellij.util.ArrayUtil +import com.intellij.util.containers.ContainerUtil +import com.intellij.util.io.ZipUtil +import kotlin.KotlinPackage +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.model.java.JpsJavaDependencyScope +import org.jetbrains.jps.model.java.JpsJavaExtensionService +import org.jetbrains.jps.model.module.JpsModule +import org.jetbrains.jps.util.JpsPathUtil +import org.jetbrains.kotlin.codegen.AsmUtil +import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.test.MockLibraryUtil +import org.jetbrains.kotlin.utils.PathUtil +import org.jetbrains.org.objectweb.asm.ClassReader +import org.jetbrains.org.objectweb.asm.ClassVisitor +import org.jetbrains.org.objectweb.asm.MethodVisitor +import org.jetbrains.org.objectweb.asm.Opcodes -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.*; -import java.util.regex.Pattern; -import java.util.zip.ZipOutputStream; +import java.io.File +import java.io.FileNotFoundException +import java.io.FileOutputStream +import java.io.IOException +import java.util.* +import java.util.regex.Pattern +import java.util.zip.ZipOutputStream -import static com.intellij.openapi.util.io.FileUtil.toSystemIndependentName; +import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName -public class KotlinJpsBuildTest extends AbstractKotlinJpsBuildTestCase { - private static final String PROJECT_NAME = "kotlinProject"; - private static final String ADDITIONAL_MODULE_NAME = "module2"; - private static final String JDK_NAME = "IDEA_JDK"; +public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { - private static final String[] EXCLUDE_FILES = { "Excluded.class", "YetAnotherExcluded.class" }; - private static final String[] NOTHING = {}; - private static final String KOTLIN_JS_LIBRARY = "jslib-example"; - private static final String PATH_TO_KOTLIN_JS_LIBRARY = TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY; - private static final String KOTLIN_JS_LIBRARY_JAR = KOTLIN_JS_LIBRARY + ".jar"; - private static final Set EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY = KotlinPackage.hashSetOf( - PROJECT_NAME + ".js", - PROJECT_NAME + ".meta.js", - "lib/kotlin.js", - "lib/stdlib.meta.js" - ); - private static final Set EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY = KotlinPackage.hashSetOf( - ADDITIONAL_MODULE_NAME + ".js", - ADDITIONAL_MODULE_NAME + ".meta.js", - "lib/kotlin.js", - "lib/stdlib.meta.js" - ); - private static final Set EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY = KotlinPackage.hashSetOf( - PROJECT_NAME + ".js", - PROJECT_NAME + ".meta.js" - ); - private static final Set EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR = - KotlinPackage.hashSetOf( - PROJECT_NAME + ".js", - PROJECT_NAME + ".meta.js", - "lib/kotlin.js", - "lib/stdlib.meta.js", - "lib/jslib-example.js", - "lib/file0.js", - "lib/dir/file1.js", - "lib/META-INF-ex/file2.js", - "lib/res0.js", - "lib/resdir/res1.js"); - private static final Set EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR = - KotlinPackage.hashSetOf( - PROJECT_NAME + ".js", - PROJECT_NAME + ".meta.js", - "custom/kotlin.js", - "custom/stdlib.meta.js", - "custom/jslib-example.js", - "custom/file0.js", - "custom/dir/file1.js", - "custom/META-INF-ex/file2.js", - "custom/res0.js", - "custom/resdir/res1.js"); - - @Override - public void setUp() throws Exception { - super.setUp(); - File sourceFilesRoot = new File(TEST_DATA_PATH + "general/" + getTestName(false)); - workDir = copyTestDataToTmpDir(sourceFilesRoot); - getOrCreateProjectDir(); + throws(Exception::class) + override fun setUp() { + super.setUp() + val sourceFilesRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) + workDir = AbstractKotlinJpsBuildTestCase.copyTestDataToTmpDir(sourceFilesRoot) + getOrCreateProjectDir() } - @Override - public void tearDown() throws Exception { - FileUtil.delete(workDir); - super.tearDown(); + throws(Exception::class) + override fun tearDown() { + FileUtil.delete(workDir) + super.tearDown() } - @Override - protected File doGetProjectDir() throws IOException { - return workDir; + throws(IOException::class) + override fun doGetProjectDir(): File { + return workDir } - private void initProject() { - addJdk(JDK_NAME); - loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr"); + private fun initProject() { + addJdk(JDK_NAME) + loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr") } - public void doTest() { - initProject(); - makeAll().assertSuccessful(); + public fun doTest() { + initProject() + makeAll().assertSuccessful() } - public void doTestWithRuntime() { - initProject(); - addKotlinRuntimeDependency(); - makeAll().assertSuccessful(); + public fun doTestWithRuntime() { + initProject() + addKotlinRuntimeDependency() + makeAll().assertSuccessful() } - public void doTestWithKotlinJavaScriptLibrary() { - initProject(); - addKotlinJavaScriptStdlibDependency(); - createKotlinJavaScriptLibraryArchive(); - addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, new File(workDir, KOTLIN_JS_LIBRARY_JAR)); - makeAll().assertSuccessful(); + public fun doTestWithKotlinJavaScriptLibrary() { + initProject() + addKotlinJavaScriptStdlibDependency() + createKotlinJavaScriptLibraryArchive() + addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + makeAll().assertSuccessful() } - public void testKotlinProject() { - doTest(); + public fun testKotlinProject() { + doTest() - checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")); + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) } - public void testKotlinJavaScriptProject() { - initProject(); - addKotlinJavaScriptStdlibDependency(); - makeAll().assertSuccessful(); + public fun testKotlinJavaScriptProject() { + initProject() + addKotlinJavaScriptStdlibDependency() + makeAll().assertSuccessful() - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testKotlinJavaScriptProjectWithTwoModules() { - initProject(); - addKotlinJavaScriptStdlibDependency(); - makeAll().assertSuccessful(); + public fun testKotlinJavaScriptProjectWithTwoModules() { + initProject() + addKotlinJavaScriptStdlibDependency() + makeAll().assertSuccessful() - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)); - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY, contentOfOutputDir(ADDITIONAL_MODULE_NAME)); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY, contentOfOutputDir(ADDITIONAL_MODULE_NAME)) - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - checkWhen(touch("module2/src/module2.kt"), null, k2jsOutput(ADDITIONAL_MODULE_NAME)); - checkWhen(new Action[]{ touch("src/test1.kt"), touch("module2/src/module2.kt")}, null, k2jsOutput(PROJECT_NAME, - ADDITIONAL_MODULE_NAME)); + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) + checkWhen(touch("module2/src/module2.kt"), null, k2jsOutput(ADDITIONAL_MODULE_NAME)) + checkWhen(arrayOf(touch("src/test1.kt"), touch("module2/src/module2.kt")), null, k2jsOutput(PROJECT_NAME, ADDITIONAL_MODULE_NAME)) } - public void testKotlinJavaScriptProjectWithDirectoryAsStdlib() { - initProject(); - File jslibJar = PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath(); - File jslibDir = new File(workDir, "KotlinJavaScript"); + public fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() { + initProject() + val jslibJar = PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath() + val jslibDir = File(workDir, "KotlinJavaScript") try { - ZipUtil.extract(jslibJar, jslibDir, null); + ZipUtil.extract(jslibJar, jslibDir, null) } - catch (IOException ex) { - throw new IllegalStateException(ex.getMessage()); - } - addKotlinJavaScriptDependency("KotlinJavaScript", jslibDir); - makeAll().assertSuccessful(); - - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - } - - public void testKotlinJavaScriptProjectWithDirectoryAsLibrary() { - initProject(); - addKotlinJavaScriptStdlibDependency(); - addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, new File(workDir, KOTLIN_JS_LIBRARY)); - makeAll().assertSuccessful(); - - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - } - - public void testKotlinJavaScriptProjectWithLibrary() { - doTestWithKotlinJavaScriptLibrary(); - - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - } - - public void testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { - doTestWithKotlinJavaScriptLibrary(); - - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - } - - public void testKotlinJavaScriptProjectWithLibraryNoCopy() { - doTestWithKotlinJavaScriptLibrary(); - - assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME)); - checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)); - } - - public void testKotlinJavaScriptProjectWithLibraryAndErrors() { - initProject(); - addKotlinJavaScriptStdlibDependency(); - createKotlinJavaScriptLibraryArchive(); - addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, new File(workDir, KOTLIN_JS_LIBRARY_JAR)); - makeAll().assertFailed(); - - assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME)); - } - - public void testExcludeFolderInSourceRoot() { - doTest(); - - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "Foo.class"); - assertFilesNotExistInOutput(module, EXCLUDE_FILES); - - checkWhen(touch("src/foo.kt"), null, new String[] {klass("kotlinProject", "Foo")}); - } - - public void testExcludeModuleFolderInSourceRootOfAnotherModule() { - doTest(); - - for (JpsModule module : myProject.getModules()) { - assertFilesExistInOutput(module, "Foo.class"); + catch (ex: IOException) { + throw IllegalStateException(ex.getMessage()) } - checkWhen(touch("src/foo.kt"), null, new String[] {klass("kotlinProject", "Foo")}); - checkWhen(touch("src/module2/src/foo.kt"), null, new String[] {klass("module2", "Foo")}); + addKotlinJavaScriptDependency("KotlinJavaScript", jslibDir) + makeAll().assertSuccessful() + + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testExcludeFileUsingCompilerSettings() { - doTest(); + public fun testKotlinJavaScriptProjectWithDirectoryAsLibrary() { + initProject() + addKotlinJavaScriptStdlibDependency() + addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY)) + makeAll().assertSuccessful() - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "Foo.class", "Bar.class"); - assertFilesNotExistInOutput(module, EXCLUDE_FILES); - - checkWhen(touch("src/foo.kt"), null, new String[] {klass("kotlinProject", "Foo")}); - checkWhen(touch("src/Excluded.kt"), null, NOTHING ); - checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testExcludeFolderNonRecursivelyUsingCompilerSettings() { - doTest(); + public fun testKotlinJavaScriptProjectWithLibrary() { + doTestWithKotlinJavaScriptLibrary() - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "Foo.class", "Bar.class"); - assertFilesNotExistInOutput(module, EXCLUDE_FILES); - - checkWhen(touch("src/foo.kt"), null, new String[] {klass("kotlinProject", "Foo")}); - checkWhen(touch("src/dir/subdir/bar.kt"), null, new String[] { klass("kotlinProject", "Bar")} ); - - checkWhen(touch("src/dir/Excluded.kt"), null, NOTHING ); - checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testExcludeFolderRecursivelyUsingCompilerSettings() { - doTest(); + public fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { + doTestWithKotlinJavaScriptLibrary() - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "Foo.class", "Bar.class"); - assertFilesNotExistInOutput(module, EXCLUDE_FILES); - - checkWhen(touch("src/foo.kt"), null, new String[] {klass("kotlinProject", "Foo")}); - - checkWhen(touch("src/exclude/Excluded.kt"), null, NOTHING); - checkWhen(touch("src/exclude/YetAnotherExcluded.kt"), null, NOTHING); - checkWhen(touch("src/exclude/subdir/Excluded.kt"), null, NOTHING); - checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testManyFiles() { - doTest(); + public fun testKotlinJavaScriptProjectWithLibraryNoCopy() { + doTestWithKotlinJavaScriptLibrary() - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class"); - - checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage")); - checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")); - checkWhen(touch("src/Bar.kt"), - new String[] {"src/Bar.kt"}, - new String[] {klass("kotlinProject", "foo.Bar")}); - - checkWhen(del("src/main.kt"), - new String[] {"src/Bar.kt", "src/boo.kt"}, - mergeArrays( - packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage"), - packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage"), - new String[]{ klass("kotlinProject", "foo.Bar") } - )); - assertFilesExistInOutput(module, "boo/BooPackage.class", "foo/Bar.class"); - assertFilesNotExistInOutput(module, "foo/FooPackage.class"); - - checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")); - checkWhen(touch("src/Bar.kt"), null, new String[] {klass("kotlinProject", "foo.Bar")}); + TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME)) + checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } - public void testManyFilesForPackage() { - doTest(); + public fun testKotlinJavaScriptProjectWithLibraryAndErrors() { + initProject() + addKotlinJavaScriptStdlibDependency() + createKotlinJavaScriptLibraryArchive() + addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) + makeAll().assertFailed() - JpsModule module = myProject.getModules().get(0); - assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class"); - - checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage")); - checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")); - checkWhen(touch("src/Bar.kt"), - new String[] {"src/Bar.kt"}, - new String[] { - klass("kotlinProject", "foo.Bar"), - klass("kotlinProject", "foo.FooPackage"), - packagePartClass("kotlinProject", "src/Bar.kt", "foo.FooPackage")}); - - checkWhen(del("src/main.kt"), - new String[] {"src/Bar.kt", "src/boo.kt"}, - mergeArrays( - packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage"), - packageClasses("kotlinProject", "src/Bar.kt", "foo.FooPackage"), - packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage"), - new String[] {klass("kotlinProject", "foo.Bar")} - )); - assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class"); - - checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")); - checkWhen(touch("src/Bar.kt"), null, - new String[] { - klass("kotlinProject", "foo.Bar"), - klass("kotlinProject", "foo.FooPackage"), - packagePartClass("kotlinProject", "src/Bar.kt", "foo.FooPackage") - }); + TestCase.assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME)) } - public void testKotlinProjectTwoFilesInOnePackage() { - doTest(); + public fun testExcludeFolderInSourceRoot() { + doTest() - checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")); - checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")); + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "Foo.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) - checkWhen(new Action[]{ del("src/test1.kt"), del("src/test2.kt") }, NOTHING, - new String[] { - packagePartClass("kotlinProject", "src/test1.kt", "_DefaultPackage"), - packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"), - klass("kotlinProject", "_DefaultPackage") - }); - - assertFilesNotExistInOutput(myProject.getModules().get(0), "_DefaultPackage.class"); + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) } - public void testKotlinJavaProject() { - doTestWithRuntime(); + public fun testExcludeModuleFolderInSourceRootOfAnotherModule() { + doTest() + + for (module in myProject.getModules()) { + assertFilesExistInOutput(module, "Foo.class") + } + + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + checkWhen(touch("src/module2/src/foo.kt"), null, arrayOf(klass("module2", "Foo"))) } - public void testJKJProject() { - doTestWithRuntime(); + public fun testExcludeFileUsingCompilerSettings() { + doTest() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + checkWhen(touch("src/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/YetAnotherExcluded.kt"), null, NOTHING) } - public void testKJKProject() { - doTestWithRuntime(); + public fun testExcludeFolderNonRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + checkWhen(touch("src/dir/subdir/bar.kt"), null, arrayOf(klass("kotlinProject", "Bar"))) + + checkWhen(touch("src/dir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/dir/subdir/YetAnotherExcluded.kt"), null, NOTHING) } - public void testKJCircularProject() { - doTestWithRuntime(); + public fun testExcludeFolderRecursivelyUsingCompilerSettings() { + doTest() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "Foo.class", "Bar.class") + assertFilesNotExistInOutput(module, *EXCLUDE_FILES) + + checkWhen(touch("src/foo.kt"), null, arrayOf(klass("kotlinProject", "Foo"))) + + checkWhen(touch("src/exclude/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/YetAnotherExcluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/Excluded.kt"), null, NOTHING) + checkWhen(touch("src/exclude/subdir/YetAnotherExcluded.kt"), null, NOTHING) } - public void testJKJInheritanceProject() { - doTestWithRuntime(); + public fun testManyFiles() { + doTest() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class") + + checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage")) + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")) + checkWhen(touch("src/Bar.kt"), arrayOf("src/Bar.kt"), arrayOf(klass("kotlinProject", "foo.Bar"))) + + checkWhen(del("src/main.kt"), arrayOf("src/Bar.kt", "src/boo.kt"), mergeArrays(packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage"), packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage"), arrayOf(klass("kotlinProject", "foo.Bar")))) + assertFilesExistInOutput(module, "boo/BooPackage.class", "foo/Bar.class") + assertFilesNotExistInOutput(module, "foo/FooPackage.class") + + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")) + checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar"))) } - public void testKJKInheritanceProject() { - doTestWithRuntime(); + public fun testManyFilesForPackage() { + doTest() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class") + + checkWhen(touch("src/main.kt"), null, packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage")) + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")) + checkWhen(touch("src/Bar.kt"), arrayOf("src/Bar.kt"), arrayOf(klass("kotlinProject", "foo.Bar"), klass("kotlinProject", "foo.FooPackage"), packagePartClass("kotlinProject", "src/Bar.kt", "foo.FooPackage"))) + + checkWhen(del("src/main.kt"), arrayOf("src/Bar.kt", "src/boo.kt"), mergeArrays(packageClasses("kotlinProject", "src/main.kt", "foo.FooPackage"), packageClasses("kotlinProject", "src/Bar.kt", "foo.FooPackage"), packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage"), arrayOf(klass("kotlinProject", "foo.Bar")))) + assertFilesExistInOutput(module, "foo/FooPackage.class", "boo/BooPackage.class", "foo/Bar.class") + + checkWhen(touch("src/boo.kt"), null, packageClasses("kotlinProject", "src/boo.kt", "boo.BooPackage")) + checkWhen(touch("src/Bar.kt"), null, arrayOf(klass("kotlinProject", "foo.Bar"), klass("kotlinProject", "foo.FooPackage"), packagePartClass("kotlinProject", "src/Bar.kt", "foo.FooPackage"))) } - public void testCircularDependenciesNoKotlinFiles() { - doTest(); + public fun testKotlinProjectTwoFilesInOnePackage() { + doTest() + + checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "_DefaultPackage")) + checkWhen(touch("src/test2.kt"), null, packageClasses("kotlinProject", "src/test2.kt", "_DefaultPackage")) + + checkWhen(arrayOf(del("src/test1.kt"), del("src/test2.kt")), NOTHING, arrayOf(packagePartClass("kotlinProject", "src/test1.kt", "_DefaultPackage"), packagePartClass("kotlinProject", "src/test2.kt", "_DefaultPackage"), klass("kotlinProject", "_DefaultPackage"))) + + assertFilesNotExistInOutput(myProject.getModules().get(0), "_DefaultPackage.class") } - public void testCircularDependenciesDifferentPackages() { - initProject(); - BuildResult result = makeAll(); + public fun testKotlinJavaProject() { + doTestWithRuntime() + } + + public fun testJKJProject() { + doTestWithRuntime() + } + + public fun testKJKProject() { + doTestWithRuntime() + } + + public fun testKJCircularProject() { + doTestWithRuntime() + } + + public fun testJKJInheritanceProject() { + doTestWithRuntime() + } + + public fun testKJKInheritanceProject() { + doTestWithRuntime() + } + + public fun testCircularDependenciesNoKotlinFiles() { + doTest() + } + + public fun testCircularDependenciesDifferentPackages() { + initProject() + val result = makeAll() // Check that outputs are located properly - assertFilesExistInOutput(findModule("module2"), "kt1/Kt1Package.class"); - assertFilesExistInOutput(findModule("kotlinProject"), "kt2/Kt2Package.class"); + assertFilesExistInOutput(findModule("module2"), "kt1/Kt1Package.class") + assertFilesExistInOutput(findModule("kotlinProject"), "kt2/Kt2Package.class") - result.assertSuccessful(); + result.assertSuccessful() - checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Package")); - checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Package")); + checkWhen(touch("src/kt2.kt"), null, packageClasses("kotlinProject", "src/kt2.kt", "kt2.Kt2Package")) + checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Package")) } - public void testCircularDependenciesSamePackage() throws IOException { - initProject(); - BuildResult result = makeAll(); - result.assertSuccessful(); + throws(IOException::class) + public fun testCircularDependenciesSamePackage() { + initProject() + val result = makeAll() + result.assertSuccessful() // Check that outputs are located properly - File facadeWithA = findFileInOutputDir(findModule("module1"), "test/TestPackage.class"); - File facadeWithB = findFileInOutputDir(findModule("module2"), "test/TestPackage.class"); - assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "getA"); - assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "getB", "setB"); + val facadeWithA = findFileInOutputDir(findModule("module1"), "test/TestPackage.class") + val facadeWithB = findFileInOutputDir(findModule("module2"), "test/TestPackage.class") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithA), "", "a", "getA") + UsefulTestCase.assertSameElements(getMethodsOfClass(facadeWithB), "", "b", "getB", "setB") - checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")); - checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")); + checkWhen(touch("module1/src/a.kt"), null, packageClasses("module1", "module1/src/a.kt", "test.TestPackage")) + checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) } - public void testCircularDependencyWithReferenceToOldVersionLib() throws IOException { - initProject(); + throws(IOException::class) + public fun testCircularDependencyWithReferenceToOldVersionLib() { + initProject() - File libraryJar = MockLibraryUtil.compileLibraryToJar( - workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false); + val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false) - addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, - "module-lib", libraryJar); + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar) - BuildResult result = makeAll(); - result.assertSuccessful(); + val result = makeAll() + result.assertSuccessful() } - public void testDependencyToOldKotlinLib() throws IOException { - initProject(); + throws(IOException::class) + public fun testDependencyToOldKotlinLib() { + initProject() - File libraryJar = MockLibraryUtil.compileLibraryToJar( - workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false); + val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.getAbsolutePath() + File.separator + "oldModuleLib/src", "module-lib", false) - addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar); + AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar) - addKotlinRuntimeDependency(); + addKotlinRuntimeDependency() - BuildResult result = makeAll(); - result.assertSuccessful(); + val result = makeAll() + result.assertSuccessful() } - private void createKotlinJavaScriptLibraryArchive() { - File jarFile = new File(workDir, KOTLIN_JS_LIBRARY_JAR); + private fun createKotlinJavaScriptLibraryArchive() { + val jarFile = File(workDir, KOTLIN_JS_LIBRARY_JAR) try { - ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(jarFile)); - ZipUtil.addDirToZipRecursively(zip, jarFile, new File(PATH_TO_KOTLIN_JS_LIBRARY), "", null, null); - zip.close(); + val zip = ZipOutputStream(FileOutputStream(jarFile)) + ZipUtil.addDirToZipRecursively(zip, jarFile, File(PATH_TO_KOTLIN_JS_LIBRARY), "", null, null) + zip.close() } - catch (FileNotFoundException ex) { - throw new IllegalStateException(ex.getMessage()); + catch (ex: FileNotFoundException) { + throw IllegalStateException(ex.getMessage()) } - catch (IOException ex) { - throw new IllegalStateException(ex.getMessage()); + catch (ex: IOException) { + throw IllegalStateException(ex.getMessage()) } + } - @NotNull - private static String[] k2jsOutput(String ...moduleNames) { - int length = moduleNames.length; - String[] result = new String[2 * length]; - int index = 0; - for(String moduleName : moduleNames) { - File outputDir = new File("out/production/" + moduleName); - result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).getPath()); - result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).getPath()); + private fun contentOfOutputDir(moduleName: String): Set { + val outputDir = "out/production/$moduleName" + val baseDir = File(workDir, outputDir) + val files = FileUtil.findFilesByMask(Pattern.compile(".*"), baseDir) + val result = HashSet() + for (file in files) { + val relativePath = FileUtil.getRelativePath(baseDir, file) + assert(relativePath != null, "relativePath should not be null") + result.add(toSystemIndependentName(relativePath)) } - return result; + return result } - @NotNull - private Set contentOfOutputDir(String moduleName) { - String outputDir = "out/production/" + moduleName; - File baseDir = new File(workDir, outputDir); - List files = FileUtil.findFilesByMask(Pattern.compile(".*"), baseDir); - Set result = new HashSet(); - for(File file : files) { - String relativePath = FileUtil.getRelativePath(baseDir, file); - assert relativePath != null : "relativePath should not be null"; - result.add(toSystemIndependentName(relativePath)); - } - return result; - } - - @NotNull - private static Set getMethodsOfClass(@NotNull File classFile) throws IOException { - final Set result = new TreeSet(); - new ClassReader(FileUtil.loadFileBytes(classFile)).accept(new ClassVisitor(Opcodes.ASM5) { - @Override - public MethodVisitor visitMethod(int access, @NotNull String name, @NotNull String desc, String signature, String[] exceptions) { - result.add(name); - return null; + public fun testReexportedDependency() { + initProject() + AbstractKotlinJpsBuildTestCase.addKotlinRuntimeDependency(JpsJavaDependencyScope.COMPILE, ContainerUtil.filter(myProject.getModules(), object : Condition { + override fun value(module: JpsModule): Boolean { + return module.getName() == "module2" } - }, 0); - return result; + }), true) + makeAll().assertSuccessful() } - public void testReexportedDependency() { - initProject(); - addKotlinRuntimeDependency(JpsJavaDependencyScope.COMPILE, - ContainerUtil.filter(myProject.getModules(), new Condition() { - @Override - public boolean value(JpsModule module) { - return module.getName().equals("module2"); - } - }), true - ); - makeAll().assertSuccessful(); + throws(InterruptedException::class) + public fun testDoNotCreateUselessKotlinIncrementalCaches() { + initProject() + makeAll().assertSuccessful() + + val storageRoot = BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot() + TestCase.assertTrue(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()) + TestCase.assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) } - public void testDoNotCreateUselessKotlinIncrementalCaches() throws InterruptedException { - initProject(); - makeAll().assertSuccessful(); - - File storageRoot = new BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot(); - assertTrue(new File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()); - assertFalse(new File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()); - } - - @NotNull - private JpsModule findModule(@NotNull String name) { - for (JpsModule module : myProject.getModules()) { - if (module.getName().equals(name)) { - return module; + private fun findModule(name: String): JpsModule { + for (module in myProject.getModules()) { + if (module.getName() == name) { + return module } } - throw new IllegalStateException("Couldn't find module " + name); + throw IllegalStateException("Couldn't find module $name") } - private static void assertFilesExistInOutput(JpsModule module, String... relativePaths) { - for (String path : relativePaths) { - File outputFile = findFileInOutputDir(module, path); - assertTrue("Output not written: " + - outputFile.getAbsolutePath() + - "\n Directory contents: \n" + - dirContents(outputFile.getParentFile()), - outputFile.exists()); - } + private fun checkWhen(action: Action, pathsToCompile: Array?, pathsToDelete: Array?) { + checkWhen(arrayOf(action), pathsToCompile, pathsToDelete) } - private static File findFileInOutputDir(JpsModule module, String relativePath) { - String outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false); - assertNotNull(outputUrl); - File outputDir = new File(JpsPathUtil.urlToPath(outputUrl)); - return new File(outputDir, relativePath); - } - - - private static void assertFilesNotExistInOutput(JpsModule module, String... relativePaths) { - String outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false); - assertNotNull(outputUrl); - File outputDir = new File(JpsPathUtil.urlToPath(outputUrl)); - for (String path : relativePaths) { - File outputFile = new File(outputDir, path); - assertFalse("Output directory \"" + outputFile.getAbsolutePath() + "\" contains \"" + path + "\"", - outputFile.exists()); - } - } - - private static String dirContents(File dir) { - File[] files = dir.listFiles(); - if (files == null) { - return ""; - } - StringBuilder builder = new StringBuilder(); - for (File file : files) { - builder.append(" * ").append(file.getName()).append("\n"); - } - return builder.toString(); - } - - private void checkWhen(Action action, @Nullable String[] pathsToCompile, @Nullable String[] pathsToDelete) { - checkWhen(new Action[]{action}, pathsToCompile, pathsToDelete); - } - - private void checkWhen(Action[] actions, @Nullable String[] pathsToCompile, @Nullable String[] pathsToDelete) { - for (Action action : actions) { - action.apply(); + private fun checkWhen(actions: Array, pathsToCompile: Array?, pathsToDelete: Array?) { + for (action in actions) { + action.apply() } - makeAll().assertSuccessful(); + makeAll().assertSuccessful() if (pathsToCompile != null) { - assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, pathsToCompile); + assertCompiled(KotlinBuilder.KOTLIN_BUILDER_NAME, *pathsToCompile) } if (pathsToDelete != null) { - assertDeleted(pathsToDelete); + assertDeleted(*pathsToDelete) } } - private static String klass(String moduleName, String classFqName) { - String outputDirPrefix = "out/production/" + moduleName + "/"; - return outputDirPrefix + classFqName.replace('.', '/') + ".class"; + private fun packageClasses(moduleName: String, fileName: String, packageClassFqName: String): Array { + return arrayOf(klass(moduleName, packageClassFqName), packagePartClass(moduleName, fileName, packageClassFqName)) } - private String[] packageClasses(String moduleName, String fileName, String packageClassFqName) { - return new String[] {klass(moduleName, packageClassFqName), packagePartClass(moduleName, fileName, packageClassFqName)}; - } - - private String packagePartClass(String moduleName, String fileName, String packageClassFqName) { - String path = FileUtilRt.toSystemIndependentName(new File(workDir, fileName).getAbsolutePath()); - LightVirtualFile fakeVirtualFile = new LightVirtualFile(path) { - @NotNull - @Override - public String getPath() { + private fun packagePartClass(moduleName: String, fileName: String, packageClassFqName: String): String { + val path = FileUtilRt.toSystemIndependentName(File(workDir, fileName).getAbsolutePath()) + val fakeVirtualFile = object : LightVirtualFile(path) { + override fun getPath(): String { // strip extra "/" from the beginning - return super.getPath().substring(1); + return super.getPath().substring(1) } - }; - - FqName packagePartFqName = PackagePartClassUtils.getPackagePartFqName(new FqName(packageClassFqName), fakeVirtualFile); - return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)); - } - - public static String[] mergeArrays(String[]... stringArrays) { - Set result = new HashSet(); - for (String[] array : stringArrays) { - result.addAll(Arrays.asList(array)); - } - return ArrayUtil.toStringArray(result); - } - - private enum Operation { - CHANGE, DELETE - } - - protected Action touch(String path) { - return new Action(Operation.CHANGE, path); - } - - protected Action del(String path) { - return new Action(Operation.DELETE, path); - } - - protected class Action { - private final Operation operation; - private final String path; - - protected Action(Operation operation, String path) { - this.operation = operation; - this.path = path; } - protected void apply() { - File file = new File(workDir, path); + val packagePartFqName = PackagePartClassUtils.getPackagePartFqName(FqName(packageClassFqName), fakeVirtualFile) + return klass(moduleName, AsmUtil.internalNameByFqNameWithoutInnerClasses(packagePartFqName)) + } - if (operation == Operation.CHANGE) { - change(file.getAbsolutePath()); + private enum class Operation { + CHANGE, + DELETE + } + + protected fun touch(path: String): Action { + return Action(Operation.CHANGE, path) + } + + protected fun del(path: String): Action { + return Action(Operation.DELETE, path) + } + + protected inner class Action protected constructor(private val operation: Operation, private val path: String) { + + protected fun apply() { + val file = File(workDir, path) + + if (operation === Operation.CHANGE) { + JpsBuildTestCase.change(file.getAbsolutePath()) } - else if(operation == Operation.DELETE) { - assertTrue("Can not delete file \"" + file.getAbsolutePath() + "\"", file.delete()); + else if (operation === Operation.DELETE) { + TestCase.assertTrue("Can not delete file \"" + file.getAbsolutePath() + "\"", file.delete()) } else { - fail("Unknown operation"); + TestCase.fail("Unknown operation") } } } + + companion object { + private val PROJECT_NAME = "kotlinProject" + private val ADDITIONAL_MODULE_NAME = "module2" + private val JDK_NAME = "IDEA_JDK" + + private val EXCLUDE_FILES = arrayOf("Excluded.class", "YetAnotherExcluded.class") + private val NOTHING = arrayOf() + private val KOTLIN_JS_LIBRARY = "jslib-example" + private val PATH_TO_KOTLIN_JS_LIBRARY = AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY + private val KOTLIN_JS_LIBRARY_JAR = "$KOTLIN_JS_LIBRARY.jar" + private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js") + private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY = KotlinPackage.hashSetOf("$ADDITIONAL_MODULE_NAME.js", "$ADDITIONAL_MODULE_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js") + private val EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js") + private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js", "lib/jslib-example.js", "lib/file0.js", "lib/dir/file1.js", "lib/META-INF-ex/file2.js", "lib/res0.js", "lib/resdir/res1.js") + private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "custom/kotlin.js", "custom/stdlib.meta.js", "custom/jslib-example.js", "custom/file0.js", "custom/dir/file1.js", "custom/META-INF-ex/file2.js", "custom/res0.js", "custom/resdir/res1.js") + + private fun k2jsOutput(vararg moduleNames: String): Array { + val length = moduleNames.size() + val result = arrayOfNulls(2 * length) + var index = 0 + for (moduleName in moduleNames) { + val outputDir = File("out/production/$moduleName") + result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).getPath()) + result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).getPath()) + } + return result + } + + throws(IOException::class) + private fun getMethodsOfClass(classFile: File): Set { + val result = TreeSet() + ClassReader(FileUtil.loadFileBytes(classFile)).accept(object : ClassVisitor(Opcodes.ASM5) { + override fun visitMethod(access: Int, name: String, desc: String, signature: String, exceptions: Array): MethodVisitor? { + result.add(name) + return null + } + }, 0) + return result + } + + private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { + for (path in relativePaths) { + val outputFile = findFileInOutputDir(module, path) + TestCase.assertTrue("Output not written: " + outputFile.getAbsolutePath() + "\n Directory contents: \n" + dirContents(outputFile.getParentFile()), outputFile.exists()) + } + } + + private fun findFileInOutputDir(module: JpsModule, relativePath: String): File { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + TestCase.assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + return File(outputDir, relativePath) + } + + + private fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + TestCase.assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + for (path in relativePaths) { + val outputFile = File(outputDir, path) + TestCase.assertFalse("Output directory \"" + outputFile.getAbsolutePath() + "\" contains \"" + path + "\"", outputFile.exists()) + } + } + + private fun dirContents(dir: File): String { + val files = dir.listFiles() ?: return "" + val builder = StringBuilder() + for (file in files) { + builder.append(" * ").append(file.getName()).append("\n") + } + return builder.toString() + } + + private fun klass(moduleName: String, classFqName: String): String { + val outputDirPrefix = "out/production/$moduleName/" + return outputDirPrefix + classFqName.replace('.', '/') + ".class" + } + + public fun mergeArrays(vararg stringArrays: Array): Array { + val result = HashSet() + for (array in stringArrays) { + result.addAll(Arrays.asList(*array)) + } + return ArrayUtil.toStringArray(result) + } + } } From 13bda2de448e9499041212cff7d8516c78c59aee Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Fri, 3 Jul 2015 13:55:24 +0300 Subject: [PATCH 017/450] convert KotlinJpsBuildTest to Kotlin: step 1: rename --- .../jps/build/{KotlinJpsBuildTest.java => KotlinJpsBuildTest.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename jps-plugin/test/org/jetbrains/kotlin/jps/build/{KotlinJpsBuildTest.java => KotlinJpsBuildTest.kt} (100%) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt similarity index 100% rename from jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.java rename to jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt From ea0c14d7ad9ddce3de1bf501775f22a812425e94 Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Fri, 3 Jul 2015 14:38:56 +0300 Subject: [PATCH 018/450] KotlinJpsBuildTest.kt: minor refactoring after converting --- .../kotlin/jps/build/KotlinJpsBuildTest.kt | 282 +++++++++--------- 1 file changed, 149 insertions(+), 133 deletions(-) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 181a5ec8f34..0c633517d4a 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -19,13 +19,14 @@ package org.jetbrains.kotlin.jps.build import com.google.common.collect.Lists import com.intellij.openapi.util.Condition import com.intellij.openapi.util.io.FileUtil +import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName import com.intellij.openapi.util.io.FileUtilRt import com.intellij.testFramework.LightVirtualFile +import com.intellij.testFramework.UsefulTestCase import com.intellij.util.ArrayUtil import com.intellij.util.containers.ContainerUtil import com.intellij.util.io.ZipUtil -import kotlin.KotlinPackage -import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.JpsBuildTestCase import org.jetbrains.jps.builders.impl.BuildDataPathsImpl import org.jetbrains.jps.model.java.JpsJavaDependencyScope import org.jetbrains.jps.model.java.JpsJavaExtensionService @@ -40,20 +41,136 @@ import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.ClassVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.Opcodes - import java.io.File import java.io.FileNotFoundException import java.io.FileOutputStream import java.io.IOException -import java.util.* +import java.util.Arrays +import java.util.Collections +import java.util.HashSet +import java.util.TreeSet import java.util.regex.Pattern import java.util.zip.ZipOutputStream - -import com.intellij.openapi.util.io.FileUtil.toSystemIndependentName +import kotlin.test.* public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { + companion object { + private val PROJECT_NAME = "kotlinProject" + private val ADDITIONAL_MODULE_NAME = "module2" + private val JDK_NAME = "IDEA_JDK" + + private val EXCLUDE_FILES = arrayOf("Excluded.class", "YetAnotherExcluded.class") + private val NOTHING = arrayOf() + private val KOTLIN_JS_LIBRARY = "jslib-example" + private val PATH_TO_KOTLIN_JS_LIBRARY = AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY + private val KOTLIN_JS_LIBRARY_JAR = "$KOTLIN_JS_LIBRARY.jar" + private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY = hashSetOf( + "$PROJECT_NAME.js", + "$PROJECT_NAME.meta.js", + "lib/kotlin.js", + "lib/stdlib.meta.js" + ) + private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY = hashSetOf( + "$ADDITIONAL_MODULE_NAME.js", + "$ADDITIONAL_MODULE_NAME.meta.js", + "lib/kotlin.js", + "lib/stdlib.meta.js" + ) + private val EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY = hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js") + private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR = hashSetOf( + "$PROJECT_NAME.js", + "$PROJECT_NAME.meta.js", + "lib/kotlin.js", + "lib/stdlib.meta.js", + "lib/jslib-example.js", + "lib/file0.js", + "lib/dir/file1.js", + "lib/META-INF-ex/file2.js", + "lib/res0.js", + "lib/resdir/res1.js" + ) + private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR = hashSetOf( + "$PROJECT_NAME.js", + "$PROJECT_NAME.meta.js", + "custom/kotlin.js", + "custom/stdlib.meta.js", + "custom/jslib-example.js", + "custom/file0.js", + "custom/dir/file1.js", + "custom/META-INF-ex/file2.js", + "custom/res0.js", + "custom/resdir/res1.js" + ) + + private fun k2jsOutput(vararg moduleNames: String): Array { + val list = arrayListOf() + for (moduleName in moduleNames) { + val outputDir = File("out/production/$moduleName") + list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).getPath())) + list.add(toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).getPath())) + } + return list.toTypedArray() + } + + private fun getMethodsOfClass(classFile: File): Set { + val result = TreeSet() + ClassReader(FileUtil.loadFileBytes(classFile)).accept(object : ClassVisitor(Opcodes.ASM5) { + override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array?): MethodVisitor? { + result.add(name) + return null + } + }, 0) + return result + } + + private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { + for (path in relativePaths) { + val outputFile = findFileInOutputDir(module, path) + assertTrue(outputFile.exists(), "Output not written: " + outputFile.getAbsolutePath() + "\n Directory contents: \n" + dirContents(outputFile.getParentFile())) + } + } + + private fun findFileInOutputDir(module: JpsModule, relativePath: String): File { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + return File(outputDir, relativePath) + } + + + private fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) { + val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) + assertNotNull(outputUrl) + val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) + for (path in relativePaths) { + val outputFile = File(outputDir, path) + assertFalse(outputFile.exists(), "Output directory \"" + outputFile.getAbsolutePath() + "\" contains \"" + path + "\"") + } + } + + private fun dirContents(dir: File): String { + val files = dir.listFiles() ?: return "" + val builder = StringBuilder() + for (file in files) { + builder.append(" * ").append(file.getName()).append("\n") + } + return builder.toString() + } + + private fun klass(moduleName: String, classFqName: String): String { + val outputDirPrefix = "out/production/$moduleName/" + return outputDirPrefix + classFqName.replace('.', '/') + ".class" + } + + public fun mergeArrays(vararg stringArrays: Array): Array { + val result = HashSet() + for (array in stringArrays) { + result.addAll(Arrays.asList(*array)) + } + return ArrayUtil.toStringArray(result) + } + } - throws(Exception::class) override fun setUp() { super.setUp() val sourceFilesRoot = File(AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/" + getTestName(false)) @@ -61,16 +178,12 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { getOrCreateProjectDir() } - throws(Exception::class) override fun tearDown() { FileUtil.delete(workDir) super.tearDown() } - throws(IOException::class) - override fun doGetProjectDir(): File { - return workDir - } + override fun doGetProjectDir(): File = workDir private fun initProject() { addJdk(JDK_NAME) @@ -107,7 +220,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { addKotlinJavaScriptStdlibDependency() makeAll().assertSuccessful() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } @@ -116,8 +229,8 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { addKotlinJavaScriptStdlibDependency() makeAll().assertSuccessful() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY, contentOfOutputDir(ADDITIONAL_MODULE_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY, contentOfOutputDir(ADDITIONAL_MODULE_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) checkWhen(touch("module2/src/module2.kt"), null, k2jsOutput(ADDITIONAL_MODULE_NAME)) @@ -138,7 +251,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { addKotlinJavaScriptDependency("KotlinJavaScript", jslibDir) makeAll().assertSuccessful() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } @@ -148,28 +261,28 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY)) makeAll().assertSuccessful() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } public fun testKotlinJavaScriptProjectWithLibrary() { doTestWithKotlinJavaScriptLibrary() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } public fun testKotlinJavaScriptProjectWithLibraryCustomOutputDir() { doTestWithKotlinJavaScriptLibrary() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } public fun testKotlinJavaScriptProjectWithLibraryNoCopy() { doTestWithKotlinJavaScriptLibrary() - TestCase.assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME)) + assertEquals(EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY, contentOfOutputDir(PROJECT_NAME)) checkWhen(touch("src/test1.kt"), null, k2jsOutput(PROJECT_NAME)) } @@ -180,7 +293,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { addKotlinJavaScriptDependency(KOTLIN_JS_LIBRARY, File(workDir, KOTLIN_JS_LIBRARY_JAR)) makeAll().assertFailed() - TestCase.assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME)) + assertEquals(Collections.EMPTY_SET, contentOfOutputDir(PROJECT_NAME)) } public fun testExcludeFolderInSourceRoot() { @@ -333,7 +446,6 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { checkWhen(touch("module2/src/kt1.kt"), null, packageClasses("module2", "module2/src/kt1.kt", "kt1.Kt1Package")) } - throws(IOException::class) public fun testCircularDependenciesSamePackage() { initProject() val result = makeAll() @@ -349,7 +461,6 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { checkWhen(touch("module2/src/b.kt"), null, packageClasses("module2", "module2/src/b.kt", "test.TestPackage")) } - throws(IOException::class) public fun testCircularDependencyWithReferenceToOldVersionLib() { initProject() @@ -361,7 +472,6 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { result.assertSuccessful() } - throws(IOException::class) public fun testDependencyToOldKotlinLib() { initProject() @@ -399,7 +509,7 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { for (file in files) { val relativePath = FileUtil.getRelativePath(baseDir, file) assert(relativePath != null, "relativePath should not be null") - result.add(toSystemIndependentName(relativePath)) + result.add(toSystemIndependentName(relativePath!!)) } return result } @@ -414,14 +524,13 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { makeAll().assertSuccessful() } - throws(InterruptedException::class) public fun testDoNotCreateUselessKotlinIncrementalCaches() { initProject() makeAll().assertSuccessful() val storageRoot = BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot() - TestCase.assertTrue(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()) - TestCase.assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) + assertTrue(File(storageRoot, "targets/java-test/kotlinProject/kotlin").exists()) + assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) } private fun findModule(name: String): JpsModule { @@ -475,116 +584,23 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { DELETE } - protected fun touch(path: String): Action { - return Action(Operation.CHANGE, path) - } + protected fun touch(path: String): Action = Action(Operation.CHANGE, path) - protected fun del(path: String): Action { - return Action(Operation.DELETE, path) - } + protected fun del(path: String): Action = Action(Operation.DELETE, path) - protected inner class Action protected constructor(private val operation: Operation, private val path: String) { + protected fun change(filePath: String): Unit = JpsBuildTestCase.change(filePath) - protected fun apply() { + protected inner class Action constructor(private val operation: Operation, private val path: String) { + fun apply() { val file = File(workDir, path) - - if (operation === Operation.CHANGE) { - JpsBuildTestCase.change(file.getAbsolutePath()) + when (operation) { + Operation.CHANGE -> + change(file.getAbsolutePath()) + Operation.DELETE -> + assertTrue(file.delete(), "Can not delete file \"" + file.getAbsolutePath() + "\"") + else -> + fail("Unknown operation") } - else if (operation === Operation.DELETE) { - TestCase.assertTrue("Can not delete file \"" + file.getAbsolutePath() + "\"", file.delete()) - } - else { - TestCase.fail("Unknown operation") - } - } - } - - companion object { - private val PROJECT_NAME = "kotlinProject" - private val ADDITIONAL_MODULE_NAME = "module2" - private val JDK_NAME = "IDEA_JDK" - - private val EXCLUDE_FILES = arrayOf("Excluded.class", "YetAnotherExcluded.class") - private val NOTHING = arrayOf() - private val KOTLIN_JS_LIBRARY = "jslib-example" - private val PATH_TO_KOTLIN_JS_LIBRARY = AbstractKotlinJpsBuildTestCase.TEST_DATA_PATH + "general/KotlinJavaScriptProjectWithDirectoryAsLibrary/" + KOTLIN_JS_LIBRARY - private val KOTLIN_JS_LIBRARY_JAR = "$KOTLIN_JS_LIBRARY.jar" - private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_STDLIB_ONLY = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js") - private val EXPECTED_JS_FILES_IN_OUTPUT_FOR_MODULE_STDLIB_ONLY = KotlinPackage.hashSetOf("$ADDITIONAL_MODULE_NAME.js", "$ADDITIONAL_MODULE_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js") - private val EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js") - private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "lib/kotlin.js", "lib/stdlib.meta.js", "lib/jslib-example.js", "lib/file0.js", "lib/dir/file1.js", "lib/META-INF-ex/file2.js", "lib/res0.js", "lib/resdir/res1.js") - private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR = KotlinPackage.hashSetOf("$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", "custom/kotlin.js", "custom/stdlib.meta.js", "custom/jslib-example.js", "custom/file0.js", "custom/dir/file1.js", "custom/META-INF-ex/file2.js", "custom/res0.js", "custom/resdir/res1.js") - - private fun k2jsOutput(vararg moduleNames: String): Array { - val length = moduleNames.size() - val result = arrayOfNulls(2 * length) - var index = 0 - for (moduleName in moduleNames) { - val outputDir = File("out/production/$moduleName") - result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputFile(outputDir, moduleName).getPath()) - result[index++] = toSystemIndependentName(JpsJsModuleUtils.getOutputMetaFile(outputDir, moduleName).getPath()) - } - return result - } - - throws(IOException::class) - private fun getMethodsOfClass(classFile: File): Set { - val result = TreeSet() - ClassReader(FileUtil.loadFileBytes(classFile)).accept(object : ClassVisitor(Opcodes.ASM5) { - override fun visitMethod(access: Int, name: String, desc: String, signature: String, exceptions: Array): MethodVisitor? { - result.add(name) - return null - } - }, 0) - return result - } - - private fun assertFilesExistInOutput(module: JpsModule, vararg relativePaths: String) { - for (path in relativePaths) { - val outputFile = findFileInOutputDir(module, path) - TestCase.assertTrue("Output not written: " + outputFile.getAbsolutePath() + "\n Directory contents: \n" + dirContents(outputFile.getParentFile()), outputFile.exists()) - } - } - - private fun findFileInOutputDir(module: JpsModule, relativePath: String): File { - val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) - TestCase.assertNotNull(outputUrl) - val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) - return File(outputDir, relativePath) - } - - - private fun assertFilesNotExistInOutput(module: JpsModule, vararg relativePaths: String) { - val outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false) - TestCase.assertNotNull(outputUrl) - val outputDir = File(JpsPathUtil.urlToPath(outputUrl)) - for (path in relativePaths) { - val outputFile = File(outputDir, path) - TestCase.assertFalse("Output directory \"" + outputFile.getAbsolutePath() + "\" contains \"" + path + "\"", outputFile.exists()) - } - } - - private fun dirContents(dir: File): String { - val files = dir.listFiles() ?: return "" - val builder = StringBuilder() - for (file in files) { - builder.append(" * ").append(file.getName()).append("\n") - } - return builder.toString() - } - - private fun klass(moduleName: String, classFqName: String): String { - val outputDirPrefix = "out/production/$moduleName/" - return outputDirPrefix + classFqName.replace('.', '/') + ".class" - } - - public fun mergeArrays(vararg stringArrays: Array): Array { - val result = HashSet() - for (array in stringArrays) { - result.addAll(Arrays.asList(*array)) - } - return ArrayUtil.toStringArray(result) } } } From 8cd978bfd82a88ff6aa9d881fcbf97d1af683d55 Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Fri, 3 Jul 2015 15:37:20 +0300 Subject: [PATCH 019/450] add tests for KT-8158 make Kotlin compiler invoked from IDEA cancellable --- .../kotlin/jps/build/KotlinJpsBuildTest.kt | 106 +++++++++++++++++- .../CancelKotlinCompilation/kotlinProject.iml | 12 ++ .../CancelKotlinCompilation/kotlinProject.ipr | 14 +++ .../CancelKotlinCompilation/src/Bar.kt | 3 + .../CancelLongKotlinCompilation/expected.log | 3 + .../kotlinProject.iml | 12 ++ .../kotlinProject.ipr | 14 +++ 7 files changed, 160 insertions(+), 4 deletions(-) create mode 100644 jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml create mode 100644 jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr create mode 100644 jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt create mode 100644 jps-plugin/testData/general/CancelLongKotlinCompilation/expected.log create mode 100644 jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.iml create mode 100644 jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.ipr diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 0c633517d4a..3d1f63bbe35 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -26,8 +26,16 @@ import com.intellij.testFramework.UsefulTestCase import com.intellij.util.ArrayUtil import com.intellij.util.containers.ContainerUtil import com.intellij.util.io.ZipUtil +import org.jetbrains.jps.api.CanceledStatus +import org.jetbrains.jps.builders.BuildResult +import org.jetbrains.jps.builders.CompileScopeTestBuilder import org.jetbrains.jps.builders.JpsBuildTestCase +import org.jetbrains.jps.builders.TestProjectBuilderLogger import org.jetbrains.jps.builders.impl.BuildDataPathsImpl +import org.jetbrains.jps.builders.logging.BuildLoggingManager +import org.jetbrains.jps.incremental.BuilderRegistry +import org.jetbrains.jps.incremental.IncProjectBuilder +import org.jetbrains.jps.incremental.messages.BuildMessage import org.jetbrains.jps.model.java.JpsJavaDependencyScope import org.jetbrains.jps.model.java.JpsJavaExtensionService import org.jetbrains.jps.model.module.JpsModule @@ -41,10 +49,7 @@ import org.jetbrains.org.objectweb.asm.ClassReader import org.jetbrains.org.objectweb.asm.ClassVisitor import org.jetbrains.org.objectweb.asm.MethodVisitor import org.jetbrains.org.objectweb.asm.Opcodes -import java.io.File -import java.io.FileNotFoundException -import java.io.FileOutputStream -import java.io.IOException +import java.io.* import java.util.Arrays import java.util.Collections import java.util.HashSet @@ -533,6 +538,99 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { assertFalse(File(storageRoot, "targets/java-production/kotlinProject/kotlin").exists()) } + public fun testCancelLongKotlinCompilation() { + generateLongKotlinFile("Foo.kt", "foo", "Foo") + initProject() + + val start = System.currentTimeMillis() + val canceledStatus = CanceledStatus() { System.currentTimeMillis() - start > 2000 } + + val logger = TestProjectBuilderLogger() + val buildResult = BuildResult() + buildCustom(canceledStatus, logger, buildResult) + val interval = System.currentTimeMillis() - start + + assertCanceled(buildResult) + buildResult.assertSuccessful() + assert(interval < 8000, "expected time for canceled compilation < 8000 ms, but $interval") + + val module = myProject.getModules().get(0) + assertFilesNotExistInOutput(module, "foo/Foo.class") + + val expectedLog = workDir.getAbsolutePath() + File.separator + "expected.log" + checkFullLog(logger, File(expectedLog)) + } + + public fun testCancelKotlinCompilation() { + initProject() + makeAll().assertSuccessful() + + val module = myProject.getModules().get(0) + assertFilesExistInOutput(module, "foo/Bar.class") + + val buildResult = BuildResult() + val canceledStatus = object: CanceledStatus { + var checkFromIndex = 0; + + public override fun isCanceled(): Boolean { + val messages = buildResult.getMessages(BuildMessage.Kind.INFO) + for (i in checkFromIndex..messages.size()-1) { + if (messages.get(i).getMessageText().startsWith("Kotlin JPS plugin version")) return true; + } + + checkFromIndex = messages.size(); + return false; + } + } + + touch("src/Bar.kt").apply() + buildCustom(canceledStatus, TestProjectBuilderLogger(), buildResult) + assertCanceled(buildResult) + + assertFilesNotExistInOutput(module, "foo/Bar.class") + } + + private fun buildCustom(canceledStatus: CanceledStatus, logger: TestProjectBuilderLogger,buildResult: BuildResult) { + val scopeBuilder = CompileScopeTestBuilder.make().all() + val descriptor = this.createProjectDescriptor(BuildLoggingManager(logger)) + try { + val builder = IncProjectBuilder(descriptor, BuilderRegistry.getInstance(), this.myBuildParams, canceledStatus, null, true) + builder.addMessageHandler(buildResult) + builder.build(scopeBuilder.build(), false) + } + finally { + descriptor.release() + } + } + + private fun checkFullLog(logger: TestProjectBuilderLogger, expectedLogFile: File) { + UsefulTestCase.assertSameLinesWithFile(expectedLogFile.getAbsolutePath(), logger.getFullLog(getOrCreateProjectDir(), myDataStorageRoot)) + } + + private fun assertCanceled(buildResult: BuildResult) { + val list = buildResult.getMessages(BuildMessage.Kind.INFO) + assertTrue("The build has been canceled".equals(list.last().getMessageText())) + } + + private fun generateLongKotlinFile(filePath: String, packagename: String, className: String) { + val file = File(workDir.getAbsolutePath() + File.separator + "src" + File.separator + filePath) + FileUtilRt.createIfNotExists(file) + val writer = BufferedWriter(FileWriter(file)) + try { + writer.write("package $packagename\n\n") + writer.write("public class $className {\n") + + for (i in 0..10000) { + writer.write("fun f$i():Int = $i\n\n") + } + + writer.write("}\n") + } + finally { + writer.close() + } + } + private fun findModule(name: String): JpsModule { for (module in myProject.getModules()) { if (module.getName() == name) { diff --git a/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml b/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr b/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps-plugin/testData/general/CancelKotlinCompilation/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt b/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt new file mode 100644 index 00000000000..2c990ada4c7 --- /dev/null +++ b/jps-plugin/testData/general/CancelKotlinCompilation/src/Bar.kt @@ -0,0 +1,3 @@ +package foo + +class Bar diff --git a/jps-plugin/testData/general/CancelLongKotlinCompilation/expected.log b/jps-plugin/testData/general/CancelLongKotlinCompilation/expected.log new file mode 100644 index 00000000000..d5d22ab8abe --- /dev/null +++ b/jps-plugin/testData/general/CancelLongKotlinCompilation/expected.log @@ -0,0 +1,3 @@ +Compiling files: +src/Foo.kt +End of files \ No newline at end of file diff --git a/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.iml b/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.iml new file mode 100644 index 00000000000..0c4fb67a3d4 --- /dev/null +++ b/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.ipr b/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.ipr new file mode 100644 index 00000000000..8226e21ade3 --- /dev/null +++ b/jps-plugin/testData/general/CancelLongKotlinCompilation/kotlinProject.ipr @@ -0,0 +1,14 @@ + + + + + + + + + + + + + From 9618a3542fd99bb6409143a7d144e2bd97af17c8 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 5 Jun 2015 15:45:00 +0300 Subject: [PATCH 020/450] Provide getOrElse and getOrNull methods for indexed collections. Breaking: elementAtOrElse is no longer inlined for Iterables and Sequences. #KT-6952 --- libraries/stdlib/src/generated/_Elements.kt | 162 +++++++++++++++++- .../test/collections/ListSpecificTest.kt | 16 ++ .../src/templates/Elements.kt | 30 +++- 3 files changed, 201 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/src/generated/_Elements.kt b/libraries/stdlib/src/generated/_Elements.kt index d57c2d248ce..26a6543af20 100644 --- a/libraries/stdlib/src/generated/_Elements.kt +++ b/libraries/stdlib/src/generated/_Elements.kt @@ -600,9 +600,9 @@ public inline fun ShortArray.elementAtOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. */ -public inline fun Iterable.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { +public fun Iterable.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { if (this is List) - return this.elementAtOrElse(index, defaultValue) + return this.getOrElse(index, defaultValue) if (index < 0) return defaultValue(index) val iterator = iterator() @@ -625,7 +625,7 @@ public inline fun List.elementAtOrElse(index: Int, defaultValue: (Int) -> /** * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. */ -public inline fun Sequence.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { +public fun Sequence.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { if (index < 0) return defaultValue(index) val iterator = iterator() @@ -713,7 +713,7 @@ public fun ShortArray.elementAtOrNull(index: Int): Short? { */ public fun Iterable.elementAtOrNull(index: Int): T? { if (this is List) - return this.elementAtOrNull(index) + return this.getOrNull(index) if (index < 0) return null val iterator = iterator() @@ -1229,6 +1229,160 @@ public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? { return null } +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun Array.getOrElse(index: Int, defaultValue: (Int) -> T): T { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun BooleanArray.getOrElse(index: Int, defaultValue: (Int) -> Boolean): Boolean { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun ByteArray.getOrElse(index: Int, defaultValue: (Int) -> Byte): Byte { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun CharArray.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun DoubleArray.getOrElse(index: Int, defaultValue: (Int) -> Double): Double { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun FloatArray.getOrElse(index: Int, defaultValue: (Int) -> Float): Float { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun IntArray.getOrElse(index: Int, defaultValue: (Int) -> Int): Int { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun LongArray.getOrElse(index: Int, defaultValue: (Int) -> Long): Long { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun ShortArray.getOrElse(index: Int, defaultValue: (Int) -> Short): Short { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun List.getOrElse(index: Int, defaultValue: (Int) -> T): T { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + */ +public inline fun String.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun Array.getOrNull(index: Int): T? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun BooleanArray.getOrNull(index: Int): Boolean? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun ByteArray.getOrNull(index: Int): Byte? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun CharArray.getOrNull(index: Int): Char? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun DoubleArray.getOrNull(index: Int): Double? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun FloatArray.getOrNull(index: Int): Float? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun IntArray.getOrNull(index: Int): Int? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun LongArray.getOrNull(index: Int): Long? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun ShortArray.getOrNull(index: Int): Short? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun List.getOrNull(index: Int): T? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + +/** + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + */ +public fun String.getOrNull(index: Int): Char? { + return if (index >= 0 && index <= lastIndex) get(index) else null +} + /** * Returns first index of [element], or -1 if the collection does not contain element. */ diff --git a/libraries/stdlib/test/collections/ListSpecificTest.kt b/libraries/stdlib/test/collections/ListSpecificTest.kt index 2e136584390..b494c742724 100644 --- a/libraries/stdlib/test/collections/ListSpecificTest.kt +++ b/libraries/stdlib/test/collections/ListSpecificTest.kt @@ -28,6 +28,22 @@ class ListSpecificTest { assertEquals(listOf('C', 'A', 'D'), list.slice(iter)) } + Test fun getOr() { + expect("foo") { data.get(0) } + expect("bar") { data.get(1) } + fails { data.get(2) } + fails { data.get(-1) } + fails { empty.get(0) } + + expect("foo") { data.getOrElse(0, {""} )} + expect("zoo") { data.getOrElse(-1, { "zoo" })} + expect("zoo") { data.getOrElse(2, { "zoo" })} + expect("zoo") { empty.getOrElse(0) { "zoo" }} + + expect(null) { empty.getOrNull(0) } + + } + Test fun lastIndex() { assertEquals(-1, empty.lastIndex) assertEquals(1, data.lastIndex) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 1a1553ee019..c05cfece09e 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -202,11 +202,10 @@ fun elements(): List { templates add f("elementAtOrElse(index: Int, defaultValue: (Int) -> T)") { doc { "Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection." } returns("T") - inline(true) body { """ if (this is List) - return this.elementAtOrElse(index, defaultValue) + return this.getOrElse(index, defaultValue) if (index < 0) return defaultValue(index) val iterator = iterator() @@ -233,6 +232,7 @@ fun elements(): List { return defaultValue(index) """ } + inline(true, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) body(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) @@ -240,6 +240,18 @@ fun elements(): List { } } + templates add f("getOrElse(index: Int, defaultValue: (Int) -> T)") { + doc { "Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection." } + returns("T") + inline(true) + only(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) + body { + """ + return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) + """ + } + } + templates add f("elementAtOrNull(index: Int)") { doc { "Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection." } @@ -247,7 +259,7 @@ fun elements(): List { body { """ if (this is List) - return this.elementAtOrNull(index) + return this.getOrNull(index) if (index < 0) return null val iterator = iterator() @@ -281,6 +293,18 @@ fun elements(): List { } } + templates add f("getOrNull(index: Int)") { + doc { "Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection." } + returns("T?") + only(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) + body { + """ + return if (index >= 0 && index <= lastIndex) get(index) else null + """ + } + } + + templates add f("first()") { doc { """Returns first element. @throws [NoSuchElementException] if the collection is empty. From f7436064d04932364775b5ca6f232142c908151e Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Jul 2015 20:56:10 +0300 Subject: [PATCH 021/450] Unify componentN templates and add NOTHING_TO_INLINE suppression. --- libraries/stdlib/src/generated/_Elements.kt | 50 +++++++++++++++++++ .../src/templates/Elements.kt | 49 ++++++------------ 2 files changed, 65 insertions(+), 34 deletions(-) diff --git a/libraries/stdlib/src/generated/_Elements.kt b/libraries/stdlib/src/generated/_Elements.kt index 26a6543af20..e308581f8e1 100644 --- a/libraries/stdlib/src/generated/_Elements.kt +++ b/libraries/stdlib/src/generated/_Elements.kt @@ -13,6 +13,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun Array.component1(): T { return get(0) } @@ -20,6 +21,7 @@ public inline fun Array.component1(): T { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun BooleanArray.component1(): Boolean { return get(0) } @@ -27,6 +29,7 @@ public inline fun BooleanArray.component1(): Boolean { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ByteArray.component1(): Byte { return get(0) } @@ -34,6 +37,7 @@ public inline fun ByteArray.component1(): Byte { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun CharArray.component1(): Char { return get(0) } @@ -41,6 +45,7 @@ public inline fun CharArray.component1(): Char { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun DoubleArray.component1(): Double { return get(0) } @@ -48,6 +53,7 @@ public inline fun DoubleArray.component1(): Double { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun FloatArray.component1(): Float { return get(0) } @@ -55,6 +61,7 @@ public inline fun FloatArray.component1(): Float { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun IntArray.component1(): Int { return get(0) } @@ -62,6 +69,7 @@ public inline fun IntArray.component1(): Int { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun LongArray.component1(): Long { return get(0) } @@ -69,6 +77,7 @@ public inline fun LongArray.component1(): Long { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ShortArray.component1(): Short { return get(0) } @@ -76,6 +85,7 @@ public inline fun ShortArray.component1(): Short { /** * Returns 1st *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun List.component1(): T { return get(0) } @@ -83,6 +93,7 @@ public inline fun List.component1(): T { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun Array.component2(): T { return get(1) } @@ -90,6 +101,7 @@ public inline fun Array.component2(): T { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun BooleanArray.component2(): Boolean { return get(1) } @@ -97,6 +109,7 @@ public inline fun BooleanArray.component2(): Boolean { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ByteArray.component2(): Byte { return get(1) } @@ -104,6 +117,7 @@ public inline fun ByteArray.component2(): Byte { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun CharArray.component2(): Char { return get(1) } @@ -111,6 +125,7 @@ public inline fun CharArray.component2(): Char { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun DoubleArray.component2(): Double { return get(1) } @@ -118,6 +133,7 @@ public inline fun DoubleArray.component2(): Double { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun FloatArray.component2(): Float { return get(1) } @@ -125,6 +141,7 @@ public inline fun FloatArray.component2(): Float { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun IntArray.component2(): Int { return get(1) } @@ -132,6 +149,7 @@ public inline fun IntArray.component2(): Int { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun LongArray.component2(): Long { return get(1) } @@ -139,6 +157,7 @@ public inline fun LongArray.component2(): Long { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ShortArray.component2(): Short { return get(1) } @@ -146,6 +165,7 @@ public inline fun ShortArray.component2(): Short { /** * Returns 2nd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun List.component2(): T { return get(1) } @@ -153,6 +173,7 @@ public inline fun List.component2(): T { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun Array.component3(): T { return get(2) } @@ -160,6 +181,7 @@ public inline fun Array.component3(): T { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun BooleanArray.component3(): Boolean { return get(2) } @@ -167,6 +189,7 @@ public inline fun BooleanArray.component3(): Boolean { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ByteArray.component3(): Byte { return get(2) } @@ -174,6 +197,7 @@ public inline fun ByteArray.component3(): Byte { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun CharArray.component3(): Char { return get(2) } @@ -181,6 +205,7 @@ public inline fun CharArray.component3(): Char { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun DoubleArray.component3(): Double { return get(2) } @@ -188,6 +213,7 @@ public inline fun DoubleArray.component3(): Double { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun FloatArray.component3(): Float { return get(2) } @@ -195,6 +221,7 @@ public inline fun FloatArray.component3(): Float { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun IntArray.component3(): Int { return get(2) } @@ -202,6 +229,7 @@ public inline fun IntArray.component3(): Int { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun LongArray.component3(): Long { return get(2) } @@ -209,6 +237,7 @@ public inline fun LongArray.component3(): Long { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ShortArray.component3(): Short { return get(2) } @@ -216,6 +245,7 @@ public inline fun ShortArray.component3(): Short { /** * Returns 3rd *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun List.component3(): T { return get(2) } @@ -223,6 +253,7 @@ public inline fun List.component3(): T { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun Array.component4(): T { return get(3) } @@ -230,6 +261,7 @@ public inline fun Array.component4(): T { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun BooleanArray.component4(): Boolean { return get(3) } @@ -237,6 +269,7 @@ public inline fun BooleanArray.component4(): Boolean { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ByteArray.component4(): Byte { return get(3) } @@ -244,6 +277,7 @@ public inline fun ByteArray.component4(): Byte { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun CharArray.component4(): Char { return get(3) } @@ -251,6 +285,7 @@ public inline fun CharArray.component4(): Char { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun DoubleArray.component4(): Double { return get(3) } @@ -258,6 +293,7 @@ public inline fun DoubleArray.component4(): Double { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun FloatArray.component4(): Float { return get(3) } @@ -265,6 +301,7 @@ public inline fun FloatArray.component4(): Float { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun IntArray.component4(): Int { return get(3) } @@ -272,6 +309,7 @@ public inline fun IntArray.component4(): Int { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun LongArray.component4(): Long { return get(3) } @@ -279,6 +317,7 @@ public inline fun LongArray.component4(): Long { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ShortArray.component4(): Short { return get(3) } @@ -286,6 +325,7 @@ public inline fun ShortArray.component4(): Short { /** * Returns 4th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun List.component4(): T { return get(3) } @@ -293,6 +333,7 @@ public inline fun List.component4(): T { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun Array.component5(): T { return get(4) } @@ -300,6 +341,7 @@ public inline fun Array.component5(): T { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun BooleanArray.component5(): Boolean { return get(4) } @@ -307,6 +349,7 @@ public inline fun BooleanArray.component5(): Boolean { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ByteArray.component5(): Byte { return get(4) } @@ -314,6 +357,7 @@ public inline fun ByteArray.component5(): Byte { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun CharArray.component5(): Char { return get(4) } @@ -321,6 +365,7 @@ public inline fun CharArray.component5(): Char { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun DoubleArray.component5(): Double { return get(4) } @@ -328,6 +373,7 @@ public inline fun DoubleArray.component5(): Double { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun FloatArray.component5(): Float { return get(4) } @@ -335,6 +381,7 @@ public inline fun FloatArray.component5(): Float { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun IntArray.component5(): Int { return get(4) } @@ -342,6 +389,7 @@ public inline fun IntArray.component5(): Int { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun LongArray.component5(): Long { return get(4) } @@ -349,6 +397,7 @@ public inline fun LongArray.component5(): Long { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun ShortArray.component5(): Short { return get(4) } @@ -356,6 +405,7 @@ public inline fun ShortArray.component5(): Short { /** * Returns 5th *element* from the collection. */ +suppress("NOTHING_TO_INLINE") public inline fun List.component5(): T { return get(4) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index c05cfece09e..00a5bf4519b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -704,40 +704,21 @@ fun elements(): List { } } - templates add f("component1()") { - inline(true) - doc { "Returns 1st *element* from the collection." } - returns("T") - body { "return get(0)" } - only(Lists, ArraysOfObjects, ArraysOfPrimitives) - } - templates add f("component2()") { - inline(true) - doc { "Returns 2nd *element* from the collection." } - returns("T") - body { "return get(1)" } - only(Lists, ArraysOfObjects, ArraysOfPrimitives) - } - templates add f("component3()") { - inline(true) - doc { "Returns 3rd *element* from the collection." } - returns("T") - body { "return get(2)" } - only(Lists, ArraysOfObjects, ArraysOfPrimitives) - } - templates add f("component4()") { - inline(true) - doc { "Returns 4th *element* from the collection." } - returns("T") - body { "return get(3)" } - only(Lists, ArraysOfObjects, ArraysOfPrimitives) - } - templates add f("component5()") { - inline(true) - doc { "Returns 5th *element* from the collection." } - returns("T") - body { "return get(4)" } - only(Lists, ArraysOfObjects, ArraysOfPrimitives) + templates addAll (1..5).map { n -> + f("component$n()") { + inline(true) + annotations("""suppress("NOTHING_TO_INLINE")""") + fun getOrdinal(n: Int) = n.toString() + when (n) { + 1 -> "st" + 2 -> "nd" + 3 -> "rd" + else -> "th" + } + doc { "Returns ${getOrdinal(n)} *element* from the collection." } + returns("T") + body { "return get(${n-1})" } + only(Lists, ArraysOfObjects, ArraysOfPrimitives) + } } return templates From e135b6ae967a46a0b91068b50e6306f1827c162d Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 2 Jul 2015 18:03:31 +0300 Subject: [PATCH 022/450] Recompute KotlinResolveCache for synthetic files on project structure modification Since computed KotlinResolveCache depends on corresponding synthetic files location (namely, moduleFilter), it should be recomputed in this case The STR for this issue provided by Alexander Udalov: 1. Open a library source, wait for it to be analyzed. In this case library sources are files in the project under core/builtins/src/. 2. Go to project settings and remove the source from the library. 3. Exception now on each file change, out of block doesn't seem to help. --- .../idea/caches/resolve/KotlinCacheService.kt | 123 ++++++++++-------- 1 file changed, 67 insertions(+), 56 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt index d3c016855c9..b22b6120619 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.openapi.roots.ProjectRootModificationTracker import com.intellij.psi.util.CachedValueProvider +import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.PsiModificationTracker import com.intellij.util.containers.SLRUCache import org.jetbrains.kotlin.analyzer.AnalysisResult @@ -102,67 +103,77 @@ public class KotlinCacheService(val project: Project) { private fun getGlobalCache(platform: TargetPlatform) = globalCachesPerPlatform[platform]!!.modulesCache private fun getGlobalLibrariesCache(platform: TargetPlatform) = globalCachesPerPlatform[platform]!!.librariesCache - private val syntheticFileCaches = object : SLRUCache, KotlinResolveCache>(2, 3) { - override fun createValue(files: Set): KotlinResolveCache { - // we assume that all files come from the same module - val targetPlatform = files.map { TargetPlatformDetector.getPlatform(it) }.toSet().single() - val syntheticFileModule = files.map { it.getModuleInfo() }.toSet().single() - val dependenciesForSyntheticFileCache = listOf( - PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, - KotlinOutOfBlockCompletionModificationTracker.getInstance(project) - ) - return when { - syntheticFileModule is ModuleSourceInfo -> { - val dependentModules = syntheticFileModule.getDependentModules() - KotlinResolveCache( - project, - globalResolveSessionProvider( - targetPlatform, - syntheticFiles = files, - reuseDataFromCache = getGlobalCache(targetPlatform), - moduleFilter = { it in dependentModules }, - dependencies = dependenciesForSyntheticFileCache - ) - ) - } - - syntheticFileModule is LibrarySourceInfo || syntheticFileModule is NotUnderContentRootModuleInfo -> { - KotlinResolveCache( - project, - globalResolveSessionProvider( - targetPlatform, - syntheticFiles = files, - reuseDataFromCache = getGlobalLibrariesCache(targetPlatform), - moduleFilter = { it == syntheticFileModule }, - dependencies = dependenciesForSyntheticFileCache - ) - ) - } - - syntheticFileModule.isLibraryClasses() -> { - //NOTE: this code should not be called for sdk or library classes - // currently the only known scenario is when we cannot determine that file is a library source - // (file under both classes and sources root) - LOG.warn("Creating cache with synthetic files ($files) in classes of library $syntheticFileModule") - KotlinResolveCache( - project, - globalResolveSessionProvider( - targetPlatform, - syntheticFiles = files, - moduleFilter = { true }, - dependencies = dependenciesForSyntheticFileCache - ) - ) - } - - else -> throw IllegalStateException("Unknown IdeaModuleInfo ${syntheticFileModule.javaClass}") + private fun createCacheForSyntheticFiles(files: Set): KotlinResolveCache { + // we assume that all files come from the same module + val targetPlatform = files.map { TargetPlatformDetector.getPlatform(it) }.toSet().single() + val syntheticFileModule = files.map { it.getModuleInfo() }.toSet().single() + val dependenciesForSyntheticFileCache = listOf( + PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, + KotlinOutOfBlockCompletionModificationTracker.getInstance(project) + ) + return when { + syntheticFileModule is ModuleSourceInfo -> { + val dependentModules = syntheticFileModule.getDependentModules() + KotlinResolveCache( + project, + globalResolveSessionProvider( + targetPlatform, + syntheticFiles = files, + reuseDataFromCache = getGlobalCache(targetPlatform), + moduleFilter = { it in dependentModules }, + dependencies = dependenciesForSyntheticFileCache + ) + ) } + + syntheticFileModule is LibrarySourceInfo || syntheticFileModule is NotUnderContentRootModuleInfo -> { + KotlinResolveCache( + project, + globalResolveSessionProvider( + targetPlatform, + syntheticFiles = files, + reuseDataFromCache = getGlobalLibrariesCache(targetPlatform), + moduleFilter = { it == syntheticFileModule }, + dependencies = dependenciesForSyntheticFileCache + ) + ) + } + + syntheticFileModule.isLibraryClasses() -> { + //NOTE: this code should not be called for sdk or library classes + // currently the only known scenario is when we cannot determine that file is a library source + // (file under both classes and sources root) + LOG.warn("Creating cache with synthetic files ($files) in classes of library $syntheticFileModule") + KotlinResolveCache( + project, + globalResolveSessionProvider( + targetPlatform, + syntheticFiles = files, + moduleFilter = { true }, + dependencies = dependenciesForSyntheticFileCache + ) + ) + } + + else -> throw IllegalStateException("Unknown IdeaModuleInfo ${syntheticFileModule.javaClass}") } } + private val syntheticFileCachesLock = Any() + + private val slruCacheProvider = CachedValueProvider { + CachedValueProvider.Result(object : SLRUCache, KotlinResolveCache>(2, 3) { + override fun createValue(files: Set): KotlinResolveCache { + return createCacheForSyntheticFiles(files) + } + }, LibraryModificationTracker.getInstance(project), ProjectRootModificationTracker.getInstance(project)) + } + private fun getCacheForSyntheticFiles(files: Set): KotlinResolveCache { - return synchronized(syntheticFileCaches) { - syntheticFileCaches[files] + return synchronized(syntheticFileCachesLock) { + //NOTE: computations inside createCacheForSyntheticFiles depend on project root structure + // so we additionally drop the whole slru cache on change + CachedValuesManager.getManager(project).getCachedValue(project, slruCacheProvider).get(files) } } From c66a4d53fd0d1290bad86adf6b947cff1dfee4cc Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Mon, 29 Jun 2015 17:45:46 +0300 Subject: [PATCH 023/450] Introduce Variable: Use name entered in template as a variable name #KT-8358 Fixed --- .../introduceVariable/KotlinVariableInplaceIntroducer.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt index d4de5a32ae8..7df0eeb6479 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinVariableInplaceIntroducer.kt @@ -147,7 +147,9 @@ public class KotlinVariableInplaceIntroducer( override fun getComponent() = myWholePanel override fun performIntroduce() { - val replacement = JetPsiFactory(myProject).createExpression(addedVariable.getName() ?: return) + val newName = getInputName() ?: return + addedVariable.setName(newName) + val replacement = JetPsiFactory(myProject).createExpression(newName) getOccurrences().forEach { if (it.isValid()) { it.replace(replacement) From c96349f42b9c5fafcb01ba7e559fb5db679733d8 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 30 Jun 2015 18:08:57 +0300 Subject: [PATCH 024/450] Change Signature: Filter out OverriderUsageInfo(s) corresponding to Kotlin declarations --- .../JetChangeSignatureUsageProcessor.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index c80ab2dd743..25c2def5e92 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -40,6 +40,7 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.intellij.util.containers.MultiMap; +import jet.runtime.typeinfo.JetValueParameter; import kotlin.KotlinPackage; import kotlin.Unit; import kotlin.jvm.functions.Function1; @@ -55,6 +56,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde; import org.jetbrains.kotlin.idea.codeInsight.JetFileReferencesResolver; import org.jetbrains.kotlin.idea.core.refactoring.RefactoringPackage; import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.*; +import org.jetbrains.kotlin.idea.refactoring.rename.UnresolvableConventionViolationUsageInfo; import org.jetbrains.kotlin.idea.references.JetSimpleNameReference; import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage; import org.jetbrains.kotlin.kdoc.psi.impl.KDocName; @@ -381,10 +383,25 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro public MultiMap findConflicts(ChangeInfo info, Ref refUsages) { MultiMap result = new MultiMap(); - if (!(info instanceof JetChangeInfo)) { - return result; + // Delete OverriderUsageInfo for Kotlin declarations since they can't be processed correctly + // TODO: Drop when OverriderUsageInfo.getElement() gets deleted + UsageInfo[] usageInfos = refUsages.get(); + List adjustedUsages = KotlinPackage.filterNot( + usageInfos, + new Function1() { + @Override + public Boolean invoke(UsageInfo info) { + return info instanceof OverriderUsageInfo && + ((OverriderUsageInfo) info).getOverridingMethod() instanceof KotlinLightMethod; + } + } + ); + if (adjustedUsages.size() < usageInfos.length) { + refUsages.set(adjustedUsages.toArray(new UsageInfo[adjustedUsages.size()])); } + if (!(info instanceof JetChangeInfo)) return result; + Set parameterNames = new HashSet(); JetChangeInfo changeInfo = (JetChangeInfo) info; PsiElement function = info.getMethod(); From 2ff63d37c23f50646d41c07a4b62c21aaa2be21f Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 24 Jun 2015 14:17:23 +0300 Subject: [PATCH 025/450] Change Signature: Property support #KT-6599 Fixed --- .../kotlin/idea/JetBundle.properties | 2 +- .../quickfix/AddFunctionParametersFix.java | 2 +- .../CreateParameterActionFactory.kt | 2 +- ...teParameterByNamedArgumentActionFactory.kt | 2 +- .../changeSignature/JetChangeInfo.kt | 199 +++++++++++------- .../JetChangePropertySignatureDialog.kt | 174 +++++++++++++++ .../changeSignature/JetChangeSignature.kt | 78 ++++--- .../changeSignature/JetChangeSignatureData.kt | 57 ++--- .../JetChangeSignatureDialog.java | 2 +- .../JetChangeSignatureHandler.java | 66 +++--- .../JetChangeSignatureProcessor.java | 18 +- .../JetChangeSignatureUsageProcessor.java | 102 ++++----- .../changeSignature/JetMethodDescriptor.kt | 14 +- .../changeSignature/JetParameterInfo.kt | 44 ++-- .../refactoring/changeSignature/typeUtils.kt | 39 ++-- .../usages/JavaMethodDeferredKotlinUsage.kt | 4 +- .../JavaMethodKotlinUsageWithDelegate.kt | 6 +- ...e.java => JetCallableDefinitionUsage.java} | 148 +++++++------ .../JetConstructorDelegationCallUsage.kt | 2 +- .../JetEnumEntryWithoutSuperCallUsage.kt | 2 +- .../usages/JetFunctionCallUsage.java | 77 ++++++- .../usages/JetImplicitThisToParameterUsage.kt | 4 +- .../usages/JetParameterUsage.kt | 4 +- .../usages/JetPropertyCallUsage.kt | 64 ++++++ .../usages/KotlinWrapperForJavaUsageInfos.kt | 12 +- .../KotlinIntroduceParameterDialog.kt | 14 +- .../KotlinIntroduceParameterHandler.kt | 2 +- ...nIntroduceParameterMethodUsageProcessor.kt | 6 +- .../idea/refactoring/jetRefactoringUtil.kt | 12 ++ .../AddPropertyReceiverAfter.1.java | 28 +++ .../AddPropertyReceiverAfter.kt | 26 +++ .../AddPropertyReceiverBefore.1.java | 28 +++ .../AddPropertyReceiverBefore.kt | 26 +++ .../AddPropertyReceiverConflictBefore.kt | 8 + .../AddPropertyReceiverConflictMessages.txt | 2 + .../AddTopLevelPropertyReceiverAfter.1.java | 8 + .../AddTopLevelPropertyReceiverAfter.kt | 14 ++ .../AddTopLevelPropertyReceiverBefore.1.java | 8 + .../AddTopLevelPropertyReceiverBefore.kt | 14 ++ .../ChangePropertyAfter.1.java | 31 +++ .../changeSignature/ChangePropertyAfter.kt | 18 ++ .../ChangePropertyBefore.1.java | 28 +++ .../changeSignature/ChangePropertyBefore.kt | 18 ++ .../ChangePropertyReceiverAfter.1.java | 28 +++ .../ChangePropertyReceiverAfter.kt | 26 +++ .../ChangePropertyReceiverBefore.1.java | 28 +++ .../ChangePropertyReceiverBefore.kt | 26 +++ ...ChangeTopLevelPropertyReceiverAfter.1.java | 8 + .../ChangeTopLevelPropertyReceiverAfter.kt | 19 ++ ...hangeTopLevelPropertyReceiverBefore.1.java | 8 + .../ChangeTopLevelPropertyReceiverBefore.kt | 19 ++ .../RemovePropertyReceiverAfter.1.java | 28 +++ .../RemovePropertyReceiverAfter.kt | 26 +++ .../RemovePropertyReceiverBefore.1.java | 28 +++ .../RemovePropertyReceiverBefore.kt | 26 +++ ...RemoveTopLevelPropertyReceiverAfter.1.java | 8 + .../RemoveTopLevelPropertyReceiverAfter.kt | 19 ++ ...emoveTopLevelPropertyReceiverBefore.1.java | 8 + .../RemoveTopLevelPropertyReceiverBefore.kt | 19 ++ .../JetChangeSignatureTest.java | 69 +++++- 60 files changed, 1431 insertions(+), 377 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/{JetFunctionDefinitionUsage.java => JetCallableDefinitionUsage.java} (74%) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictMessages.txt create mode 100644 idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.kt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties index c57187ff1aa..caad43ddb91 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties @@ -270,7 +270,7 @@ usageType.packageMemberAccess = Package member access x.in.y={0} in {1} x.implements.y={0} in {1} implements {2} in {3}. -x.overrides.y.in.class.list={0} in {1} overrides functions in the following classes/interfaces: {2} Do you want to {3} the base functions? +x.overrides.y.in.class.list={0} in {1} overrides declarations in the following classes/interfaces: {2} Do you want to {3} the base declarations? unused.overriding.methods.title=Unused Overriding Members there.are.unused.methods.that.override.methods.you.delete=There are unused members that override methods you delete. diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.java index 3aea9c28072..1407e383106 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddFunctionParametersFix.java @@ -147,7 +147,7 @@ public class AddFunctionParametersFix extends ChangeFunctionSignatureFix { } else { JetParameterInfo parameterInfo = - getNewParameterInfo(originalDescriptor.getBaseDescriptor(), bindingContext, argument, validator); + getNewParameterInfo((FunctionDescriptor) originalDescriptor.getBaseDescriptor(), bindingContext, argument, validator); typesToShorten.add(parameterInfo.getOriginalType()); if (expression != null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterActionFactory.kt index 60bfe2d3729..b1ba8e9b60b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterActionFactory.kt @@ -115,7 +115,7 @@ object CreateParameterActionFactory: JetSingleIntentionActionFactory() { return CreateParameterFromUsageFix( functionDescriptor, context, - JetParameterInfo(functionDescriptor = functionDescriptor, + JetParameterInfo(callableDescriptor = functionDescriptor, name = refExpr.getReferencedName(), type = paramType, valOrVar = valOrVar), diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt index 25c5fa9d1ac..30a354b6600 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterByNamedArgumentActionFactory.kt @@ -60,7 +60,7 @@ public object CreateParameterByNamedArgumentActionFactory: JetSingleIntentionAct if (paramType.hasTypeParametersToAdd(functionDescriptor, context)) return null val parameterInfo = JetParameterInfo( - functionDescriptor = functionDescriptor, + callableDescriptor = functionDescriptor, name = name, type = paramType, defaultValueForCall = argumentExpression diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 88ce79e09d2..2b48e1eca63 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -19,28 +19,35 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import com.intellij.lang.Language import com.intellij.lang.java.JavaLanguage import com.intellij.psi.* -import com.intellij.refactoring.changeSignature.* +import com.intellij.refactoring.changeSignature.ChangeInfo +import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor +import com.intellij.refactoring.changeSignature.JavaChangeInfo +import com.intellij.refactoring.changeSignature.ParameterInfoImpl import com.intellij.usageView.UsageInfo import com.intellij.util.VisibilityUtil -import org.jetbrains.kotlin.asJava.* -import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.asJava.toLightMethods +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.codegen.PropertyCodegen +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.idea.JetLanguage +import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor +import org.jetbrains.kotlin.idea.core.refactoring.j2k +import org.jetbrains.kotlin.idea.project.ProjectStructureUtil +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor.Kind +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.parameterIndex import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.idea.JetLanguage -import org.jetbrains.kotlin.idea.caches.resolve.* -import org.jetbrains.kotlin.idea.core.refactoring.j2k -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetFunctionDefinitionUsage -import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import java.util.HashMap -import kotlin.properties.Delegates import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList -import org.jetbrains.kotlin.idea.project.* -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor.Kind +import java.util.* +import kotlin.properties.Delegates public class JetChangeInfo( val methodDescriptor: JetMethodDescriptor, @@ -61,7 +68,7 @@ public class JetChangeInfo( } private val newParameters = parameterInfos.toArrayList() - private val originalPsiMethod: PsiMethod? = getCurrentPsiMethod() + private val originalPsiMethods: List = getMethod().toLightMethods() private val oldNameToParameterIndex: Map by Delegates.lazy { val map = HashMap() @@ -80,13 +87,7 @@ public class JetChangeInfo( } private var isPrimaryMethodUpdated: Boolean = false - private var javaChangeInfo: JavaChangeInfo? = null - - private fun getCurrentPsiMethod(): PsiMethod? { - val psiMethods = getMethod().toLightMethods() - assert(psiMethods.size() <= 1) { "Multiple light methods: " + getMethod().getText() } - return psiMethods.firstOrNull() - } + private var javaChangeInfos: List? = null public fun getOldParameterIndex(oldParameterName: String): Int? = oldNameToParameterIndex[oldParameterName] @@ -103,6 +104,7 @@ public class JetChangeInfo( fun getNonReceiverParametersCount(): Int = newParameters.size() - (if (receiverParameterInfo != null) 1 else 0) fun getNonReceiverParameters(): List { + if (methodDescriptor.baseDeclaration is JetProperty) return emptyList() return receiverParameterInfo?.let { receiver -> newParameters.filter { it != receiver } } ?: newParameters } @@ -146,7 +148,7 @@ public class JetChangeInfo( override fun getLanguage(): Language = JetLanguage.INSTANCE - public fun getNewSignature(inheritedFunction: JetFunctionDefinitionUsage): String { + public fun getNewSignature(inheritedCallable: JetCallableDefinitionUsage): String { val buffer = StringBuilder() val defaultVisibility = if (kind.isConstructor) Visibilities.PUBLIC else Visibilities.INTERNAL @@ -174,7 +176,7 @@ public class JetChangeInfo( buffer.append(name) } - buffer.append(getNewParametersSignature(inheritedFunction)) + buffer.append(getNewParametersSignature(inheritedCallable)) if (newReturnType != null && !KotlinBuiltIns.isUnit(newReturnType) && kind == Kind.FUNCTION) buffer.append(": ").append(newReturnTypeText) @@ -182,63 +184,75 @@ public class JetChangeInfo( return buffer.toString() } - public fun isRefactoringTarget(inheritedFunctionDescriptor: FunctionDescriptor?): Boolean { - return inheritedFunctionDescriptor != null - && getMethod() == DescriptorToSourceUtils.descriptorToDeclaration(inheritedFunctionDescriptor) + public fun isRefactoringTarget(inheritedCallableDescriptor: CallableDescriptor?): Boolean { + return inheritedCallableDescriptor != null + && getMethod() == DescriptorToSourceUtils.descriptorToDeclaration(inheritedCallableDescriptor) } - public fun getNewParametersSignature(inheritedFunction: JetFunctionDefinitionUsage): String { + public fun getNewParametersSignature(inheritedCallable: JetCallableDefinitionUsage): String { val signatureParameters = getNonReceiverParameters() - val isLambda = inheritedFunction.getDeclaration() is JetFunctionLiteral - if (isLambda && signatureParameters.size() == 1 && !signatureParameters.get(0).requiresExplicitType(inheritedFunction)) { - return signatureParameters.get(0).getDeclarationSignature(0, inheritedFunction) + val isLambda = inheritedCallable.getDeclaration() is JetFunctionLiteral + if (isLambda && signatureParameters.size() == 1 && !signatureParameters.get(0).requiresExplicitType(inheritedCallable)) { + return signatureParameters.get(0).getDeclarationSignature(0, inheritedCallable) } return signatureParameters.indices - .map { i -> signatureParameters[i].getDeclarationSignature(i, inheritedFunction) } + .map { i -> signatureParameters[i].getDeclarationSignature(i, inheritedCallable) } .joinToString(prefix = "(", separator = ", ", postfix = ")") } - public fun renderReceiverType(inheritedFunction: JetFunctionDefinitionUsage): String? { + public fun renderReceiverType(inheritedCallable: JetCallableDefinitionUsage): String? { val receiverTypeText = receiverParameterInfo?.currentTypeText ?: return null - val typeSubstitutor = inheritedFunction.getOrCreateTypeSubstitutor() ?: return receiverTypeText - val currentBaseFunction = inheritedFunction.getBaseFunction().getCurrentFunctionDescriptor() ?: return receiverTypeText + val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return receiverTypeText + val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return receiverTypeText return currentBaseFunction.getExtensionReceiverParameter()!!.getType().renderTypeWithSubstitution(typeSubstitutor, receiverTypeText, false) } - public fun renderReturnType(inheritedFunction: JetFunctionDefinitionUsage): String { - val typeSubstitutor = inheritedFunction.getOrCreateTypeSubstitutor() ?: return newReturnTypeText - val currentBaseFunction = inheritedFunction.getBaseFunction().getCurrentFunctionDescriptor() ?: return newReturnTypeText + public fun renderReturnType(inheritedCallable: JetCallableDefinitionUsage): String { + val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return newReturnTypeText + val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return newReturnTypeText return currentBaseFunction.getReturnType().renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false) } public fun primaryMethodUpdated() { isPrimaryMethodUpdated = true - javaChangeInfo = null + javaChangeInfos = null } - public fun getOrCreateJavaChangeInfo(): JavaChangeInfo? { - if (ProjectStructureUtil.isJsKotlinModule(getMethod().getContainingFile() as JetFile)) return null + public fun getOrCreateJavaChangeInfos(): List? { + /* + * When primaryMethodUpdated is false, changes to the primary Kotlin declaration are already confirmed, but not yet applied. + * It means that originalPsiMethod has already expired, but new one can't be created until Kotlin declaration is updated + * (signified by primaryMethodUpdated being true). It means we can't know actual PsiType, visibility, etc. + * to use in JavaChangeInfo. However they are not actually used at this point since only parameter count and order matters here + * So we resort to this hack and pass around "default" type (void) and visibility (package-local) + */ - if (javaChangeInfo == null) { - val currentPsiMethod = getCurrentPsiMethod() - if (originalPsiMethod == null || currentPsiMethod == null) return null - - /* - * When primaryMethodUpdated is false, changes to the primary Kotlin declaration are already confirmed, but not yet applied. - * It means that originalPsiMethod has already expired, but new one can't be created until Kotlin declaration is updated - * (signified by primaryMethodUpdated being true). It means we can't know actual PsiType, visibility, etc. - * to use in JavaChangeInfo. However they are not actually used at this point since only parameter count and order matters here - * So we resort to this hack and pass around "default" type (void) and visibility (package-local) - */ - val javaVisibility = if (isPrimaryMethodUpdated) + fun createJavaChangeInfo(originalPsiMethod: PsiMethod, + currentPsiMethod: PsiMethod, + newName: String, + newReturnType: PsiType?, + newParameters: Array + ): JavaChangeInfo? { + val newVisibility = if (isPrimaryMethodUpdated) VisibilityUtil.getVisibilityModifier(currentPsiMethod.getModifierList()) else PsiModifier.PACKAGE_LOCAL + val javaChangeInfo = ChangeSignatureProcessor(getMethod().getProject(), + originalPsiMethod, + false, + newVisibility, + newName, + newReturnType ?: PsiType.VOID, + newParameters).getChangeInfo() + javaChangeInfo.updateMethod(currentPsiMethod) - val newParameterList = receiverParameterInfo.singletonOrEmptyList() + getNonReceiverParameters() - val newJavaParameters = newParameterList.withIndex().map { pair -> + return javaChangeInfo + } + + fun getJavaParameterInfos(currentPsiMethod: PsiMethod, newParameterList: List): MutableList { + return newParameterList.withIndex().mapTo(ArrayList()) { pair -> val (i, info) = pair val type = if (isPrimaryMethodUpdated) @@ -255,25 +269,66 @@ public class JetChangeInfo( } ParameterInfoImpl(javaOldIndex, info.getName(), type, info.defaultValueForCall?.getText() ?: "") - }.toTypedArray() - - val returnType = if (isPrimaryMethodUpdated) currentPsiMethod.getReturnType() else PsiType.VOID - - javaChangeInfo = ChangeSignatureProcessor(getMethod().getProject(), - originalPsiMethod, - false, - javaVisibility, - getNewName(), - returnType, - newJavaParameters).getChangeInfo() - javaChangeInfo!!.updateMethod(currentPsiMethod) + } } - return javaChangeInfo + fun createJavaChangeInfoForFunctionOrGetter( + originalPsiMethod: PsiMethod, + currentPsiMethod: PsiMethod, + isGetter: Boolean + ): JavaChangeInfo? { + val newParameterList = receiverParameterInfo.singletonOrEmptyList() + getNonReceiverParameters() + val newJavaParameters = getJavaParameterInfos(currentPsiMethod, newParameterList).toTypedArray() + val newName = if (isGetter) PropertyCodegen.getterName(Name.identifier(getNewName())) else getNewName() + return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, currentPsiMethod.getReturnType(), newJavaParameters) + } + + fun createJavaChangeInfoForSetter(originalPsiMethod: PsiMethod, currentPsiMethod: PsiMethod): JavaChangeInfo? { + val newJavaParameters = getJavaParameterInfos(currentPsiMethod, receiverParameterInfo.singletonOrEmptyList()) + val oldIndex = if (methodDescriptor.receiver != null) 1 else 0 + if (isPrimaryMethodUpdated) { + val newIndex = if (receiverParameterInfo != null) 1 else 0 + val setterParameter = currentPsiMethod.getParameterList().getParameters()[newIndex] + newJavaParameters.add(ParameterInfoImpl(oldIndex, setterParameter.getName(), setterParameter.getType())) + } + else { + newJavaParameters.add(ParameterInfoImpl(oldIndex, "receiver", PsiType.VOID)) + } + + val newName = PropertyCodegen.setterName(Name.identifier(getNewName())) + return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, PsiType.VOID, newJavaParameters.toTypedArray()) + } + + if (ProjectStructureUtil.isJsKotlinModule(getMethod().getContainingFile() as JetFile)) return null + + if (javaChangeInfos == null) { + val method = getMethod() + javaChangeInfos = (originalPsiMethods zip method.toLightMethods()).map { + val (originalPsiMethod, currentPsiMethod) = it + + when (method) { + is JetFunction, is JetClassOrObject -> + createJavaChangeInfoForFunctionOrGetter(originalPsiMethod, currentPsiMethod, false) + is JetProperty -> { + val accessorName = originalPsiMethod.getName() + when { + accessorName.startsWith(JvmAbi.GETTER_PREFIX) -> + createJavaChangeInfoForFunctionOrGetter(originalPsiMethod, currentPsiMethod, true) + accessorName.startsWith(JvmAbi.SETTER_PREFIX) -> + createJavaChangeInfoForSetter(originalPsiMethod, currentPsiMethod) + else -> null + } + } + else -> null + } + }.filterNotNull() + } + + return javaChangeInfos } } -public val JetChangeInfo.originalBaseFunctionDescriptor: FunctionDescriptor +public val JetChangeInfo.originalBaseFunctionDescriptor: CallableDescriptor get() = methodDescriptor.baseDescriptor public val JetChangeInfo.kind: Kind get() = methodDescriptor.kind @@ -281,7 +336,7 @@ public val JetChangeInfo.kind: Kind get() = methodDescriptor.kind public val JetChangeInfo.oldName: String? get() = (methodDescriptor.getMethod() as? JetFunction)?.getName() -public val JetChangeInfo.affectedFunctions: Collection get() = methodDescriptor.affectedFunctions +public val JetChangeInfo.affectedFunctions: Collection get() = methodDescriptor.affectedCallables public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMethodDescriptor): JetChangeInfo { val method = getMethod() as PsiMethod @@ -305,7 +360,7 @@ public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMeth } else null - with(JetParameterInfo(functionDescriptor = functionDescriptor, + with(JetParameterInfo(callableDescriptor = functionDescriptor, originalIndex = oldIndex, name = info.getName(), type = if (oldIndex >= 0) originalParameterDescriptors[oldIndex].getType() else currentType, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt new file mode 100644 index 00000000000..bce53cd6946 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt @@ -0,0 +1,174 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature + +import com.intellij.openapi.options.ConfigurationException +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.PsiElement +import com.intellij.refactoring.BaseRefactoringProcessor +import com.intellij.refactoring.ui.ComboBoxVisibilityPanel +import com.intellij.refactoring.ui.RefactoringDialog +import com.intellij.ui.EditorTextField +import com.intellij.ui.NonFocusableCheckBox +import com.intellij.util.ui.FormBuilder +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.core.refactoring.validateElement +import org.jetbrains.kotlin.psi.JetExpression +import org.jetbrains.kotlin.psi.JetProperty +import org.jetbrains.kotlin.psi.JetPsiFactory +import org.jetbrains.kotlin.psi.JetTypeCodeFragment +import org.jetbrains.kotlin.resolve.AnalyzingUtils +import javax.swing.JCheckBox +import javax.swing.JComboBox +import javax.swing.JComponent +import javax.swing.JLabel +import kotlin.properties.Delegates + +public class JetChangePropertySignatureDialog( + project: Project, + private val methodDescriptor: JetMethodDescriptor, + private val commandName: String? +): RefactoringDialog(project, true) { + private val visibilityCombo = JComboBox( + arrayOf(Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC) + ) + private val nameField = EditorTextField(methodDescriptor.getName()) + private var returnTypeField: EditorTextField by Delegates.notNull() + private var receiverTypeCheckBox: JCheckBox by Delegates.notNull() + var receiverTypeLabel: JLabel by Delegates.notNull() + private var receiverTypeField: EditorTextField by Delegates.notNull() + var receiverDefaultValueLabel: JLabel? = null + private var receiverDefaultValueField: EditorTextField? = null + + init { + setTitle("Change Signature") + init() + } + + override fun getPreferredFocusedComponent() = nameField + + override fun createCenterPanel(): JComponent? { + fun updateReceiverUI() { + val withReceiver = receiverTypeCheckBox.isSelected() + receiverTypeLabel.setEnabled(withReceiver) + receiverTypeField.setEnabled(withReceiver) + receiverDefaultValueLabel?.setEnabled(withReceiver) + receiverDefaultValueField?.setEnabled(withReceiver) + } + + val documentManager = PsiDocumentManager.getInstance(myProject) + val psiFactory = JetPsiFactory(myProject) + + return with(FormBuilder.createFormBuilder()) { + if (!((methodDescriptor.baseDeclaration as? JetProperty)?.isLocal() ?: false)) { + visibilityCombo.setSelectedItem(methodDescriptor.getVisibility()) + addLabeledComponent("&Visibility: ", visibilityCombo) + } + + addLabeledComponent("&Name: ", nameField) + + val returnTypeCodeFragment = psiFactory.createTypeCodeFragment(methodDescriptor.renderOriginalReturnType(), + methodDescriptor.baseDeclaration) + returnTypeField = EditorTextField(documentManager.getDocument(returnTypeCodeFragment), myProject, JetFileType.INSTANCE) + addLabeledComponent("&Type: ", returnTypeField) + + addSeparator() + + val receiverTypeCheckBox = JCheckBox("Extension property: ") + receiverTypeCheckBox.setMnemonic('x') + receiverTypeCheckBox.addActionListener { updateReceiverUI() } + receiverTypeCheckBox.setSelected(methodDescriptor.receiver != null) + addComponent(receiverTypeCheckBox) + this@JetChangePropertySignatureDialog.receiverTypeCheckBox = receiverTypeCheckBox + + val receiverTypeCodeFragment = psiFactory.createTypeCodeFragment(methodDescriptor.renderOriginalReceiverType() ?: "", + methodDescriptor.baseDeclaration) + receiverTypeField = EditorTextField(documentManager.getDocument(receiverTypeCodeFragment), myProject, JetFileType.INSTANCE) + receiverTypeLabel = JLabel("Receiver type: ") + receiverTypeLabel.setDisplayedMnemonic('t') + addLabeledComponent(receiverTypeLabel, receiverTypeField) + + if (methodDescriptor.receiver == null) { + val receiverDefaultValueCodeFragment = psiFactory.createExpressionCodeFragment("", methodDescriptor.baseDeclaration) + receiverDefaultValueField = EditorTextField(documentManager.getDocument(receiverDefaultValueCodeFragment), + myProject, + JetFileType.INSTANCE) + receiverDefaultValueLabel = JLabel("Default receiver value: ") + receiverDefaultValueLabel!!.setDisplayedMnemonic('D') + addLabeledComponent(receiverDefaultValueLabel, receiverDefaultValueField!!) + } + + updateReceiverUI() + + getPanel() + } + } + + private fun getDefaultReceiverValue(): JetExpression? { + val receiverDefaultValue = receiverDefaultValueField?.getText() ?: "" + return if (receiverDefaultValue.isNotEmpty()) JetPsiFactory(myProject).createExpression(receiverDefaultValue) else null + } + + override fun canRun() { + val psiFactory = JetPsiFactory(myProject) + + psiFactory.createSimpleName(nameField.getText()).validateElement("Invalid name") + psiFactory.createType(returnTypeField.getText()).validateElement("Invalid return type") + if (receiverTypeCheckBox.isSelected()) { + psiFactory.createType(receiverTypeField.getText()).validateElement("Invalid receiver type") + } + getDefaultReceiverValue()?.validateElement("Invalid default receiver value") + } + + override fun doAction() { + val descriptor = (methodDescriptor as? JetMutableMethodDescriptor)?.original ?: methodDescriptor + + val receiver = if (receiverTypeCheckBox.isSelected()) { + descriptor.receiver ?: JetParameterInfo(callableDescriptor = descriptor.baseDescriptor, + name = "receiver", + defaultValueForCall = getDefaultReceiverValue()) + } else null + receiver?.currentTypeText = receiverTypeField.getText() + val changeInfo = JetChangeInfo(descriptor, + nameField.getText(), + null, + returnTypeField.getText(), + visibilityCombo.getSelectedItem() as Visibility, + emptyList(), + receiver, + descriptor.getMethod()) + + invokeRefactoring(JetChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle())) + } + + companion object { + fun createProcessorForSilentRefactoring( + project: Project, + commandName: String, + descriptor: JetMethodDescriptor + ): BaseRefactoringProcessor { + val originalDescriptor = (descriptor as? JetMutableMethodDescriptor)?.original ?: descriptor + val changeInfo = JetChangeInfo(methodDescriptor = originalDescriptor, context = originalDescriptor.getMethod()) + changeInfo.setNewName(descriptor.getName()) + changeInfo.receiverParameterInfo = descriptor.receiver + return JetChangeSignatureProcessor(project, changeInfo, commandName) + } + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index 69b1082d332..7abb411c31e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -23,11 +23,15 @@ import com.intellij.psi.PsiElement import com.intellij.refactoring.changeSignature.ChangeSignatureHandler import org.jetbrains.annotations.TestOnly import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind -import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring +import org.jetbrains.kotlin.psi.JetClass +import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.JetProperty +import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.OverrideResolver @@ -50,55 +54,64 @@ fun JetMethodDescriptor.modify(action: (JetMutableMethodDescriptor) -> Unit): Je } public fun runChangeSignature(project: Project, - functionDescriptor: FunctionDescriptor, + callableDescriptor: CallableDescriptor, configuration: JetChangeSignatureConfiguration, bindingContext: BindingContext, defaultValueContext: PsiElement, commandName: String? = null): Boolean { - return JetChangeSignature(project, functionDescriptor, configuration, bindingContext, defaultValueContext, commandName).run() + return JetChangeSignature(project, callableDescriptor, configuration, bindingContext, defaultValueContext, commandName).run() } public class JetChangeSignature(project: Project, - functionDescriptor: FunctionDescriptor, + callableDescriptor: CallableDescriptor, val configuration: JetChangeSignatureConfiguration, bindingContext: BindingContext, val defaultValueContext: PsiElement, - commandName: String?): CallableRefactoring(project, functionDescriptor, bindingContext, commandName) { + commandName: String?): CallableRefactoring(project, callableDescriptor, bindingContext, commandName) { private val LOG = Logger.getInstance(javaClass()) override fun forcePerformForSelectedFunctionOnly() = configuration.forcePerformForSelectedFunctionOnly() - override fun performRefactoring(descriptorsForChange: Collection) { - assert (descriptorsForChange.all { it is FunctionDescriptor }) { - "Function descriptors expected: " + descriptorsForChange.joinToString(separator = "\n") + private fun runSilentRefactoring(descriptor: JetMethodDescriptor) { + val commandName = commandName ?: ChangeSignatureHandler.REFACTORING_NAME + val processor = when (descriptor.baseDeclaration) { + is JetFunction, is JetClass -> { + JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature(project, commandName, descriptor, defaultValueContext) + } + is JetProperty -> { + JetChangePropertySignatureDialog.createProcessorForSilentRefactoring(project, commandName, descriptor) + } + else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") + } + processor.run() + } + + private fun runInteractiveRefactoring(descriptor: JetMethodDescriptor) { + val dialog = when (descriptor.baseDeclaration) { + is JetFunction, is JetClass -> JetChangeSignatureDialog(project, descriptor, defaultValueContext, commandName) + is JetProperty -> JetChangePropertySignatureDialog(project, descriptor, commandName) + else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") } - @suppress("UNCHECKED_CAST") - val adjustedDescriptor = adjustDescriptor(descriptorsForChange as Collection) - if (adjustedDescriptor == null) return + dialog.show() + } - val affectedFunctions = adjustedDescriptor.affectedFunctions.map { it.getElement() }.filterNotNull() + override fun performRefactoring(descriptorsForChange: Collection) { + val adjustedDescriptor = adjustDescriptor(descriptorsForChange) ?: return + val affectedFunctions = adjustedDescriptor.affectedCallables.map { it.getElement() }.filterNotNull() if (affectedFunctions.any { !checkModifiable(it) }) return - if (configuration.performSilently(affectedFunctions) - || ApplicationManager.getApplication()!!.isUnitTestMode()) { - JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature( - project, - commandName ?: ChangeSignatureHandler.REFACTORING_NAME, - adjustedDescriptor, - defaultValueContext - ).run() + if (configuration.performSilently(affectedFunctions) || ApplicationManager.getApplication()!!.isUnitTestMode()) { + runSilentRefactoring(adjustedDescriptor) } else { - val dialog = JetChangeSignatureDialog(project, adjustedDescriptor, defaultValueContext, commandName) - - dialog.show() + runInteractiveRefactoring(adjustedDescriptor) } } - fun adjustDescriptor(descriptorsForSignatureChange: Collection): JetMethodDescriptor? { + fun adjustDescriptor(descriptorsForSignatureChange: Collection): JetMethodDescriptor? { val baseDescriptor = preferContainedInClass(descriptorsForSignatureChange) val functionDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, baseDescriptor) if (functionDeclaration == null) { @@ -114,7 +127,7 @@ public class JetChangeSignature(project: Project, return configuration.configure(originalDescriptor, bindingContext) } - private fun preferContainedInClass(descriptorsForSignatureChange: Collection): FunctionDescriptor { + private fun preferContainedInClass(descriptorsForSignatureChange: Collection): CallableDescriptor { for (descriptor in descriptorsForSignatureChange) { val containingDeclaration = descriptor.getContainingDeclaration() if (containingDeclaration is ClassDescriptor && containingDeclaration.getKind() != ClassKind.INTERFACE) { @@ -127,15 +140,22 @@ public class JetChangeSignature(project: Project, } TestOnly public fun createChangeInfo(project: Project, - functionDescriptor: FunctionDescriptor, + callableDescriptor: CallableDescriptor, configuration: JetChangeSignatureConfiguration, bindingContext: BindingContext, defaultValueContext: PsiElement): JetChangeInfo? { - val jetChangeSignature = JetChangeSignature(project, functionDescriptor, configuration, bindingContext, defaultValueContext, null) - val declarations = OverrideResolver.getDeepestSuperDeclarations(functionDescriptor) + val jetChangeSignature = JetChangeSignature(project, callableDescriptor, configuration, bindingContext, defaultValueContext, null) + val declarations = if (callableDescriptor is CallableMemberDescriptor) { + OverrideResolver.getDeepestSuperDeclarations(callableDescriptor) + } else listOf(callableDescriptor) val adjustedDescriptor = jetChangeSignature.adjustDescriptor(declarations) ?: return null - val processor = JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature(project, ChangeSignatureHandler.REFACTORING_NAME, adjustedDescriptor, defaultValueContext) as JetChangeSignatureProcessor + val processor = JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature( + project, + ChangeSignatureHandler.REFACTORING_NAME, + adjustedDescriptor, + defaultValueContext + ) as JetChangeSignatureProcessor return processor.getChangeInfo() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt index 0788fb1eff4..92ce4ba83f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt @@ -23,6 +23,8 @@ import com.intellij.refactoring.changeSignature.OverriderUsageInfo import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.asJava.KotlinLightMethod import org.jetbrains.kotlin.asJava.LightClassUtil +import org.jetbrains.kotlin.asJava.namedUnwrappedElement +import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze @@ -30,10 +32,14 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.core.CollectingNameValidator import org.jetbrains.kotlin.idea.core.KotlinNameSuggester -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetFunctionDefinitionUsage +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage +import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest +import org.jetbrains.kotlin.idea.search.declarationsSearch.searchOverriders import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.JetCallableDeclaration import org.jetbrains.kotlin.psi.JetClass import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.JetNamedDeclaration import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import java.util.Collections @@ -41,9 +47,9 @@ import java.util.HashSet import kotlin.properties.Delegates public class JetChangeSignatureData( - override val baseDescriptor: FunctionDescriptor, + override val baseDescriptor: CallableDescriptor, override val baseDeclaration: PsiElement, - private val descriptorsForSignatureChange: Collection + private val descriptorsForSignatureChange: Collection ) : JetMethodDescriptor { private val parameters: List override val receiver: JetParameterInfo? @@ -60,7 +66,7 @@ public class JetChangeSignatureData( .mapTo(receiver?.let{ arrayListOf(it) } ?: arrayListOf()) { parameterDescriptor -> val jetParameter = valueParameters?.get(parameterDescriptor.getIndex()) JetParameterInfo( - functionDescriptor = baseDescriptor, + callableDescriptor = baseDescriptor, originalIndex = parameterDescriptor.getIndex(), name = parameterDescriptor.getName().asString(), type = parameterDescriptor.getType(), @@ -72,8 +78,8 @@ public class JetChangeSignatureData( } private fun createReceiverInfoIfNeeded(): JetParameterInfo? { - val function = baseDeclaration as? JetFunction ?: return null - val bodyScope = function.getBodyExpression()?.let { it.analyze()[BindingContext.RESOLUTION_SCOPE, it] } + val callable = baseDeclaration as? JetCallableDeclaration ?: return null + val bodyScope = (callable as? JetFunction)?.getBodyExpression()?.let { it.analyze()[BindingContext.RESOLUTION_SCOPE, it] } val paramNames = baseDescriptor.getValueParameters().map { it.getName().asString() } val validator = bodyScope?.let { bodyScope -> CollectingNameValidator(paramNames) { @@ -83,34 +89,37 @@ public class JetChangeSignatureData( } ?: CollectingNameValidator(paramNames) val receiverType = baseDescriptor.getExtensionReceiverParameter()?.getType() ?: return null val receiverName = KotlinNameSuggester.suggestNamesByType(receiverType, validator, "receiver").first() - return JetParameterInfo(functionDescriptor = baseDescriptor, name = receiverName, type = receiverType) + return JetParameterInfo(callableDescriptor = baseDescriptor, name = receiverName, type = receiverType) } - override val primaryFunctions: Collection> by Delegates.lazy { + override val primaryCallables: Collection> by Delegates.lazy { descriptorsForSignatureChange.map { val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it) assert(declaration != null) { "No declaration found for " + baseDescriptor } - JetFunctionDefinitionUsage(declaration, it, null, null) + JetCallableDefinitionUsage(declaration, it, null, null) } } - override val originalPrimaryFunction: JetFunctionDefinitionUsage by Delegates.lazy { - primaryFunctions.first { it.getDeclaration() == baseDeclaration } + override val originalPrimaryCallable: JetCallableDefinitionUsage by Delegates.lazy { + primaryCallables.first { it.getDeclaration() == baseDeclaration } } - override val affectedFunctions: Collection by Delegates.lazy { - primaryFunctions + primaryFunctions.flatMapTo(HashSet()) { primaryFunction -> - val primaryDeclaration = primaryFunction.getDeclaration() as? JetFunction - val lightMethod = primaryDeclaration?.let { LightClassUtil.getLightClassMethod(it) } - val overrides = lightMethod?.let { OverridingMethodsSearch.search(it).findAll() } ?: Collections.emptyList() - overrides.map { method -> - if (method is KotlinLightMethod) { - val overridingDeclaration = method.getOrigin() - val overridingDescriptor = overridingDeclaration?.resolveToDescriptor() as FunctionDescriptor - JetFunctionDefinitionUsage(overridingDeclaration, overridingDescriptor, primaryFunction, null) - } - else OverriderUsageInfo(method, lightMethod, true, true, true) - }.filterNotNullTo(HashSet()) + override val affectedCallables: Collection by Delegates.lazy { + primaryCallables + primaryCallables.flatMapTo(HashSet()) { primaryFunction -> + val primaryDeclaration = primaryFunction.getDeclaration() as? JetCallableDeclaration + val lightMethods = primaryDeclaration?.toLightMethods() ?: Collections.emptyList() + lightMethods.flatMap { baseMethod -> + OverridingMethodsSearch + .search(baseMethod) + .map { overridingMethod -> + if (overridingMethod is KotlinLightMethod) { + val overridingDeclaration = overridingMethod.namedUnwrappedElement as JetNamedDeclaration + val overridingDescriptor = overridingDeclaration.resolveToDescriptor() as CallableDescriptor + JetCallableDefinitionUsage(overridingDeclaration, overridingDescriptor, primaryFunction, null) + } + else OverriderUsageInfo(overridingMethod, baseMethod, true, true, true) + }.filterNotNullTo(HashSet()) + } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java index b07e7ae0a73..117c64a72ef 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java @@ -416,7 +416,7 @@ public class JetChangeSignatureDialog extends ChangeSignatureDialogBase< getMethodName(), myDefaultValueContext ); - return changeInfo.getNewSignature(getMethodDescriptor().getOriginalPrimaryFunction()); + return changeInfo.getNewSignature(getMethodDescriptor().getOriginalPrimaryCallable()); } @Override diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java index beeaeea3bf5..2bf88b1831d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java @@ -34,10 +34,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.TestOnly; import org.jetbrains.kotlin.asJava.AsJavaPackage; -import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils; import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde; @@ -57,44 +54,44 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { @Nullable public static PsiElement findTargetForRefactoring(@NotNull PsiElement element) { if (PsiTreeUtil.getParentOfType(element, JetParameterList.class) != null) { - return PsiTreeUtil.getParentOfType(element, JetFunction.class, JetClass.class); + return PsiTreeUtil.getParentOfType(element, JetFunction.class, JetProperty.class, JetClass.class); } JetTypeParameterList typeParameterList = PsiTreeUtil.getParentOfType(element, JetTypeParameterList.class); if (typeParameterList != null) { - return PsiTreeUtil.getParentOfType(typeParameterList, JetFunction.class, JetClass.class); + return PsiTreeUtil.getParentOfType(typeParameterList, JetFunction.class, JetProperty.class, JetClass.class); } PsiElement elementParent = element.getParent(); - if (elementParent instanceof JetNamedFunction && ((JetNamedFunction) elementParent).getNameIdentifier() == element) { - return elementParent; - } - if (elementParent instanceof JetClass && ((JetClass) elementParent).getNameIdentifier() == element) { - return elementParent; - } - if (elementParent instanceof JetSecondaryConstructor && - ((JetSecondaryConstructor) elementParent).getConstructorKeyword() == element) { - return elementParent; - } + if ((elementParent instanceof JetNamedFunction || elementParent instanceof JetClass || elementParent instanceof JetProperty) + && ((JetNamedDeclaration) elementParent).getNameIdentifier() == element) return elementParent; + if (elementParent instanceof JetSecondaryConstructor && + ((JetSecondaryConstructor) elementParent).getConstructorKeyword() == element) return elementParent; + + JetExpression calleeExpr; JetCallElement call = PsiTreeUtil.getParentOfType(element, JetCallExpression.class, JetDelegatorToSuperCall.class, JetConstructorDelegationCall.class); - if (call == null) return null; - - JetExpression receiverExpr = call.getCalleeExpression(); - if (receiverExpr instanceof JetConstructorCalleeExpression) { - receiverExpr = ((JetConstructorCalleeExpression) receiverExpr).getConstructorReferenceExpression(); + if (call != null) { + calleeExpr = call.getCalleeExpression(); } - if (receiverExpr instanceof JetSimpleNameExpression || receiverExpr instanceof JetConstructorDelegationReferenceExpression) { + else { + calleeExpr = PsiTreeUtil.getParentOfType(element, JetSimpleNameExpression.class); + } + + if (calleeExpr instanceof JetConstructorCalleeExpression) { + calleeExpr = ((JetConstructorCalleeExpression) calleeExpr).getConstructorReferenceExpression(); + } + if (calleeExpr instanceof JetSimpleNameExpression || calleeExpr instanceof JetConstructorDelegationReferenceExpression) { JetElement jetElement = PsiTreeUtil.getParentOfType(element, JetElement.class); if (jetElement == null) return null; BindingContext bindingContext = ResolvePackage.analyze(jetElement, BodyResolveMode.FULL); - DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) receiverExpr); + DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) calleeExpr); - if (descriptor instanceof ClassDescriptor || descriptor instanceof FunctionDescriptor) return receiverExpr; + if (descriptor instanceof ClassDescriptor || descriptor instanceof CallableDescriptor) return calleeExpr; } return null; @@ -107,20 +104,20 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { @Nullable Editor editor ) { BindingContext bindingContext = ResolvePackage.analyze(element, BodyResolveMode.FULL); - - FunctionDescriptor functionDescriptor = findDescriptor(element, project, editor, bindingContext); - if (functionDescriptor == null) { + + CallableDescriptor callableDescriptor = findDescriptor(element, project, editor, bindingContext); + if (callableDescriptor == null) { return; } - if (functionDescriptor instanceof JavaCallableMemberDescriptor) { - PsiElement declaration = DescriptorToSourceUtilsIde.INSTANCE$.getAnyDeclaration(project, functionDescriptor); - assert declaration instanceof PsiMethod : "PsiMethod expected: " + functionDescriptor; + if (callableDescriptor instanceof JavaCallableMemberDescriptor) { + PsiElement declaration = DescriptorToSourceUtilsIde.INSTANCE$.getAnyDeclaration(project, callableDescriptor); + assert declaration instanceof PsiMethod : "PsiMethod expected: " + callableDescriptor; ChangeSignatureUtil.invokeChangeSignatureOn((PsiMethod) declaration, project); return; } - if (TasksPackage.isDynamic(functionDescriptor)) { + if (TasksPackage.isDynamic(callableDescriptor)) { if (editor != null) { CodeInsightUtils.showErrorHint( project, @@ -133,7 +130,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { return; } - runChangeSignature(project, functionDescriptor, emptyConfiguration(), bindingContext, context, null); + runChangeSignature(project, callableDescriptor, emptyConfiguration(), bindingContext, context, null); } @TestOnly @@ -208,7 +205,7 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { } @Nullable - public static FunctionDescriptor findDescriptor( + public static CallableDescriptor findDescriptor( @NotNull PsiElement element, @NotNull Project project, @Nullable Editor editor, @@ -244,6 +241,9 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { return (FunctionDescriptor) descriptor; } + else if (descriptor instanceof PropertyDescriptor) { + return (PropertyDescriptor) descriptor; + } else { String message = RefactoringBundle.getCannotRefactorMessage(JetRefactoringBundle.message( "error.wrong.caret.position.function.or.constructor.name")); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java index 38864e103b0..5a9045dbf25 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java @@ -21,7 +21,10 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.refactoring.RefactoringBundle; -import com.intellij.refactoring.changeSignature.*; +import com.intellij.refactoring.changeSignature.ChangeSignatureProcessorBase; +import com.intellij.refactoring.changeSignature.ChangeSignatureUsageProcessor; +import com.intellij.refactoring.changeSignature.JavaChangeInfo; +import com.intellij.refactoring.changeSignature.JavaChangeSignatureUsageProcessor; import com.intellij.refactoring.rename.RenameUtil; import com.intellij.refactoring.ui.ConflictsDialog; import com.intellij.usageView.UsageInfo; @@ -29,8 +32,6 @@ import com.intellij.usageView.UsageViewDescriptor; import com.intellij.util.containers.HashSet; import com.intellij.util.containers.MultiMap; import kotlin.KotlinPackage; -import kotlin.Pair; -import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetUsageInfo; import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos; @@ -62,10 +63,13 @@ public class JetChangeSignatureProcessor extends ChangeSignatureProcessorBase { protected UsageInfo[] findUsages() { List allUsages = new ArrayList(); - JavaChangeInfo javaChangeInfo = getChangeInfo().getOrCreateJavaChangeInfo(); - if (javaChangeInfo != null) { - UsageInfo[] javaUsages = new JavaChangeSignatureUsageProcessor().findUsages(javaChangeInfo); - allUsages.add(new KotlinWrapperForJavaUsageInfos(javaUsages, getChangeInfo().getMethod())); + List javaChangeInfos = getChangeInfo().getOrCreateJavaChangeInfos(); + if (javaChangeInfos != null) { + JavaChangeSignatureUsageProcessor javaProcessor = new JavaChangeSignatureUsageProcessor(); + for (JavaChangeInfo javaChangeInfo : javaChangeInfos) { + UsageInfo[] javaUsages = javaProcessor.findUsages(javaChangeInfo); + allUsages.add(new KotlinWrapperForJavaUsageInfos(javaChangeInfo, javaUsages, getChangeInfo().getMethod())); + } } KotlinPackage.filterIsInstanceTo(super.findUsages(), allUsages, JetUsageInfo.class); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index 25c2def5e92..d9904cd5c54 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -21,9 +21,9 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.SearchScope; +import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.changeSignature.ChangeInfo; @@ -40,7 +40,6 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.HashSet; import com.intellij.util.containers.MultiMap; -import jet.runtime.typeinfo.JetValueParameter; import kotlin.KotlinPackage; import kotlin.Unit; import kotlin.jvm.functions.Function1; @@ -56,13 +55,13 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde; import org.jetbrains.kotlin.idea.codeInsight.JetFileReferencesResolver; import org.jetbrains.kotlin.idea.core.refactoring.RefactoringPackage; import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.*; -import org.jetbrains.kotlin.idea.refactoring.rename.UnresolvableConventionViolationUsageInfo; import org.jetbrains.kotlin.idea.references.JetSimpleNameReference; import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage; import org.jetbrains.kotlin.kdoc.psi.impl.KDocName; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; +import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.BindingContext; @@ -72,7 +71,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; -import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; @@ -80,10 +78,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeUtils; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsageProcessor { @Override @@ -104,8 +99,8 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro private static void findAllMethodUsages(JetChangeInfo changeInfo, Set result) { for (UsageInfo functionUsageInfo : ChangeSignaturePackage.getAffectedFunctions(changeInfo)) { - if (functionUsageInfo instanceof JetFunctionDefinitionUsage) { - findOneMethodUsages((JetFunctionDefinitionUsage) functionUsageInfo, changeInfo, result); + if (functionUsageInfo instanceof JetCallableDefinitionUsage) { + findOneMethodUsages((JetCallableDefinitionUsage) functionUsageInfo, changeInfo, result); } else { result.add(functionUsageInfo); @@ -123,7 +118,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro JetCallElement callElement = PsiTreeUtil.getParentOfType(element, JetCallElement.class); JetExpression calleeExpression = callElement != null ? callElement.getCalleeExpression() : null; if (calleeExpression != null && PsiTreeUtil.isAncestor(calleeExpression, element, false)) { - result.add(new JetFunctionCallUsage(callElement, changeInfo.getMethodDescriptor().getOriginalPrimaryFunction())); + result.add(new JetFunctionCallUsage(callElement, changeInfo.getMethodDescriptor().getOriginalPrimaryCallable())); } } } @@ -131,7 +126,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } private static void findOneMethodUsages( - @NotNull JetFunctionDefinitionUsage functionUsageInfo, + @NotNull JetCallableDefinitionUsage functionUsageInfo, final JetChangeInfo changeInfo, final Set result ) { @@ -160,6 +155,9 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (parent instanceof JetConstructorCalleeExpression && parent.getParent() instanceof JetDelegatorToSuperCall) result.add(new JetFunctionCallUsage((JetDelegatorToSuperCall)parent.getParent(), functionUsageInfo)); } + else if (element instanceof JetSimpleNameExpression && functionPsi instanceof JetProperty) { + result.add(new JetPropertyCallUsage((JetSimpleNameExpression) element)); + } } } @@ -168,9 +166,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (oldName != null) TextOccurrencesUtil.findNonCodeUsages(functionPsi, oldName, true, true, changeInfo.getNewName(), result); - List oldParameters = functionPsi instanceof JetFunction - ? ((JetFunction) functionPsi).getValueParameters() - : ((JetClass) functionPsi).getPrimaryConstructorParameters(); + List oldParameters = PsiUtilPackage.getValueParameters((JetNamedDeclaration) functionPsi); JetParameterInfo newReceiverInfo = changeInfo.getReceiverParameterInfo(); @@ -221,7 +217,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } private static void processInternalReferences( - JetFunctionDefinitionUsage functionUsageInfo, + JetCallableDefinitionUsage functionUsageInfo, JetTreeVisitor visitor ) { JetFunction jetFunction = (JetFunction) functionUsageInfo.getDeclaration(); @@ -238,12 +234,12 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } private static void findOriginalReceiversUsages( - @NotNull final JetFunctionDefinitionUsage functionUsageInfo, + @NotNull final JetCallableDefinitionUsage functionUsageInfo, @NotNull final Set result, @NotNull final JetChangeInfo changeInfo ) { final JetParameterInfo originalReceiverInfo = changeInfo.getMethodDescriptor().getReceiver(); - final FunctionDescriptor functionDescriptor = functionUsageInfo.getOriginalFunctionDescriptor(); + final CallableDescriptor callableDescriptor = functionUsageInfo.getOriginalCallableDescriptor(); processInternalReferences( functionUsageInfo, new JetTreeVisitor() { @@ -254,7 +250,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (originalReceiverInfo != null && !changeInfo.hasParameter(originalReceiverInfo)) return; if (!(expression.getParent() instanceof JetThisExpression)) return; - if (receiverDescriptor == functionDescriptor.getExtensionReceiverParameter()) { + if (receiverDescriptor == callableDescriptor.getExtensionReceiverParameter()) { assert originalReceiverInfo != null : "No original receiver info provided: " + functionUsageInfo.getDeclaration().getText(); result.add(new JetParameterUsage(expression, originalReceiverInfo, functionUsageInfo)); } @@ -270,7 +266,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro @NotNull ThisReceiver receiverValue ) { DeclarationDescriptor targetDescriptor = receiverValue.getDeclarationDescriptor(); - if (targetDescriptor == functionDescriptor) { + if (targetDescriptor == callableDescriptor) { assert originalReceiverInfo != null : "No original receiver info provided: " + functionUsageInfo.getDeclaration().getText(); result.add(new JetImplicitThisToParameterUsage(callElement, originalReceiverInfo, functionUsageInfo)); } @@ -407,7 +403,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro PsiElement function = info.getMethod(); PsiElement element = function != null ? function : changeInfo.getContext(); BindingContext bindingContext = ResolvePackage.analyze((JetElement) element, BodyResolveMode.FULL); - FunctionDescriptor oldDescriptor = ChangeSignaturePackage.getOriginalBaseFunctionDescriptor(changeInfo); + CallableDescriptor oldDescriptor = ChangeSignaturePackage.getOriginalBaseFunctionDescriptor(changeInfo); DeclarationDescriptor containingDeclaration = oldDescriptor.getContainingDeclaration(); JetScope parametersScope = null; @@ -416,17 +412,21 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro else if (function instanceof JetFunction) parametersScope = org.jetbrains.kotlin.idea.refactoring.RefactoringPackage.getBodyScope((JetFunction) function, bindingContext); - JetScope functionScope = org.jetbrains.kotlin.idea.refactoring.RefactoringPackage.getContainingScope(oldDescriptor, bindingContext); + JetScope callableScope = org.jetbrains.kotlin.idea.refactoring.RefactoringPackage.getContainingScope(oldDescriptor, bindingContext); JetMethodDescriptor.Kind kind = ChangeSignaturePackage.getKind(changeInfo); - if (!kind.getIsConstructor() && functionScope != null && !info.getNewName().isEmpty()) { - for (FunctionDescriptor conflict : functionScope.getFunctions(Name.identifier(info.getNewName()))) { + if (!kind.getIsConstructor() && callableScope != null && !info.getNewName().isEmpty()) { + Name newName = Name.identifier(info.getNewName()); + Collection conflicts = oldDescriptor instanceof FunctionDescriptor + ? callableScope.getFunctions(newName) + : callableScope.getProperties(newName); + for (CallableDescriptor conflict : conflicts) { if (conflict == oldDescriptor) continue; PsiElement conflictElement = DescriptorToSourceUtils.descriptorToDeclaration(conflict); if (conflictElement == changeInfo.getMethod()) continue; - if (getFunctionParameterTypes(conflict).equals(getFunctionParameterTypes(oldDescriptor))) { + if (getCallableParameterTypes(conflict).equals(getCallableParameterTypes(oldDescriptor))) { result.putValue(conflictElement, "Function already exists: '" + DescriptorRenderer.SHORT_NAMES_IN_TYPES.render(conflict) + "'"); break; } @@ -464,7 +464,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro JetParameterInfo newReceiverInfo = changeInfo.getReceiverParameterInfo(); JetParameterInfo originalReceiverInfo = changeInfo.getMethodDescriptor().getReceiver(); - if (function instanceof JetNamedFunction && newReceiverInfo != originalReceiverInfo) { + if (function instanceof JetCallableDeclaration && newReceiverInfo != originalReceiverInfo) { findReceiverIntroducingConflicts(result, function, newReceiverInfo); findInternalExplicitReceiverConflicts(refUsages.get(), result, originalReceiverInfo); findThisLabelConflicts((JetChangeInfo) info, refUsages, result, changeInfo, function); @@ -525,10 +525,9 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro ) { if (originalReceiverInfo == null) { for (UsageInfo usageInfo : usages) { - if (!(usageInfo instanceof JetFunctionCallUsage)) continue; + if (!(usageInfo instanceof JetFunctionCallUsage || usageInfo instanceof JetPropertyCallUsage)) continue; - JetFunctionCallUsage callUsage = (JetFunctionCallUsage) usageInfo; - JetElement callElement = callUsage.getElement(); + JetElement callElement = (JetElement) usageInfo.getElement(); if (callElement == null) continue; PsiElement parent = callElement.getParent(); @@ -546,7 +545,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro PsiElement callable, JetParameterInfo newReceiverInfo ) { - if (newReceiverInfo != null && ((JetNamedFunction) callable).getBodyExpression() != null) { + if (newReceiverInfo != null && (callable instanceof JetNamedFunction) && ((JetNamedFunction) callable).getBodyExpression() != null) { Map noReceiverRefToContext = KotlinPackage.filter( JetFileReferencesResolver.INSTANCE$.resolve((JetNamedFunction) callable, true, true), new Function1, Boolean>() { @@ -606,7 +605,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } } - private static List getFunctionParameterTypes(FunctionDescriptor descriptor) { + private static List getCallableParameterTypes(CallableDescriptor descriptor) { return ContainerUtil.map(descriptor.getValueParameters(), new Function() { @Override public JetType fun(ValueParameterDescriptor descriptor) { @@ -710,26 +709,33 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro boolean isJavaMethodUsage = isJavaMethodUsage(usageInfo); if (usageInfo instanceof KotlinWrapperForJavaUsageInfos) { - JavaChangeInfo javaChangeInfo = ((JetChangeInfo) changeInfo).getOrCreateJavaChangeInfo(); - assert javaChangeInfo != null : "JavaChangeInfo not found: " + method.getText(); - UsageInfo[] javaUsageInfos = ((KotlinWrapperForJavaUsageInfos) usageInfo).getJavaUsageInfos(); + List javaChangeInfos = ((JetChangeInfo) changeInfo).getOrCreateJavaChangeInfos(); + assert javaChangeInfos != null : "JavaChangeInfo not found: " + method.getText(); + + KotlinWrapperForJavaUsageInfos wrapperForJavaUsageInfos = (KotlinWrapperForJavaUsageInfos) usageInfo; + UsageInfo[] javaUsageInfos = wrapperForJavaUsageInfos.getJavaUsageInfos(); ChangeSignatureUsageProcessor[] processors = ChangeSignatureUsageProcessor.EP_NAME.getExtensions(); - NullabilityPropagator nullabilityPropagator = new NullabilityPropagator(javaChangeInfo.getMethod()); + for (JavaChangeInfo javaChangeInfo : javaChangeInfos) { + // Match names so that getter/setter usages are not confused with each other + if (!javaChangeInfo.getOldName().equals(wrapperForJavaUsageInfos.getJavaChangeInfo().getOldName())) continue; - for (UsageInfo usage : javaUsageInfos) { - if (usage instanceof OverriderUsageInfo && beforeMethodChange) continue; - for (ChangeSignatureUsageProcessor processor : processors) { - if (processor instanceof JetChangeSignatureUsageProcessor) continue; - if (usage instanceof OverriderUsageInfo) { - processor.processUsage(javaChangeInfo, usage, true, javaUsageInfos); + NullabilityPropagator nullabilityPropagator = new NullabilityPropagator(javaChangeInfo.getMethod()); + + for (UsageInfo usage : javaUsageInfos) { + if (usage instanceof OverriderUsageInfo && beforeMethodChange) continue; + for (ChangeSignatureUsageProcessor processor : processors) { + if (processor instanceof JetChangeSignatureUsageProcessor) continue; + if (usage instanceof OverriderUsageInfo) { + processor.processUsage(javaChangeInfo, usage, true, javaUsageInfos); + } + if (processor.processUsage(javaChangeInfo, usage, beforeMethodChange, javaUsageInfos)) break; } - if (processor.processUsage(javaChangeInfo, usage, beforeMethodChange, javaUsageInfos)) break; - } - if (usage instanceof OverriderUsageInfo) { - PsiMethod overridingMethod = ((OverriderUsageInfo)usage).getOverridingMethod(); - if (overridingMethod != null && !(overridingMethod instanceof KotlinLightMethod)) { - nullabilityPropagator.processMethod(overridingMethod); + if (usage instanceof OverriderUsageInfo) { + PsiMethod overridingMethod = ((OverriderUsageInfo) usage).getOverridingMethod(); + if (overridingMethod != null && !(overridingMethod instanceof KotlinLightMethod)) { + nullabilityPropagator.processMethod(overridingMethod); + } } } } @@ -792,7 +798,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (!(changeInfo instanceof JetChangeInfo)) return false; JetChangeInfo jetChangeInfo = (JetChangeInfo) changeInfo; - for (JetFunctionDefinitionUsage primaryFunction : jetChangeInfo.getMethodDescriptor().getPrimaryFunctions()) { + for (JetCallableDefinitionUsage primaryFunction : jetChangeInfo.getMethodDescriptor().getPrimaryCallables()) { primaryFunction.processUsage(jetChangeInfo, primaryFunction.getDeclaration()); } jetChangeInfo.primaryMethodUpdated(); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt index b84a08d8949..fa2c7911a7e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt @@ -19,10 +19,10 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import com.intellij.psi.PsiElement import com.intellij.refactoring.changeSignature.MethodDescriptor import com.intellij.usageView.UsageInfo -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.Visibility -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetFunctionDefinitionUsage +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers public trait JetMethodDescriptor : MethodDescriptor { @@ -42,11 +42,11 @@ public trait JetMethodDescriptor : MethodDescriptor - val primaryFunctions: Collection> - val affectedFunctions: Collection + val originalPrimaryCallable: JetCallableDefinitionUsage + val primaryCallables: Collection> + val affectedCallables: Collection val receiver: JetParameterInfo? } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt index 2130cb187c1..9175e0610eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetParameterInfo.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.compareDescriptors -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetFunctionDefinitionUsage +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage import org.jetbrains.kotlin.idea.references.JetReference import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.psi.* @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.JetType import java.util.LinkedHashMap public class JetParameterInfo( - val functionDescriptor: FunctionDescriptor, + val callableDescriptor: CallableDescriptor, val originalIndex: Int = -1, private var name: String, type: JetType? = null, @@ -61,7 +61,7 @@ public class JetParameterInfo( object : JetTreeVisitorVoid() { private fun selfParameterOrNull(parameter: DeclarationDescriptor?): ValueParameterDescriptor? { return if (parameter is ValueParameterDescriptor && - compareDescriptors(project, parameter.getContainingDeclaration(), functionDescriptor)) { + compareDescriptors(project, parameter.getContainingDeclaration(), callableDescriptor)) { parameter } else null } @@ -69,12 +69,12 @@ public class JetParameterInfo( private fun selfReceiverOrNull(receiverDescriptor: DeclarationDescriptor?): DeclarationDescriptor? { if (compareDescriptors(project, receiverDescriptor, - functionDescriptor.getExtensionReceiverParameter()?.getContainingDeclaration())) { + callableDescriptor.getExtensionReceiverParameter()?.getContainingDeclaration())) { return receiverDescriptor } if (compareDescriptors(project, receiverDescriptor, - functionDescriptor.getDispatchReceiverParameter()?.getContainingDeclaration())) { + callableDescriptor.getDispatchReceiverParameter()?.getContainingDeclaration())) { return receiverDescriptor } return null @@ -93,7 +93,7 @@ public class JetParameterInfo( val descriptor = ref.resolveToDescriptors(context).singleOrNull() if (descriptor is ValueParameterDescriptor) return selfParameterOrNull(descriptor) - if (descriptor is PropertyDescriptor && functionDescriptor is ConstructorDescriptor) { + if (descriptor is PropertyDescriptor && callableDescriptor is ConstructorDescriptor) { val parameter = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor) as? JetParameter return parameter?.let { selfParameterOrNull(context[BindingContext.VALUE_PARAMETER, it]) } } @@ -149,20 +149,20 @@ public class JetParameterInfo( throw UnsupportedOperationException() } - public fun renderType(parameterIndex: Int, inheritedFunction: JetFunctionDefinitionUsage<*>): String { - val typeSubstitutor = inheritedFunction.getOrCreateTypeSubstitutor() ?: return currentTypeText - val currentBaseFunction = inheritedFunction.getBaseFunction().getCurrentFunctionDescriptor() ?: return currentTypeText + public fun renderType(parameterIndex: Int, inheritedCallable: JetCallableDefinitionUsage<*>): String { + val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return currentTypeText + val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return currentTypeText val parameterType = currentBaseFunction.getValueParameters().get(parameterIndex).getType() return parameterType.renderTypeWithSubstitution(typeSubstitutor, currentTypeText, true) } - public fun getInheritedName(inheritedFunction: JetFunctionDefinitionUsage<*>): String { - if (!inheritedFunction.isInherited()) return name + public fun getInheritedName(inheritedCallable: JetCallableDefinitionUsage<*>): String { + if (!inheritedCallable.isInherited()) return name - val baseFunction = inheritedFunction.getBaseFunction() - val baseFunctionDescriptor = baseFunction.getOriginalFunctionDescriptor() + val baseFunction = inheritedCallable.getBaseFunction() + val baseFunctionDescriptor = baseFunction.getOriginalCallableDescriptor() - val inheritedFunctionDescriptor = inheritedFunction.getOriginalFunctionDescriptor() + val inheritedFunctionDescriptor = inheritedCallable.getOriginalCallableDescriptor() val inheritedParameterDescriptors = inheritedFunctionDescriptor.getValueParameters() if (originalIndex < 0 || originalIndex >= baseFunctionDescriptor.getValueParameters().size() @@ -177,18 +177,18 @@ public class JetParameterInfo( } } - public fun requiresExplicitType(inheritedFunction: JetFunctionDefinitionUsage): Boolean { - val inheritedFunctionDescriptor = inheritedFunction.getOriginalFunctionDescriptor() + public fun requiresExplicitType(inheritedCallable: JetCallableDefinitionUsage): Boolean { + val inheritedFunctionDescriptor = inheritedCallable.getOriginalCallableDescriptor() if (inheritedFunctionDescriptor !is AnonymousFunctionDescriptor) return true - if (originalIndex < 0) return !inheritedFunction.hasExpectedType() + if (originalIndex < 0) return !inheritedCallable.hasExpectedType() val inheritedParameterDescriptor = inheritedFunctionDescriptor.getValueParameters().get(originalIndex) val parameter = DescriptorToSourceUtils.descriptorToDeclaration(inheritedParameterDescriptor) as? JetParameter ?: return false return parameter.getTypeReference() != null } - public fun getDeclarationSignature(parameterIndex: Int, inheritedFunction: JetFunctionDefinitionUsage): String { + public fun getDeclarationSignature(parameterIndex: Int, inheritedCallable: JetCallableDefinitionUsage): String { val buffer = StringBuilder() if (modifierList != null) { @@ -199,13 +199,13 @@ public class JetParameterInfo( buffer.append(valOrVar).append(' ') } - buffer.append(getInheritedName(inheritedFunction)) + buffer.append(getInheritedName(inheritedCallable)) - if (requiresExplicitType(inheritedFunction)) { - buffer.append(": ").append(renderType(parameterIndex, inheritedFunction)) + if (requiresExplicitType(inheritedCallable)) { + buffer.append(": ").append(renderType(parameterIndex, inheritedCallable)) } - if (!inheritedFunction.isInherited()) { + if (!inheritedCallable.isInherited()) { defaultValueForParameter?.let { buffer.append(" = ").append(it.getText()) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/typeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/typeUtils.kt index 1f4a69ec17a..fca58008fe9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/typeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/typeUtils.kt @@ -16,18 +16,13 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.TypeConstructor -import org.jetbrains.kotlin.types.TypeProjection -import java.util.LinkedHashMap -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure -import org.jetbrains.kotlin.types.TypeProjectionImpl -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetFunctionDefinitionUsage -import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure +import java.util.LinkedHashMap private fun getTypeSubstitution(baseType: JetType, derivedType: JetType): LinkedHashMap? { val substitutedType = TypeCheckingProcedure.findCorrespondingSupertype(derivedType, baseType) ?: return null @@ -40,15 +35,15 @@ private fun getTypeSubstitution(baseType: JetType, derivedType: JetType): Linked return substitution } -private fun getFunctionSubstitution( - baseFunction: FunctionDescriptor, - derivedFunction: FunctionDescriptor +private fun getCallableSubstitution( + baseCallable: CallableDescriptor, + derivedCallable: CallableDescriptor ): MutableMap? { - val baseClass = baseFunction.getContainingDeclaration() as? ClassDescriptor ?: return null - val derivedClass = derivedFunction.getContainingDeclaration() as? ClassDescriptor ?: return null + val baseClass = baseCallable.getContainingDeclaration() as? ClassDescriptor ?: return null + val derivedClass = derivedCallable.getContainingDeclaration() as? ClassDescriptor ?: return null val substitution = getTypeSubstitution(baseClass.getDefaultType(), derivedClass.getDefaultType()) ?: return null - for ((baseParam, derivedParam) in baseFunction.getTypeParameters() zip derivedFunction.getTypeParameters()) { + for ((baseParam, derivedParam) in baseCallable.getTypeParameters() zip derivedCallable.getTypeParameters()) { substitution[baseParam.getTypeConstructor()] = TypeProjectionImpl(derivedParam.getDefaultType()) } @@ -59,15 +54,15 @@ fun getTypeSubstitutor(baseType: JetType, derivedType: JetType): TypeSubstitutor return getTypeSubstitution(baseType, derivedType)?.let { TypeSubstitutor.create(it) } } -fun getFunctionSubstitutor( - baseFunction: JetFunctionDefinitionUsage<*>, - derivedFunction: JetFunctionDefinitionUsage<*> +fun getCallableSubstitutor( + baseFunction: JetCallableDefinitionUsage<*>, + derivedCallable: JetCallableDefinitionUsage<*> ): TypeSubstitutor? { - val currentBaseFunction = baseFunction.getCurrentFunctionDescriptor() - val currentDerivedFunction = derivedFunction.getCurrentFunctionDescriptor() + val currentBaseFunction = baseFunction.getCurrentCallableDescriptor() + val currentDerivedFunction = derivedCallable.getCurrentCallableDescriptor() if (currentBaseFunction == null || currentDerivedFunction == null) return null - return getFunctionSubstitution(currentBaseFunction, currentDerivedFunction)?.let { TypeSubstitutor.create(it) } + return getCallableSubstitution(currentBaseFunction, currentDerivedFunction)?.let { TypeSubstitutor.create(it) } } fun JetType.renderTypeWithSubstitution(substitutor: TypeSubstitutor?, defaultText: String, inArgumentPosition: Boolean): String { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt index 62d67a3afa8..488c88f3947 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt @@ -35,10 +35,10 @@ public class DeferredJavaMethodOverrideOrSAMUsage( ): JavaMethodDeferredKotlinUsage(function) { override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { return object : JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { - override val delegateUsage = JetFunctionDefinitionUsage( + override val delegateUsage = JetCallableDefinitionUsage( function, functionDescriptor, - javaMethodChangeInfo.methodDescriptor.originalPrimaryFunction, + javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable, samCallType ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt index 10c3bfc21c8..87187080299 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt @@ -34,7 +34,7 @@ public abstract class JavaMethodKotlinUsageWithDelegate( public class JavaMethodKotlinCallUsage( callElement: JetCallElement, javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate(callElement, javaMethodChangeInfo) { - override protected val delegateUsage = JetFunctionCallUsage(psiElement, javaMethodChangeInfo.methodDescriptor.originalPrimaryFunction) + override protected val delegateUsage = JetFunctionCallUsage(psiElement, javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable) } public class JavaMethodKotlinDerivedDefinitionUsage( @@ -42,10 +42,10 @@ public class JavaMethodKotlinDerivedDefinitionUsage( functionDescriptor: FunctionDescriptor, javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { @suppress("CAST_NEVER_SUCCEEDS") - override protected val delegateUsage = JetFunctionDefinitionUsage( + override protected val delegateUsage = JetCallableDefinitionUsage( psiElement, functionDescriptor, - javaMethodChangeInfo.methodDescriptor.originalPrimaryFunction, + javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable, null ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java similarity index 74% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionDefinitionUsage.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index 0f611f11a9e..c2189182b48 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -26,9 +26,9 @@ import kotlin.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; +import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.codeInsight.shorten.ShortenPackage; @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.idea.util.ShortenReferences.Options; import org.jetbrains.kotlin.lexer.JetModifierKeywordToken; import org.jetbrains.kotlin.psi.*; +import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.psi.typeRefHelpers.TypeRefHelpersPackage; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; @@ -52,14 +53,14 @@ import java.util.List; import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory; -public class JetFunctionDefinitionUsage extends JetUsageInfo { +public class JetCallableDefinitionUsage extends JetUsageInfo { @NotNull - private final FunctionDescriptor originalFunctionDescriptor; + private final CallableDescriptor originalCallableDescriptor; - private FunctionDescriptor currentFunctionDescriptor; + private CallableDescriptor currentCallableDescriptor; @NotNull - private final JetFunctionDefinitionUsage baseFunction; + private final JetCallableDefinitionUsage baseFunction; private final boolean hasExpectedType; @@ -69,24 +70,25 @@ public class JetFunctionDefinitionUsage extends JetUsageIn @Nullable private TypeSubstitutor typeSubstitutor; - public JetFunctionDefinitionUsage( + public JetCallableDefinitionUsage( @NotNull T function, - @NotNull FunctionDescriptor originalFunctionDescriptor, - @Nullable JetFunctionDefinitionUsage baseFunction, - @Nullable JetType samCallType) { + @NotNull CallableDescriptor originalCallableDescriptor, + @Nullable JetCallableDefinitionUsage baseFunction, + @Nullable JetType samCallType + ) { super(function); - this.originalFunctionDescriptor = originalFunctionDescriptor; + this.originalCallableDescriptor = originalCallableDescriptor; this.baseFunction = baseFunction != null ? baseFunction : this; - this.hasExpectedType = checkIfHasExpectedType(originalFunctionDescriptor, isInherited()); + this.hasExpectedType = checkIfHasExpectedType(originalCallableDescriptor, isInherited()); this.samCallType = samCallType; } - private static boolean checkIfHasExpectedType(@NotNull FunctionDescriptor functionDescriptor, boolean isInherited) { - if (!(functionDescriptor instanceof AnonymousFunctionDescriptor && isInherited)) return false; + private static boolean checkIfHasExpectedType(@NotNull CallableDescriptor callableDescriptor, boolean isInherited) { + if (!(callableDescriptor instanceof AnonymousFunctionDescriptor && isInherited)) return false; JetFunctionLiteral functionLiteral = - (JetFunctionLiteral) DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor); - assert functionLiteral != null : "No declaration found for " + functionDescriptor; + (JetFunctionLiteral) DescriptorToSourceUtils.descriptorToDeclaration(callableDescriptor); + assert functionLiteral != null : "No declaration found for " + callableDescriptor; PsiElement parent = functionLiteral.getParent(); if (!(parent instanceof JetFunctionLiteralExpression)) return false; @@ -96,7 +98,7 @@ public class JetFunctionDefinitionUsage extends JetUsageIn } @NotNull - public JetFunctionDefinitionUsage getBaseFunction() { + public JetCallableDefinitionUsage getBaseFunction() { return baseFunction; } @@ -112,10 +114,10 @@ public class JetFunctionDefinitionUsage extends JetUsageIn if (typeSubstitutor == null) { if (samCallType == null) { - typeSubstitutor = ChangeSignaturePackage.getFunctionSubstitutor(baseFunction, this); + typeSubstitutor = ChangeSignaturePackage.getCallableSubstitutor(baseFunction, this); } else { - DeclarationDescriptor currentBaseDescriptor = baseFunction.getCurrentFunctionDescriptor(); + DeclarationDescriptor currentBaseDescriptor = baseFunction.getCurrentCallableDescriptor(); DeclarationDescriptor classDescriptor = currentBaseDescriptor != null ? currentBaseDescriptor.getContainingDeclaration() : null; @@ -140,71 +142,51 @@ public class JetFunctionDefinitionUsage extends JetUsageIn } @NotNull - public final FunctionDescriptor getOriginalFunctionDescriptor() { - return originalFunctionDescriptor; + public final CallableDescriptor getOriginalCallableDescriptor() { + return originalCallableDescriptor; } @Nullable - public final FunctionDescriptor getCurrentFunctionDescriptor() { - if (currentFunctionDescriptor == null) { + public final CallableDescriptor getCurrentCallableDescriptor() { + if (currentCallableDescriptor == null) { PsiElement element = getDeclaration(); - if (element instanceof JetFunction) { - currentFunctionDescriptor = (FunctionDescriptor) ResolvePackage.resolveToDescriptor((JetFunction) element); + if (element instanceof JetFunction || element instanceof JetProperty) { + currentCallableDescriptor = (CallableDescriptor) ResolvePackage.resolveToDescriptor((JetDeclaration) element); } else if (element instanceof JetClass) { - currentFunctionDescriptor = ((ClassDescriptor) ResolvePackage.resolveToDescriptor((JetClass) element)).getUnsubstitutedPrimaryConstructor(); + currentCallableDescriptor = ((ClassDescriptor) ResolvePackage.resolveToDescriptor((JetClass) element)).getUnsubstitutedPrimaryConstructor(); } else if (element instanceof PsiMethod) { - currentFunctionDescriptor = ResolvePackage.getJavaMethodDescriptor((PsiMethod) element); + currentCallableDescriptor = ResolvePackage.getJavaMethodDescriptor((PsiMethod) element); } } - return currentFunctionDescriptor; + return currentCallableDescriptor; } @Override public boolean processUsage(JetChangeInfo changeInfo, PsiElement element) { - JetParameterList parameterList; + if (!(element instanceof JetNamedDeclaration)) return true; JetPsiFactory psiFactory = JetPsiFactory(element.getProject()); - if (element instanceof JetFunction) { - JetFunction function = (JetFunction) element; - parameterList = function.getValueParameterList(); - if (changeInfo.isNameChanged()) { - PsiElement identifier = function.getNameIdentifier(); + if (changeInfo.isNameChanged()) { + PsiElement identifier = ((JetCallableDeclaration) element).getNameIdentifier(); - if (identifier != null) { - identifier.replace(psiFactory.createIdentifier(changeInfo.getNewName())); - } - } - - boolean returnTypeIsNeeded = (changeInfo.isRefactoringTarget(originalFunctionDescriptor) - || !(function instanceof JetFunctionLiteral) - || function.getTypeReference() != null) && - !(function instanceof JetConstructor); - if (changeInfo.isReturnTypeChanged() && returnTypeIsNeeded) { - function.setTypeReference(null); - String returnTypeText = changeInfo.renderReturnType((JetFunctionDefinitionUsage) this); - - //TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready - if (!KotlinBuiltIns.getInstance().getUnitType().toString().equals(returnTypeText)) { - ShortenPackage.addToShorteningWaitSet( - function.setTypeReference(JetPsiFactory(function).createType(returnTypeText)), - Options.DEFAULT - ); - } + if (identifier != null) { + identifier.replace(psiFactory.createIdentifier(changeInfo.getNewName())); } } - else { - parameterList = ((JetClass) element).getPrimaryConstructorParameterList(); - } + + changeReturnTypeIfNeeded(changeInfo, element); + + JetParameterList parameterList = PsiUtilPackage.getValueParameterList((JetNamedDeclaration) element); if (changeInfo.isParameterSetOrOrderChanged()) { processParameterListWithStructuralChanges(changeInfo, element, parameterList, psiFactory); } else if (parameterList != null) { - int paramIndex = originalFunctionDescriptor.getExtensionReceiverParameter() != null ? 1 : 0; + int paramIndex = originalCallableDescriptor.getExtensionReceiverParameter() != null ? 1 : 0; for (JetParameter parameter : parameterList.getParameters()) { JetParameterInfo parameterInfo = changeInfo.getNewParameters()[paramIndex]; @@ -215,11 +197,11 @@ public class JetFunctionDefinitionUsage extends JetUsageIn ShortenPackage.addToShorteningWaitSet(parameterList, Options.DEFAULT); } - if (element instanceof JetFunction && changeInfo.isReceiverTypeChanged()) { + if (element instanceof JetCallableDeclaration && changeInfo.isReceiverTypeChanged()) { //noinspection unchecked - String receiverTypeText = changeInfo.renderReceiverType((JetFunctionDefinitionUsage) this); + String receiverTypeText = changeInfo.renderReceiverType((JetCallableDefinitionUsage) this); JetTypeReference receiverTypeRef = receiverTypeText != null ? psiFactory.createType(receiverTypeText) : null; - JetTypeReference newReceiverTypeRef = TypeRefHelpersPackage.setReceiverTypeReference((JetFunction) element, receiverTypeRef); + JetTypeReference newReceiverTypeRef = TypeRefHelpersPackage.setReceiverTypeReference((JetCallableDeclaration) element, receiverTypeRef); if (newReceiverTypeRef != null) { ShortenPackage.addToShorteningWaitSet(newReceiverTypeRef, ShortenReferences.Options.DEFAULT); } @@ -232,6 +214,36 @@ public class JetFunctionDefinitionUsage extends JetUsageIn return true; } + protected void changeReturnTypeIfNeeded(JetChangeInfo changeInfo, PsiElement element) { + if (!(element instanceof JetCallableDeclaration)) return; + if (element instanceof JetConstructor) return; + + JetCallableDeclaration callable = (JetCallableDeclaration) element; + + boolean returnTypeIsNeeded; + if (element instanceof JetFunction) { + returnTypeIsNeeded = (changeInfo.isRefactoringTarget(originalCallableDescriptor) || + !(callable instanceof JetFunctionLiteral) || + callable.getTypeReference() != null); + } + else { + returnTypeIsNeeded = element instanceof JetProperty; + } + + if (changeInfo.isReturnTypeChanged() && returnTypeIsNeeded) { + callable.setTypeReference(null); + String returnTypeText = changeInfo.renderReturnType((JetCallableDefinitionUsage) this); + + //TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready + if (!KotlinBuiltIns.getInstance().getUnitType().toString().equals(returnTypeText)) { + ShortenPackage.addToShorteningWaitSet( + callable.setTypeReference(JetPsiFactory(callable).createType(returnTypeText)), + Options.DEFAULT + ); + } + } + } + private void processParameterListWithStructuralChanges( JetChangeInfo changeInfo, PsiElement element, @@ -256,14 +268,14 @@ public class JetFunctionDefinitionUsage extends JetUsageIn } else { newParameterList = psiFactory.createFunctionLiteralParameterList(changeInfo.getNewParametersSignature( - (JetFunctionDefinitionUsage) this) + (JetCallableDefinitionUsage) this) ); canReplaceEntireList = true; } } - else { + else if (!(element instanceof JetProperty)) { newParameterList = psiFactory.createParameterList(changeInfo.getNewParametersSignature( - (JetFunctionDefinitionUsage) this) + (JetCallableDefinitionUsage) this) ); } @@ -339,14 +351,15 @@ public class JetFunctionDefinitionUsage extends JetUsageIn private static void changeVisibility(JetChangeInfo changeInfo, PsiElement element) { JetModifierKeywordToken newVisibilityToken = JetRefactoringUtil.getVisibilityToken(changeInfo.getNewVisibility()); - if (element instanceof JetFunction) { - ((JetFunction)element).addModifier(newVisibilityToken); + if (element instanceof JetCallableDeclaration) { + ((JetCallableDeclaration)element).addModifier(newVisibilityToken); } - else { + else if (element instanceof JetClass) { JetPrimaryConstructor constructor = ((JetClass) element).getPrimaryConstructor(); assert constructor != null : "Primary constructor should be created before changing visibility"; constructor.addModifier(newVisibilityToken); } + else throw new AssertionError("Invalid element: " + PsiUtilPackage.getElementTextWithContext(element)); } private void changeParameter(int parameterIndex, JetParameter parameter, JetParameterInfo parameterInfo) { @@ -365,6 +378,7 @@ public class JetFunctionDefinitionUsage extends JetUsageIn } else if (valOrVar != JetValVar.None) { PsiElement firstChild = parameter.getFirstChild(); + //noinspection ConstantConditions parameter.addBefore(valOrVar.createKeyword(psiFactory), firstChild); parameter.addBefore(psiFactory.createWhiteSpace(), firstChild); } @@ -378,7 +392,7 @@ public class JetFunctionDefinitionUsage extends JetUsageIn if (identifier != null) { //noinspection unchecked - String newName = parameterInfo.getInheritedName((JetFunctionDefinitionUsage) this); + String newName = parameterInfo.getInheritedName(this); identifier.replace(psiFactory.createIdentifier(newName)); } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt index 5dfd37b2718..617b5e14139 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt @@ -25,7 +25,7 @@ public class JetConstructorDelegationCallUsage( call: JetConstructorDelegationCall, changeInfo: JetChangeInfo ) : JetUsageInfo(call) { - val delegate = JetFunctionCallUsage(call, changeInfo.methodDescriptor.originalPrimaryFunction) + val delegate = JetFunctionCallUsage(call, changeInfo.methodDescriptor.originalPrimaryCallable) override fun processUsage(changeInfo: JetChangeInfo, element: JetConstructorDelegationCall): Boolean { val isThisCall = element.isCallToThis() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt index 24c726ab86b..d7e3f3cbd8a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt @@ -35,7 +35,7 @@ public class JetEnumEntryWithoutSuperCallUsage(enumEntry: JetEnumEntry) : JetUsa ) as JetDelegatorToSuperCall element.addBefore(psiFactory.createColon(), delegatorToSuperCall) - return JetFunctionCallUsage(delegatorToSuperCall, changeInfo.methodDescriptor.originalPrimaryFunction) + return JetFunctionCallUsage(delegatorToSuperCall, changeInfo.methodDescriptor.originalPrimaryCallable) .processUsage(changeInfo, delegatorToSuperCall) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index f88883571d3..7468e5ea0b1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -29,6 +29,7 @@ import kotlin.Unit; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.codegen.PropertyCodegen; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.codeInsight.shorten.ShortenPackage; @@ -38,6 +39,9 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.ExtractionEnginePackage; import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinIntroduceVariableHandler; import org.jetbrains.kotlin.idea.util.ShortenReferences; +import org.jetbrains.kotlin.load.java.JvmAbi; +import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor; +import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; @@ -75,11 +79,11 @@ public class JetFunctionCallUsage extends JetUsageInfo { private static final ShortenReferences.Options SHORTEN_ARGUMENTS_OPTIONS = new ShortenReferences.Options(true, true); - private final JetFunctionDefinitionUsage callee; + private final JetCallableDefinitionUsage callee; private final BindingContext context; private final ResolvedCall resolvedCall; - public JetFunctionCallUsage(@NotNull JetCallElement element, JetFunctionDefinitionUsage callee) { + public JetFunctionCallUsage(@NotNull JetCallElement element, JetCallableDefinitionUsage callee) { super(element); this.callee = callee; this.context = ResolvePackage.analyze(element, BodyResolveMode.FULL); @@ -88,13 +92,7 @@ public class JetFunctionCallUsage extends JetUsageInfo { @Override public boolean processUsage(JetChangeInfo changeInfo, JetCallElement element) { - if (changeInfo.isNameChanged()) { - JetExpression callee = element.getCalleeExpression(); - - if (callee instanceof JetSimpleNameExpression) { - callee.replace(JetPsiFactory(getProject()).createSimpleName(changeInfo.getNewName())); - } - } + changeNameIfNeeded(changeInfo, element); if (element.getValueArgumentList() != null) { if (changeInfo.isParameterSetOrOrderChanged()) { @@ -118,6 +116,27 @@ public class JetFunctionCallUsage extends JetUsageInfo { return true; } + private boolean isPropertyJavaUsage() { + return this.callee.getElement() instanceof JetProperty + && resolvedCall != null && resolvedCall.getResultingDescriptor() instanceof JavaMethodDescriptor; + } + + protected void changeNameIfNeeded(JetChangeInfo changeInfo, JetCallElement element) { + if (!changeInfo.isNameChanged()) return; + + JetExpression callee = element.getCalleeExpression(); + if (!(callee instanceof JetSimpleNameExpression)) return; + + String newName = changeInfo.getNewName(); + if (isPropertyJavaUsage()) { + String currentName = ((JetSimpleNameExpression) callee).getReferencedName(); + if (currentName.startsWith(JvmAbi.GETTER_PREFIX)) newName = PropertyCodegen.getterName(Name.identifier(newName)); + else if (currentName.startsWith(JvmAbi.SETTER_PREFIX)) newName = PropertyCodegen.setterName(Name.identifier(newName)); + } + + callee.replace(JetPsiFactory(getProject()).createSimpleName(newName)); + } + @Nullable private JetExpression getReceiverExpressionIfMatched( @NotNull ReceiverValue receiverValue, @@ -288,6 +307,11 @@ public class JetFunctionCallUsage extends JetUsageInfo { assert arguments != null : "Argument list is expected: " + element.getText(); List oldArguments = element.getValueArguments(); + if (isPropertyJavaUsage()) { + updateJavaPropertyCall(changeInfo, element); + return; + } + boolean isNamedCall = oldArguments.size() > 1 && oldArguments.get(0).isNamed(); StringBuilder parametersBuilder = new StringBuilder("("); boolean isFirst = true; @@ -388,7 +412,8 @@ public class JetFunctionCallUsage extends JetUsageInfo { //TODO: this is not correct! JetValueArgument lastArgument = KotlinPackage.lastOrNull(newArgumentList.getArguments()); - boolean hasTrailingLambdaInArgumentListAfter = lastArgument != null && PsiPackage.unpackFunctionLiteral(lastArgument.getArgumentExpression()) != null; + boolean hasTrailingLambdaInArgumentListAfter = + lastArgument != null && PsiPackage.unpackFunctionLiteral(lastArgument.getArgumentExpression()) != null; arguments = (JetValueArgumentList) arguments.replace(newArgumentList); @@ -435,6 +460,38 @@ public class JetFunctionCallUsage extends JetUsageInfo { } } + private static void updateJavaPropertyCall(JetChangeInfo changeInfo, JetCallElement element) { + JetParameterInfo newReceiverInfo = changeInfo.getReceiverParameterInfo(); + JetParameterInfo originalReceiverInfo = changeInfo.getMethodDescriptor().getReceiver(); + if (newReceiverInfo == originalReceiverInfo) return; + + JetValueArgumentList arguments = element.getValueArgumentList(); + assert arguments != null : "Argument list is expected: " + element.getText(); + List oldArguments = element.getValueArguments(); + + JetPsiFactory psiFactory = new JetPsiFactory(element.getProject()); + + JetValueArgument firstArgument = oldArguments.isEmpty() ? null : (JetValueArgument) oldArguments.get(0); + + if (newReceiverInfo == null) { + if (firstArgument != null) arguments.removeArgument(firstArgument); + } + else { + JetExpression defaultValueForCall = newReceiverInfo.getDefaultValueForCall(); + if (defaultValueForCall == null) { + defaultValueForCall = psiFactory.createExpression("_"); + } + JetValueArgument newReceiverArgument = psiFactory.createArgument(defaultValueForCall, null, false); + + if (originalReceiverInfo != null) { + if (firstArgument != null) firstArgument.replace(newReceiverArgument); + } + else { + arguments.addArgumentAfter(newReceiverArgument, null); + } + } + } + @Nullable private static JetExpression getReceiverExpression(@NotNull ReceiverValue receiver, @NotNull JetPsiFactory psiFactory) { if (receiver instanceof ExpressionReceiver) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt index b67d7c1ce6e..72a11726f36 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt @@ -44,9 +44,9 @@ public abstract class JetImplicitReceiverUsage(callElement: JetElement): JetUsag public class JetImplicitThisToParameterUsage( callElement: JetElement, val parameterInfo: JetParameterInfo, - val containingFunction: JetFunctionDefinitionUsage<*> + val containingCallable: JetCallableDefinitionUsage<*> ): JetImplicitReceiverUsage(callElement) { - override fun getNewReceiverText(): String = parameterInfo.getInheritedName(containingFunction) + override fun getNewReceiverText(): String = parameterInfo.getInheritedName(containingCallable) override fun processReplacedElement(element: JetElement) { element.addToShorteningWaitSet(Options(removeThisLabels = true)) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt index 5af65b9a57b..dbc6122a78d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt @@ -46,7 +46,7 @@ public abstract class JetExplicitReferenceUsage(element: T) : Jet public class JetParameterUsage( element: JetElement, private val parameterInfo: JetParameterInfo, - val containingFunction: JetFunctionDefinitionUsage<*> + val containingCallable: JetCallableDefinitionUsage<*> ) : JetExplicitReferenceUsage(element) { override fun processReplacedElement(element: JetElement) { val qualifiedExpression = element.getParent() as? JetQualifiedExpression @@ -56,7 +56,7 @@ public class JetParameterUsage( override fun getReplacementText(changeInfo: JetChangeInfo): String = if (changeInfo.receiverParameterInfo != parameterInfo) { - parameterInfo.getInheritedName(containingFunction) + parameterInfo.getInheritedName(containingCallable) } else "this@${changeInfo.getNewName()}" } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt new file mode 100644 index 00000000000..7ae906377bb --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt @@ -0,0 +1,64 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages + +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo +import org.jetbrains.kotlin.psi.JetPsiFactory +import org.jetbrains.kotlin.psi.JetQualifiedExpression +import org.jetbrains.kotlin.psi.JetSimpleNameExpression +import org.jetbrains.kotlin.psi.createExpressionByPattern +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver + +public class JetPropertyCallUsage(element: JetSimpleNameExpression): JetUsageInfo(element) { + private val resolvedCall = element.getResolvedCall(element.analyze()) + + override fun processUsage(changeInfo: JetChangeInfo, element: JetSimpleNameExpression): Boolean { + updateName(changeInfo, element) + updateReceiver(changeInfo, element) + return true + } + + private fun updateName(changeInfo: JetChangeInfo, element: JetSimpleNameExpression) { + if (changeInfo.isNameChanged()) { + element.getReference()?.handleElementRename(changeInfo.getNewName()) + } + } + + private fun updateReceiver(changeInfo: JetChangeInfo, element: JetSimpleNameExpression) { + val newReceiver = changeInfo.receiverParameterInfo + val oldReceiver = changeInfo.methodDescriptor.receiver + if (newReceiver == oldReceiver) return + + val elementToReplace = element.getQualifiedExpressionForSelectorOrThis() + + // Do not add extension receiver to calls with explicit dispatch receiver + if (newReceiver != null + && elementToReplace is JetQualifiedExpression + && resolvedCall?.getDispatchReceiver() is ExpressionReceiver) return + + val replacingElement = newReceiver?.let { + val psiFactory = JetPsiFactory(getProject()) + val receiver = it.defaultValueForCall ?: psiFactory.createExpression("_") + psiFactory.createExpressionByPattern("$0.$1", receiver, element) + } ?: element + + elementToReplace.replace(replacingElement) + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt index 3d941aba020..f1ade8c2a92 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinWrapperForJavaUsageInfos.kt @@ -17,9 +17,19 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages import com.intellij.psi.PsiElement +import com.intellij.refactoring.changeSignature.JavaChangeInfo import com.intellij.usageView.UsageInfo public class KotlinWrapperForJavaUsageInfos( + val javaChangeInfo: JavaChangeInfo, val javaUsageInfos: Array, val primaryMethod: PsiElement -): UsageInfo(primaryMethod) +): UsageInfo(primaryMethod) { + override fun hashCode(): Int { + return javaChangeInfo.getMethod().hashCode(); + } + + override fun equals(other: Any?): Boolean { + return other == this || (other is KotlinWrapperForJavaUsageInfos && javaChangeInfo.getMethod() == other.javaChangeInfo.getMethod()) + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt index c5d2a50adb6..cbe75dba431 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt @@ -32,6 +32,7 @@ import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.JetFileType import org.jetbrains.kotlin.idea.core.refactoring.isMultiLine import org.jetbrains.kotlin.idea.core.refactoring.runRefactoringWithPostprocessing +import org.jetbrains.kotlin.idea.core.refactoring.validateElement import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinExtractFunctionDialog import org.jetbrains.kotlin.idea.refactoring.introduce.extractFunction.ui.KotlinParameterTablePanel import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.* @@ -233,18 +234,9 @@ public class KotlinIntroduceParameterDialog private constructor( override fun createCenterPanel() = null override fun canRun() { - fun validateElement(e: PsiElement, errorMessage: String) { - try { - AnalyzingUtils.checkForSyntacticErrors(e) - } - catch(e: Exception) { - throw ConfigurationException(errorMessage) - } - } - val psiFactory = JetPsiFactory(myProject) - validateElement(psiFactory.createType(nameField.getEnteredName()), "Invalid parameter name") - validateElement(psiFactory.createType(typeField.getEnteredName()), "Invalid parameter type") + psiFactory.createSimpleName(nameField.getEnteredName()).validateElement("Invalid parameter name") + psiFactory.createType(typeField.getEnteredName()).validateElement("Invalid parameter type") } override fun doAction() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 5d35a857ab3..190a7cc24b3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -142,7 +142,7 @@ fun IntroduceParameterDescriptor.performRefactoring() { .forEach { methodDescriptor.removeParameter(it) } } - val parameterInfo = JetParameterInfo(functionDescriptor = callableDescriptor, + val parameterInfo = JetParameterInfo(callableDescriptor = callableDescriptor, name = newParameterName, defaultValueForCall = if (withDefaultValue) null else newArgumentValue, defaultValueForParameter = if (withDefaultValue) newArgumentValue else null, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt index 1eb345ea27f..3cbb070c9f4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt @@ -77,7 +77,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe // Temporarily assume that the new parameter is of Any type. Actual type is substituted during the signature update phase val defaultValueForCall = (data.getParameterInitializer().getExpression()!! as? PsiExpression)?.let { it.j2k() } - changeInfo.addParameter(JetParameterInfo(functionDescriptor = psiMethodDescriptor, + changeInfo.addParameter(JetParameterInfo(callableDescriptor = psiMethodDescriptor, name = data.getParameterName(), type = KotlinBuiltIns.getInstance().getAnyType(), defaultValueForCall = defaultValueForCall)) @@ -100,7 +100,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe .map { it.unwrapped } .filterIsInstance() return (kotlinFunctions + element).all { - JetFunctionDefinitionUsage(it, changeInfo.originalBaseFunctionDescriptor, null, null).processUsage(changeInfo, it) + JetCallableDefinitionUsage(it, changeInfo.originalBaseFunctionDescriptor, null, null).processUsage(changeInfo, it) } } @@ -114,7 +114,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe (JetConstructorDelegationCallUsage(callElement, changeInfo) as JetUsageInfo) } else { - JetFunctionCallUsage(callElement, changeInfo.methodDescriptor.originalPrimaryFunction) + JetFunctionCallUsage(callElement, changeInfo.methodDescriptor.originalPrimaryCallable) } return delegateUsage.processUsage(changeInfo, callElement) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 56f03c0a868..10254d376e7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -78,6 +78,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind import com.intellij.lang.java.JavaLanguage import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils +import com.intellij.openapi.options.ConfigurationException import com.intellij.psi.* import com.intellij.refactoring.listeners.RefactoringEventData import com.intellij.refactoring.listeners.RefactoringEventListener @@ -88,6 +89,7 @@ import org.jetbrains.kotlin.j2k.ConverterSettings import org.jetbrains.kotlin.j2k.IdeaReferenceSearcher import org.jetbrains.kotlin.j2k.JavaToKotlinConverter import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.resolve.AnalyzingUtils fun PsiElement.getAndRemoveCopyableUserData(key: Key): T? { val data = getCopyableUserData(key) @@ -604,4 +606,14 @@ public fun (() -> Any).runRefactoringWithPostprocessing( } }) this() +} + +@throws(ConfigurationException::class) +public fun JetElement.validateElement(errorMessage: String) { + try { + AnalyzingUtils.checkForSyntacticErrors(this) + } + catch(e: Exception) { + throw ConfigurationException(errorMessage) + } } \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.1.java new file mode 100644 index 00000000000..9af0f122297 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP(String receiver) { + return p; + } + + @Override + public void setP(String receiver, int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(""); + new A().setP("", 1); + + new B().getP(""); + new B().setP("", 2); + + new J().getP(""); + new J().setP("", 3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.kt new file mode 100644 index 00000000000..fa1d413afa5 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverAfter.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var String.p: Int = 1 +} + +class B: A() { + override var String.p: Int = 2 +} + +fun test() { + with(A()) { + val t = "".p + "".p = 1 + } + + with(B()) { + val t = "".p + "".p = 2 + } + + with(J()) { + val t = getP("") + setP("", 3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.1.java new file mode 100644 index 00000000000..8dd79bb216b --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP() { + return p; + } + + @Override + public void setP(int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(); + new A().setP(1); + + new B().getP(); + new B().setP(2); + + new J().getP(); + new J().setP(3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.kt new file mode 100644 index 00000000000..9e209bcf45f --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverBefore.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var p: Int = 1 +} + +class B: A() { + override var p: Int = 2 +} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + with(B()) { + val t = p + p = 2 + } + + with(J()) { + val t = getP() + setP(3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictBefore.kt b/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictBefore.kt new file mode 100644 index 00000000000..acdeca86b89 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictBefore.kt @@ -0,0 +1,8 @@ +open class A { + open var p: Int = 1 +} + +fun test() { + val t1 = A().p + A().p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictMessages.txt b/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictMessages.txt new file mode 100644 index 00000000000..65ca46ee958 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddPropertyReceiverConflictMessages.txt @@ -0,0 +1,2 @@ +Explicit receiver is already present in call element: A().p +Explicit receiver is already present in call element: A().p \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.1.java new file mode 100644 index 00000000000..efc4ff583e9 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(A()); + TestPackage.setP(A(), 1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.kt new file mode 100644 index 00000000000..5a3370a1688 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverAfter.kt @@ -0,0 +1,14 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var A.p: Int + get() = 1 + set(value: Int) {} + +fun test() { + val t = A().p + A().p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.1.java new file mode 100644 index 00000000000..f34461bb3f2 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(); + TestPackage.setP(1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.kt new file mode 100644 index 00000000000..f6f59b884c8 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/AddTopLevelPropertyReceiverBefore.kt @@ -0,0 +1,14 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var p: Int + get() = 1 + set(value: Int) {} + +fun test() { + val t = p + p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyAfter.1.java b/idea/testData/refactoring/changeSignature/ChangePropertyAfter.1.java new file mode 100644 index 00000000000..a6ea52fd86f --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyAfter.1.java @@ -0,0 +1,31 @@ +import org.jetbrains.annotations.NotNull; + +import java.lang.Override; + +class J extends A { + private int p; + + @NotNull + @Override + public String getS() { + return p; + } + + @Override + public void setS(@NotNull String value) { + p = value; + } +} + +class Test { + static void test() { + new A().getS(); + new A().setS(1); + + new B().getS(); + new B().setS(2); + + new J().getS(); + new J().setS(3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyAfter.kt b/idea/testData/refactoring/changeSignature/ChangePropertyAfter.kt new file mode 100644 index 00000000000..df9f9e173de --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyAfter.kt @@ -0,0 +1,18 @@ +open class A { + open var s: String = 1 +} + +class B: A() { + override var s: String = 2 +} + +fun test() { + val t1 = A().s + A().s = 1 + + val t2 = B().s + B().s = 2 + + val t3 = J().getS() + J().setS(3) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyBefore.1.java b/idea/testData/refactoring/changeSignature/ChangePropertyBefore.1.java new file mode 100644 index 00000000000..8dd79bb216b --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyBefore.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP() { + return p; + } + + @Override + public void setP(int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(); + new A().setP(1); + + new B().getP(); + new B().setP(2); + + new J().getP(); + new J().setP(3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyBefore.kt b/idea/testData/refactoring/changeSignature/ChangePropertyBefore.kt new file mode 100644 index 00000000000..3ff85c27509 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyBefore.kt @@ -0,0 +1,18 @@ +open class A { + open var p: Int = 1 +} + +class B: A() { + override var p: Int = 2 +} + +fun test() { + val t1 = A().p + A().p = 1 + + val t2 = B().p + B().p = 2 + + val t3 = J().getP() + J().setP(3) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.1.java new file mode 100644 index 00000000000..6953ccbb4c9 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP(int receiver) { + return p; + } + + @Override + public void setP(int receiver, int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(""); + new A().setP("", 1); + + new B().getP(""); + new B().setP("", 2); + + new J().getP(""); + new J().setP("", 3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.kt new file mode 100644 index 00000000000..430766d4d34 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverAfter.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var Int.p: Int = 1 +} + +class B: A() { + override var Int.p: Int = 2 +} + +fun test() { + with(A()) { + val t = "".p + "".p = 1 + } + + with(B()) { + val t = "".p + "".p = 2 + } + + with(J()) { + val t = getP("") + setP("", 3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.1.java new file mode 100644 index 00000000000..9af0f122297 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP(String receiver) { + return p; + } + + @Override + public void setP(String receiver, int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(""); + new A().setP("", 1); + + new B().getP(""); + new B().setP("", 2); + + new J().getP(""); + new J().setP("", 3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.kt new file mode 100644 index 00000000000..8871d02caf6 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangePropertyReceiverBefore.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var String.p: Int = 1 +} + +class B: A() { + override var String.p: Int = 2 +} + +fun test() { + with(A()) { + val t = "".p + "".p = 1 + } + + with(B()) { + val t = "".p + "".p = 2 + } + + with(J()) { + val t = getP("") + setP("", 3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.1.java new file mode 100644 index 00000000000..cfe96b406b8 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(new A()); + TestPackage.setP(new A(), 1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.kt new file mode 100644 index 00000000000..05320988e3e --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverAfter.kt @@ -0,0 +1,19 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var String.p: Int + get() = 1 + set(value: Int) {} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + val t1 = A().p + A().p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.1.java new file mode 100644 index 00000000000..cfe96b406b8 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(new A()); + TestPackage.setP(new A(), 1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.kt new file mode 100644 index 00000000000..b4e977e4dae --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeTopLevelPropertyReceiverBefore.kt @@ -0,0 +1,19 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var A.p: Int + get() = 1 + set(value: Int) {} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + val t1 = A().p + A().p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.1.java new file mode 100644 index 00000000000..8dd79bb216b --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP() { + return p; + } + + @Override + public void setP(int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(); + new A().setP(1); + + new B().getP(); + new B().setP(2); + + new J().getP(); + new J().setP(3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.kt new file mode 100644 index 00000000000..9e209bcf45f --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverAfter.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var p: Int = 1 +} + +class B: A() { + override var p: Int = 2 +} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + with(B()) { + val t = p + p = 2 + } + + with(J()) { + val t = getP() + setP(3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.1.java new file mode 100644 index 00000000000..9af0f122297 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.1.java @@ -0,0 +1,28 @@ +import java.lang.Override; + +class J extends A { + private int p; + + @Override + public int getP(String receiver) { + return p; + } + + @Override + public void setP(String receiver, int value) { + p = value; + } +} + +class Test { + static void test() { + new A().getP(""); + new A().setP("", 1); + + new B().getP(""); + new B().setP("", 2); + + new J().getP(""); + new J().setP("", 3); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.kt new file mode 100644 index 00000000000..8871d02caf6 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemovePropertyReceiverBefore.kt @@ -0,0 +1,26 @@ +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +open class A { + open var String.p: Int = 1 +} + +class B: A() { + override var String.p: Int = 2 +} + +fun test() { + with(A()) { + val t = "".p + "".p = 1 + } + + with(B()) { + val t = "".p + "".p = 2 + } + + with(J()) { + val t = getP("") + setP("", 3) + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.1.java b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.1.java new file mode 100644 index 00000000000..f34461bb3f2 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(); + TestPackage.setP(1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.kt b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.kt new file mode 100644 index 00000000000..09ac893e96e --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverAfter.kt @@ -0,0 +1,19 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var p: Int + get() = 1 + set(value: Int) {} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + val t1 = p + p = 1 +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.1.java b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.1.java new file mode 100644 index 00000000000..cfe96b406b8 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.1.java @@ -0,0 +1,8 @@ +import test.TestPackage; + +class Test { + static void test() { + TestPackage.getP(new A()); + TestPackage.setP(new A(), 1); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.kt b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.kt new file mode 100644 index 00000000000..b4e977e4dae --- /dev/null +++ b/idea/testData/refactoring/changeSignature/RemoveTopLevelPropertyReceiverBefore.kt @@ -0,0 +1,19 @@ +package test + +public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() + +class A + +open var A.p: Int + get() = 1 + set(value: Int) {} + +fun test() { + with(A()) { + val t = p + p = 1 + } + + val t1 = A().p + A().p = 1 +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index ee46b50d103..afe85398e31 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -33,7 +33,7 @@ import com.intellij.util.VisibilityUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; +import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.descriptors.Visibilities; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; @@ -995,6 +995,67 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { ); } + public void testChangeProperty() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + changeInfo.setNewName("s"); + changeInfo.setNewReturnTypeText("String"); + doTest(changeInfo); + } + + public void testAddPropertyReceiverConflict() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "receiver", KotlinBuiltIns.getInstance().getStringType(), null, + new JetPsiFactory(getProject()).createExpression("\"\""), JetValVar.None, null); + changeInfo.setReceiverParameterInfo(newParameter); + doTestConflict(changeInfo); + } + + public void testAddPropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "receiver", KotlinBuiltIns.getInstance().getStringType(), null, + new JetPsiFactory(getProject()).createExpression("\"\""), JetValVar.None, null); + changeInfo.setReceiverParameterInfo(newParameter); + doTest(changeInfo); + } + + public void testChangePropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + //noinspection ConstantConditions + changeInfo.getReceiverParameterInfo().setCurrentTypeText("Int"); + doTest(changeInfo); + } + + public void testRemovePropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + changeInfo.setReceiverParameterInfo(null); + doTest(changeInfo); + } + + public void testAddTopLevelPropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "receiver", null, null, + new JetPsiFactory(getProject()).createExpression("A()"), JetValVar.None, null); + newParameter.setCurrentTypeText("test.A"); + changeInfo.setReceiverParameterInfo(newParameter); + doTest(changeInfo); + } + + public void testChangeTopLevelPropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + //noinspection ConstantConditions + changeInfo.getReceiverParameterInfo().setCurrentTypeText("String"); + doTest(changeInfo); + } + + public void testRemoveTopLevelPropertyReceiver() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + changeInfo.setReceiverParameterInfo(null); + doTest(changeInfo); + } + @NotNull @Override protected String getTestDataPath() { @@ -1039,11 +1100,11 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { PsiElement context = file.findElementAt(editor.getCaretModel().getOffset()); assertNotNull(context); - FunctionDescriptor functionDescriptor = JetChangeSignatureHandler.findDescriptor(element, project, editor, bindingContext); - assertNotNull(functionDescriptor); + CallableDescriptor callableDescriptor = JetChangeSignatureHandler.findDescriptor(element, project, editor, bindingContext); + assertNotNull(callableDescriptor); return ChangeSignaturePackage.createChangeInfo( - project, functionDescriptor, JetChangeSignatureHandler.getConfiguration(), bindingContext, context); + project, callableDescriptor, JetChangeSignatureHandler.getConfiguration(), bindingContext, context); } private class JavaRefactoringProvider { From 161539f3da9c0003d07c0c0689f17ac90b75ebca Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 15:17:53 +0300 Subject: [PATCH 026/450] Change Signature: val/var parameter support --- .../idea/refactoring/CallableRefactoring.kt | 2 +- .../changeSignature/JetChangeInfo.kt | 4 +- .../JetChangePropertySignatureDialog.kt | 61 ++++++++++--------- .../changeSignature/JetChangeSignature.kt | 5 +- .../JetChangeSignatureHandler.java | 27 +++++--- .../JetChangeSignatureUsageProcessor.java | 3 +- .../usages/JetCallableDefinitionUsage.java | 6 +- .../usages/JetFunctionCallUsage.java | 3 +- .../ChangeClassParameterAfter.1.java | 38 ++++++++++++ .../ChangeClassParameterAfter.kt | 21 +++++++ .../ChangeClassParameterBefore.1.java | 35 +++++++++++ .../ChangeClassParameterBefore.kt | 21 +++++++ .../ConstructorSwapArgumentsBefore.kt | 2 +- .../JetChangeSignatureTest.java | 7 +++ 14 files changed, 186 insertions(+), 49 deletions(-) create mode 100644 idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt index 8ec8a4bc1eb..3efcd5c053c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt @@ -150,7 +150,7 @@ public abstract class CallableRefactoring( return true } - if (closestModifiableDescriptors.size() == 1 && deepestSuperDeclarations == closestModifiableDescriptors) { + if (closestModifiableDescriptors.size() == 1 && deepestSuperDeclarations.subtract(closestModifiableDescriptors).isEmpty()) { performRefactoring(closestModifiableDescriptors) return true } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 2b48e1eca63..79a0838311d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -104,7 +104,7 @@ public class JetChangeInfo( fun getNonReceiverParametersCount(): Int = newParameters.size() - (if (receiverParameterInfo != null) 1 else 0) fun getNonReceiverParameters(): List { - if (methodDescriptor.baseDeclaration is JetProperty) return emptyList() + methodDescriptor.baseDeclaration.let { if (it is JetProperty || it is JetParameter) return emptyList() } return receiverParameterInfo?.let { receiver -> newParameters.filter { it != receiver } } ?: newParameters } @@ -309,7 +309,7 @@ public class JetChangeInfo( when (method) { is JetFunction, is JetClassOrObject -> createJavaChangeInfoForFunctionOrGetter(originalPsiMethod, currentPsiMethod, false) - is JetProperty -> { + is JetProperty, is JetParameter -> { val accessorName = originalPsiMethod.getName() when { accessorName.startsWith(JvmAbi.GETTER_PREFIX) -> diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt index bce53cd6946..623b78f1e60 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt @@ -51,7 +51,7 @@ public class JetChangePropertySignatureDialog( ) private val nameField = EditorTextField(methodDescriptor.getName()) private var returnTypeField: EditorTextField by Delegates.notNull() - private var receiverTypeCheckBox: JCheckBox by Delegates.notNull() + private var receiverTypeCheckBox: JCheckBox? = null var receiverTypeLabel: JLabel by Delegates.notNull() private var receiverTypeField: EditorTextField by Delegates.notNull() var receiverDefaultValueLabel: JLabel? = null @@ -66,7 +66,7 @@ public class JetChangePropertySignatureDialog( override fun createCenterPanel(): JComponent? { fun updateReceiverUI() { - val withReceiver = receiverTypeCheckBox.isSelected() + val withReceiver = receiverTypeCheckBox!!.isSelected() receiverTypeLabel.setEnabled(withReceiver) receiverTypeField.setEnabled(withReceiver) receiverDefaultValueLabel?.setEnabled(withReceiver) @@ -77,7 +77,8 @@ public class JetChangePropertySignatureDialog( val psiFactory = JetPsiFactory(myProject) return with(FormBuilder.createFormBuilder()) { - if (!((methodDescriptor.baseDeclaration as? JetProperty)?.isLocal() ?: false)) { + val baseDeclaration = methodDescriptor.baseDeclaration + if (!((baseDeclaration as? JetProperty)?.isLocal() ?: false)) { visibilityCombo.setSelectedItem(methodDescriptor.getVisibility()) addLabeledComponent("&Visibility: ", visibilityCombo) } @@ -85,38 +86,40 @@ public class JetChangePropertySignatureDialog( addLabeledComponent("&Name: ", nameField) val returnTypeCodeFragment = psiFactory.createTypeCodeFragment(methodDescriptor.renderOriginalReturnType(), - methodDescriptor.baseDeclaration) + baseDeclaration) returnTypeField = EditorTextField(documentManager.getDocument(returnTypeCodeFragment), myProject, JetFileType.INSTANCE) addLabeledComponent("&Type: ", returnTypeField) - addSeparator() + if (baseDeclaration is JetProperty) { + addSeparator() - val receiverTypeCheckBox = JCheckBox("Extension property: ") - receiverTypeCheckBox.setMnemonic('x') - receiverTypeCheckBox.addActionListener { updateReceiverUI() } - receiverTypeCheckBox.setSelected(methodDescriptor.receiver != null) - addComponent(receiverTypeCheckBox) - this@JetChangePropertySignatureDialog.receiverTypeCheckBox = receiverTypeCheckBox + val receiverTypeCheckBox = JCheckBox("Extension property: ") + receiverTypeCheckBox.setMnemonic('x') + receiverTypeCheckBox.addActionListener { updateReceiverUI() } + receiverTypeCheckBox.setSelected(methodDescriptor.receiver != null) + addComponent(receiverTypeCheckBox) + this@JetChangePropertySignatureDialog.receiverTypeCheckBox = receiverTypeCheckBox - val receiverTypeCodeFragment = psiFactory.createTypeCodeFragment(methodDescriptor.renderOriginalReceiverType() ?: "", - methodDescriptor.baseDeclaration) - receiverTypeField = EditorTextField(documentManager.getDocument(receiverTypeCodeFragment), myProject, JetFileType.INSTANCE) - receiverTypeLabel = JLabel("Receiver type: ") - receiverTypeLabel.setDisplayedMnemonic('t') - addLabeledComponent(receiverTypeLabel, receiverTypeField) + val receiverTypeCodeFragment = psiFactory.createTypeCodeFragment(methodDescriptor.renderOriginalReceiverType() ?: "", + methodDescriptor.baseDeclaration) + receiverTypeField = EditorTextField(documentManager.getDocument(receiverTypeCodeFragment), myProject, JetFileType.INSTANCE) + receiverTypeLabel = JLabel("Receiver type: ") + receiverTypeLabel.setDisplayedMnemonic('t') + addLabeledComponent(receiverTypeLabel, receiverTypeField) - if (methodDescriptor.receiver == null) { - val receiverDefaultValueCodeFragment = psiFactory.createExpressionCodeFragment("", methodDescriptor.baseDeclaration) - receiverDefaultValueField = EditorTextField(documentManager.getDocument(receiverDefaultValueCodeFragment), - myProject, - JetFileType.INSTANCE) - receiverDefaultValueLabel = JLabel("Default receiver value: ") - receiverDefaultValueLabel!!.setDisplayedMnemonic('D') - addLabeledComponent(receiverDefaultValueLabel, receiverDefaultValueField!!) + if (methodDescriptor.receiver == null) { + val receiverDefaultValueCodeFragment = psiFactory.createExpressionCodeFragment("", methodDescriptor.baseDeclaration) + receiverDefaultValueField = EditorTextField(documentManager.getDocument(receiverDefaultValueCodeFragment), + myProject, + JetFileType.INSTANCE) + receiverDefaultValueLabel = JLabel("Default receiver value: ") + receiverDefaultValueLabel!!.setDisplayedMnemonic('D') + addLabeledComponent(receiverDefaultValueLabel, receiverDefaultValueField!!) + } + + updateReceiverUI() } - updateReceiverUI() - getPanel() } } @@ -131,7 +134,7 @@ public class JetChangePropertySignatureDialog( psiFactory.createSimpleName(nameField.getText()).validateElement("Invalid name") psiFactory.createType(returnTypeField.getText()).validateElement("Invalid return type") - if (receiverTypeCheckBox.isSelected()) { + if (receiverTypeCheckBox?.isSelected() ?: false) { psiFactory.createType(receiverTypeField.getText()).validateElement("Invalid receiver type") } getDefaultReceiverValue()?.validateElement("Invalid default receiver value") @@ -140,7 +143,7 @@ public class JetChangePropertySignatureDialog( override fun doAction() { val descriptor = (methodDescriptor as? JetMutableMethodDescriptor)?.original ?: methodDescriptor - val receiver = if (receiverTypeCheckBox.isSelected()) { + val receiver = if (receiverTypeCheckBox?.isSelected() ?: false) { descriptor.receiver ?: JetParameterInfo(callableDescriptor = descriptor.baseDescriptor, name = "receiver", defaultValueForCall = getDefaultReceiverValue()) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index 7abb411c31e..5aea8ec9027 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring import org.jetbrains.kotlin.psi.JetClass import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.psi.JetProperty import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext @@ -79,7 +80,7 @@ public class JetChangeSignature(project: Project, is JetFunction, is JetClass -> { JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature(project, commandName, descriptor, defaultValueContext) } - is JetProperty -> { + is JetProperty, is JetParameter -> { JetChangePropertySignatureDialog.createProcessorForSilentRefactoring(project, commandName, descriptor) } else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") @@ -90,7 +91,7 @@ public class JetChangeSignature(project: Project, private fun runInteractiveRefactoring(descriptor: JetMethodDescriptor) { val dialog = when (descriptor.baseDeclaration) { is JetFunction, is JetClass -> JetChangeSignatureDialog(project, descriptor, defaultValueContext, commandName) - is JetProperty -> JetChangePropertySignatureDialog(project, descriptor, commandName) + is JetProperty, is JetParameter -> JetChangePropertySignatureDialog(project, descriptor, commandName) else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java index 2bf88b1831d..3b287850290 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java @@ -53,6 +53,22 @@ import static org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignat public class JetChangeSignatureHandler implements ChangeSignatureHandler { @Nullable public static PsiElement findTargetForRefactoring(@NotNull PsiElement element) { + PsiElement elementParent = element.getParent(); + if ((elementParent instanceof JetNamedFunction || elementParent instanceof JetClass || elementParent instanceof JetProperty) + && ((JetNamedDeclaration) elementParent).getNameIdentifier() == element) return elementParent; + + if (elementParent instanceof JetParameter) { + JetParameter parameter = (JetParameter) elementParent; + JetPrimaryConstructor primaryConstructor = PsiTreeUtil.getParentOfType(parameter, JetPrimaryConstructor.class); + if (parameter.hasValOrVar() + && (parameter.getNameIdentifier() == element || parameter.getValOrVarKeyword() == element) + && primaryConstructor != null + && primaryConstructor.getValueParameterList() == parameter.getParent()) return parameter; + } + + if (elementParent instanceof JetSecondaryConstructor && + ((JetSecondaryConstructor) elementParent).getConstructorKeyword() == element) return elementParent; + if (PsiTreeUtil.getParentOfType(element, JetParameterList.class) != null) { return PsiTreeUtil.getParentOfType(element, JetFunction.class, JetProperty.class, JetClass.class); } @@ -62,13 +78,6 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { return PsiTreeUtil.getParentOfType(typeParameterList, JetFunction.class, JetProperty.class, JetClass.class); } - PsiElement elementParent = element.getParent(); - if ((elementParent instanceof JetNamedFunction || elementParent instanceof JetClass || elementParent instanceof JetProperty) - && ((JetNamedDeclaration) elementParent).getNameIdentifier() == element) return elementParent; - - if (elementParent instanceof JetSecondaryConstructor && - ((JetSecondaryConstructor) elementParent).getConstructorKeyword() == element) return elementParent; - JetExpression calleeExpr; JetCallElement call = PsiTreeUtil.getParentOfType(element, JetCallExpression.class, @@ -241,8 +250,8 @@ public class JetChangeSignatureHandler implements ChangeSignatureHandler { return (FunctionDescriptor) descriptor; } - else if (descriptor instanceof PropertyDescriptor) { - return (PropertyDescriptor) descriptor; + else if (descriptor instanceof PropertyDescriptor || descriptor instanceof ValueParameterDescriptor) { + return (CallableDescriptor) descriptor; } else { String message = RefactoringBundle.getCannotRefactorMessage(JetRefactoringBundle.message( diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index d9904cd5c54..3294100a876 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -155,7 +155,8 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (parent instanceof JetConstructorCalleeExpression && parent.getParent() instanceof JetDelegatorToSuperCall) result.add(new JetFunctionCallUsage((JetDelegatorToSuperCall)parent.getParent(), functionUsageInfo)); } - else if (element instanceof JetSimpleNameExpression && functionPsi instanceof JetProperty) { + else if (element instanceof JetSimpleNameExpression + && (functionPsi instanceof JetProperty || functionPsi instanceof JetParameter)) { result.add(new JetPropertyCallUsage((JetSimpleNameExpression) element)); } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index c2189182b48..ae5d4c1cb52 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -151,7 +151,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn if (currentCallableDescriptor == null) { PsiElement element = getDeclaration(); - if (element instanceof JetFunction || element instanceof JetProperty) { + if (element instanceof JetFunction || element instanceof JetProperty || element instanceof JetParameter) { currentCallableDescriptor = (CallableDescriptor) ResolvePackage.resolveToDescriptor((JetDeclaration) element); } else if (element instanceof JetClass) { @@ -227,7 +227,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn callable.getTypeReference() != null); } else { - returnTypeIsNeeded = element instanceof JetProperty; + returnTypeIsNeeded = element instanceof JetProperty || element instanceof JetParameter; } if (changeInfo.isReturnTypeChanged() && returnTypeIsNeeded) { @@ -273,7 +273,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn canReplaceEntireList = true; } } - else if (!(element instanceof JetProperty)) { + else if (!(element instanceof JetProperty || element instanceof JetParameter)) { newParameterList = psiFactory.createParameterList(changeInfo.getNewParametersSignature( (JetCallableDefinitionUsage) this) ); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index 7468e5ea0b1..785ecd6cf3f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -117,7 +117,8 @@ public class JetFunctionCallUsage extends JetUsageInfo { } private boolean isPropertyJavaUsage() { - return this.callee.getElement() instanceof JetProperty + PsiElement calleeElement = this.callee.getElement(); + return (calleeElement instanceof JetProperty || calleeElement instanceof JetParameter) && resolvedCall != null && resolvedCall.getResultingDescriptor() instanceof JavaMethodDescriptor; } diff --git a/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.1.java b/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.1.java new file mode 100644 index 00000000000..cc7c2eee483 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.1.java @@ -0,0 +1,38 @@ +import org.jetbrains.annotations.NotNull; + +import java.lang.Override; + +class J extends A { + private int p; + + public J() { + super(0); + } + + @NotNull + @Override + public String getS() { + return p; + } + + @Override + public void setS(@NotNull String value) { + p = value; + } +} + +class Test { + static void test() { + new A(0).getS(); + new A(0).setS(1); + + new B(0).getS(); + new B(0).setS(2); + + new C().getS(); + new C().setS(3); + + new J().getS(); + new J().setS(4); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.kt b/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.kt new file mode 100644 index 00000000000..4a3e1ee1c61 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeClassParameterAfter.kt @@ -0,0 +1,21 @@ +open class A(open var s: String) + +class B(override var s: String): A(s) + +class C: A(0) { + override var s: String = 1 +} + +fun test() { + val t1 = A(0).s + A(0).s = 1 + + val t2 = B(0).s + B(0).s = 2 + + val t3 = C().s + C().s = 3 + + val t4 = J().getS() + J().setS(4) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.1.java b/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.1.java new file mode 100644 index 00000000000..8b02953c102 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.1.java @@ -0,0 +1,35 @@ +import java.lang.Override; + +class J extends A { + private int p; + + public J() { + super(0); + } + + @Override + public int getP() { + return p; + } + + @Override + public void setP(int value) { + p = value; + } +} + +class Test { + static void test() { + new A(0).getP(); + new A(0).setP(1); + + new B(0).getP(); + new B(0).setP(2); + + new C().getP(); + new C().setP(3); + + new J().getP(); + new J().setP(4); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.kt b/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.kt new file mode 100644 index 00000000000..4d900d38252 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ChangeClassParameterBefore.kt @@ -0,0 +1,21 @@ +open class A(open var p: Int) + +class B(override var p: Int): A(p) + +class C: A(0) { + override var p: Int = 1 +} + +fun test() { + val t1 = A(0).p + A(0).p = 1 + + val t2 = B(0).p + B(0).p = 2 + + val t3 = C().p + C().p = 3 + + val t4 = J().getP() + J().setP(4) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ConstructorSwapArgumentsBefore.kt b/idea/testData/refactoring/changeSignature/ConstructorSwapArgumentsBefore.kt index e66856e92e8..b66d50dc46a 100644 --- a/idea/testData/refactoring/changeSignature/ConstructorSwapArgumentsBefore.kt +++ b/idea/testData/refactoring/changeSignature/ConstructorSwapArgumentsBefore.kt @@ -1,4 +1,4 @@ -open class C1 protected (val x1: Int = 1, var x2: Float, x3: ((Int) -> Int)?) { +open class C1 protected (val x1: Int = 1, var x2: Float, x3: ((Int) -> Int)?) { fun bar() { val y1 = x1; val y2 = x2; diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index afe85398e31..9ca0a99a743 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -1056,6 +1056,13 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { doTest(changeInfo); } + public void testChangeClassParameter() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + changeInfo.setNewName("s"); + changeInfo.setNewReturnTypeText("String"); + doTest(changeInfo); + } + @NotNull @Override protected String getTestDataPath() { From e9b2732aa98f3aee32dd3c49fddf0bbd829d652e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 26 Jun 2015 18:22:49 +0300 Subject: [PATCH 027/450] Minor: Drop unused class --- .../usages/JavaMethodKotlinUsageWithDelegate.kt | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt index 87187080299..39b42d0a29f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt @@ -36,16 +36,3 @@ public class JavaMethodKotlinCallUsage( javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate(callElement, javaMethodChangeInfo) { override protected val delegateUsage = JetFunctionCallUsage(psiElement, javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable) } - -public class JavaMethodKotlinDerivedDefinitionUsage( - function: JetFunction, - functionDescriptor: FunctionDescriptor, - javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { - @suppress("CAST_NEVER_SUCCEEDS") - override protected val delegateUsage = JetCallableDefinitionUsage( - psiElement, - functionDescriptor, - javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable, - null - ) -} From 4cc2a57aed9962d67a2debb4fe2393b5d79e02df Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 1 Jul 2015 15:55:37 +0300 Subject: [PATCH 028/450] Minor: Pull up `original` property --- .../JetChangePropertySignatureDialog.kt | 14 +++++++------- .../changeSignature/JetChangeSignatureData.kt | 3 +++ .../changeSignature/JetChangeSignatureDialog.java | 5 +---- .../changeSignature/JetMethodDescriptor.kt | 2 ++ .../changeSignature/JetMutableMethodDescriptor.kt | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt index 623b78f1e60..02eb0db99cf 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt @@ -141,22 +141,22 @@ public class JetChangePropertySignatureDialog( } override fun doAction() { - val descriptor = (methodDescriptor as? JetMutableMethodDescriptor)?.original ?: methodDescriptor + val originalDescriptor = methodDescriptor.original val receiver = if (receiverTypeCheckBox?.isSelected() ?: false) { - descriptor.receiver ?: JetParameterInfo(callableDescriptor = descriptor.baseDescriptor, - name = "receiver", - defaultValueForCall = getDefaultReceiverValue()) + originalDescriptor.receiver ?: JetParameterInfo(callableDescriptor = originalDescriptor.baseDescriptor, + name = "receiver", + defaultValueForCall = getDefaultReceiverValue()) } else null receiver?.currentTypeText = receiverTypeField.getText() - val changeInfo = JetChangeInfo(descriptor, + val changeInfo = JetChangeInfo(originalDescriptor, nameField.getText(), null, returnTypeField.getText(), visibilityCombo.getSelectedItem() as Visibility, emptyList(), receiver, - descriptor.getMethod()) + originalDescriptor.getMethod()) invokeRefactoring(JetChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle())) } @@ -167,7 +167,7 @@ public class JetChangePropertySignatureDialog( commandName: String, descriptor: JetMethodDescriptor ): BaseRefactoringProcessor { - val originalDescriptor = (descriptor as? JetMutableMethodDescriptor)?.original ?: descriptor + val originalDescriptor = descriptor.original val changeInfo = JetChangeInfo(methodDescriptor = originalDescriptor, context = originalDescriptor.getMethod()) changeInfo.setNewName(descriptor.getName()) changeInfo.receiverParameterInfo = descriptor.receiver diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt index 92ce4ba83f1..8f4eada231b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt @@ -92,6 +92,9 @@ public class JetChangeSignatureData( return JetParameterInfo(callableDescriptor = baseDescriptor, name = receiverName, type = receiverType) } + override val original: JetMethodDescriptor + get() = this + override val primaryCallables: Collection> by Delegates.lazy { descriptorsForSignatureChange.map { val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java index 117c64a72ef..60b414f99eb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java @@ -520,11 +520,8 @@ public class JetChangeSignatureDialog extends ChangeSignatureDialogBase< } String returnTypeText = returnTypeCodeFragment != null ? returnTypeCodeFragment.getText().trim() : ""; - JetMethodDescriptor descriptor = methodDescriptor instanceof JetMutableMethodDescriptor - ? ((JetMutableMethodDescriptor) methodDescriptor).getOriginal() - : methodDescriptor; JetType returnType = getType((JetTypeCodeFragment) returnTypeCodeFragment); - return new JetChangeInfo(descriptor, methodName, returnType, returnTypeText, + return new JetChangeInfo(methodDescriptor.getOriginal(), methodName, returnType, returnTypeText, visibility, parameters, parametersModel.getReceiver(), defaultValueContext); } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt index fa2c7911a7e..7f93e37a641 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetMethodDescriptor.kt @@ -41,6 +41,8 @@ public trait JetMethodDescriptor : MethodDescriptor = original.getParameters() override var receiver: JetParameterInfo? = original.receiver From 9e82411e78fa5cc9160a1ba3085dc70a88088890 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Mon, 29 Jun 2015 17:45:05 +0300 Subject: [PATCH 029/450] Change Signature: Do not process calls with unmatched arguments/parameters --- .../JetChangeSignatureUsageProcessor.java | 29 ++++++++++++------- .../JavaMethodKotlinUsageWithDelegate.kt | 2 +- .../usages/JetFunctionCallUsage.java | 22 ++++++++++++-- .../addConstructorParameter.kt.after | 2 +- .../addFunctionParameter.kt.after | 4 +-- ...ddFunctionParameterAndChangeTypes.kt.after | 6 ++-- .../removeConstructorParameter.kt.after | 2 +- .../removeFunctionFirstParameter.kt.after | 4 +-- .../removeFunctionSecondParameter1.kt.after | 2 +- .../removeFunctionSecondParameter2.kt.after | 4 +-- .../removeNamedParameter.kt.after | 2 +- 11 files changed, 51 insertions(+), 28 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index 3294100a876..216aac90765 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -750,6 +750,20 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (changeSignatureData != originalJavaMethodDescriptor) { originalJavaMethodDescriptor = changeSignatureData; } + + // This change info is used as a placeholder before primary method update + // It gets replaced with real change info afterwards + JetChangeInfo dummyChangeInfo = + new JetChangeInfo(originalJavaMethodDescriptor, "", null, "", Visibilities.INTERNAL, Collections.emptyList(), null, changeInfo.getMethod()); + for (int i = 0; i < usages.length; i++) { + UsageInfo oldUsageInfo = usages[i]; + if (!isJavaMethodUsage(oldUsageInfo)) continue; + + UsageInfo newUsageInfo = createReplacementUsage(oldUsageInfo, dummyChangeInfo); + if (newUsageInfo != null) { + usages[i] = newUsageInfo; + } + } } return true; @@ -758,20 +772,13 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro PsiElement element = usageInfo.getElement(); if (element == null) return false; - if (isJavaMethodUsage && originalJavaMethodDescriptor != null) { + if (originalJavaMethodDescriptor != null) { JetChangeInfo javaMethodChangeInfo = ChangeSignaturePackage.toJetChangeInfo(changeInfo, originalJavaMethodDescriptor); originalJavaMethodDescriptor = null; - for (int i = 0; i < usages.length; i++) { - UsageInfo oldUsageInfo = usages[i]; - if (!isJavaMethodUsage(oldUsageInfo)) continue; - - UsageInfo newUsageInfo = createReplacementUsage(oldUsageInfo, javaMethodChangeInfo); - if (newUsageInfo != null) { - usages[i] = newUsageInfo; - if (oldUsageInfo == usageInfo) { - usageInfo = newUsageInfo; - } + for (UsageInfo info : usages) { + if (info instanceof JavaMethodKotlinUsageWithDelegate) { + ((JavaMethodKotlinUsageWithDelegate) info).setJavaMethodChangeInfo(javaMethodChangeInfo); } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt index 39b42d0a29f..2a319434b91 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor public abstract class JavaMethodKotlinUsageWithDelegate( val psiElement: T, - val javaMethodChangeInfo: JetChangeInfo): UsageInfo(psiElement) { + var javaMethodChangeInfo: JetChangeInfo): UsageInfo(psiElement) { protected abstract val delegateUsage: JetUsageInfo fun processUsage(): Boolean = delegateUsage.processUsage(javaMethodChangeInfo, psiElement) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index 785ecd6cf3f..e5e155b094d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -45,9 +45,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; -import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument; -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument; +import org.jetbrains.kotlin.resolve.calls.model.*; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver; @@ -92,6 +90,8 @@ public class JetFunctionCallUsage extends JetUsageInfo { @Override public boolean processUsage(JetChangeInfo changeInfo, JetCallElement element) { + if (shouldSkipUsage(element)) return true; + changeNameIfNeeded(changeInfo, element); if (element.getValueArgumentList() != null) { @@ -116,6 +116,22 @@ public class JetFunctionCallUsage extends JetUsageInfo { return true; } + private boolean shouldSkipUsage(JetCallElement element) { + // TODO: We probable need more clever processing of invalid calls, but for now default to Java-like behaviour + // TODO: Investigate why resolved call is not recorded for enum constructor call + if (resolvedCall == null && !(element instanceof JetDelegatorToSuperCall)) return true; + if (resolvedCall != null && !resolvedCall.getStatus().isSuccess()) { + for (ValueArgument valueArgument : resolvedCall.getCall().getValueArguments()) { + if (!(resolvedCall.getArgumentMapping(valueArgument) instanceof ArgumentMatch)) return true; + } + Map arguments = resolvedCall.getValueArguments(); + for (ValueParameterDescriptor valueParameter : resolvedCall.getResultingDescriptor().getValueParameters()) { + if (!arguments.containsKey(valueParameter)) return true; + } + } + return false; + } + private boolean isPropertyJavaUsage() { PsiElement calleeElement = this.callee.getElement(); return (calleeElement instanceof JetProperty || calleeElement instanceof JetParameter) diff --git a/idea/testData/quickfix/changeSignature/addConstructorParameter.kt.after b/idea/testData/quickfix/changeSignature/addConstructorParameter.kt.after index 46e025b3162..de8e0e17339 100644 --- a/idea/testData/quickfix/changeSignature/addConstructorParameter.kt.after +++ b/idea/testData/quickfix/changeSignature/addConstructorParameter.kt.after @@ -2,7 +2,7 @@ // DISABLE-ERRORS open class Base(var x: Int, d: Double) { - val y = Base(1, 2.5); + val y = Base(1, 2); fun f() { val base = Base(1, 2.5); diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameter.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameter.kt.after index ea126c90485..43ecbb9773b 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameter.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameter.kt.after @@ -2,8 +2,8 @@ // DISABLE-ERRORS fun foo(x: Int, i: Int) { - foo(, 4); + foo(); foo(1, 4); foo(1, 4); - foo(2, 4); + foo(2, 3, sdsd); } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addFunctionParameterAndChangeTypes.kt.after b/idea/testData/quickfix/changeSignature/addFunctionParameterAndChangeTypes.kt.after index 14629bbb076..3e2ef77d39f 100644 --- a/idea/testData/quickfix/changeSignature/addFunctionParameterAndChangeTypes.kt.after +++ b/idea/testData/quickfix/changeSignature/addFunctionParameterAndChangeTypes.kt.after @@ -2,9 +2,9 @@ // DISABLE-ERRORS fun foo(x: Double, i: Int, i1: Int, i2: Int) { - foo(,, 5, 6); - foo(1,, 5, 6); + foo(); + foo(1); foo(1, 2.5, 5, 6); foo(1.5, 4, 5, 6); - foo(2, 3, 5, 6); + foo(2, 3, sdsd); } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeConstructorParameter.kt.after b/idea/testData/quickfix/changeSignature/removeConstructorParameter.kt.after index 69b96d13914..6c40ec1d8dd 100644 --- a/idea/testData/quickfix/changeSignature/removeConstructorParameter.kt.after +++ b/idea/testData/quickfix/changeSignature/removeConstructorParameter.kt.after @@ -5,7 +5,7 @@ open class Base() { val y = Base(); fun f() { - val base = Base(); + val base = Base(1, 2); } } diff --git a/idea/testData/quickfix/changeSignature/removeFunctionFirstParameter.kt.after b/idea/testData/quickfix/changeSignature/removeFunctionFirstParameter.kt.after index b59b76f88e3..cf636f4f4ec 100644 --- a/idea/testData/quickfix/changeSignature/removeFunctionFirstParameter.kt.after +++ b/idea/testData/quickfix/changeSignature/removeFunctionFirstParameter.kt.after @@ -3,7 +3,7 @@ fun foo(y: Int) { foo(); - foo(); + foo(1); foo(2); - foo(3); + foo(2, 3, sdsd); } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter1.kt.after b/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter1.kt.after index baa5fc9cdab..85ceb301e66 100644 --- a/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter1.kt.after +++ b/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter1.kt.after @@ -5,5 +5,5 @@ fun foo(x: Int) { foo(); foo(1); foo(1); - foo(2); + foo(2, 3, sdsd); } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter2.kt.after b/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter2.kt.after index 75434347a0f..85ceb301e66 100644 --- a/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter2.kt.after +++ b/idea/testData/quickfix/changeSignature/removeFunctionSecondParameter2.kt.after @@ -3,7 +3,7 @@ fun foo(x: Int) { foo(); - foo(1); foo(1); - foo(2); + foo(1); + foo(2, 3, sdsd); } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeNamedParameter.kt.after b/idea/testData/quickfix/changeSignature/removeNamedParameter.kt.after index a57cce2079b..52081e7d94a 100644 --- a/idea/testData/quickfix/changeSignature/removeNamedParameter.kt.after +++ b/idea/testData/quickfix/changeSignature/removeNamedParameter.kt.after @@ -5,5 +5,5 @@ fun foo(y: Int) { foo(); foo(y = 1); foo(2); - foo(3); + foo(2, 3, sdsd); } \ No newline at end of file From 5319e9e761e3a1b61e5b81f0d1519618c09a7375 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 26 Jun 2015 17:17:30 +0300 Subject: [PATCH 030/450] Change Signature: Support configurable Change Signature for Java code #KT-5923 Fixed --- .../idea/refactoring/CallableRefactoring.kt | 2 +- .../changeSignature/JetChangeInfo.kt | 16 ++- .../changeSignature/JetChangeSignature.kt | 109 +++++++++++++++-- .../KotlinAwareJavaParameterInfoImpl.kt | 28 +++++ .../idea/refactoring/jetRefactoringUtil.kt | 110 ++++++++---------- ...dJavaMethodParameter.after.Dependency.java | 15 +++ .../addJavaMethodParameter.after.kt | 9 ++ ...JavaMethodParameter.before.Dependency.java | 15 +++ .../addJavaMethodParameter.before.Main.kt | 9 ++ ...eJavaMethodParameter.after.Dependency.java | 14 +++ .../removeJavaMethodParameter.after.kt | 8 ++ ...JavaMethodParameter.before.Dependency.java | 14 +++ .../removeJavaMethodParameter.before.Main.kt | 8 ++ .../QuickFixMultiFileTestGenerated.java | 12 ++ 14 files changed, 290 insertions(+), 79 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt create mode 100644 idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.Dependency.java create mode 100644 idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.kt create mode 100644 idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Dependency.java create mode 100644 idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Main.kt create mode 100644 idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.Dependency.java create mode 100644 idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.kt create mode 100644 idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Dependency.java create mode 100644 idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Main.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt index 3efcd5c053c..a4cc78d7c8e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/CallableRefactoring.kt @@ -50,7 +50,7 @@ public abstract class CallableRefactoring( val project: Project, val callableDescriptor: T, val bindingContext: BindingContext, - val commandName: String?) { + val commandName: String) { private val LOG = Logger.getInstance(javaClass>()) private val kind = (callableDescriptor as? CallableMemberDescriptor)?.getKind() ?: CallableMemberDescriptor.Kind.DECLARATION diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 79a0838311d..9cc6f918034 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -353,12 +353,16 @@ public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMeth val currentType = parameterDescriptors[i].getType() val defaultValueText = info.getDefaultValue() - val defaultValueExpr = if (getLanguage().`is`(JavaLanguage.INSTANCE) && !defaultValueText.isNullOrEmpty()) { - PsiElementFactory.SERVICE.getInstance(method.getProject()) - .createExpressionFromText(defaultValueText!!, null) - .j2k() - } - else null + val defaultValueExpr = + when { + info is KotlinAwareJavaParameterInfoImpl -> info.kotlinDefaultValue + getLanguage().`is`(JavaLanguage.INSTANCE) && !defaultValueText.isNullOrEmpty() -> { + PsiElementFactory.SERVICE.getInstance(method.getProject()) + .createExpressionFromText(defaultValueText!!, null) + .j2k() + } + else -> null + } with(JetParameterInfo(callableDescriptor = functionDescriptor, originalIndex = oldIndex, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index 5aea8ec9027..d92efb82d2e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -16,22 +16,36 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature +import com.intellij.lang.java.JavaLanguage import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger +import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.Messages import com.intellij.psi.PsiElement -import com.intellij.refactoring.changeSignature.ChangeSignatureHandler +import com.intellij.psi.PsiElementFactory +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiType +import com.intellij.refactoring.BaseRefactoringProcessor +import com.intellij.refactoring.changeSignature.* +import com.intellij.refactoring.util.CanonicalTypes +import com.intellij.testFramework.LightVirtualFile +import com.intellij.util.VisibilityUtil import org.jetbrains.annotations.TestOnly +import org.jetbrains.kotlin.asJava.KotlinLightMethod +import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde +import org.jetbrains.kotlin.idea.core.refactoring.createJavaClass +import org.jetbrains.kotlin.idea.core.refactoring.createJavaMethod +import org.jetbrains.kotlin.idea.core.refactoring.toPsiFile import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring -import org.jetbrains.kotlin.psi.JetClass -import org.jetbrains.kotlin.psi.JetFunction -import org.jetbrains.kotlin.psi.JetParameter -import org.jetbrains.kotlin.psi.JetProperty +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.OverrideResolver @@ -68,36 +82,109 @@ public class JetChangeSignature(project: Project, val configuration: JetChangeSignatureConfiguration, bindingContext: BindingContext, val defaultValueContext: PsiElement, - commandName: String?): CallableRefactoring(project, callableDescriptor, bindingContext, commandName) { + commandName: String?): CallableRefactoring(project, + callableDescriptor, + bindingContext, + commandName ?: ChangeSignatureHandler.REFACTORING_NAME) { private val LOG = Logger.getInstance(javaClass()) override fun forcePerformForSelectedFunctionOnly() = configuration.forcePerformForSelectedFunctionOnly() private fun runSilentRefactoring(descriptor: JetMethodDescriptor) { - val commandName = commandName ?: ChangeSignatureHandler.REFACTORING_NAME - val processor = when (descriptor.baseDeclaration) { + val baseDeclaration = descriptor.baseDeclaration + val processor = when (baseDeclaration) { is JetFunction, is JetClass -> { JetChangeSignatureDialog.createRefactoringProcessorForSilentChangeSignature(project, commandName, descriptor, defaultValueContext) } is JetProperty, is JetParameter -> { JetChangePropertySignatureDialog.createProcessorForSilentRefactoring(project, commandName, descriptor) } - else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") + is PsiMethod -> { + if (baseDeclaration.getLanguage() != JavaLanguage.INSTANCE) { + Messages.showErrorDialog("Can't change signature of ${baseDeclaration.getLanguage().getDisplayName()} method", commandName) + return + } + + ChangeSignatureProcessor(project, getPreviewInfoForJavaMethod(descriptor).second) + } + else -> throw AssertionError("Unexpected declaration: ${baseDeclaration.getElementTextWithContext()}") } processor.run() } private fun runInteractiveRefactoring(descriptor: JetMethodDescriptor) { - val dialog = when (descriptor.baseDeclaration) { + val baseDeclaration = descriptor.baseDeclaration + val dialog = when (baseDeclaration) { is JetFunction, is JetClass -> JetChangeSignatureDialog(project, descriptor, defaultValueContext, commandName) is JetProperty, is JetParameter -> JetChangePropertySignatureDialog(project, descriptor, commandName) - else -> throw AssertionError("Unexpected declaration: ${descriptor.baseDeclaration.getElementTextWithContext()}") + is PsiMethod -> { + // No changes are made from Kotlin side: just run foreign refactoring + if (descriptor is JetChangeSignatureData) { + ChangeSignatureUtil.invokeChangeSignatureOn(baseDeclaration, project) + return + } + + if (baseDeclaration.getLanguage() != JavaLanguage.INSTANCE) { + Messages.showErrorDialog("Can't change signature of ${baseDeclaration.getLanguage().getDisplayName()} method", commandName) + return + } + + val (preview, javaChangeInfo) = getPreviewInfoForJavaMethod(descriptor) + object: JavaChangeSignatureDialog(project, JavaMethodDescriptor(preview), false, null) { + override fun createRefactoringProcessor(): BaseRefactoringProcessor? { + val processor = super.createRefactoringProcessor() + (processor as? ChangeSignatureProcessor)?.getChangeInfo()?.updateMethod(javaChangeInfo.getMethod()) + return processor + } + } + } + else -> throw AssertionError("Unexpected declaration: ${baseDeclaration.getElementTextWithContext()}") } dialog.show() } + private fun getPreviewInfoForJavaMethod(descriptor: JetMethodDescriptor): Pair { + val originalMethod = descriptor.baseDeclaration as PsiMethod + val contextFile = defaultValueContext.getContainingFile() as JetFile + + // Generate new Java method signature from the Kotlin point of view + val ktChangeInfo = JetChangeInfo(methodDescriptor = descriptor, context = defaultValueContext) + val ktSignature = ktChangeInfo.getNewSignature(descriptor.originalPrimaryCallable) + val dummyFileText = with(StringBuilder()) { + contextFile.getPackageDirective()?.let { append(it.getText()).append("\n") } + append("class Dummy {\n").append(ktSignature).append("{}\n}") + toString() + } + val dummyFile = LightVirtualFile("dummy.kt", JetFileType.INSTANCE, dummyFileText).toPsiFile(project) as JetFile + val dummyDeclaration = (dummyFile.getDeclarations().first() as JetClass).getBody()!!.getDeclarations().first() + + // Convert to PsiMethod which can be used in Change Signature dialog + val containingClass = PsiElementFactory.SERVICE.getInstance(project).createClass("Dummy") + val preview = createJavaMethod(dummyDeclaration.getRepresentativeLightMethod()!!, containingClass) + + // Create JavaChangeInfo based on new signature + // TODO: Support visibility change + val visibility = VisibilityUtil.getVisibilityModifier(originalMethod.getModifierList()) + val returnType = CanonicalTypes.createTypeWrapper(preview.getReturnType() ?: PsiType.VOID) + val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map { + val (param, paramInfo) = it + // Keep original default value for proper update of Kotlin usages + KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName(), param.getType(), paramInfo.defaultValueForCall) + }.toTypedArray() + + return preview to JavaChangeInfoImpl(visibility, + originalMethod, + preview.getName(), + returnType, + params, + arrayOf(), + false, + emptySet(), + emptySet()) + } + override fun performRefactoring(descriptorsForChange: Collection) { val adjustedDescriptor = adjustDescriptor(descriptorsForChange) ?: return diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt new file mode 100644 index 00000000000..7886850ec90 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinAwareJavaParameterInfoImpl.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature + +import com.intellij.psi.PsiType +import com.intellij.refactoring.changeSignature.ParameterInfoImpl +import org.jetbrains.kotlin.psi.JetExpression + +public class KotlinAwareJavaParameterInfoImpl( + oldParameterIndex: Int, + name: String, + type: PsiType, + val kotlinDefaultValue: JetExpression? +): ParameterInfoImpl(oldParameterIndex, name, type, kotlinDefaultValue?.getText() ?: "") \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 10254d376e7..6340a695db6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -16,80 +16,68 @@ package org.jetbrains.kotlin.idea.core.refactoring -import com.intellij.openapi.util.Key -import com.intellij.openapi.roots.JavaProjectRootsUtil -import com.intellij.psi.util.PsiTreeUtil -import com.intellij.refactoring.util.ConflictsUtil -import com.intellij.psi.PsiFileFactory -import org.jetbrains.kotlin.idea.core.getPackage -import org.jetbrains.kotlin.idea.JetFileType -import com.intellij.openapi.project.Project -import java.io.File -import com.intellij.openapi.vfs.LocalFileSystem -import com.intellij.openapi.vfs.VirtualFile -import org.jetbrains.kotlin.psi.* -import java.util.ArrayList -import com.intellij.openapi.application.ApplicationManager -import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException -import com.intellij.refactoring.ui.ConflictsDialog -import com.intellij.util.containers.MultiMap -import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode -import com.intellij.ide.util.PsiElementListCellRenderer -import com.intellij.openapi.ui.popup.JBPopup -import com.intellij.openapi.ui.popup.PopupChooserBuilder -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.util.TextRange +import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils import com.intellij.codeInsight.unwrap.RangeSplitter import com.intellij.codeInsight.unwrap.UnwrapHandler -import com.intellij.openapi.editor.markup.TextAttributes -import com.intellij.openapi.editor.markup.HighlighterTargetArea -import com.intellij.openapi.editor.markup.RangeHighlighter -import java.util.Collections +import com.intellij.ide.util.PsiElementListCellRenderer +import com.intellij.lang.java.JavaLanguage +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.EditorColors import com.intellij.openapi.editor.colors.EditorColorsManager -import com.intellij.ui.components.JBList +import com.intellij.openapi.editor.markup.HighlighterTargetArea +import com.intellij.openapi.editor.markup.RangeHighlighter +import com.intellij.openapi.editor.markup.TextAttributes +import com.intellij.openapi.options.ConfigurationException +import com.intellij.openapi.project.Project +import com.intellij.openapi.roots.JavaProjectRootsUtil +import com.intellij.openapi.ui.popup.JBPopup import com.intellij.openapi.ui.popup.JBPopupAdapter import com.intellij.openapi.ui.popup.LightweightWindowEvent -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.psi.psiUtil.isAncestor -import com.intellij.psi.PsiNamedElement -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.renderer.DescriptorRenderer +import com.intellij.openapi.ui.popup.PopupChooserBuilder +import com.intellij.openapi.util.Key +import com.intellij.openapi.util.TextRange import com.intellij.openapi.util.text.StringUtil -import javax.swing.Icon -import org.jetbrains.kotlin.idea.util.string.collapseSpaces -import org.jetbrains.kotlin.asJava.KotlinLightMethod -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import com.intellij.psi.PsiPackage -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil -import com.intellij.refactoring.util.RefactoringUIUtil -import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor -import com.intellij.refactoring.changeSignature.ChangeSignatureUtil -import org.jetbrains.kotlin.asJava.LightClassUtil -import com.intellij.util.VisibilityUtil -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind -import org.jetbrains.kotlin.resolve.OverridingUtil -import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ClassKind -import com.intellij.lang.java.JavaLanguage -import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils -import com.intellij.openapi.options.ConfigurationException +import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.* +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.refactoring.BaseRefactoringProcessor.ConflictsInTestsException +import com.intellij.refactoring.changeSignature.ChangeSignatureUtil import com.intellij.refactoring.listeners.RefactoringEventData import com.intellij.refactoring.listeners.RefactoringEventListener -import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde +import com.intellij.refactoring.ui.ConflictsDialog +import com.intellij.refactoring.util.ConflictsUtil +import com.intellij.refactoring.util.RefactoringUIUtil +import com.intellij.ui.components.JBList +import com.intellij.util.VisibilityUtil +import com.intellij.util.containers.MultiMap +import org.jetbrains.kotlin.asJava.KotlinLightMethod +import org.jetbrains.kotlin.asJava.LightClassUtil +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.caches.resolve.getJavaMemberDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor +import org.jetbrains.kotlin.idea.core.getPackage import org.jetbrains.kotlin.idea.j2k.IdeaResolverForConverter -import org.jetbrains.kotlin.idea.j2k.J2kPostProcessor +import org.jetbrains.kotlin.idea.util.ProjectRootsUtil +import org.jetbrains.kotlin.idea.util.string.collapseSpaces import org.jetbrains.kotlin.j2k.ConverterSettings import org.jetbrains.kotlin.j2k.IdeaReferenceSearcher import org.jetbrains.kotlin.j2k.JavaToKotlinConverter +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.AnalyzingUtils +import org.jetbrains.kotlin.resolve.BindingContext +import java.io.File +import java.util.ArrayList +import java.util.Collections +import javax.swing.Icon fun PsiElement.getAndRemoveCopyableUserData(key: Key): T? { val data = getCopyableUserData(key) @@ -113,14 +101,14 @@ fun createKotlinFile(fileName: String, targetDir: PsiDirectory): JetFile { public fun File.toVirtualFile(): VirtualFile? = LocalFileSystem.getInstance().findFileByIoFile(this) -public fun File.toPsiFile(project: Project): PsiFile? { - return toVirtualFile()?.let { vfile -> PsiManager.getInstance(project).findFile(vfile) } -} +public fun File.toPsiFile(project: Project): PsiFile? = toVirtualFile()?.toPsiFile(project) public fun File.toPsiDirectory(project: Project): PsiDirectory? { return toVirtualFile()?.let { vfile -> PsiManager.getInstance(project).findDirectory(vfile) } } +public fun VirtualFile.toPsiFile(project: Project): PsiFile? = PsiManager.getInstance(project).findFile(this) + public fun PsiElement.getUsageContext(): PsiElement { return when (this) { is JetElement -> PsiTreeUtil.getParentOfType(this, javaClass(), javaClass())!! diff --git a/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.Dependency.java b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.Dependency.java new file mode 100644 index 00000000000..724af9d6f0b --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.Dependency.java @@ -0,0 +1,15 @@ +class Foo { + static void foo(int n, int m, int i) { + + } +} + +class Test { + static void test() { + Foo.foo(); + Foo.foo(1); + Foo.foo(1, 2, 3); + Foo.foo(1, 2, 3); + Foo.foo(4, 5, 6); + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.kt b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.kt new file mode 100644 index 00000000000..10a51064812 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.after.kt @@ -0,0 +1,9 @@ +// "Add parameter to function 'foo'" "true" +// DISABLE-ERRORS +fun test() { + Foo.foo() + Foo.foo(1) + Foo.foo(1, 2, 3) + Foo.foo(1, 2, 3) + Foo.foo(4, 5, 6) +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Dependency.java b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Dependency.java new file mode 100644 index 00000000000..905b6820a9e --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Dependency.java @@ -0,0 +1,15 @@ +class Foo { + static void foo(int n, int m) { + + } +} + +class Test { + static void test() { + Foo.foo(); + Foo.foo(1); + Foo.foo(1, 2); + Foo.foo(1, 2, 3); + Foo.foo(4, 5, 6); + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Main.kt b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Main.kt new file mode 100644 index 00000000000..dd0909b5b01 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Main.kt @@ -0,0 +1,9 @@ +// "Add parameter to function 'foo'" "true" +// DISABLE-ERRORS +fun test() { + Foo.foo() + Foo.foo(1) + Foo.foo(1, 2) + Foo.foo(1, 2, 3) + Foo.foo(4, 5, 6) +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.Dependency.java b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.Dependency.java new file mode 100644 index 00000000000..702da7216d1 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.Dependency.java @@ -0,0 +1,14 @@ +class Foo { + static void foo(int n) { + + } +} + +class Test { + static void test() { + Foo.foo(); + Foo.foo(1); + Foo.foo(1); + Foo.foo(3); + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.kt b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.kt new file mode 100644 index 00000000000..4c543309c6e --- /dev/null +++ b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.after.kt @@ -0,0 +1,8 @@ +// "Remove parameter 'm'" "true" +// DISABLE-ERRORS +fun test() { + Foo.foo() + Foo.foo(1) + Foo.foo(1) + Foo.foo(3) +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Dependency.java b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Dependency.java new file mode 100644 index 00000000000..7ffe6cba400 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Dependency.java @@ -0,0 +1,14 @@ +class Foo { + static void foo(int n, int m) { + + } +} + +class Test { + static void test() { + Foo.foo(); + Foo.foo(1); + Foo.foo(1, 2); + Foo.foo(3, 4); + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Main.kt b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Main.kt new file mode 100644 index 00000000000..dccdb733e27 --- /dev/null +++ b/idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Main.kt @@ -0,0 +1,8 @@ +// "Remove parameter 'm'" "true" +// DISABLE-ERRORS +fun test() { + Foo.foo() + Foo.foo(1) + Foo.foo(1, 2) + Foo.foo(3, 4) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index e69b13eae81..8ea878b8edd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -250,6 +250,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class ChangeSignature extends AbstractQuickFixMultiFileTest { + @TestMetadata("addJavaMethodParameter.before.Main.kt") + public void testAddJavaMethodParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/addJavaMethodParameter.before.Main.kt"); + doTestWithExtraFile(fileName); + } + @TestMetadata("addParameterWithImport.before.Main.kt") public void testAddParameterWithImport() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/addParameterWithImport.before.Main.kt"); @@ -265,6 +271,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/matchFunctionLiteralWithSAMType.before.Main.kt"); doTestWithExtraFile(fileName); } + + @TestMetadata("removeJavaMethodParameter.before.Main.kt") + public void testRemoveJavaMethodParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/changeSignature/removeJavaMethodParameter.before.Main.kt"); + doTestWithExtraFile(fileName); + } } @TestMetadata("idea/testData/quickfix/createFromUsage") From 01b83b3e3ed79d40bec65b83d964550295844184 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Fri, 3 Jul 2015 19:48:01 +0400 Subject: [PATCH 031/450] Minor. Fixed test data. --- .../kotlinPrivatePropertyUsages2.results.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt index 2c7f2972fa0..4e7b35d3730 100644 --- a/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt +++ b/idea/testData/findUsages/kotlin/findPropertyUsages/kotlinPrivatePropertyUsages2.results.txt @@ -1,5 +1,5 @@ [kotlinPrivatePropertyUsages2.0.kt] Named argument (9: 33) public class ServerEx(): Server(foo = "!") { -[kotlinPrivatePropertyUsages2.0.kt] Value read (10: 45) override fun processRequest() = "foo" + foo +[kotlinPrivatePropertyUsages2.0.kt] Value read (10: 45) override fun processRequest() = "foo" + foo // this reference is found as a side effect of big use scope of constructor parameter: [kotlinPrivatePropertyUsages2.0.kt] Value read (6: 33) open fun processRequest() = foo [kotlinPrivatePropertyUsages2.1.kt] Named argument (5: 24) println(Server(foo = "!").foo) -[kotlinPrivatePropertyUsages2.1.kt] Value read (5: 35) println(Server(foo = "!").foo) \ No newline at end of file +[kotlinPrivatePropertyUsages2.1.kt] Value read (5: 35) println(Server(foo = "!").foo) From ff9c251438e59de04e35e2539e7718155c1359a0 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 2 Jul 2015 18:27:13 +0300 Subject: [PATCH 032/450] Filter out overridden candidates before looking for most specific This filtering will remove signature duplicates that prevent findMaximallySpecific() from finding best candidate. --- .../results/ResolutionResultsHandler.java | 14 ++++---- .../tests/multimodule/varargConflict.kt | 26 +++++++++++++++ .../tests/multimodule/varargConflict.txt | 33 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++ 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/multimodule/varargConflict.kt create mode 100644 compiler/testData/diagnostics/tests/multimodule/varargConflict.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java index 348c526a932..dccbe67d9ea 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java @@ -179,24 +179,24 @@ public class ResolutionResultsHandler { return OverloadResolutionResultsImpl.success(candidates.iterator().next()); } - MutableResolvedCall maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(candidates, false); + Set> noOverrides = OverrideResolver.filterOutOverridden(candidates, MAP_TO_RESULT); + if (noOverrides.size() == 1) { + return OverloadResolutionResultsImpl.success(noOverrides.iterator().next()); + } + + MutableResolvedCall maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(noOverrides, false); if (maximallySpecific != null) { return OverloadResolutionResultsImpl.success(maximallySpecific); } if (discriminateGenerics) { MutableResolvedCall maximallySpecificGenericsDiscriminated = OverloadingConflictResolver.INSTANCE.findMaximallySpecific( - candidates, true); + noOverrides, true); if (maximallySpecificGenericsDiscriminated != null) { return OverloadResolutionResultsImpl.success(maximallySpecificGenericsDiscriminated); } } - Set> noOverrides = OverrideResolver.filterOutOverridden(candidates, MAP_TO_RESULT); - if (noOverrides.size() == 1) { - return OverloadResolutionResultsImpl.success(noOverrides.iterator().next()); - } - return OverloadResolutionResultsImpl.ambiguity(noOverrides); } diff --git a/compiler/testData/diagnostics/tests/multimodule/varargConflict.kt b/compiler/testData/diagnostics/tests/multimodule/varargConflict.kt new file mode 100644 index 00000000000..0631d24ad78 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multimodule/varargConflict.kt @@ -0,0 +1,26 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// MODULE: m1 +// FILE: a.kt + +package p + +public fun foo(a: Int) {} +public fun foo(vararg values: Int) {} + +// MODULE: m2 +// FILE: b.kt + +package p + +public fun foo(a: Int) {} +public fun foo(vararg values: Int) {} + +// MODULE: m3(m1, m2) +// FILE: c.kt +package m + +import p.foo + +fun main() { + foo(12) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/multimodule/varargConflict.txt b/compiler/testData/diagnostics/tests/multimodule/varargConflict.txt new file mode 100644 index 00000000000..148397c48a3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multimodule/varargConflict.txt @@ -0,0 +1,33 @@ +// -- Module: -- +package + +package p { + public fun foo(/*0*/ a: kotlin.Int): kotlin.Unit + public fun foo(/*0*/ vararg values: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +} + + +// -- Module: -- +package + +package p { + public fun foo(/*0*/ a: kotlin.Int): kotlin.Unit + public fun foo(/*0*/ vararg values: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +} + + +// -- Module: -- +package + +package m { + internal fun main(): kotlin.Unit +} + +package p { + public fun foo(/*0*/ a: kotlin.Int): kotlin.Unit + public fun foo(/*0*/ a: kotlin.Int): kotlin.Unit + public fun foo(/*0*/ vararg values: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit + public fun foo(/*0*/ vararg values: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit +} + + diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index ff2bcebd025..7f828debc5d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -8388,6 +8388,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("varargConflict.kt") + public void testVarargConflict() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multimodule/varargConflict.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/diagnostics/tests/multimodule/duplicateClass") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 005a0a1eb6416718670a1fd5d6b49139afb732a9 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 1 Jul 2015 20:32:15 +0300 Subject: [PATCH 033/450] Eliminate deprecated char operation usages in stdlib --- libraries/stdlib/test/collections/ArraysJVMTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/stdlib/test/collections/ArraysJVMTest.kt b/libraries/stdlib/test/collections/ArraysJVMTest.kt index 6605aa45b5a..32622573b0e 100644 --- a/libraries/stdlib/test/collections/ArraysJVMTest.kt +++ b/libraries/stdlib/test/collections/ArraysJVMTest.kt @@ -21,7 +21,7 @@ class ArraysJVMTest { checkContent(longArrayOf(0, 1, 2, 3, 4, 5).copyOf().iterator(), 6) { it.toLong() } checkContent(floatArrayOf(0.toFloat(), 1.toFloat(), 2.toFloat(), 3.toFloat()).copyOf().iterator(), 4) { it.toFloat() } checkContent(doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0).copyOf().iterator(), 6) { it.toDouble() } - checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOf().iterator(), 6) { (it + '0').toChar() } + checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOf().iterator(), 6) { ('0' + it).toChar() } } test fun copyOfRange() { @@ -32,7 +32,7 @@ class ArraysJVMTest { checkContent(longArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3).iterator(), 3) { it.toLong() } checkContent(floatArrayOf(0.toFloat(), 1.toFloat(), 2.toFloat(), 3.toFloat()).copyOfRange(0, 3).iterator(), 3) { it.toFloat() } checkContent(doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0).copyOfRange(0, 3).iterator(), 3) { it.toDouble() } - checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOfRange(0, 3).iterator(), 3) { (it + '0').toChar() } + checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOfRange(0, 3).iterator(), 3) { ('0' + it).toChar() } } test fun reduce() { From 2c4db42319710df4265ba5e7fae8d6780682e892 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 1 Jul 2015 22:56:16 +0300 Subject: [PATCH 034/450] Drop deprecated char binary operations. --- .../evaluate/OperationsMapGenerated.kt | 72 --------- core/builtins/native/kotlin/Char.kt | 135 ---------------- core/builtins/native/kotlin/Primitives.kt | 150 ------------------ .../kotlin/generators/builtins/common.kt | 4 +- .../kotlin/generators/builtins/primitives.kt | 18 +-- 5 files changed, 6 insertions(+), 373 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt index 6b8824c4241..8febef7e49b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/OperationsMapGenerated.kt @@ -38,8 +38,6 @@ private val unaryOperations: HashMap, Pair a.toLong() }, emptyUnaryFun), unaryOperation(BYTE, "toShort", { a -> a.toShort() }, emptyUnaryFun), unaryOperation(BYTE, "toString", { a -> a.toString() }, emptyUnaryFun), - unaryOperation(CHAR, "minus", { a -> a.minus() }, emptyUnaryFun), - unaryOperation(CHAR, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(CHAR, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(CHAR, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(CHAR, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), @@ -112,124 +110,78 @@ private val binaryOperations: HashMap, Pair a.xor(b) }, emptyBinaryFun), binaryOperation(BOOLEAN, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(BYTE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(BYTE, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(BYTE, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(BYTE, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(BYTE, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(BYTE, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(BYTE, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(CHAR, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), @@ -237,42 +189,36 @@ private val binaryOperations: HashMap, Pair a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), @@ -281,28 +227,24 @@ private val binaryOperations: HashMap, Pair a.equals(b) }, emptyBinaryFun), binaryOperation(INT, INT, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }), binaryOperation(INT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(INT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(INT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(INT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(INT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(INT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(INT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(INT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(INT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(INT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(INT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), @@ -310,7 +252,6 @@ private val binaryOperations: HashMap, Pair a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(INT, INT, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), binaryOperation(INT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(INT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), @@ -319,7 +260,6 @@ private val binaryOperations: HashMap, Pair a.shl(b) }, emptyBinaryFun), binaryOperation(INT, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(INT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), @@ -330,28 +270,24 @@ private val binaryOperations: HashMap, Pair a.equals(b) }, emptyBinaryFun), binaryOperation(LONG, LONG, "and", { a, b -> a.and(b) }, { a, b -> a.and(b) }), binaryOperation(LONG, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(LONG, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(LONG, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(LONG, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(LONG, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(LONG, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(LONG, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(LONG, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(LONG, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(LONG, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(LONG, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), @@ -359,7 +295,6 @@ private val binaryOperations: HashMap, Pair a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(LONG, LONG, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), binaryOperation(LONG, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(LONG, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), @@ -368,7 +303,6 @@ private val binaryOperations: HashMap, Pair a.shl(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(LONG, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), @@ -378,42 +312,36 @@ private val binaryOperations: HashMap, Pair a.xor(b) }, { a, b -> a.xor(b) }), binaryOperation(LONG, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(SHORT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(SHORT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(SHORT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(SHORT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(SHORT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(SHORT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(SHORT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), diff --git a/core/builtins/native/kotlin/Char.kt b/core/builtins/native/kotlin/Char.kt index e9d618dffed..ed2d8454d53 100644 --- a/core/builtins/native/kotlin/Char.kt +++ b/core/builtins/native/kotlin/Char.kt @@ -23,162 +23,27 @@ package kotlin public class Char private () : Comparable { companion object {} - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") - public fun compareTo(other: Byte): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, * or a positive number if its greater than other. */ public override fun compareTo(other: Char): Int - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") - public fun compareTo(other: Short): Int - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") - public fun compareTo(other: Int): Int - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") - public fun compareTo(other: Long): Int - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Float): Int - /** - * Compares the character code of this character with the specified value for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Double): Int - /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Byte): Int - /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Short): Int /** Adds the other value to this value. */ deprecated("This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public fun plus(other: Int): Int - /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Long): Long - /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Float): Float - /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Double): Double - /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Byte): Int /** Subtracts the other value from this value. */ public fun minus(other: Char): Int /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Short): Int - /** Subtracts the other value from this value. */ deprecated("This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public fun minus(other: Int): Int - /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Long): Long - /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Float): Float - /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Double): Double - - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Byte): Int - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Short): Int - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Int): Int - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Long): Long - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Float): Float - /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Double): Double - - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Byte): Int - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Short): Int - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Int): Int - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Long): Long - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Float): Float - /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Double): Double - - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Byte): Int - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Short): Int - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Int): Int - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Long): Long - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Float): Float - /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Double): Double /** Increments this value. */ public fun inc(): Char /** Decrements this value. */ public fun dec(): Char - /** Returns this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(): Int - /** Returns the negative of this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(): Int /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Char): CharRange diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index 1f4bbc8b09d..c0f93d7577f 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -31,13 +31,6 @@ public class Byte private () : Number, Comparable { * or a positive number if its greater than other. */ public override fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -72,9 +65,6 @@ public class Byte private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Int /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Int - /** Adds the other value to this value. */ public fun plus(other: Short): Int /** Adds the other value to this value. */ public fun plus(other: Int): Int @@ -88,9 +78,6 @@ public class Byte private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Int - /** Subtracts the other value from this value. */ public fun minus(other: Short): Int /** Subtracts the other value from this value. */ public fun minus(other: Int): Int @@ -104,9 +91,6 @@ public class Byte private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Int /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Int - /** Multiplies this value by the other value. */ public fun times(other: Short): Int /** Multiplies this value by the other value. */ public fun times(other: Int): Int @@ -120,9 +104,6 @@ public class Byte private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Int /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Int - /** Divides this value by the other value. */ public fun div(other: Short): Int /** Divides this value by the other value. */ public fun div(other: Int): Int @@ -136,9 +117,6 @@ public class Byte private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Int - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int @@ -161,9 +139,6 @@ public class Byte private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): ByteRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): CharRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): ShortRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange @@ -196,13 +171,6 @@ public class Short private () : Number, Comparable { * or a positive number if its greater than other. */ public fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -237,9 +205,6 @@ public class Short private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Int /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Int - /** Adds the other value to this value. */ public fun plus(other: Short): Int /** Adds the other value to this value. */ public fun plus(other: Int): Int @@ -253,9 +218,6 @@ public class Short private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Int - /** Subtracts the other value from this value. */ public fun minus(other: Short): Int /** Subtracts the other value from this value. */ public fun minus(other: Int): Int @@ -269,9 +231,6 @@ public class Short private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Int /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Int - /** Multiplies this value by the other value. */ public fun times(other: Short): Int /** Multiplies this value by the other value. */ public fun times(other: Int): Int @@ -285,9 +244,6 @@ public class Short private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Int /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Int - /** Divides this value by the other value. */ public fun div(other: Short): Int /** Divides this value by the other value. */ public fun div(other: Int): Int @@ -301,9 +257,6 @@ public class Short private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Int - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int @@ -326,9 +279,6 @@ public class Short private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): ShortRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): ShortRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): ShortRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange @@ -361,13 +311,6 @@ public class Int private () : Number, Comparable { * or a positive number if its greater than other. */ public fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -402,9 +345,6 @@ public class Int private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Int /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Int - /** Adds the other value to this value. */ public fun plus(other: Short): Int /** Adds the other value to this value. */ public fun plus(other: Int): Int @@ -418,9 +358,6 @@ public class Int private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Int /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Int - /** Subtracts the other value from this value. */ public fun minus(other: Short): Int /** Subtracts the other value from this value. */ public fun minus(other: Int): Int @@ -434,9 +371,6 @@ public class Int private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Int /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Int - /** Multiplies this value by the other value. */ public fun times(other: Short): Int /** Multiplies this value by the other value. */ public fun times(other: Int): Int @@ -450,9 +384,6 @@ public class Int private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Int /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Int - /** Divides this value by the other value. */ public fun div(other: Short): Int /** Divides this value by the other value. */ public fun div(other: Int): Int @@ -466,9 +397,6 @@ public class Int private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Int /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Int - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Int /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Int @@ -491,9 +419,6 @@ public class Int private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): IntRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): IntRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): IntRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): IntRange @@ -541,13 +466,6 @@ public class Long private () : Number, Comparable { * or a positive number if its greater than other. */ public fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -582,9 +500,6 @@ public class Long private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Long /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Long - /** Adds the other value to this value. */ public fun plus(other: Short): Long /** Adds the other value to this value. */ public fun plus(other: Int): Long @@ -598,9 +513,6 @@ public class Long private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Long /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Long - /** Subtracts the other value from this value. */ public fun minus(other: Short): Long /** Subtracts the other value from this value. */ public fun minus(other: Int): Long @@ -614,9 +526,6 @@ public class Long private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Long /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Long - /** Multiplies this value by the other value. */ public fun times(other: Short): Long /** Multiplies this value by the other value. */ public fun times(other: Int): Long @@ -630,9 +539,6 @@ public class Long private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Long /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Long - /** Divides this value by the other value. */ public fun div(other: Short): Long /** Divides this value by the other value. */ public fun div(other: Int): Long @@ -646,9 +552,6 @@ public class Long private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Long /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Long - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Long /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Long @@ -671,9 +574,6 @@ public class Long private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): LongRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): LongRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): LongRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): LongRange @@ -721,13 +621,6 @@ public class Float private () : Number, Comparable { * or a positive number if its greater than other. */ public fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -762,9 +655,6 @@ public class Float private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Float /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Float - /** Adds the other value to this value. */ public fun plus(other: Short): Float /** Adds the other value to this value. */ public fun plus(other: Int): Float @@ -778,9 +668,6 @@ public class Float private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Float /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Float - /** Subtracts the other value from this value. */ public fun minus(other: Short): Float /** Subtracts the other value from this value. */ public fun minus(other: Int): Float @@ -794,9 +681,6 @@ public class Float private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Float /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Float - /** Multiplies this value by the other value. */ public fun times(other: Short): Float /** Multiplies this value by the other value. */ public fun times(other: Int): Float @@ -810,9 +694,6 @@ public class Float private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Float /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Float - /** Divides this value by the other value. */ public fun div(other: Short): Float /** Divides this value by the other value. */ public fun div(other: Int): Float @@ -826,9 +707,6 @@ public class Float private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Float /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Float - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Float /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Float @@ -851,9 +729,6 @@ public class Float private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): FloatRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): FloatRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): FloatRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): FloatRange @@ -886,13 +761,6 @@ public class Double private () : Number, Comparable { * or a positive number if its greater than other. */ public fun compareTo(other: Byte): Int -/** - * Compares this value with the character code of the specified character for order. - * Returns zero if this value is equal to the specified other value, a negative number if its less than other, - * or a positive number if its greater than other. - */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun compareTo(other: Char): Int /** * Compares this value with the specified value for order. * Returns zero if this value is equal to the specified other value, a negative number if its less than other, @@ -927,9 +795,6 @@ public class Double private () : Number, Comparable { /** Adds the other value to this value. */ public fun plus(other: Byte): Double /** Adds the other value to this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun plus(other: Char): Double - /** Adds the other value to this value. */ public fun plus(other: Short): Double /** Adds the other value to this value. */ public fun plus(other: Int): Double @@ -943,9 +808,6 @@ public class Double private () : Number, Comparable { /** Subtracts the other value from this value. */ public fun minus(other: Byte): Double /** Subtracts the other value from this value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun minus(other: Char): Double - /** Subtracts the other value from this value. */ public fun minus(other: Short): Double /** Subtracts the other value from this value. */ public fun minus(other: Int): Double @@ -959,9 +821,6 @@ public class Double private () : Number, Comparable { /** Multiplies this value by the other value. */ public fun times(other: Byte): Double /** Multiplies this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun times(other: Char): Double - /** Multiplies this value by the other value. */ public fun times(other: Short): Double /** Multiplies this value by the other value. */ public fun times(other: Int): Double @@ -975,9 +834,6 @@ public class Double private () : Number, Comparable { /** Divides this value by the other value. */ public fun div(other: Byte): Double /** Divides this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun div(other: Char): Double - /** Divides this value by the other value. */ public fun div(other: Short): Double /** Divides this value by the other value. */ public fun div(other: Int): Double @@ -991,9 +847,6 @@ public class Double private () : Number, Comparable { /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Byte): Double /** Calculates the remainder of dividing this value by the other value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun mod(other: Char): Double - /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Short): Double /** Calculates the remainder of dividing this value by the other value. */ public fun mod(other: Int): Double @@ -1016,9 +869,6 @@ public class Double private () : Number, Comparable { /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Byte): DoubleRange /** Creates a range from this value to the specified [other] value. */ - deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") - public fun rangeTo(other: Char): DoubleRange - /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Short): DoubleRange /** Creates a range from this value to the specified [other] value. */ public fun rangeTo(other: Int): DoubleRange diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/common.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/common.kt index 736282866aa..75d6acd97ba 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/common.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/common.kt @@ -31,8 +31,8 @@ enum class PrimitiveType { val capitalized: String get() = name().toLowerCase().capitalize() companion object { - val exceptBoolean: List by Delegates.lazy { PrimitiveType.values().filterNot { it == BOOLEAN } } - val onlyNumeric: List by Delegates.lazy { PrimitiveType.values().filterNot { it == BOOLEAN || it == CHAR }} + val exceptBoolean: List by lazy { PrimitiveType.values().filterNot { it == BOOLEAN } } + val onlyNumeric: List by lazy { PrimitiveType.values().filterNot { it == BOOLEAN || it == CHAR }} } } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index a54d632126c..0b2b85af5ef 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -90,18 +90,12 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { } private fun generateCompareTo(thisKind: PrimitiveType) { - for (otherKind in PrimitiveType.exceptBoolean) { + for (otherKind in PrimitiveType.onlyNumeric) { out.println("/**") - if (otherKind == PrimitiveType.CHAR) { - out.println(" * Compares this value with the character code of the specified character for order.") - } else { - out.println(" * Compares this value with the specified value for order.") - } + out.println(" * Compares this value with the specified value for order.") out.println(" * Returns zero if this value is equal to the specified other value, a negative number if its less than other, ") out.println(" * or a positive number if its greater than other.") out.println(" */") - if (otherKind == PrimitiveType.CHAR) - out.println(""" deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.")""") out.print(" public ") if (otherKind == thisKind) out.print("override ") out.println("fun compareTo(other: ${otherKind.capitalized}): Int") @@ -116,22 +110,18 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { } private fun generateOperator(name: String, doc: String, thisKind: PrimitiveType) { - for (otherKind in PrimitiveType.exceptBoolean) { + for (otherKind in PrimitiveType.onlyNumeric) { val returnType = getOperatorReturnType(thisKind, otherKind) out.println(" /** $doc */") - if (otherKind == PrimitiveType.CHAR) - out.println(""" deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.")""") out.println(" public fun $name(other: ${otherKind.capitalized}): $returnType") } out.println() } private fun generateRangeTo(thisKind: PrimitiveType) { - for (otherKind in PrimitiveType.exceptBoolean) { + for (otherKind in PrimitiveType.onlyNumeric) { val returnType = if (otherKind.ordinal() > thisKind.ordinal()) otherKind else thisKind out.println(" /** Creates a range from this value to the specified [other] value. */") - if (otherKind == PrimitiveType.CHAR) - out.println(""" deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.")""") out.println(" public fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range") } out.println() From e8aff3360a7bd37e36006e5aced2eb345655bfb9 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Jul 2015 02:38:15 +0300 Subject: [PATCH 035/450] Do not use deprecated operations in ranges and progressions hashCode. --- core/builtins/src/kotlin/Progressions.kt | 6 +++--- core/builtins/src/kotlin/Ranges.kt | 6 +++--- .../jetbrains/kotlin/generators/builtins/progressions.kt | 2 +- .../src/org/jetbrains/kotlin/generators/builtins/ranges.kt | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/builtins/src/kotlin/Progressions.kt b/core/builtins/src/kotlin/Progressions.kt index a64cee8c46b..15b45025bd7 100644 --- a/core/builtins/src/kotlin/Progressions.kt +++ b/core/builtins/src/kotlin/Progressions.kt @@ -40,7 +40,7 @@ public class ByteProgression( start == other.start && end == other.end && increment == other.increment) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * (31 * start.toInt() + end) + increment) + if (isEmpty()) -1 else (31 * (31 * start.toInt() + end.toInt()) + increment) override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}" } @@ -67,7 +67,7 @@ public class CharProgression( start == other.start && end == other.end && increment == other.increment) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * (31 * start.toInt() + end) + increment) + if (isEmpty()) -1 else (31 * (31 * start.toInt() + end.toInt()) + increment) override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}" } @@ -94,7 +94,7 @@ public class ShortProgression( start == other.start && end == other.end && increment == other.increment) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * (31 * start.toInt() + end) + increment) + if (isEmpty()) -1 else (31 * (31 * start.toInt() + end.toInt()) + increment) override fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}" } diff --git a/core/builtins/src/kotlin/Ranges.kt b/core/builtins/src/kotlin/Ranges.kt index b957723d37f..bda8c7e6551 100644 --- a/core/builtins/src/kotlin/Ranges.kt +++ b/core/builtins/src/kotlin/Ranges.kt @@ -36,7 +36,7 @@ public class ByteRange(override val start: Byte, override val end: Byte) : Range start == other.start && end == other.end) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * start.toInt() + end) + if (isEmpty()) -1 else (31 * start.toInt() + end.toInt()) companion object { /** An empty range of values of type Byte. */ @@ -62,7 +62,7 @@ public class CharRange(override val start: Char, override val end: Char) : Range start == other.start && end == other.end) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * start.toInt() + end) + if (isEmpty()) -1 else (31 * start.toInt() + end.toInt()) companion object { /** An empty range of values of type Char. */ @@ -88,7 +88,7 @@ public class ShortRange(override val start: Short, override val end: Short) : Ra start == other.start && end == other.end) override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * start.toInt() + end) + if (isEmpty()) -1 else (31 * start.toInt() + end.toInt()) companion object { /** An empty range of values of type Short. */ diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt index 490bc979152..2674cfe06dd 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt @@ -46,7 +46,7 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) { val hashCode = when (kind) { BYTE, CHAR, SHORT -> "=\n" + - " if (isEmpty()) -1 else (31 * (31 * start.toInt() + end) + increment)" + " if (isEmpty()) -1 else (31 * (31 * start.toInt() + end.toInt()) + increment)" INT -> "=\n" + " if (isEmpty()) -1 else (31 * (31 * start + end) + increment)" LONG -> "=\n" + diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt index 377db8d7130..d049c24850c 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt @@ -46,7 +46,7 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) { val hashCode = when (kind) { BYTE, CHAR, SHORT -> "=\n" + - " if (isEmpty()) -1 else (31 * start.toInt() + end)" + " if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())" INT -> "=\n" + " if (isEmpty()) -1 else (31 * start + end)" LONG -> "=\n" + From 39b27751df5a11e3d9cccfe9603eeabaf85af690 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Jul 2015 18:04:54 +0300 Subject: [PATCH 036/450] Drop deprecated char operations: correct test data. --- compiler/testData/builtin-classes.txt | 78 ------------------- .../codegen/box/primitiveTypes/rangeTo.kt | 20 +---- .../assignmentOperationsCheckReturnType.kt | 8 +- .../pseudocodeMemoryOverhead.kt | 73 +---------------- .../parameters/expressions/unaryMinus.kt | 7 +- .../parameters/expressions/unaryPlus.kt | 7 +- .../kotlin/types/JetTypeCheckerTest.java | 3 - .../char/cases/charBinaryOperations.kt | 68 +--------------- .../char/cases/charCompareToIntrinsic.kt | 17 +--- .../char/cases/charUnaryOperations.kt | 4 - .../testData/number/cases/numberCompareTo.kt | 13 ---- 11 files changed, 17 insertions(+), 281 deletions(-) diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index f17d20445cd..639eb8f2ffd 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -49,7 +49,6 @@ public abstract class BooleanIterator : kotlin.Iterator { public final class Byte : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Byte() public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -57,7 +56,6 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Byte public final fun div(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Int public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Float public final fun div(/*0*/ other: kotlin.Int): kotlin.Int @@ -66,14 +64,12 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public final fun inc(): kotlin.Byte public final fun minus(): kotlin.Int public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Int public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float public final fun minus(/*0*/ other: kotlin.Int): kotlin.Int public final fun minus(/*0*/ other: kotlin.Long): kotlin.Long public final fun minus(/*0*/ other: kotlin.Short): kotlin.Int public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Int public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float public final fun mod(/*0*/ other: kotlin.Int): kotlin.Int @@ -81,21 +77,18 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public final fun mod(/*0*/ other: kotlin.Short): kotlin.Int public final fun plus(): kotlin.Int public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Int public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float public final fun plus(/*0*/ other: kotlin.Int): kotlin.Int public final fun plus(/*0*/ other: kotlin.Long): kotlin.Long public final fun plus(/*0*/ other: kotlin.Short): kotlin.Int public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.ByteRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.CharRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.IntRange public final fun rangeTo(/*0*/ other: kotlin.Long): kotlin.LongRange public final fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ShortRange public final fun times(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Int public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Float public final fun times(/*0*/ other: kotlin.Int): kotlin.Int @@ -184,49 +177,13 @@ public final class ByteRange : kotlin.Range, kotlin.Progression { /*primary*/ private constructor Char() - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") public final fun compareTo(/*0*/ other: kotlin.Long): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.") public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Char - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Double): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Float): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Long): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Short): kotlin.Int public final fun inc(): kotlin.Char - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Int public final fun minus(/*0*/ other: kotlin.Char): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float kotlin.deprecated(value = "This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Long): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Short): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Long): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Short): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float kotlin.deprecated(value = "This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Long): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Short): kotlin.Int public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.CharRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Double): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Float): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Long): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Short): kotlin.Int public open fun toByte(): kotlin.Byte public open fun toChar(): kotlin.Char public open fun toDouble(): kotlin.Double @@ -329,7 +286,6 @@ public interface Comparable { public final class Double : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Double() public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -337,7 +293,6 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Double public final fun div(/*0*/ other: kotlin.Byte): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Double public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Double public final fun div(/*0*/ other: kotlin.Int): kotlin.Double @@ -346,14 +301,12 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final fun inc(): kotlin.Double public final fun minus(): kotlin.Double public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Double public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Double public final fun minus(/*0*/ other: kotlin.Int): kotlin.Double public final fun minus(/*0*/ other: kotlin.Long): kotlin.Double public final fun minus(/*0*/ other: kotlin.Short): kotlin.Double public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Double public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Double public final fun mod(/*0*/ other: kotlin.Int): kotlin.Double @@ -361,21 +314,18 @@ public final class Double : kotlin.Number, kotlin.Comparable { public final fun mod(/*0*/ other: kotlin.Short): kotlin.Double public final fun plus(): kotlin.Double public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Double public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Double public final fun plus(/*0*/ other: kotlin.Int): kotlin.Double public final fun plus(/*0*/ other: kotlin.Long): kotlin.Double public final fun plus(/*0*/ other: kotlin.Short): kotlin.Double public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.DoubleRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Long): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Short): kotlin.DoubleRange public final fun times(/*0*/ other: kotlin.Byte): kotlin.Double - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Double public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Double public final fun times(/*0*/ other: kotlin.Int): kotlin.Double @@ -479,7 +429,6 @@ public abstract class Enum> : kotlin.Comparable { public final class Float : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Float() public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -487,7 +436,6 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Float public final fun div(/*0*/ other: kotlin.Byte): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Float public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Float public final fun div(/*0*/ other: kotlin.Int): kotlin.Float @@ -496,14 +444,12 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final fun inc(): kotlin.Float public final fun minus(): kotlin.Float public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Float public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float public final fun minus(/*0*/ other: kotlin.Int): kotlin.Float public final fun minus(/*0*/ other: kotlin.Long): kotlin.Float public final fun minus(/*0*/ other: kotlin.Short): kotlin.Float public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Float public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float public final fun mod(/*0*/ other: kotlin.Int): kotlin.Float @@ -511,21 +457,18 @@ public final class Float : kotlin.Number, kotlin.Comparable { public final fun mod(/*0*/ other: kotlin.Short): kotlin.Float public final fun plus(): kotlin.Float public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Float public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float public final fun plus(/*0*/ other: kotlin.Int): kotlin.Float public final fun plus(/*0*/ other: kotlin.Long): kotlin.Float public final fun plus(/*0*/ other: kotlin.Short): kotlin.Float public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.FloatRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Long): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Short): kotlin.FloatRange public final fun times(/*0*/ other: kotlin.Byte): kotlin.Float - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Float public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Float public final fun times(/*0*/ other: kotlin.Int): kotlin.Float @@ -685,7 +628,6 @@ public final class Int : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Int() public final fun and(/*0*/ other: kotlin.Int): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -693,7 +635,6 @@ public final class Int : kotlin.Number, kotlin.Comparable { public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Int public final fun div(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Int public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Float public final fun div(/*0*/ other: kotlin.Int): kotlin.Int @@ -703,14 +644,12 @@ public final class Int : kotlin.Number, kotlin.Comparable { public final fun inv(): kotlin.Int public final fun minus(): kotlin.Int public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Int public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float public final fun minus(/*0*/ other: kotlin.Int): kotlin.Int public final fun minus(/*0*/ other: kotlin.Long): kotlin.Long public final fun minus(/*0*/ other: kotlin.Short): kotlin.Int public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Int public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float public final fun mod(/*0*/ other: kotlin.Int): kotlin.Int @@ -719,14 +658,12 @@ public final class Int : kotlin.Number, kotlin.Comparable { public final fun or(/*0*/ other: kotlin.Int): kotlin.Int public final fun plus(): kotlin.Int public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Int public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float public final fun plus(/*0*/ other: kotlin.Int): kotlin.Int public final fun plus(/*0*/ other: kotlin.Long): kotlin.Long public final fun plus(/*0*/ other: kotlin.Short): kotlin.Int public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.IntRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.IntRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.IntRange @@ -735,7 +672,6 @@ public final class Int : kotlin.Number, kotlin.Comparable { public final fun shl(/*0*/ bits: kotlin.Int): kotlin.Int public final fun shr(/*0*/ bits: kotlin.Int): kotlin.Int public final fun times(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Int public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Float public final fun times(/*0*/ other: kotlin.Int): kotlin.Int @@ -867,7 +803,6 @@ public final class Long : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Long() public final fun and(/*0*/ other: kotlin.Long): kotlin.Long public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -875,7 +810,6 @@ public final class Long : kotlin.Number, kotlin.Comparable { public final fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Long public final fun div(/*0*/ other: kotlin.Byte): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Long public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Float public final fun div(/*0*/ other: kotlin.Int): kotlin.Long @@ -885,14 +819,12 @@ public final class Long : kotlin.Number, kotlin.Comparable { public final fun inv(): kotlin.Long public final fun minus(): kotlin.Long public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Long public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float public final fun minus(/*0*/ other: kotlin.Int): kotlin.Long public final fun minus(/*0*/ other: kotlin.Long): kotlin.Long public final fun minus(/*0*/ other: kotlin.Short): kotlin.Long public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Long public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float public final fun mod(/*0*/ other: kotlin.Int): kotlin.Long @@ -901,14 +833,12 @@ public final class Long : kotlin.Number, kotlin.Comparable { public final fun or(/*0*/ other: kotlin.Long): kotlin.Long public final fun plus(): kotlin.Long public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Long public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float public final fun plus(/*0*/ other: kotlin.Int): kotlin.Long public final fun plus(/*0*/ other: kotlin.Long): kotlin.Long public final fun plus(/*0*/ other: kotlin.Short): kotlin.Long public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.LongRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.LongRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.LongRange @@ -917,7 +847,6 @@ public final class Long : kotlin.Number, kotlin.Comparable { public final fun shl(/*0*/ bits: kotlin.Int): kotlin.Long public final fun shr(/*0*/ bits: kotlin.Int): kotlin.Long public final fun times(/*0*/ other: kotlin.Byte): kotlin.Long - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Long public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Float public final fun times(/*0*/ other: kotlin.Int): kotlin.Long @@ -1181,7 +1110,6 @@ public interface Set : kotlin.Collection { public final class Short : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Short() public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun compareTo(/*0*/ other: kotlin.Char): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Double): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Float): kotlin.Int public final fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int @@ -1189,7 +1117,6 @@ public final class Short : kotlin.Number, kotlin.Comparable { public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Short): kotlin.Int public final fun dec(): kotlin.Short public final fun div(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun div(/*0*/ other: kotlin.Char): kotlin.Int public final fun div(/*0*/ other: kotlin.Double): kotlin.Double public final fun div(/*0*/ other: kotlin.Float): kotlin.Float public final fun div(/*0*/ other: kotlin.Int): kotlin.Int @@ -1198,14 +1125,12 @@ public final class Short : kotlin.Number, kotlin.Comparable { public final fun inc(): kotlin.Short public final fun minus(): kotlin.Int public final fun minus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Char): kotlin.Int public final fun minus(/*0*/ other: kotlin.Double): kotlin.Double public final fun minus(/*0*/ other: kotlin.Float): kotlin.Float public final fun minus(/*0*/ other: kotlin.Int): kotlin.Int public final fun minus(/*0*/ other: kotlin.Long): kotlin.Long public final fun minus(/*0*/ other: kotlin.Short): kotlin.Int public final fun mod(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun mod(/*0*/ other: kotlin.Char): kotlin.Int public final fun mod(/*0*/ other: kotlin.Double): kotlin.Double public final fun mod(/*0*/ other: kotlin.Float): kotlin.Float public final fun mod(/*0*/ other: kotlin.Int): kotlin.Int @@ -1213,21 +1138,18 @@ public final class Short : kotlin.Number, kotlin.Comparable { public final fun mod(/*0*/ other: kotlin.Short): kotlin.Int public final fun plus(): kotlin.Int public final fun plus(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Char): kotlin.Int public final fun plus(/*0*/ other: kotlin.Double): kotlin.Double public final fun plus(/*0*/ other: kotlin.Float): kotlin.Float public final fun plus(/*0*/ other: kotlin.Int): kotlin.Int public final fun plus(/*0*/ other: kotlin.Long): kotlin.Long public final fun plus(/*0*/ other: kotlin.Short): kotlin.Int public final fun rangeTo(/*0*/ other: kotlin.Byte): kotlin.ShortRange - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ShortRange public final fun rangeTo(/*0*/ other: kotlin.Double): kotlin.DoubleRange public final fun rangeTo(/*0*/ other: kotlin.Float): kotlin.FloatRange public final fun rangeTo(/*0*/ other: kotlin.Int): kotlin.IntRange public final fun rangeTo(/*0*/ other: kotlin.Long): kotlin.LongRange public final fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ShortRange public final fun times(/*0*/ other: kotlin.Byte): kotlin.Int - kotlin.deprecated(value = "This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int.") public final fun times(/*0*/ other: kotlin.Char): kotlin.Int public final fun times(/*0*/ other: kotlin.Double): kotlin.Double public final fun times(/*0*/ other: kotlin.Float): kotlin.Float public final fun times(/*0*/ other: kotlin.Int): kotlin.Int diff --git a/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt b/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt index 089d33c836c..798246e70d3 100644 --- a/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt +++ b/compiler/testData/codegen/box/primitiveTypes/rangeTo.kt @@ -10,9 +10,6 @@ fun box(): String { b.rangeTo(b) b rangeTo b b..b - b.rangeTo(c) - b rangeTo c - b..c b.rangeTo(s) b rangeTo s b..s @@ -36,9 +33,6 @@ fun box(): String { s.rangeTo(b) s rangeTo b s..b - s.rangeTo(c) - s rangeTo c - s..c s.rangeTo(s) s rangeTo s s..s @@ -58,9 +52,6 @@ fun box(): String { i.rangeTo(b) i rangeTo b i..b - i.rangeTo(c) - i rangeTo c - i..c i.rangeTo(s) i rangeTo s i..s @@ -80,9 +71,6 @@ fun box(): String { j.rangeTo(b) j rangeTo b j..b - j.rangeTo(c) - j rangeTo c - j..c j.rangeTo(s) j rangeTo s j..s @@ -102,9 +90,6 @@ fun box(): String { f.rangeTo(b) f rangeTo b f..b - f.rangeTo(c) - f rangeTo c - f..c f.rangeTo(s) f rangeTo s f..s @@ -124,9 +109,6 @@ fun box(): String { d.rangeTo(b) d rangeTo b d..b - d.rangeTo(c) - d rangeTo c - d..c d.rangeTo(s) d rangeTo s d..s @@ -151,7 +133,7 @@ fun main(args: Array) { val s = "bcsijfd" for (i in s) { for (j in s) { - if (i == 'c' && j != 'c') continue + if ((i == 'c') != (j == 'c')) continue println(" $i.rangeTo($j)") println(" $i rangeTo $j") println(" $i..$j") diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/assignmentOperationsCheckReturnType.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/assignmentOperationsCheckReturnType.kt index 1f29d7de724..209820a1ced 100644 --- a/compiler/testData/diagnostics/tests/operatorsOverloading/assignmentOperationsCheckReturnType.kt +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/assignmentOperationsCheckReturnType.kt @@ -1,12 +1,12 @@ fun intBinEq() { var x = 0 - x += 'a' + x += 'a' x += 1.toByte() x += 1.toShort() x += 1L x += 1f x += 1.0 - x *= 'a' + x *= 'a' x *= 1.toByte() x *= 1.toShort() x *= 1L @@ -16,14 +16,14 @@ fun intBinEq() { fun shortBinEq() { var x = 0.toShort() - x += 'a' + x += 'a' x += 1.toByte() x += 1.toShort() x += 1L x += 1f x += 1.0 - x *= 'a' + x *= 'a' x *= 1.toByte() x *= 1.toShort() x *= 1L diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt index c4078737066..dc7fce7169e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt @@ -49,10 +49,8 @@ private val unaryOperations: HashMap, Pair a.toShort() }, emptyUnaryFun), unaryOperation(BYTE, "toByte", { a -> a.toByte() }, emptyUnaryFun), unaryOperation(CHAR, "toInt", { a -> a.toInt() }, emptyUnaryFun), - unaryOperation(CHAR, "minus", { a -> a.minus() }, emptyUnaryFun), unaryOperation(CHAR, "toChar", { a -> a.toChar() }, emptyUnaryFun), unaryOperation(CHAR, "toLong", { a -> a.toLong() }, emptyUnaryFun), - unaryOperation(CHAR, "plus", { a -> a.plus() }, emptyUnaryFun), unaryOperation(CHAR, "toFloat", { a -> a.toFloat() }, emptyUnaryFun), unaryOperation(CHAR, "toDouble", { a -> a.toDouble() }, emptyUnaryFun), unaryOperation(CHAR, "toShort", { a -> a.toShort() }, emptyUnaryFun), @@ -115,110 +113,66 @@ private val binaryOperations: HashMap, Pair a.and(b) }, emptyBinaryFun), binaryOperation(BOOLEAN, BOOLEAN, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(BYTE, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(BYTE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(BYTE, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(BYTE, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(BYTE, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(BYTE, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(BYTE, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(BYTE, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(BYTE, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(BYTE, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(BYTE, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(BYTE, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, LONG, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, SHORT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(BYTE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(CHAR, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, LONG, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(CHAR, SHORT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(CHAR, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), @@ -231,7 +185,6 @@ private val binaryOperations: HashMap, Pair a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(DOUBLE, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), @@ -239,42 +192,36 @@ private val binaryOperations: HashMap, Pair a.times(b) }, emptyBinaryFun), binaryOperation(DOUBLE, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "div", { a, b -> a.div(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, LONG, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, SHORT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(FLOAT, BYTE, "times", { a, b -> a.times(b) }, emptyBinaryFun), - binaryOperation(FLOAT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, INT, "times", { a, b -> a.times(b) }, emptyBinaryFun), @@ -282,14 +229,12 @@ private val binaryOperations: HashMap, Pair a.times(b) }, emptyBinaryFun), binaryOperation(FLOAT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(INT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(INT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(INT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), @@ -298,7 +243,6 @@ private val binaryOperations: HashMap, Pair a.shl(b) }, emptyBinaryFun), binaryOperation(INT, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(INT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(INT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), @@ -306,14 +250,12 @@ private val binaryOperations: HashMap, Pair a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(INT, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), binaryOperation(INT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(INT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(INT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(INT, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(INT, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(INT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(INT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(INT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), @@ -321,7 +263,6 @@ private val binaryOperations: HashMap, Pair a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(INT, INT, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), binaryOperation(INT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(INT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(INT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), @@ -331,14 +272,12 @@ private val binaryOperations: HashMap, Pair a.xor(b) }, { a, b -> a.xor(b) }), binaryOperation(INT, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(LONG, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(LONG, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), @@ -347,7 +286,6 @@ private val binaryOperations: HashMap, Pair a.shl(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "ushr", { a, b -> a.ushr(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(LONG, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), @@ -355,14 +293,12 @@ private val binaryOperations: HashMap, Pair a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(LONG, INT, "shr", { a, b -> a.shr(b) }, emptyBinaryFun), binaryOperation(LONG, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(LONG, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(LONG, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(LONG, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(LONG, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(LONG, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), @@ -370,7 +306,6 @@ private val binaryOperations: HashMap, Pair a.times(b) }, { a, b -> a.multiply(b) }), binaryOperation(LONG, LONG, "or", { a, b -> a.or(b) }, { a, b -> a.or(b) }), binaryOperation(LONG, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(LONG, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(LONG, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), @@ -380,42 +315,36 @@ private val binaryOperations: HashMap, Pair a.xor(b) }, { a, b -> a.xor(b) }), binaryOperation(LONG, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(SHORT, BYTE, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), - binaryOperation(SHORT, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, LONG, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, SHORT, "minus", { a, b -> a.minus(b) }, { a, b -> a.subtract(b) }), binaryOperation(SHORT, BYTE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(SHORT, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, LONG, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, SHORT, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), binaryOperation(SHORT, BYTE, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), - binaryOperation(SHORT, CHAR, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, LONG, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, SHORT, "plus", { a, b -> a.plus(b) }, { a, b -> a.add(b) }), binaryOperation(SHORT, BYTE, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), - binaryOperation(SHORT, CHAR, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "div", { a, b -> a.div(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, LONG, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, SHORT, "div", { a, b -> a.div(b) }, { a, b -> a.divide(b) }), binaryOperation(SHORT, BYTE, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), - binaryOperation(SHORT, CHAR, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "mod", { a, b -> a.mod(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, LONG, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, SHORT, "mod", { a, b -> a.mod(b) }, { a, b -> a.mod(b) }), binaryOperation(SHORT, BYTE, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), - binaryOperation(SHORT, CHAR, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, DOUBLE, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, FLOAT, "times", { a, b -> a.times(b) }, emptyBinaryFun), binaryOperation(SHORT, INT, "times", { a, b -> a.times(b) }, { a, b -> a.multiply(b) }), diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt index b318960bcb6..d2203adca7b 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt @@ -6,10 +6,9 @@ annotation class Ann( val b3: Int, val b4: Long, val b5: Double, - val b6: Float, - val b7: Char + val b6: Float ) -Ann(-1, -1, -1, -1, -1.0, -1.0.toFloat(), -'c') class MyClass +Ann(-1, -1, -1, -1, -1.0, -1.0.toFloat()) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(-1), b2 = IntegerValueType(-1), b3 = IntegerValueType(-1), b4 = IntegerValueType(-1), b5 = -1.0.toDouble(), b6 = -1.0.toFloat(), b7 = IntegerValueType(-99)) +// EXPECTED: Ann(b1 = IntegerValueType(-1), b2 = IntegerValueType(-1), b3 = IntegerValueType(-1), b4 = IntegerValueType(-1), b5 = -1.0.toDouble(), b6 = -1.0.toFloat()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt index c0751b02203..5d519646817 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt @@ -6,10 +6,9 @@ annotation class Ann( val b3: Int, val b4: Long, val b5: Double, - val b6: Float, - val b7: Char + val b6: Float ) -Ann(+1, +1, +1, +1, +1.0, +1.0.toFloat(), +'c') class MyClass +Ann(+1, +1, +1, +1, +1.0, +1.0.toFloat()) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = IntegerValueType(1), b3 = IntegerValueType(1), b4 = IntegerValueType(1), b5 = 1.0.toDouble(), b6 = 1.0.toFloat(), b7 = IntegerValueType(99)) +// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = IntegerValueType(1), b3 = IntegerValueType(1), b4 = IntegerValueType(1), b5 = 1.0.toDouble(), b6 = 1.0.toFloat()) diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index a00efd960a8..49afde88c79 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -434,9 +434,6 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertType("1.plus(1.toLong())", "Long"); assertType("1.plus(1)", "Int"); - assertType("'1'.plus(1.toDouble())", "Double"); - assertType("'1'.plus(1.toFloat())", "Float"); - assertType("'1'.plus(1.toLong())", "Long"); assertType("'1'.plus(1)", "Int"); assertType("'1'.minus('1')", "Int"); // Plus is not available for char diff --git a/js/js.translator/testData/char/cases/charBinaryOperations.kt b/js/js.translator/testData/char/cases/charBinaryOperations.kt index f774fd69cc1..2845cf16db8 100644 --- a/js/js.translator/testData/char/cases/charBinaryOperations.kt +++ b/js/js.translator/testData/char/cases/charBinaryOperations.kt @@ -2,76 +2,10 @@ package foo fun box(): String { - assertEquals(75, 10 + 'A') - assertEquals(75, (10: Short) + 'A') - assertEquals(75, (10: Byte) + 'A') - assertEquals(75.0, 10.0 + 'A') - assertEquals(75.0, 10.0f + 'A') - assertEquals(75L, 10L + 'A') - assertEquals(75, 'A' + 10) - assertEquals(75, 'A' + (10: Short)) - assertEquals(75, 'A' + (10: Byte)) - assertEquals(75.0, 'A' + 10.0) - assertEquals(75.0, 'A' + 10.0f) - assertEquals(75L, 'A' + 10L) - - assertEquals(-55, 10 - 'A') - assertEquals(-55, (10: Short) - 'A') - assertEquals(-55, (10: Byte) - 'A') - assertEquals(-55.0, 10.0 - 'A') - assertEquals(-55.0, 10.0f - 'A') - assertEquals(-55L, 10L - 'A') - assertEquals(55, 'A' - 10) - assertEquals(55, 'A' - (10: Short)) - assertEquals(55, 'A' - (10: Byte)) - assertEquals(55.0, 'A' - 10.0) - assertEquals(55.0, 'A' - 10.0f) - assertEquals(55L, 'A' - 10L) - assertEquals(650, 10 * 'A') - assertEquals(650, (10: Short) * 'A') - assertEquals(650, (10: Byte) * 'A') - assertEquals(650.0, 10.0 * 'A') - assertEquals(650.0, 10.0f * 'A') - assertEquals(650L, 10L * 'A') - - assertEquals(650, 'A' * 10) - assertEquals(650, 'A' * (10: Short)) - assertEquals(650, 'A' * (10: Byte)) - assertEquals(650.0, 'A' * 10.0) - assertEquals(650.0, 'A' * 10.0f) - assertEquals(650L, 'A' * 10L) - - assertEquals(1, 100 / 'A') - assertEquals(1, (100: Short) / 'A') - assertEquals(1, (100: Byte) / 'A') - assertEquals(100.0 / 65.0, 100.0 / 'A') - assertEquals(100.0 / 65.0, 100.0f / 'A') - assertEquals(1L, 100L / 'A') - - assertEquals(6, 'A' / 10) - assertEquals(6, 'A' / (10: Short)) - assertEquals(6, 'A' / (10: Byte)) - assertEquals(6.5, 'A' / 10.0) - assertEquals(6.5, 'A' / 10.0f) - assertEquals(6L, 'A' / 10L) - - assertEquals(35, 100 % 'A') - assertEquals(35, (100: Short) % 'A') - assertEquals(35, (100: Byte) % 'A') - // TODO Uncomment when KT-5860 (Double.mod(Char) is absent) will be fixed - //assertEquals(35.0, 100.0 % 'A') - assertEquals(35.0, 100.0f % 'A') - assertEquals(35L, 100L % 'A') - - assertEquals(5, 'A' % 10) - assertEquals(5, 'A' % (10: Short)) - assertEquals(5, 'A' % (10: Byte)) - assertEquals(5.0, 'A' % 10.0) - assertEquals(5.0, 'A' % 10.0f) - assertEquals(5L, 'A' % 10L) + assertEquals(4, '4' - '0') return "OK" } \ No newline at end of file diff --git a/js/js.translator/testData/char/cases/charCompareToIntrinsic.kt b/js/js.translator/testData/char/cases/charCompareToIntrinsic.kt index 481a557fe74..945a97fab91 100644 --- a/js/js.translator/testData/char/cases/charCompareToIntrinsic.kt +++ b/js/js.translator/testData/char/cases/charCompareToIntrinsic.kt @@ -2,19 +2,10 @@ package foo fun box(): String { - assertEquals(true, 64 < 'A') - assertEquals(true, (64: Short) < 'A') - assertEquals(true, (64: Byte) < 'A') - assertEquals(true, 64L < 'A') - assertEquals(true, 64.0 < 'A') - assertEquals(true, 64.0f < 'A') - - assertEquals(true, 'A' > 64) - assertEquals(true, 'A' > (64: Short)) - assertEquals(true, 'A' > (64: Byte)) - assertEquals(true, 'A' > 64L) - assertEquals(true, 'A' > 64.0) - assertEquals(true, 'A' > 64.0f) + assertEquals(true, 'A' < '\uFFFF') + assertEquals(true, 'A' > '\u0000') + assertEquals(true, 'A' <= '\u0041') + assertEquals(true, 'A' >= '\u0041') return "OK" } \ No newline at end of file diff --git a/js/js.translator/testData/char/cases/charUnaryOperations.kt b/js/js.translator/testData/char/cases/charUnaryOperations.kt index e73f8baaca2..38489196be2 100644 --- a/js/js.translator/testData/char/cases/charUnaryOperations.kt +++ b/js/js.translator/testData/char/cases/charUnaryOperations.kt @@ -21,9 +21,5 @@ fun box(): String { --x assertEquals('C', x) - assertEquals(67, +x) - assertEquals(-67, -x) - - return "OK" } \ No newline at end of file diff --git a/js/js.translator/testData/number/cases/numberCompareTo.kt b/js/js.translator/testData/number/cases/numberCompareTo.kt index 82e9fc17a53..9507a39d539 100644 --- a/js/js.translator/testData/number/cases/numberCompareTo.kt +++ b/js/js.translator/testData/number/cases/numberCompareTo.kt @@ -19,7 +19,6 @@ fun box(): String { assertEquals(-1, 1 compareTo (2:Byte)) assertEquals(-1, 1 compareTo 2.0) assertEquals(-1, 1 compareTo 2.0f) - assertEquals(-1, 1 compareTo 'A') assertEquals(1, 10 compareTo 2L) assertEquals(1, 10 compareTo 2) @@ -43,7 +42,6 @@ fun box(): String { assertEquals(-1, (1: Short) compareTo (2:Byte)) assertEquals(-1, (1: Short) compareTo 2.0) assertEquals(-1, (1: Short) compareTo 2.0f) - assertEquals(-1, (1: Short) compareTo 'A') assertEquals(1, (10: Byte) compareTo 2L) assertEquals(-1, (10: Byte) compareTo 7540113804746346429L) @@ -53,7 +51,6 @@ fun box(): String { assertEquals(1, ((10: Byte): Comparable) compareTo (2:Byte)) assertEquals(1, (10: Byte) compareTo 2.0) assertEquals(1, (10: Byte) compareTo 2.0f) - assertEquals(-1, (10: Byte) compareTo 'A') assertEquals(0, 2.0 compareTo 2L) assertEquals(-1, 2.0 compareTo 7540113804746346429L) @@ -63,7 +60,6 @@ fun box(): String { assertEquals(0, 2.0 compareTo 2.0) assertEquals(0, (2.0: Comparable) compareTo 2.0) assertEquals(0, 2.0 compareTo 2.0f) - assertEquals(-1, 2.0 compareTo 'A') assertEquals(1, 3.0f compareTo 2L) assertEquals(-1, 3.0f compareTo 7540113804746346429L) @@ -72,7 +68,6 @@ fun box(): String { assertEquals(1, 3.0f compareTo (2:Byte)) assertEquals(1, 3.0f compareTo 2.0) assertEquals(1, 3.0f compareTo 2.0f) - assertEquals(-1, 3.0f compareTo 'A') assertEquals(1, (3.0f: Comparable) compareTo 2.0f) assertEquals(1, 10L compareTo 2L) @@ -83,15 +78,7 @@ fun box(): String { assertEquals(1, 10L compareTo (2:Byte)) assertEquals(1, 10L compareTo 2.0) assertEquals(1, 10L compareTo 2.0f) - assertEquals(-1, 10L compareTo 'A') - assertEquals(-1, 'A' compareTo 200L) - assertEquals(-1, 'A' compareTo 7540113804746346429L) - assertEquals(1, 'A' compareTo 2) - assertEquals(1, 'A' compareTo (2:Short)) - assertEquals(1, 'A' compareTo (2:Byte)) - assertEquals(1, 'A' compareTo 2.0) - assertEquals(1, 'A' compareTo 2.0f) assertEquals(0, 'A' compareTo 'A') assertEquals(-1, 1L compareTo 2L) From 1605027b192ce8367e5901960999d0b8dd38794c Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Jul 2015 19:31:50 +0300 Subject: [PATCH 037/450] Change return type of `Char plus Int` and `Char minus Int` binary operations. JS: Remove unnecessary intrinsic binary operation patterns, adjust intrinsics for binary operations with char. --- compiler/testData/builtin-classes.txt | 4 +-- .../pseudocodeMemoryOverhead.kt | 4 +-- .../kotlin/types/JetTypeCheckerTest.java | 5 +-- core/builtins/native/kotlin/Char.kt | 12 +++---- .../PrimitiveBinaryOperationFIF.java | 36 ++++++------------- .../char/cases/charBinaryOperations.kt | 6 ++-- 6 files changed, 26 insertions(+), 41 deletions(-) diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 639eb8f2ffd..c72043805a5 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -181,8 +181,8 @@ public final class Char : kotlin.Comparable { public final fun dec(): kotlin.Char public final fun inc(): kotlin.Char public final fun minus(/*0*/ other: kotlin.Char): kotlin.Int - kotlin.deprecated(value = "This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public final fun minus(/*0*/ other: kotlin.Int): kotlin.Int - kotlin.deprecated(value = "This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") public final fun plus(/*0*/ other: kotlin.Int): kotlin.Int + public final fun minus(/*0*/ other: kotlin.Int): kotlin.Char + public final fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final fun rangeTo(/*0*/ other: kotlin.Char): kotlin.CharRange public open fun toByte(): kotlin.Byte public open fun toChar(): kotlin.Char diff --git a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt index dc7fce7169e..f6cf29b6555 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/functionLiterals/pseudocodeMemoryOverhead.kt @@ -151,8 +151,8 @@ private val binaryOperations: HashMap, Pair a.equals(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(CHAR, CHAR, "compareTo", { a, b -> a.compareTo(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), - binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), + binaryOperation(CHAR, INT, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), + binaryOperation(CHAR, INT, "plus", { a, b -> a.plus(b) }, emptyBinaryFun), binaryOperation(CHAR, ANY, "equals", { a, b -> a.equals(b) }, emptyBinaryFun), binaryOperation(DOUBLE, BYTE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), binaryOperation(DOUBLE, DOUBLE, "minus", { a, b -> a.minus(b) }, emptyBinaryFun), diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index 49afde88c79..0beede9467d 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -434,8 +434,9 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertType("1.plus(1.toLong())", "Long"); assertType("1.plus(1)", "Int"); - assertType("'1'.plus(1)", "Int"); - assertType("'1'.minus('1')", "Int"); // Plus is not available for char + assertType("'1'.plus(1)", "Char"); + assertType("'1'.minus(1)", "Char"); + assertType("'1'.minus('1')", "Int"); assertType("(1:Short).plus(1.toDouble())", "Double"); assertType("(1:Short).plus(1.toFloat())", "Float"); diff --git a/core/builtins/native/kotlin/Char.kt b/core/builtins/native/kotlin/Char.kt index ed2d8454d53..140094a91d3 100644 --- a/core/builtins/native/kotlin/Char.kt +++ b/core/builtins/native/kotlin/Char.kt @@ -30,15 +30,13 @@ public class Char private () : Comparable { */ public override fun compareTo(other: Char): Int - /** Adds the other value to this value. */ - deprecated("This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") - public fun plus(other: Int): Int + /** Adds the other Int value to this value resulting a Char. */ + public fun plus(other: Int): Char - /** Subtracts the other value from this value. */ + /** Subtracts the other Char value from this value resulting an Int. */ public fun minus(other: Char): Int - /** Subtracts the other value from this value. */ - deprecated("This operation will change return type to Char in M13. Either call toInt or toChar on return value or convert Char operand to Int.") - public fun minus(other: Int): Int + /** Subtracts the other Int value from this value resulting a Char. */ + public fun minus(other: Int): Char /** Increments this value. */ public fun inc(): Char diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java index dddc90a77d0..90df880ebfa 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java @@ -134,14 +134,6 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { @Nullable @Override public FunctionIntrinsic getIntrinsic(@NotNull FunctionDescriptor descriptor) { - if (pattern("Int|Short|Byte|Double|Float.compareTo(Char)").apply(descriptor)) { - return new WithCharAsSecondOperandFunctionIntrinsic(PRIMITIVE_NUMBER_COMPARE_TO_INTRINSIC); - } - - if (pattern("Char.compareTo(Int|Short|Byte|Double|Float)").apply(descriptor)) { - return new WithCharAsFirstOperandFunctionIntrinsic(PRIMITIVE_NUMBER_COMPARE_TO_INTRINSIC); - } - if (pattern("Char.rangeTo(Char)").apply(descriptor)) { return CHAR_RANGE_TO_INTRINSIC; } @@ -161,13 +153,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { if (pattern("Int|Short|Byte.div(Int|Short|Byte)").apply(descriptor)) { - return INTEGER_DIVISION_INTRINSIC; - } - if (pattern("Char.div(Int|Short|Byte)").apply(descriptor)) { - return new WithCharAsFirstOperandFunctionIntrinsic(INTEGER_DIVISION_INTRINSIC); - } - if (pattern("Int|Short|Byte.div(Char)").apply(descriptor)) { - return new WithCharAsSecondOperandFunctionIntrinsic(INTEGER_DIVISION_INTRINSIC); + return INTEGER_DIVISION_INTRINSIC; } if (descriptor.getName().equals(Name.identifier("rangeTo"))) { return RANGE_TO_INTRINSIC; @@ -181,11 +167,11 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { JsBinaryOperator operator = getOperator(descriptor); BinaryOperationInstrinsicBase result = new PrimitiveBinaryOperationFunctionIntrinsic(operator); - if (pattern("Char.plus|minus|times|div|mod(Int|Short|Byte|Double|Float)").apply(descriptor)) { - return new WithCharAsFirstOperandFunctionIntrinsic(result); + if (pattern("Char.plus|minus(Int)").apply(descriptor)) { + return new CharAndIntBinaryOperationFunctionIntrinsic(result); } - if (pattern("Int|Short|Byte|Double|Float.plus|minus|times|div|mod(Char)").apply(descriptor)) { - return new WithCharAsSecondOperandFunctionIntrinsic(result); + if (pattern("Char.minus(Char)").apply(descriptor)) { + return new CharAndCharBinaryOperationFunctionIntrinsic(result); } return result; } @@ -219,35 +205,35 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { } } - private static class WithCharAsFirstOperandFunctionIntrinsic extends BinaryOperationInstrinsicBase { + private static class CharAndIntBinaryOperationFunctionIntrinsic extends BinaryOperationInstrinsicBase { @NotNull private final BinaryOperationInstrinsicBase functionIntrinsic; - private WithCharAsFirstOperandFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { + private CharAndIntBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { this.functionIntrinsic = functionIntrinsic; } @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { - return functionIntrinsic.doApply(JsAstUtils.charToInt(left), right, context); + return JsAstUtils.toChar(functionIntrinsic.doApply(JsAstUtils.charToInt(left), right, context)); } } - private static class WithCharAsSecondOperandFunctionIntrinsic extends BinaryOperationInstrinsicBase { + private static class CharAndCharBinaryOperationFunctionIntrinsic extends BinaryOperationInstrinsicBase { @NotNull private final BinaryOperationInstrinsicBase functionIntrinsic; - private WithCharAsSecondOperandFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { + private CharAndCharBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { this.functionIntrinsic = functionIntrinsic; } @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { - return functionIntrinsic.doApply(left, JsAstUtils.charToInt(right), context); + return functionIntrinsic.doApply(JsAstUtils.charToInt(left), JsAstUtils.charToInt(right), context); } } } diff --git a/js/js.translator/testData/char/cases/charBinaryOperations.kt b/js/js.translator/testData/char/cases/charBinaryOperations.kt index 2845cf16db8..aaca3495760 100644 --- a/js/js.translator/testData/char/cases/charBinaryOperations.kt +++ b/js/js.translator/testData/char/cases/charBinaryOperations.kt @@ -2,10 +2,10 @@ package foo fun box(): String { - assertEquals(75, 'A' + 10) - assertEquals(55, 'A' - 10) + assertEquals('K', 'A' + 10) + assertEquals('7', 'A' - 10) - assertEquals(4, '4' - '0') + assertEquals(3, 'd' - 'a') return "OK" } \ No newline at end of file From 80074c71fa925a1c7173e3fffeea4cdc5872460f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Jul 2015 19:35:39 +0300 Subject: [PATCH 038/450] Minor: Correct typo in 'intrinsic' --- .../PrimitiveBinaryOperationFIF.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java index 90df880ebfa..39b5ee4cc9c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/functions/factories/PrimitiveBinaryOperationFIF.java @@ -43,7 +43,7 @@ import static org.jetbrains.kotlin.js.patterns.PatternBuilder.pattern; public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { INSTANCE; - private static abstract class BinaryOperationInstrinsicBase extends FunctionIntrinsic { + private static abstract class BinaryOperationIntrinsicBase extends FunctionIntrinsic { @NotNull public abstract JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context); @@ -60,7 +60,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { } @NotNull - private static final BinaryOperationInstrinsicBase RANGE_TO_INTRINSIC = new BinaryOperationInstrinsicBase() { + private static final BinaryOperationIntrinsicBase RANGE_TO_INTRINSIC = new BinaryOperationIntrinsicBase() { @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { @@ -70,7 +70,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { }; @NotNull - private static final BinaryOperationInstrinsicBase CHAR_RANGE_TO_INTRINSIC = new BinaryOperationInstrinsicBase() { + private static final BinaryOperationIntrinsicBase CHAR_RANGE_TO_INTRINSIC = new BinaryOperationIntrinsicBase() { @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { @@ -80,7 +80,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { }; @NotNull - private static final BinaryOperationInstrinsicBase INTEGER_DIVISION_INTRINSIC = new BinaryOperationInstrinsicBase() { + private static final BinaryOperationIntrinsicBase INTEGER_DIVISION_INTRINSIC = new BinaryOperationIntrinsicBase() { @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { @@ -90,7 +90,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { }; @NotNull - private static final BinaryOperationInstrinsicBase BUILTINS_COMPARE_TO_INTRINSIC = new BinaryOperationInstrinsicBase() { + private static final BinaryOperationIntrinsicBase BUILTINS_COMPARE_TO_INTRINSIC = new BinaryOperationIntrinsicBase() { @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { @@ -99,7 +99,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { }; @NotNull - private static final BinaryOperationInstrinsicBase PRIMITIVE_NUMBER_COMPARE_TO_INTRINSIC = new BinaryOperationInstrinsicBase() { + private static final BinaryOperationIntrinsicBase PRIMITIVE_NUMBER_COMPARE_TO_INTRINSIC = new BinaryOperationIntrinsicBase() { @NotNull @Override public JsExpression doApply(@NotNull JsExpression left, @NotNull JsExpression right, @NotNull TranslationContext context) { @@ -165,7 +165,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { } } JsBinaryOperator operator = getOperator(descriptor); - BinaryOperationInstrinsicBase result = new PrimitiveBinaryOperationFunctionIntrinsic(operator); + BinaryOperationIntrinsicBase result = new PrimitiveBinaryOperationFunctionIntrinsic(operator); if (pattern("Char.plus|minus(Int)").apply(descriptor)) { return new CharAndIntBinaryOperationFunctionIntrinsic(result); @@ -189,7 +189,7 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { return OperatorTable.getBinaryOperator(token); } - private static class PrimitiveBinaryOperationFunctionIntrinsic extends BinaryOperationInstrinsicBase { + private static class PrimitiveBinaryOperationFunctionIntrinsic extends BinaryOperationIntrinsicBase { @NotNull private final JsBinaryOperator operator; @@ -205,12 +205,12 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { } } - private static class CharAndIntBinaryOperationFunctionIntrinsic extends BinaryOperationInstrinsicBase { + private static class CharAndIntBinaryOperationFunctionIntrinsic extends BinaryOperationIntrinsicBase { @NotNull - private final BinaryOperationInstrinsicBase functionIntrinsic; + private final BinaryOperationIntrinsicBase functionIntrinsic; - private CharAndIntBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { + private CharAndIntBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationIntrinsicBase functionIntrinsic) { this.functionIntrinsic = functionIntrinsic; } @@ -221,12 +221,12 @@ public enum PrimitiveBinaryOperationFIF implements FunctionIntrinsicFactory { } } - private static class CharAndCharBinaryOperationFunctionIntrinsic extends BinaryOperationInstrinsicBase { + private static class CharAndCharBinaryOperationFunctionIntrinsic extends BinaryOperationIntrinsicBase { @NotNull - private final BinaryOperationInstrinsicBase functionIntrinsic; + private final BinaryOperationIntrinsicBase functionIntrinsic; - private CharAndCharBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationInstrinsicBase functionIntrinsic) { + private CharAndCharBinaryOperationFunctionIntrinsic(@NotNull BinaryOperationIntrinsicBase functionIntrinsic) { this.functionIntrinsic = functionIntrinsic; } From 62c22bf0ec0c82f9f40f2f1b9e852b000917500b Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Sat, 4 Jul 2015 02:40:48 +0300 Subject: [PATCH 039/450] Minor, simplify ExpressionCodegen#binaryWithTypeRHS --- .../kotlin/codegen/ExpressionCodegen.java | 87 ++++++++----------- 1 file changed, 38 insertions(+), 49 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index c7f0f2dc69e..0d9ab774cd0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3727,63 +3727,52 @@ The "returned" value of try expression with no finally is either the last expres @Override public StackValue visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression, StackValue receiver) { - JetSimpleNameExpression operationSign = expression.getOperationReference(); - final IElementType opToken = operationSign.getReferencedNameElementType(); + final JetExpression left = expression.getLeft(); + final IElementType opToken = expression.getOperationReference().getReferencedNameElementType(); if (opToken == JetTokens.COLON) { - return gen(expression.getLeft()); + return gen(left); } - else { - JetTypeReference typeReference = expression.getRight(); - final JetType rightType = bindingContext.get(TYPE, typeReference); - assert rightType != null; - Type rightTypeAsm = boxType(asmType(rightType)); - final JetExpression left = expression.getLeft(); + final JetType rightType = bindingContext.get(TYPE, expression.getRight()); + assert rightType != null; - DeclarationDescriptor descriptor = rightType.getConstructor().getDeclarationDescriptor(); - if (descriptor instanceof ClassDescriptor || descriptor instanceof TypeParameterDescriptor) { - final StackValue value = genQualified(receiver, left); + final StackValue value = genQualified(receiver, left); - return StackValue.operation(rightTypeAsm, new Function1() { - @Override - public Unit invoke(InstructionAdapter v) { - value.put(boxType(value.type), v); + return StackValue.operation(boxType(asmType(rightType)), new Function1() { + @Override + public Unit invoke(InstructionAdapter v) { + value.put(boxType(value.type), v); - if (value.type == Type.VOID_TYPE) { - v.aconst(null); - } - else if (opToken != JetTokens.AS_SAFE) { - if (!TypeUtils.isNullableType(rightType)) { - v.dup(); - Label nonnull = new Label(); - v.ifnonnull(nonnull); - JetType leftType = bindingContext.getType(left); - assert leftType != null; - genThrow(v, "kotlin/TypeCastException", DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(leftType) + - " cannot be cast to " + - DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(rightType)); - v.mark(nonnull); - } - } - else { - v.dup(); - generateInstanceOfInstruction(rightType); - Label ok = new Label(); - v.ifne(ok); - v.pop(); - v.aconst(null); - v.mark(ok); - } - - generateCheckCastInstruction(rightType); - return Unit.INSTANCE$; + if (value.type == Type.VOID_TYPE) { + v.aconst(null); + } + else if (opToken != JetTokens.AS_SAFE) { + if (!TypeUtils.isNullableType(rightType)) { + v.dup(); + Label nonnull = new Label(); + v.ifnonnull(nonnull); + JetType leftType = bindingContext.getType(left); + assert leftType != null; + genThrow(v, "kotlin/TypeCastException", DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(leftType) + + " cannot be cast to " + + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(rightType)); + v.mark(nonnull); } - }); + } + else { + v.dup(); + generateInstanceOfInstruction(rightType); + Label ok = new Label(); + v.ifne(ok); + v.pop(); + v.aconst(null); + v.mark(ok); + } + + generateCheckCastInstruction(rightType); + return Unit.INSTANCE$; } - else { - throw new UnsupportedOperationException("Don't know how to handle non-class types in as/as? : " + descriptor); - } - } + }); } @Override From cb03f0df5aea2ed51fc753e785a468f702c2bd5b Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Sat, 4 Jul 2015 03:10:09 +0300 Subject: [PATCH 040/450] Fix casts of Unit value to other types --- .../kotlin/codegen/ExpressionCodegen.java | 5 +++-- compiler/testData/codegen/box/casts/asAny.kt | 7 ------- .../testData/codegen/box/casts/unitAsAny.kt | 8 ++++++++ .../codegen/box/casts/unitAsSafeAny.kt | 8 ++++++++ .../codegen/boxWithStdlib/casts/unitAsInt.kt | 15 +++++++++++++++ .../BlackBoxCodegenTestGenerated.java | 18 ++++++++++++------ ...BlackBoxWithStdlibCodegenTestGenerated.java | 6 ++++++ 7 files changed, 52 insertions(+), 15 deletions(-) delete mode 100644 compiler/testData/codegen/box/casts/asAny.kt create mode 100644 compiler/testData/codegen/box/casts/unitAsAny.kt create mode 100644 compiler/testData/codegen/box/casts/unitAsSafeAny.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/casts/unitAsInt.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 0d9ab774cd0..47dc409c800 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3744,9 +3744,10 @@ The "returned" value of try expression with no finally is either the last expres value.put(boxType(value.type), v); if (value.type == Type.VOID_TYPE) { - v.aconst(null); + StackValue.putUnitInstance(v); } - else if (opToken != JetTokens.AS_SAFE) { + + if (opToken != JetTokens.AS_SAFE) { if (!TypeUtils.isNullableType(rightType)) { v.dup(); Label nonnull = new Label(); diff --git a/compiler/testData/codegen/box/casts/asAny.kt b/compiler/testData/codegen/box/casts/asAny.kt deleted file mode 100644 index 5c277379d48..00000000000 --- a/compiler/testData/codegen/box/casts/asAny.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun println(s: String) { -} - -fun box(): String { - println(":Hi!") as Any - return "OK" -} diff --git a/compiler/testData/codegen/box/casts/unitAsAny.kt b/compiler/testData/codegen/box/casts/unitAsAny.kt new file mode 100644 index 00000000000..74326356cba --- /dev/null +++ b/compiler/testData/codegen/box/casts/unitAsAny.kt @@ -0,0 +1,8 @@ +fun println(s: String) { +} + +fun box(): String { + val x = println(":Hi!") as Any + if (x != Unit) return "Fail: $x" + return "OK" +} diff --git a/compiler/testData/codegen/box/casts/unitAsSafeAny.kt b/compiler/testData/codegen/box/casts/unitAsSafeAny.kt new file mode 100644 index 00000000000..81d5a495425 --- /dev/null +++ b/compiler/testData/codegen/box/casts/unitAsSafeAny.kt @@ -0,0 +1,8 @@ +fun println(s: String) { +} + +fun box(): String { + val x = println(":Hi!") as? Any + if (x != Unit) return "Fail: $x" + return "OK" +} diff --git a/compiler/testData/codegen/boxWithStdlib/casts/unitAsInt.kt b/compiler/testData/codegen/boxWithStdlib/casts/unitAsInt.kt new file mode 100644 index 00000000000..39713cf804f --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/casts/unitAsInt.kt @@ -0,0 +1,15 @@ +fun foo() {} + +fun box(): String { + try { + foo() as Int? + } + catch (e: ClassCastException) { + return "OK" + } + catch (e: Throwable) { + return "Fail: ClassCastException should have been thrown, but was instead ${e.javaClass.getName()}: ${e.getMessage()}" + } + + return "Fail: no exception was thrown" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 908f62af7a2..f1b138005b2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -829,12 +829,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("asAny.kt") - public void testAsAny() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/asAny.kt"); - doTest(fileName); - } - @TestMetadata("asForConstants.kt") public void testAsForConstants() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/asForConstants.kt"); @@ -889,6 +883,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("unitAsAny.kt") + public void testUnitAsAny() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/unitAsAny.kt"); + doTest(fileName); + } + + @TestMetadata("unitAsSafeAny.kt") + public void testUnitAsSafeAny() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/unitAsSafeAny.kt"); + doTest(fileName); + } + @TestMetadata("unitNullableCast.kt") public void testUnitNullableCast() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/unitNullableCast.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 675239c3466..e228260576b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -888,6 +888,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/casts/asWithGeneric.kt"); doTestWithStdlib(fileName); } + + @TestMetadata("unitAsInt.kt") + public void testUnitAsInt() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/casts/unitAsInt.kt"); + doTestWithStdlib(fileName); + } } @TestMetadata("compiler/testData/codegen/boxWithStdlib/classes") From ac0db5ce807b6637326f89edb74e7f630594f8b0 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Sat, 4 Jul 2015 03:18:50 +0300 Subject: [PATCH 041/450] Fix incorrect TypeCastException message when casting null #KT-5121 Fixed --- .../kotlin/codegen/ExpressionCodegen.java | 7 ++----- .../regressions/typeCastException.kt | 20 ++++++++++++++++--- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 47dc409c800..99be45477c4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3727,7 +3727,7 @@ The "returned" value of try expression with no finally is either the last expres @Override public StackValue visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionWithTypeRHS expression, StackValue receiver) { - final JetExpression left = expression.getLeft(); + JetExpression left = expression.getLeft(); final IElementType opToken = expression.getOperationReference().getReferencedNameElementType(); if (opToken == JetTokens.COLON) { return gen(left); @@ -3752,10 +3752,7 @@ The "returned" value of try expression with no finally is either the last expres v.dup(); Label nonnull = new Label(); v.ifnonnull(nonnull); - JetType leftType = bindingContext.getType(left); - assert leftType != null; - genThrow(v, "kotlin/TypeCastException", DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(leftType) + - " cannot be cast to " + + genThrow(v, "kotlin/TypeCastException", "null cannot be cast to non-null type " + DescriptorRenderer.FQ_NAMES_IN_TYPES.renderType(rightType)); v.mark(nonnull); } diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/typeCastException.kt b/compiler/testData/codegen/boxWithStdlib/regressions/typeCastException.kt index e67ff8472d5..5a25780bb51 100644 --- a/compiler/testData/codegen/boxWithStdlib/regressions/typeCastException.kt +++ b/compiler/testData/codegen/boxWithStdlib/regressions/typeCastException.kt @@ -1,4 +1,7 @@ +import java.util.ArrayList + // KT-2823 TypeCastException has no message +// KT-5121 Better error message in on casting null to non-null type fun box(): String { try { @@ -6,9 +9,20 @@ fun box(): String { a as Array } catch (e: TypeCastException) { - if (e.getMessage() == "kotlin.Any? cannot be cast to kotlin.Array") { - return "OK" + if (e.getMessage() != "null cannot be cast to non-null type kotlin.Array") { + return "Fail 1: $e" } } - return "fail" + + try { + val x: String? = null + x as String + } + catch (e: TypeCastException) { + if (e.getMessage() != "null cannot be cast to non-null type kotlin.String") { + return "Fail 2: $e" + } + } + + return "OK" } From 0bad4e01378fa59d8548f6e51c2904d996b72618 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 3 Jul 2015 16:18:13 +0300 Subject: [PATCH 042/450] Make KotlinJvmCheckerProvider non-singleton, pass module to it --- .../kotlin/cli/jvm/repl/di/injection.kt | 2 +- .../kotlin/frontend/java/di/injection.kt | 4 ++-- .../load/kotlin/KotlinJvmCheckerProvider.kt | 2 +- .../AbstractDescriptorRendererTest.kt | 3 ++- .../jetbrains/kotlin/tests/di/injection.kt | 2 +- .../kotlin/resolve/lazy/ElementResolver.kt | 14 +++++++++---- .../idea/caches/resolve/KotlinResolveCache.kt | 12 +++++------ .../idea/project/ResolveElementCache.java | 5 +++-- .../kotlin/idea/project/TargetPlatform.java | 20 +++++++++++++++--- .../idea/project/TargetPlatformImpl.java | 21 ++++--------------- 10 files changed, 46 insertions(+), 39 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/di/injection.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/di/injection.kt index fab6bb69af9..b8cb74cb7bf 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/di/injection.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/di/injection.kt @@ -38,7 +38,7 @@ public fun createContainerForReplWithJava( moduleContext: ModuleContext, bindingTrace: BindingTrace, declarationProviderFactory: DeclarationProviderFactory, moduleContentScope: GlobalSearchScope, additionalFileScopeProvider: FileScopeProvider.AdditionalScopes ): ContainerForReplWithJava = createContainer("ReplWithJava") { - configureModule(moduleContext, KotlinJvmCheckerProvider, bindingTrace) + configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) useInstance(additionalFileScopeProvider) 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 83aa1d5826a..09f771e130c 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 @@ -71,7 +71,7 @@ public fun createContainerForLazyResolveWithJava( moduleContext: ModuleContext, bindingTrace: BindingTrace, declarationProviderFactory: DeclarationProviderFactory, moduleContentScope: GlobalSearchScope, moduleClassResolver: ModuleClassResolver ): Pair = createContainer("LazyResolveWithJava") { - configureModule(moduleContext, KotlinJvmCheckerProvider, bindingTrace) + configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) useInstance(moduleClassResolver) @@ -92,7 +92,7 @@ public fun createContainerForTopDownAnalyzerForJvm( declarationProviderFactory: DeclarationProviderFactory, moduleContentScope: GlobalSearchScope ): ContainerForTopDownAnalyzerForJvm = createContainer("TopDownAnalyzerForJvm") { - configureModule(moduleContext, KotlinJvmCheckerProvider, bindingTrace) + configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) useInstance(declarationProviderFactory) useInstance(BodyResolveCache.ThrowException) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index 63d278bb1ee..35b6fe8c2f4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -52,7 +52,7 @@ import org.jetbrains.kotlin.types.expressions.SenselessComparisonChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible -public object KotlinJvmCheckerProvider : AdditionalCheckerProvider( +public class KotlinJvmCheckerProvider(private val module: ModuleDescriptor) : AdditionalCheckerProvider( additionalDeclarationCheckers = listOf(PlatformStaticAnnotationChecker(), LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker(), diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt index 7ba11e2b160..065e6623946 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt @@ -53,7 +53,8 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment context, FileBasedDeclarationProviderFactory(context.storageManager, listOf(psiFile)), CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(), - KotlinJvmCheckerProvider, DynamicTypesSettings()) + KotlinJvmCheckerProvider(context.module), DynamicTypesSettings() + ) context.initializeModuleContents(resolveSession.getPackageFragmentProvider()) diff --git a/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt b/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt index 37e60cb697d..b1e1da7070b 100644 --- a/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt +++ b/compiler/tests/org/jetbrains/kotlin/tests/di/injection.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.types.expressions.FakeCallResolver public fun createContainerForTests(project: Project, module: ModuleDescriptor): ContainerForTests { return ContainerForTests(createContainer("Tests") { - configureModule(ModuleContext(module, project), KotlinJvmCheckerProvider) + configureModule(ModuleContext(module, project), KotlinJvmCheckerProvider(module)) useImpl() }) } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index eb253798cf4..2d93627af24 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -401,11 +401,17 @@ public abstract class ElementResolver protected constructor( return trace } - private fun createBodyResolver(resolveSession: ResolveSession, trace: BindingTrace, file: JetFile, statementFilter: StatementFilter): BodyResolver { + private fun createBodyResolver( + resolveSession: ResolveSession, + trace: BindingTrace, + file: JetFile, + statementFilter: StatementFilter + ): BodyResolver { val globalContext = SimpleGlobalContext(resolveSession.getStorageManager(), resolveSession.getExceptionTracker()) + val module = resolveSession.getModuleDescriptor() return createContainerForBodyResolve( - globalContext.withProject(file.getProject()).withModule(resolveSession.getModuleDescriptor()), - trace, getAdditionalCheckerProvider(file), statementFilter, getDynamicTypesSettings(file) + globalContext.withProject(file.getProject()).withModule(module), + trace, createAdditionalCheckerProvider(file, module), statementFilter, getDynamicTypesSettings(file) ).get() } @@ -477,7 +483,7 @@ public abstract class ElementResolver protected constructor( return null } - protected abstract fun getAdditionalCheckerProvider(jetFile: JetFile): AdditionalCheckerProvider + protected abstract fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor): AdditionalCheckerProvider protected abstract fun getDynamicTypesSettings(jetFile: JetFile): DynamicTypesSettings private class BodyResolveContextForLazy( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt index b4d824fadd7..4a5179f8c2d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt @@ -215,11 +215,9 @@ private object KotlinResolveDataProvider { fun analyze(project: Project, resolveSession: ResolveSessionForBodies, analyzableElement: JetElement): AnalysisResult { try { + val module = resolveSession.getModuleDescriptor() if (analyzableElement is JetCodeFragment) { - return AnalysisResult.success( - analyzeExpressionCodeFragment(resolveSession, analyzableElement), - resolveSession.getModuleDescriptor() - ) + return AnalysisResult.success(analyzeExpressionCodeFragment(resolveSession, analyzableElement), module) } val file = analyzableElement.getContainingJetFile() @@ -232,12 +230,12 @@ private object KotlinResolveDataProvider { val targetPlatform = TargetPlatformDetector.getPlatform(analyzableElement.getContainingJetFile()) val globalContext = SimpleGlobalContext(resolveSession.getStorageManager(), resolveSession.getExceptionTracker()) - val moduleContext = globalContext.withProject(project).withModule(resolveSession.getModuleDescriptor()) + val moduleContext = globalContext.withProject(project).withModule(module) val lazyTopDownAnalyzer = createContainerForLazyBodyResolve( moduleContext, resolveSession, trace, - targetPlatform.getAdditionalCheckerProvider(), + targetPlatform.createAdditionalCheckerProvider(module), targetPlatform.getDynamicTypesSettings(), resolveSession.getBodyResolveCache() ).get() @@ -248,7 +246,7 @@ private object KotlinResolveDataProvider { ) return AnalysisResult.success( trace.getBindingContext(), - resolveSession.getModuleDescriptor() + module ) } catch (e: ProcessCanceledException) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java index da676ed39b9..8475afbc693 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java @@ -24,6 +24,7 @@ import com.intellij.psi.util.PsiModificationTracker; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.descriptors.ModuleDescriptor; import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex; import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex; import org.jetbrains.kotlin.psi.JetElement; @@ -88,8 +89,8 @@ public class ResolveElementCache extends ElementResolver implements BodyResolveC @NotNull @Override - public AdditionalCheckerProvider getAdditionalCheckerProvider(@NotNull JetFile jetFile) { - return TargetPlatformDetector.getPlatform(jetFile).getAdditionalCheckerProvider(); + public AdditionalCheckerProvider createAdditionalCheckerProvider(@NotNull JetFile jetFile, @NotNull ModuleDescriptor module) { + return TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module); } @NotNull diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatform.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatform.java index 03b7117e50a..b9e363fabf3 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatform.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatform.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.idea.project; import org.jetbrains.annotations.NotNull; +import org.jetbrains.kotlin.descriptors.ModuleDescriptor; import org.jetbrains.kotlin.js.resolve.KotlinJsCheckerProvider; import org.jetbrains.kotlin.load.kotlin.KotlinJvmCheckerProvider; import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider; @@ -25,11 +26,24 @@ import org.jetbrains.kotlin.types.DynamicTypesSettings; public interface TargetPlatform { @NotNull - AdditionalCheckerProvider getAdditionalCheckerProvider(); + AdditionalCheckerProvider createAdditionalCheckerProvider(@NotNull ModuleDescriptor module); @NotNull DynamicTypesSettings getDynamicTypesSettings(); - TargetPlatform JVM = new TargetPlatformImpl("JVM", KotlinJvmCheckerProvider.INSTANCE$, new DynamicTypesSettings()); - TargetPlatform JS = new TargetPlatformImpl("JS", KotlinJsCheckerProvider.INSTANCE$, new DynamicTypesAllowed()); + TargetPlatform JVM = new TargetPlatformImpl("JVM", new DynamicTypesSettings()) { + @NotNull + @Override + public AdditionalCheckerProvider createAdditionalCheckerProvider(@NotNull ModuleDescriptor module) { + return new KotlinJvmCheckerProvider(module); + } + }; + + TargetPlatform JS = new TargetPlatformImpl("JS", new DynamicTypesAllowed()) { + @NotNull + @Override + public AdditionalCheckerProvider createAdditionalCheckerProvider(@NotNull ModuleDescriptor module) { + return KotlinJsCheckerProvider.INSTANCE$; + } + }; } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatformImpl.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatformImpl.java index e653fc1c691..a577f7bd45f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatformImpl.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/TargetPlatformImpl.java @@ -17,30 +17,17 @@ package org.jetbrains.kotlin.idea.project; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider; import org.jetbrains.kotlin.types.DynamicTypesSettings; -public class TargetPlatformImpl implements TargetPlatform { - @NotNull private final String platformName; - @NotNull private final AdditionalCheckerProvider additionalCheckerProvider; - @NotNull private final DynamicTypesSettings dynamicTypesSettings; +public abstract class TargetPlatformImpl implements TargetPlatform { + private final String platformName; + private final DynamicTypesSettings dynamicTypesSettings; - public TargetPlatformImpl( - @NotNull String platformName, - @NotNull AdditionalCheckerProvider additionalCheckerProvider, - @NotNull DynamicTypesSettings dynamicTypesSettings - ) { + public TargetPlatformImpl(@NotNull String platformName, @NotNull DynamicTypesSettings dynamicTypesSettings) { this.platformName = platformName; - this.additionalCheckerProvider = additionalCheckerProvider; this.dynamicTypesSettings = dynamicTypesSettings; } - @NotNull - @Override - public AdditionalCheckerProvider getAdditionalCheckerProvider() { - return additionalCheckerProvider; - } - @NotNull @Override public DynamicTypesSettings getDynamicTypesSettings() { From feb4dd7b8fc228eeaad305ae4681f61586b906bc Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 26 Jun 2015 21:55:13 +0300 Subject: [PATCH 043/450] Drop 'OBJECT$' field deprecated in M11 --- .../org/jetbrains/kotlin/codegen/FieldInfo.java | 13 ------------- .../codegen/ImplementationBodyCodegen.java | 8 -------- .../org/jetbrains/kotlin/codegen/StackValue.java | 4 ---- .../jetbrains/kotlin/asJava/LightClassUtil.java | 5 ++--- .../nullabilityAnnotations/ClassObjectField.java | 5 ----- .../TraitClassObjectField.java | 5 ----- .../boxWithJava/classObjectAccessor/J.java | 2 +- .../specialNames/classObject.kt | 6 ------ .../specialNames/classObject.txt | 15 --------------- .../specialNames/classObjectCopiedFieldObject.kt | 8 -------- .../classObjectCopiedFieldObject.txt | 16 ---------------- .../org/jetbrains/kotlin/load/java/JvmAbi.java | 4 ---- .../testData/injava/ClassObjectField.java | 1 - .../fields/classObjectCopiedFieldObject.kt | 8 -------- .../DeprecatedClassObjectField.java | 7 ------- .../idea/javaFacade/JetJavaFacadeTest.java | 9 --------- .../ReferenceResolveInJavaTestGenerated.java | 6 ------ .../parse/nestedClasses/annotations.txt | 2 -- .../resources/parse/nestedClasses/parsed.txt | 1 - .../parse/platformStatic/annotations.txt | 2 -- .../resources/parse/platformStatic/parsed.txt | 1 - .../collectToFile/nestedClasses/annotations.txt | 1 - .../collectToFile/platformStatic/annotations.txt | 2 -- 23 files changed, 3 insertions(+), 128 deletions(-) delete mode 100644 idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java index c00db37fe29..99e97b4bddc 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FieldInfo.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.CompanionObjectMapping; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.org.objectweb.asm.Type; @@ -46,18 +45,6 @@ public class FieldInfo { } } - @SuppressWarnings("deprecation") - @NotNull - public static FieldInfo deprecatedFieldForCompanionObject(@NotNull ClassDescriptor companionObject, @NotNull JetTypeMapper typeMapper) { - assert DescriptorUtils.isCompanionObject(companionObject) : "Not a companion object: " + companionObject; - return new FieldInfo( - typeMapper.mapType((ClassifierDescriptor) companionObject.getContainingDeclaration()), - typeMapper.mapType(companionObject), - JvmAbi.DEPRECATED_COMPANION_OBJECT_FIELD, - true - ); - } - @NotNull public static FieldInfo createForHiddenField(@NotNull Type owner, @NotNull Type fieldType, @NotNull String fieldName) { return new FieldInfo(owner, fieldType, fieldName, false); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 547b58b0836..118d894d66f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -43,7 +43,6 @@ import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.load.java.JvmAnnotationNames; import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinClass; import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor; -import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; @@ -1008,12 +1007,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper); v.newField(OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null); - StackValue.Field deprecatedField = StackValue.deprecatedCompanionObjectAccessor(companionObjectDescriptor, typeMapper); - FieldVisitor fv = v.newField(OtherOrigin(companionObject), ACC_PUBLIC | ACC_STATIC | ACC_FINAL | ACC_DEPRECATED, - deprecatedField.name, deprecatedField.type.getDescriptor(), null, null); - - fv.visitAnnotation(asmDescByFqNameWithoutInnerClasses(new FqName("java.lang.Deprecated")), true).visitEnd(); - if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return; if (!isCompanionObjectWithBackingFieldsInOuter(companionObjectDescriptor)) { @@ -1074,7 +1067,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { codegen.v.dup(); StackValue instance = StackValue.onStack(typeMapper.mapClass(companionObject)); StackValue.singleton(companionObject, typeMapper).store(instance, codegen.v, true); - StackValue.deprecatedCompanionObjectAccessor(companionObject, typeMapper).store(instance, codegen.v, true); } private void generatePrimaryConstructor(final DelegationFieldsInfo delegationFieldsInfo) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index f99bc87ba1d..025dc639989 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -552,10 +552,6 @@ public abstract class StackValue { return field(FieldInfo.createForSingleton(classDescriptor, typeMapper)); } - public static Field deprecatedCompanionObjectAccessor(ClassDescriptor classDescriptor, JetTypeMapper typeMapper) { - return field(FieldInfo.deprecatedFieldForCompanionObject(classDescriptor, typeMapper)); - } - public static StackValue operation(Type type, Function1 lambda) { return new OperationStackValue(type, lambda); } diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java index 305e9aadb16..e9951862f26 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java @@ -154,9 +154,8 @@ public class LightClassUtil { PsiClass outerPsiClass = getWrappingClass(companionObject); if (outerPsiClass != null) { for (PsiField fieldOfParent : outerPsiClass.getFields()) { - if (!(fieldOfParent instanceof KotlinLightElement)) continue; - if (((KotlinLightElement) fieldOfParent).getOrigin() == companionObject && - fieldOfParent.getName().equals(companionObject.getName())) { // TODO this check is relevant while light class has deprecated OBJECT$ field + if ((fieldOfParent instanceof KotlinLightElement) && + ((KotlinLightElement) fieldOfParent).getOrigin() == companionObject) { return fieldOfParent; } } diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java index 216eca84c56..74373b189c7 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/ClassObjectField.java @@ -3,11 +3,6 @@ public final class ClassObjectField { public static final java.lang.String x = ""; private static final java.lang.String y = ""; public static final ClassObjectField.Companion Companion; - /** - * @deprecated - */ - @java.lang.Deprecated - public static final ClassObjectField.Companion OBJECT$; public ClassObjectField() { /* compiled code */ } diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java index 27b9d09742c..6a1577a11e3 100644 --- a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.java @@ -1,10 +1,5 @@ public interface TraitClassObjectField { TraitClassObjectField.Companion Companion; - /** - * @deprecated - */ - @java.lang.Deprecated - TraitClassObjectField.Companion OBJECT$; @org.jetbrains.annotations.Nullable java.lang.String x = ""; diff --git a/compiler/testData/codegen/boxWithJava/classObjectAccessor/J.java b/compiler/testData/codegen/boxWithJava/classObjectAccessor/J.java index 308c328b2b8..1464f02b7bc 100644 --- a/compiler/testData/codegen/boxWithJava/classObjectAccessor/J.java +++ b/compiler/testData/codegen/boxWithJava/classObjectAccessor/J.java @@ -1,5 +1,5 @@ public class J { public static int f() { - return A.Companion.getI1() + A.OBJECT$.getI2() + B.Named.getI1() + B.OBJECT$.getI2(); + return A.Companion.getI1() + A.Companion.getI2() + B.Named.getI1() + B.Named.getI2(); } } diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.kt index f4fc2430b45..7cb3dde5a54 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.kt @@ -3,9 +3,3 @@ class C { val Companion = C } - -class D { - companion object {} - - val `OBJECT$` = D -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.txt index 4fac25c9706..d0332ec3902 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObject.txt @@ -14,18 +14,3 @@ internal final class C { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } } - -internal final class D { - public constructor D() - internal final val `OBJECT$`: D.Companion - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - public companion object Companion { - private constructor Companion() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.kt index 63f2176ecf8..a95ee845d35 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.kt @@ -11,11 +11,3 @@ class C { } } - -class D { - companion object { - val `OBJECT$` = this - } - - val `OBJECT$` = D -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.txt index 353977e4cb0..4971046d69d 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/specialNames/classObjectCopiedFieldObject.txt @@ -29,19 +29,3 @@ internal final class C { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } } - -internal final class D { - public constructor D() - internal final val `OBJECT$`: D.Companion - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - public companion object Companion { - private constructor Companion() - internal final val `OBJECT$`: D.Companion - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java index 5fe52492bad..a0f89706774 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -45,10 +45,6 @@ public final class JvmAbi { public static final String KOTLIN_PACKAGE_FIELD_NAME = "$kotlinPackage"; public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl")); - //TODO: To be removed after kotlin M11 - @Deprecated - public static final String DEPRECATED_COMPANION_OBJECT_FIELD = "OBJECT$"; - @NotNull public static String getSyntheticMethodNameForAnnotatedProperty(@NotNull Name propertyName) { return propertyName.asString() + ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX; diff --git a/idea/idea-completion/testData/injava/ClassObjectField.java b/idea/idea-completion/testData/injava/ClassObjectField.java index 0173f41c06f..a5ae5f15cd8 100644 --- a/idea/idea-completion/testData/injava/ClassObjectField.java +++ b/idea/idea-completion/testData/injava/ClassObjectField.java @@ -5,4 +5,3 @@ public class Testing { } // EXIST: Companion -// EXIST: OBJECT$ \ No newline at end of file diff --git a/idea/testData/checker/duplicateJvmSignature/fields/classObjectCopiedFieldObject.kt b/idea/testData/checker/duplicateJvmSignature/fields/classObjectCopiedFieldObject.kt index 75b1c68ea7c..4505579a855 100644 --- a/idea/testData/checker/duplicateJvmSignature/fields/classObjectCopiedFieldObject.kt +++ b/idea/testData/checker/duplicateJvmSignature/fields/classObjectCopiedFieldObject.kt @@ -11,11 +11,3 @@ class C { } } - -class D { - companion object A { - val `OBJECT$` = this - } - - val `OBJECT$` = D -} \ No newline at end of file diff --git a/idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java b/idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java deleted file mode 100644 index 0199370c25f..00000000000 --- a/idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java +++ /dev/null @@ -1,7 +0,0 @@ -public class ClassObjectField { - public static void foo() { - k.ClassWithClassObject.OBJECT$.f(); - } -} - -// REF: companion object of (k).ClassWithClassObject diff --git a/idea/tests/org/jetbrains/kotlin/idea/javaFacade/JetJavaFacadeTest.java b/idea/tests/org/jetbrains/kotlin/idea/javaFacade/JetJavaFacadeTest.java index 9d51a2cdad4..f41d01efdbd 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/javaFacade/JetJavaFacadeTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/javaFacade/JetJavaFacadeTest.java @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.asJava.LightClassUtil; import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase; import org.jetbrains.kotlin.idea.test.JetLightProjectDescriptor; import org.jetbrains.kotlin.idea.test.PluginTestCaseBase; -import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.name.SpecialNames; import org.jetbrains.kotlin.psi.*; @@ -199,14 +198,6 @@ public class JetJavaFacadeTest extends JetLightCodeInsightFixtureTestCase { assertTrue(instance.hasModifierProperty(PsiModifier.STATIC)); assertTrue(instance.hasModifierProperty(PsiModifier.FINAL)); - PsiField deprecatedAccessor = theClass.findFieldByName(JvmAbi.DEPRECATED_COMPANION_OBJECT_FIELD, false); - assertNotNull(deprecatedAccessor); - assertEquals("foo.TheClass." + defaultCompanionObjectName, deprecatedAccessor.getType().getCanonicalText()); - assertTrue(deprecatedAccessor.hasModifierProperty(PsiModifier.PUBLIC)); - assertTrue(deprecatedAccessor.hasModifierProperty(PsiModifier.STATIC)); - assertTrue(deprecatedAccessor.hasModifierProperty(PsiModifier.FINAL)); - assertTrue(deprecatedAccessor.isDeprecated()); - PsiMethod[] methods = classObjectClass.findMethodsByName("getOut", false); assertEquals("java.io.PrintStream", methods[0].getReturnType().getCanonicalText()); diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveInJavaTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveInJavaTestGenerated.java index 2f28ae5f55d..4cf14ac99e5 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveInJavaTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveInJavaTestGenerated.java @@ -77,12 +77,6 @@ public class ReferenceResolveInJavaTestGenerated extends AbstractReferenceResolv doTest(fileName); } - @TestMetadata("DeprecatedClassObjectField.java") - public void testDeprecatedClassObjectField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/DeprecatedClassObjectField.java"); - doTest(fileName); - } - @TestMetadata("EnumEntry.java") public void testEnumEntry() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/referenceInJava/EnumEntry.java"); diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/annotations.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/annotations.txt index 06d233ba572..c8d587fc057 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/annotations.txt +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/annotations.txt @@ -6,5 +6,3 @@ m 1 0/SomeClass$Companion access$init$0 c 0 0/SomeClass$SomeInnerObject c 0 0/SomeClass$InnerClass c 0 0/SomeClass$NestedClass -a java.lang.Deprecated 2 -f 2 0/SomeClass OBJECT$ diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/parsed.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/parsed.txt index 5611a2ca5d2..c22f8eb4807 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/parsed.txt +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/nestedClasses/parsed.txt @@ -1,4 +1,3 @@ -java.lang.Deprecated org.test.SomeClass OBJECT$ javax.inject.Named org.test.SomeClass.Companion javax.inject.Named org.test.SomeClass.InnerClass javax.inject.Named org.test.SomeClass.NestedClass diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/annotations.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/annotations.txt index 4d9c66f1134..8ba2076e654 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/annotations.txt +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/annotations.txt @@ -5,7 +5,5 @@ a kotlin.inline 1 m 1 0/SomeClass$Companion a a org.jetbrains.annotations.NotNull 2 m 2 0/SomeClass$Companion access$init$0 -a java.lang.Deprecated 3 -f 3 0/SomeClass OBJECT$ m 0 0/SomeClass a m 1 0/SomeClass a diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/parsed.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/parsed.txt index 0cb4a1b4bed..004d4e6ea11 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/parsed.txt +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/platformStatic/parsed.txt @@ -1,4 +1,3 @@ -java.lang.Deprecated org.test.SomeClass OBJECT$ kotlin.inline org.test.SomeClass.Companion a kotlin.platform.platformStatic org.test.SomeClass.Companion a org.jetbrains.annotations.NotNull org.test.SomeClass.Companion access$init$0 \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/nestedClasses/annotations.txt b/plugins/annotation-collector/testData/collectToFile/nestedClasses/annotations.txt index 4183ec87fa3..036ab4d5eb6 100644 --- a/plugins/annotation-collector/testData/collectToFile/nestedClasses/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/nestedClasses/annotations.txt @@ -5,4 +5,3 @@ c 0 0/SomeClass$SomeInnerObject c 0 0/SomeClass$InnerClass c 0 0/SomeClass$InnerClass$InnerClassInInnerClass c 0 0/SomeClass$NestedClass -f 0 0/SomeClass OBJECT$ diff --git a/plugins/annotation-collector/testData/collectToFile/platformStatic/annotations.txt b/plugins/annotation-collector/testData/collectToFile/platformStatic/annotations.txt index b8d64a800d4..51b1222d98d 100644 --- a/plugins/annotation-collector/testData/collectToFile/platformStatic/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/platformStatic/annotations.txt @@ -3,7 +3,5 @@ p org.test 0 m 0 0/SomeClass$Companion a a kotlin.inline 1 m 1 0/SomeClass$Companion a -a java.lang.Deprecated 2 -f 2 0/SomeClass OBJECT$ m 0 0/SomeClass a m 1 0/SomeClass a From 5e011b92efe7098524fc857bdbbcb085487c9578 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 17:14:44 +0300 Subject: [PATCH 044/450] Add source roots to modules 'builtins' and 'runtime.jvm' This is done to be able to write code in the module 'reflection.jvm' in the IDE without lots of unresolved errors and such --- .idea/libraries/kotlin_runtime.xml | 2 -- core/builtins/builtins.iml | 7 ++++--- core/reflection.jvm/reflection.jvm.iml | 1 + core/runtime.jvm/runtime.jvm.iml | 4 +++- core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt | 1 + .../src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt | 8 +++++--- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.idea/libraries/kotlin_runtime.xml b/.idea/libraries/kotlin_runtime.xml index 217f24d439d..cb98de382af 100644 --- a/.idea/libraries/kotlin_runtime.xml +++ b/.idea/libraries/kotlin_runtime.xml @@ -7,8 +7,6 @@ - - \ No newline at end of file diff --git a/core/builtins/builtins.iml b/core/builtins/builtins.iml index ef582b1af94..c90834f2d60 100644 --- a/core/builtins/builtins.iml +++ b/core/builtins/builtins.iml @@ -2,9 +2,10 @@ - + + + - - + \ No newline at end of file diff --git a/core/reflection.jvm/reflection.jvm.iml b/core/reflection.jvm/reflection.jvm.iml index c27ceec3095..401fe141a0d 100644 --- a/core/reflection.jvm/reflection.jvm.iml +++ b/core/reflection.jvm/reflection.jvm.iml @@ -8,6 +8,7 @@ + diff --git a/core/runtime.jvm/runtime.jvm.iml b/core/runtime.jvm/runtime.jvm.iml index b5df517c6fb..7ce21791fb6 100644 --- a/core/runtime.jvm/runtime.jvm.iml +++ b/core/runtime.jvm/runtime.jvm.iml @@ -2,7 +2,9 @@ - + + + diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt b/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt index 59e857a5b10..a8b68232083 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Lambda.kt @@ -19,5 +19,6 @@ package kotlin.jvm.internal public abstract class Lambda(private val arity: Int) : FunctionImpl() { override fun getArity() = arity + @suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") override fun toString() = "${(this as Object).getClass().getGenericInterfaces()[0]}" } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt index bca205a0877..0646197b3ac 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PrimitiveSpreadBuilders.kt @@ -20,6 +20,8 @@ private abstract class PrimitiveSpreadBuilder(private val size: Int) { abstract protected fun T.getSize(): Int protected var position: Int = 0 + + @suppress("CAST_NEVER_SUCCEEDS") private val spreads: Array = arrayOfNulls(size) as Array public fun addSpread(spreadArgument: T) { @@ -41,17 +43,17 @@ private abstract class PrimitiveSpreadBuilder(private val size: Int) { val spreadArgument = spreads[i] if (spreadArgument != null) { if (copyValuesFrom < i) { - System.arraycopy(values, copyValuesFrom, result, dstIndex, i-copyValuesFrom) + System.arraycopy(values, copyValuesFrom, result, dstIndex, i - copyValuesFrom) dstIndex += i - copyValuesFrom } val spreadSize = spreadArgument.getSize() System.arraycopy(spreadArgument, 0, result, dstIndex, spreadSize) dstIndex += spreadSize - copyValuesFrom = i+1 + copyValuesFrom = i + 1 } } if (copyValuesFrom < size) { - System.arraycopy(values, copyValuesFrom, result, dstIndex, size-copyValuesFrom) + System.arraycopy(values, copyValuesFrom, result, dstIndex, size - copyValuesFrom) } return result From b0e963bf34a71fd7e152c78e27f70ac8326c5711 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 26 Jun 2015 21:28:36 +0300 Subject: [PATCH 045/450] Binary metadata: make repeated int fields packed To save some bytes for enums and classes with many nested classes --- .../kotlin/serialization/DebugProtoBuf.java | 168 ++++++++++-------- core/deserialization/src/descriptors.proto | 4 +- .../kotlin/serialization/ProtoBuf.java | 92 ++++++---- 3 files changed, 152 insertions(+), 112 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java index a5d2c1021e2..c5b70508134 100644 --- a/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java +++ b/compiler/tests/org/jetbrains/kotlin/serialization/DebugProtoBuf.java @@ -9435,9 +9435,9 @@ public final class DebugProtoBuf { org.jetbrains.kotlin.serialization.DebugProtoBuf.TypeOrBuilder getSupertypeOrBuilder( int index); - // repeated int32 nested_class_name = 7; + // repeated int32 nested_class_name = 7 [packed = true]; /** - * repeated int32 nested_class_name = 7; + * repeated int32 nested_class_name = 7 [packed = true]; * *
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9446,7 +9446,7 @@ public final class DebugProtoBuf {
      */
     java.util.List getNestedClassNameList();
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9455,7 +9455,7 @@ public final class DebugProtoBuf {
      */
     int getNestedClassNameCount();
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9489,17 +9489,17 @@ public final class DebugProtoBuf {
     org.jetbrains.kotlin.serialization.DebugProtoBuf.CallableOrBuilder getMemberOrBuilder(
         int index);
 
-    // repeated int32 enum_entry = 12;
+    // repeated int32 enum_entry = 12 [packed = true];
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     java.util.List getEnumEntryList();
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     int getEnumEntryCount();
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     int getEnumEntry(int index);
 
@@ -10655,11 +10655,11 @@ public final class DebugProtoBuf {
       return supertype_.get(index);
     }
 
-    // repeated int32 nested_class_name = 7;
+    // repeated int32 nested_class_name = 7 [packed = true];
     public static final int NESTED_CLASS_NAME_FIELD_NUMBER = 7;
     private java.util.List nestedClassName_;
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -10671,7 +10671,7 @@ public final class DebugProtoBuf {
       return nestedClassName_;
     }
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -10682,7 +10682,7 @@ public final class DebugProtoBuf {
       return nestedClassName_.size();
     }
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -10692,6 +10692,7 @@ public final class DebugProtoBuf {
     public int getNestedClassName(int index) {
       return nestedClassName_.get(index);
     }
+    private int nestedClassNameMemoizedSerializedSize = -1;
 
     // repeated .org.jetbrains.kotlin.serialization.Callable member = 11;
     public static final int MEMBER_FIELD_NUMBER = 11;
@@ -10729,28 +10730,29 @@ public final class DebugProtoBuf {
       return member_.get(index);
     }
 
-    // repeated int32 enum_entry = 12;
+    // repeated int32 enum_entry = 12 [packed = true];
     public static final int ENUM_ENTRY_FIELD_NUMBER = 12;
     private java.util.List enumEntry_;
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public java.util.List
         getEnumEntryList() {
       return enumEntry_;
     }
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public int getEnumEntryCount() {
       return enumEntry_.size();
     }
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public int getEnumEntry(int index) {
       return enumEntry_.get(index);
     }
+    private int enumEntryMemoizedSerializedSize = -1;
 
     // optional .org.jetbrains.kotlin.serialization.Class.PrimaryConstructor primary_constructor = 13;
     public static final int PRIMARY_CONSTRUCTOR_FIELD_NUMBER = 13;
@@ -10902,14 +10904,22 @@ public final class DebugProtoBuf {
       for (int i = 0; i < supertype_.size(); i++) {
         output.writeMessage(6, supertype_.get(i));
       }
+      if (getNestedClassNameList().size() > 0) {
+        output.writeRawVarint32(58);
+        output.writeRawVarint32(nestedClassNameMemoizedSerializedSize);
+      }
       for (int i = 0; i < nestedClassName_.size(); i++) {
-        output.writeInt32(7, nestedClassName_.get(i));
+        output.writeInt32NoTag(nestedClassName_.get(i));
       }
       for (int i = 0; i < member_.size(); i++) {
         output.writeMessage(11, member_.get(i));
       }
+      if (getEnumEntryList().size() > 0) {
+        output.writeRawVarint32(98);
+        output.writeRawVarint32(enumEntryMemoizedSerializedSize);
+      }
       for (int i = 0; i < enumEntry_.size(); i++) {
-        output.writeInt32(12, enumEntry_.get(i));
+        output.writeInt32NoTag(enumEntry_.get(i));
       }
       if (((bitField0_ & 0x00000008) == 0x00000008)) {
         output.writeMessage(13, primaryConstructor_);
@@ -10954,7 +10964,12 @@ public final class DebugProtoBuf {
             .computeInt32SizeNoTag(nestedClassName_.get(i));
         }
         size += dataSize;
-        size += 1 * getNestedClassNameList().size();
+        if (!getNestedClassNameList().isEmpty()) {
+          size += 1;
+          size += com.google.protobuf.CodedOutputStream
+              .computeInt32SizeNoTag(dataSize);
+        }
+        nestedClassNameMemoizedSerializedSize = dataSize;
       }
       for (int i = 0; i < member_.size(); i++) {
         size += com.google.protobuf.CodedOutputStream
@@ -10967,7 +10982,12 @@ public final class DebugProtoBuf {
             .computeInt32SizeNoTag(enumEntry_.get(i));
         }
         size += dataSize;
-        size += 1 * getEnumEntryList().size();
+        if (!getEnumEntryList().isEmpty()) {
+          size += 1;
+          size += com.google.protobuf.CodedOutputStream
+              .computeInt32SizeNoTag(dataSize);
+        }
+        enumEntryMemoizedSerializedSize = dataSize;
       }
       if (((bitField0_ & 0x00000008) == 0x00000008)) {
         size += com.google.protobuf.CodedOutputStream
@@ -12082,7 +12102,7 @@ public final class DebugProtoBuf {
         return supertypeBuilder_;
       }
 
-      // repeated int32 nested_class_name = 7;
+      // repeated int32 nested_class_name = 7 [packed = true];
       private java.util.List nestedClassName_ = java.util.Collections.emptyList();
       private void ensureNestedClassNameIsMutable() {
         if (!((bitField0_ & 0x00000020) == 0x00000020)) {
@@ -12091,7 +12111,7 @@ public final class DebugProtoBuf {
          }
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12103,7 +12123,7 @@ public final class DebugProtoBuf {
         return java.util.Collections.unmodifiableList(nestedClassName_);
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12114,7 +12134,7 @@ public final class DebugProtoBuf {
         return nestedClassName_.size();
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12125,7 +12145,7 @@ public final class DebugProtoBuf {
         return nestedClassName_.get(index);
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12140,7 +12160,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12154,7 +12174,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12169,7 +12189,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -12423,7 +12443,7 @@ public final class DebugProtoBuf {
         return memberBuilder_;
       }
 
-      // repeated int32 enum_entry = 12;
+      // repeated int32 enum_entry = 12 [packed = true];
       private java.util.List enumEntry_ = java.util.Collections.emptyList();
       private void ensureEnumEntryIsMutable() {
         if (!((bitField0_ & 0x00000080) == 0x00000080)) {
@@ -12432,26 +12452,26 @@ public final class DebugProtoBuf {
          }
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public java.util.List
           getEnumEntryList() {
         return java.util.Collections.unmodifiableList(enumEntry_);
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public int getEnumEntryCount() {
         return enumEntry_.size();
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public int getEnumEntry(int index) {
         return enumEntry_.get(index);
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder setEnumEntry(
           int index, int value) {
@@ -12461,7 +12481,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder addEnumEntry(int value) {
         ensureEnumEntryIsMutable();
@@ -12470,7 +12490,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder addAllEnumEntry(
           java.lang.Iterable values) {
@@ -12480,7 +12500,7 @@ public final class DebugProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder clearEnumEntry() {
         enumEntry_ = java.util.Collections.emptyList();
@@ -17064,48 +17084,48 @@ public final class DebugProtoBuf {
       "eParameter.Variance:\003INV\022=\n\013upper_bound\030",
       "\005 \003(\0132(.org.jetbrains.kotlin.serializati" +
       "on.Type\"$\n\010Variance\022\006\n\002IN\020\000\022\007\n\003OUT\020\001\022\007\n\003" +
-      "INV\020\002\"\261\005\n\005Class\022\020\n\005flags\030\001 \001(\005:\0010\022\017\n\007fq_" +
+      "INV\020\002\"\271\005\n\005Class\022\020\n\005flags\030\001 \001(\005:\0010\022\017\n\007fq_" +
       "name\030\003 \002(\005\022\035\n\025companion_object_name\030\004 \001(" +
       "\005\022I\n\016type_parameter\030\005 \003(\01321.org.jetbrain" +
       "s.kotlin.serialization.TypeParameter\022;\n\t" +
       "supertype\030\006 \003(\0132(.org.jetbrains.kotlin.s" +
-      "erialization.Type\022\031\n\021nested_class_name\030\007" +
-      " \003(\005\022<\n\006member\030\013 \003(\0132,.org.jetbrains.kot" +
-      "lin.serialization.Callable\022\022\n\nenum_entry",
-      "\030\014 \003(\005\022Y\n\023primary_constructor\030\r \001(\0132<.or" +
-      "g.jetbrains.kotlin.serialization.Class.P" +
-      "rimaryConstructor\022K\n\025secondary_construct" +
-      "or\030\016 \003(\0132,.org.jetbrains.kotlin.serializ" +
-      "ation.Callable\032P\n\022PrimaryConstructor\022:\n\004" +
-      "data\030\001 \001(\0132,.org.jetbrains.kotlin.serial" +
-      "ization.Callable\"p\n\004Kind\022\t\n\005CLASS\020\000\022\t\n\005T" +
-      "RAIT\020\001\022\016\n\nENUM_CLASS\020\002\022\016\n\nENUM_ENTRY\020\003\022\024" +
-      "\n\020ANNOTATION_CLASS\020\004\022\n\n\006OBJECT\020\005\022\020\n\014CLAS" +
-      "S_OBJECT\020\006*\005\010d\020\310\001\"N\n\007Package\022<\n\006member\030\001",
-      " \003(\0132,.org.jetbrains.kotlin.serializatio" +
-      "n.Callable*\005\010d\020\310\001\"\300\005\n\010Callable\022\r\n\005flags\030" +
-      "\001 \001(\005\022\024\n\014getter_flags\030\t \001(\005\022\024\n\014setter_fl" +
-      "ags\030\n \001(\005\022I\n\016type_parameter\030\004 \003(\01321.org." +
-      "jetbrains.kotlin.serialization.TypeParam" +
-      "eter\022?\n\rreceiver_type\030\005 \001(\0132(.org.jetbra" +
-      "ins.kotlin.serialization.Type\022\014\n\004name\030\006 " +
-      "\002(\005\022T\n\017value_parameter\030\007 \003(\0132;.org.jetbr" +
-      "ains.kotlin.serialization.Callable.Value" +
-      "Parameter\022=\n\013return_type\030\010 \002(\0132(.org.jet",
-      "brains.kotlin.serialization.Type\032\263\001\n\016Val" +
-      "ueParameter\022\r\n\005flags\030\001 \001(\005\022\014\n\004name\030\002 \002(\005" +
-      "\0226\n\004type\030\003 \002(\0132(.org.jetbrains.kotlin.se" +
-      "rialization.Type\022E\n\023vararg_element_type\030" +
-      "\004 \001(\0132(.org.jetbrains.kotlin.serializati" +
-      "on.Type*\005\010d\020\310\001\"Q\n\nMemberKind\022\017\n\013DECLARAT" +
-      "ION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELEGATION\020\002" +
-      "\022\017\n\013SYNTHESIZED\020\003\":\n\014CallableKind\022\007\n\003FUN" +
-      "\020\000\022\007\n\003VAL\020\001\022\007\n\003VAR\020\002\022\017\n\013CONSTRUCTOR\020\003*\005\010" +
-      "d\020\310\001*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004OPEN\020\001\022\014\n",
-      "\010ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisibility\022\014\n" +
-      "\010INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROTECTED\020\002\022" +
-      "\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004\022\t\n\005LOCA" +
-      "L\020\005B\022B\rDebugProtoBuf\210\001\000"
+      "erialization.Type\022\035\n\021nested_class_name\030\007" +
+      " \003(\005B\002\020\001\022<\n\006member\030\013 \003(\0132,.org.jetbrains" +
+      ".kotlin.serialization.Callable\022\026\n\nenum_e",
+      "ntry\030\014 \003(\005B\002\020\001\022Y\n\023primary_constructor\030\r " +
+      "\001(\0132<.org.jetbrains.kotlin.serialization" +
+      ".Class.PrimaryConstructor\022K\n\025secondary_c" +
+      "onstructor\030\016 \003(\0132,.org.jetbrains.kotlin." +
+      "serialization.Callable\032P\n\022PrimaryConstru" +
+      "ctor\022:\n\004data\030\001 \001(\0132,.org.jetbrains.kotli" +
+      "n.serialization.Callable\"p\n\004Kind\022\t\n\005CLAS" +
+      "S\020\000\022\t\n\005TRAIT\020\001\022\016\n\nENUM_CLASS\020\002\022\016\n\nENUM_E" +
+      "NTRY\020\003\022\024\n\020ANNOTATION_CLASS\020\004\022\n\n\006OBJECT\020\005" +
+      "\022\020\n\014CLASS_OBJECT\020\006*\005\010d\020\310\001\"N\n\007Package\022<\n\006",
+      "member\030\001 \003(\0132,.org.jetbrains.kotlin.seri" +
+      "alization.Callable*\005\010d\020\310\001\"\300\005\n\010Callable\022\r" +
+      "\n\005flags\030\001 \001(\005\022\024\n\014getter_flags\030\t \001(\005\022\024\n\014s" +
+      "etter_flags\030\n \001(\005\022I\n\016type_parameter\030\004 \003(" +
+      "\01321.org.jetbrains.kotlin.serialization.T" +
+      "ypeParameter\022?\n\rreceiver_type\030\005 \001(\0132(.or" +
+      "g.jetbrains.kotlin.serialization.Type\022\014\n" +
+      "\004name\030\006 \002(\005\022T\n\017value_parameter\030\007 \003(\0132;.o" +
+      "rg.jetbrains.kotlin.serialization.Callab" +
+      "le.ValueParameter\022=\n\013return_type\030\010 \002(\0132(",
+      ".org.jetbrains.kotlin.serialization.Type" +
+      "\032\263\001\n\016ValueParameter\022\r\n\005flags\030\001 \001(\005\022\014\n\004na" +
+      "me\030\002 \002(\005\0226\n\004type\030\003 \002(\0132(.org.jetbrains.k" +
+      "otlin.serialization.Type\022E\n\023vararg_eleme" +
+      "nt_type\030\004 \001(\0132(.org.jetbrains.kotlin.ser" +
+      "ialization.Type*\005\010d\020\310\001\"Q\n\nMemberKind\022\017\n\013" +
+      "DECLARATION\020\000\022\021\n\rFAKE_OVERRIDE\020\001\022\016\n\nDELE" +
+      "GATION\020\002\022\017\n\013SYNTHESIZED\020\003\":\n\014CallableKin" +
+      "d\022\007\n\003FUN\020\000\022\007\n\003VAL\020\001\022\007\n\003VAR\020\002\022\017\n\013CONSTRUC" +
+      "TOR\020\003*\005\010d\020\310\001*9\n\010Modality\022\t\n\005FINAL\020\000\022\010\n\004O",
+      "PEN\020\001\022\014\n\010ABSTRACT\020\002\022\n\n\006SEALED\020\003*b\n\nVisib" +
+      "ility\022\014\n\010INTERNAL\020\000\022\013\n\007PRIVATE\020\001\022\r\n\tPROT" +
+      "ECTED\020\002\022\n\n\006PUBLIC\020\003\022\023\n\017PRIVATE_TO_THIS\020\004" +
+      "\022\t\n\005LOCAL\020\005B\022B\rDebugProtoBuf\210\001\000"
     };
     com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
       new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
diff --git a/core/deserialization/src/descriptors.proto b/core/deserialization/src/descriptors.proto
index 65056d72d46..531b62e9a18 100644
--- a/core/deserialization/src/descriptors.proto
+++ b/core/deserialization/src/descriptors.proto
@@ -189,11 +189,11 @@ message Class {
 
   // we store only names, because the actual information must reside in the corresponding .class files,
   // to be obtainable through reflection at runtime
-  repeated int32 nested_class_name = 7;
+  repeated int32 nested_class_name = 7 [packed = true];
 
   repeated Callable member = 11;
 
-  repeated int32 enum_entry = 12;
+  repeated int32 enum_entry = 12 [packed = true];
 
   message PrimaryConstructor {
     // If this field is present, it contains serialized data for the primary constructor.
diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
index 8caaf42eb3d..d5cae9f51fd 100644
--- a/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
+++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/ProtoBuf.java
@@ -7417,9 +7417,9 @@ public final class ProtoBuf {
      */
     int getSupertypeCount();
 
-    // repeated int32 nested_class_name = 7;
+    // repeated int32 nested_class_name = 7 [packed = true];
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -7428,7 +7428,7 @@ public final class ProtoBuf {
      */
     java.util.List getNestedClassNameList();
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -7437,7 +7437,7 @@ public final class ProtoBuf {
      */
     int getNestedClassNameCount();
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -7461,17 +7461,17 @@ public final class ProtoBuf {
      */
     int getMemberCount();
 
-    // repeated int32 enum_entry = 12;
+    // repeated int32 enum_entry = 12 [packed = true];
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     java.util.List getEnumEntryList();
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     int getEnumEntryCount();
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     int getEnumEntry(int index);
 
@@ -8394,11 +8394,11 @@ public final class ProtoBuf {
       return supertype_.get(index);
     }
 
-    // repeated int32 nested_class_name = 7;
+    // repeated int32 nested_class_name = 7 [packed = true];
     public static final int NESTED_CLASS_NAME_FIELD_NUMBER = 7;
     private java.util.List nestedClassName_;
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -8410,7 +8410,7 @@ public final class ProtoBuf {
       return nestedClassName_;
     }
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -8421,7 +8421,7 @@ public final class ProtoBuf {
       return nestedClassName_.size();
     }
     /**
-     * repeated int32 nested_class_name = 7;
+     * repeated int32 nested_class_name = 7 [packed = true];
      *
      * 
      * we store only names, because the actual information must reside in the corresponding .class files,
@@ -8431,6 +8431,7 @@ public final class ProtoBuf {
     public int getNestedClassName(int index) {
       return nestedClassName_.get(index);
     }
+    private int nestedClassNameMemoizedSerializedSize = -1;
 
     // repeated .org.jetbrains.kotlin.serialization.Callable member = 11;
     public static final int MEMBER_FIELD_NUMBER = 11;
@@ -8468,28 +8469,29 @@ public final class ProtoBuf {
       return member_.get(index);
     }
 
-    // repeated int32 enum_entry = 12;
+    // repeated int32 enum_entry = 12 [packed = true];
     public static final int ENUM_ENTRY_FIELD_NUMBER = 12;
     private java.util.List enumEntry_;
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public java.util.List
         getEnumEntryList() {
       return enumEntry_;
     }
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public int getEnumEntryCount() {
       return enumEntry_.size();
     }
     /**
-     * repeated int32 enum_entry = 12;
+     * repeated int32 enum_entry = 12 [packed = true];
      */
     public int getEnumEntry(int index) {
       return enumEntry_.get(index);
     }
+    private int enumEntryMemoizedSerializedSize = -1;
 
     // optional .org.jetbrains.kotlin.serialization.Class.PrimaryConstructor primary_constructor = 13;
     public static final int PRIMARY_CONSTRUCTOR_FIELD_NUMBER = 13;
@@ -8631,14 +8633,22 @@ public final class ProtoBuf {
       for (int i = 0; i < supertype_.size(); i++) {
         output.writeMessage(6, supertype_.get(i));
       }
+      if (getNestedClassNameList().size() > 0) {
+        output.writeRawVarint32(58);
+        output.writeRawVarint32(nestedClassNameMemoizedSerializedSize);
+      }
       for (int i = 0; i < nestedClassName_.size(); i++) {
-        output.writeInt32(7, nestedClassName_.get(i));
+        output.writeInt32NoTag(nestedClassName_.get(i));
       }
       for (int i = 0; i < member_.size(); i++) {
         output.writeMessage(11, member_.get(i));
       }
+      if (getEnumEntryList().size() > 0) {
+        output.writeRawVarint32(98);
+        output.writeRawVarint32(enumEntryMemoizedSerializedSize);
+      }
       for (int i = 0; i < enumEntry_.size(); i++) {
-        output.writeInt32(12, enumEntry_.get(i));
+        output.writeInt32NoTag(enumEntry_.get(i));
       }
       if (((bitField0_ & 0x00000008) == 0x00000008)) {
         output.writeMessage(13, primaryConstructor_);
@@ -8682,7 +8692,12 @@ public final class ProtoBuf {
             .computeInt32SizeNoTag(nestedClassName_.get(i));
         }
         size += dataSize;
-        size += 1 * getNestedClassNameList().size();
+        if (!getNestedClassNameList().isEmpty()) {
+          size += 1;
+          size += com.google.protobuf.CodedOutputStream
+              .computeInt32SizeNoTag(dataSize);
+        }
+        nestedClassNameMemoizedSerializedSize = dataSize;
       }
       for (int i = 0; i < member_.size(); i++) {
         size += com.google.protobuf.CodedOutputStream
@@ -8695,7 +8710,12 @@ public final class ProtoBuf {
             .computeInt32SizeNoTag(enumEntry_.get(i));
         }
         size += dataSize;
-        size += 1 * getEnumEntryList().size();
+        if (!getEnumEntryList().isEmpty()) {
+          size += 1;
+          size += com.google.protobuf.CodedOutputStream
+              .computeInt32SizeNoTag(dataSize);
+        }
+        enumEntryMemoizedSerializedSize = dataSize;
       }
       if (((bitField0_ & 0x00000008) == 0x00000008)) {
         size += com.google.protobuf.CodedOutputStream
@@ -9429,7 +9449,7 @@ public final class ProtoBuf {
         return this;
       }
 
-      // repeated int32 nested_class_name = 7;
+      // repeated int32 nested_class_name = 7 [packed = true];
       private java.util.List nestedClassName_ = java.util.Collections.emptyList();
       private void ensureNestedClassNameIsMutable() {
         if (!((bitField0_ & 0x00000020) == 0x00000020)) {
@@ -9438,7 +9458,7 @@ public final class ProtoBuf {
          }
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9450,7 +9470,7 @@ public final class ProtoBuf {
         return java.util.Collections.unmodifiableList(nestedClassName_);
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9461,7 +9481,7 @@ public final class ProtoBuf {
         return nestedClassName_.size();
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9472,7 +9492,7 @@ public final class ProtoBuf {
         return nestedClassName_.get(index);
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9487,7 +9507,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9501,7 +9521,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9516,7 +9536,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 nested_class_name = 7;
+       * repeated int32 nested_class_name = 7 [packed = true];
        *
        * 
        * we store only names, because the actual information must reside in the corresponding .class files,
@@ -9655,7 +9675,7 @@ public final class ProtoBuf {
         return this;
       }
 
-      // repeated int32 enum_entry = 12;
+      // repeated int32 enum_entry = 12 [packed = true];
       private java.util.List enumEntry_ = java.util.Collections.emptyList();
       private void ensureEnumEntryIsMutable() {
         if (!((bitField0_ & 0x00000080) == 0x00000080)) {
@@ -9664,26 +9684,26 @@ public final class ProtoBuf {
          }
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public java.util.List
           getEnumEntryList() {
         return java.util.Collections.unmodifiableList(enumEntry_);
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public int getEnumEntryCount() {
         return enumEntry_.size();
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public int getEnumEntry(int index) {
         return enumEntry_.get(index);
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder setEnumEntry(
           int index, int value) {
@@ -9693,7 +9713,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder addEnumEntry(int value) {
         ensureEnumEntryIsMutable();
@@ -9702,7 +9722,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder addAllEnumEntry(
           java.lang.Iterable values) {
@@ -9712,7 +9732,7 @@ public final class ProtoBuf {
         return this;
       }
       /**
-       * repeated int32 enum_entry = 12;
+       * repeated int32 enum_entry = 12 [packed = true];
        */
       public Builder clearEnumEntry() {
         enumEntry_ = java.util.Collections.emptyList();

From f9afb4f95bfda91125940fc92bd19863f7908e2b Mon Sep 17 00:00:00 2001
From: Alexander Udalov 
Date: Fri, 26 Jun 2015 21:25:20 +0300
Subject: [PATCH 046/450] Make CLASS default class kind in binary metadata

Don't write the kind to the class file if it's CLASS to save some bytes
---
 .../codegen/ImplementationBodyCodegen.java    | 22 ++++++++++++++-----
 ...eadKotlinClassHeaderAnnotationVisitor.java |  5 +++++
 .../src/kotlin/jvm/internal/KotlinClass.java  |  4 ++--
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java
index 118d894d66f..8e43cb0b89b 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java
@@ -239,13 +239,20 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
             kind = KotlinClass.Kind.ANONYMOUS_OBJECT;
         }
         else if (isTopLevelOrInnerClass(descriptor)) {
-            kind = KotlinClass.Kind.CLASS;
+            // Default value is Kind.CLASS
+            kind = null;
         }
         else {
             // LOCAL_CLASS is also written to inner classes of local classes
             kind = KotlinClass.Kind.LOCAL_CLASS;
         }
 
+        // Temporarily write class kind anyway because old compiler may not expect its absence
+        // TODO: remove after M13
+        if (kind == null) {
+            kind = KotlinClass.Kind.CLASS;
+        }
+
         DescriptorSerializer serializer =
                 DescriptorSerializer.create(descriptor, new JvmSerializerExtension(v.getSerializationBindings(), typeMapper));
 
@@ -257,11 +264,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
 
         AnnotationVisitor av = v.getVisitor().visitAnnotation(asmDescByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_CLASS), true);
         av.visit(JvmAnnotationNames.ABI_VERSION_FIELD_NAME, JvmAbi.VERSION);
-        av.visitEnum(
-                JvmAnnotationNames.KIND_FIELD_NAME,
-                Type.getObjectType(KotlinClass.KIND_INTERNAL_NAME).getDescriptor(),
-                kind.toString()
-        );
+        //noinspection ConstantConditions
+        if (kind != null) {
+            av.visitEnum(
+                    JvmAnnotationNames.KIND_FIELD_NAME,
+                    Type.getObjectType(KotlinClass.KIND_INTERNAL_NAME).getDescriptor(),
+                    kind.toString()
+            );
+        }
         AnnotationVisitor array = av.visitArray(JvmAnnotationNames.DATA_FIELD_NAME);
         for (String string : BitEncoding.encodeBytes(SerializationUtil.serializeClassData(data))) {
             array.visit(null, string);
diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java
index 8d378365ded..1365f6a39b9 100644
--- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java
+++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java
@@ -68,6 +68,11 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
             return null;
         }
 
+        if (headerKind == CLASS && classKind == null) {
+            // Default class kind is Kind.CLASS
+            classKind = KotlinClass.Kind.CLASS;
+        }
+
         if (!AbiVersionUtil.isAbiVersionCompatible(version)) {
             return new KotlinClassHeader(headerKind, version, null, classKind, syntheticClassKind);
         }
diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/KotlinClass.java b/core/runtime.jvm/src/kotlin/jvm/internal/KotlinClass.java
index 8efd073d8f3..cf67e5352cc 100644
--- a/core/runtime.jvm/src/kotlin/jvm/internal/KotlinClass.java
+++ b/core/runtime.jvm/src/kotlin/jvm/internal/KotlinClass.java
@@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy;
 public @interface KotlinClass {
     int abiVersion();
 
-    Kind kind();
+    Kind kind() default Kind.CLASS;
 
     String[] data();
 
@@ -31,7 +31,7 @@ public @interface KotlinClass {
         CLASS,
 
         /**
-         * A class has this kind if and only if its first non-class container is not a package.
+         * A class has kind LOCAL_CLASS if and only if it's not an anonymous object and its first non-class container is not a package.
          */
         LOCAL_CLASS,
 

From fdff2c7153cb7ae67edfa23fa2e3d2a30af722a8 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 12:41:53 +0300
Subject: [PATCH 047/450] J2K: preserving line breaks between enum members from
 original code

---
 .../org/jetbrains/kotlin/j2k/CodeBuilder.kt   | 102 +++++++++++-------
 .../kotlin/j2k/ConstructorConverter.kt        |   2 +-
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt |  14 +--
 .../org/jetbrains/kotlin/j2k/ast/ClassBody.kt |   2 +-
 .../jetbrains/kotlin/j2k/ast/Constructors.kt  |   2 +-
 .../org/jetbrains/kotlin/j2k/ast/Element.kt   |  14 ++-
 .../annotations/annotationInterface3.kt       |   3 +-
 .../fieldsWithPrimaryPrivateConstructor.kt    |   6 +-
 .../fileOrElement/enum/overrideToString.kt    |   6 +-
 .../enum/runnableImplementation.kt            |   6 +-
 .../fileOrElement/enum/typeSafeEnum.kt        |   5 +-
 11 files changed, 91 insertions(+), 71 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
index 4589ca7999a..1568b628fe5 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
@@ -21,9 +21,13 @@ import com.intellij.psi.*
 import com.intellij.psi.javadoc.PsiDocComment
 import org.jetbrains.kotlin.j2k.ast.CommentsAndSpacesInheritance
 import org.jetbrains.kotlin.j2k.ast.Element
+import org.jetbrains.kotlin.j2k.ast.SpacesInheritance
 import org.jetbrains.kotlin.name.FqName
 import org.jetbrains.kotlin.psi.psiUtil.isAncestor
-import java.util.*
+import org.jetbrains.kotlin.utils.addIfNotNull
+import java.util.ArrayList
+import java.util.HashSet
+import java.util.LinkedHashSet
 import kotlin.platform.platformName
 
 fun CodeBuilder.append(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
@@ -117,31 +121,25 @@ class CodeBuilder(private val topElement: PsiElement?) {
         }
 
         val notInsideElements = HashSet()
-        val prefixElements = ArrayList(1)
+        var prefix = Prefix.Empty
         val postfixElements = ArrayList(1)
         for ((prototype, inheritance) in element.prototypes!!) {
             assert(prototype !is PsiComment)
             assert(prototype !is PsiWhiteSpace)
             if (!topElement.isAncestor(prototype)) continue
-            prefixElements.collectPrefixElements(prototype, inheritance, notInsideElements)
+            prefix += collectPrefixElements(prototype, inheritance, notInsideElements)
             postfixElements.collectPostfixElements(prototype, inheritance, notInsideElements)
         }
 
-        commentsAndSpacesUsed.addAll(prefixElements)
-        commentsAndSpacesUsed.addAll(postfixElements)
-
-        for ((i, e) in prefixElements.withIndex()) {
-            if (i == 0 && e is PsiWhiteSpace) {
-                val blankLines = e.newLinesCount() - 1
-                for (_ in 1..blankLines) {
-                    append("\n", false)
-                }
-            }
-            else {
-                appendCommentOrWhiteSpace(e)
+        if (prefix.lineBreaksBefore > 0) {
+            val lineBreaksToAdd = prefix.lineBreaksBefore - builder.trailingLineBreakCount()
+            for (_ in 1..lineBreaksToAdd) {
+                append("\n", false)
             }
         }
 
+        prefix.elements.forEach { appendCommentOrWhiteSpace(it) }
+
         element.generateCode(this)
 
         // scan for all comments inside which are not yet used in the text and put them here to not loose any comment from code
@@ -164,29 +162,52 @@ class CodeBuilder(private val topElement: PsiElement?) {
         return this
     }
 
-    private fun MutableList.collectPrefixElements(element: PsiElement,
-                                                              inheritance: CommentsAndSpacesInheritance,
-                                                              notInsideElements: MutableSet) {
+    private data class Prefix(val elements: Collection, val lineBreaksBefore: Int) {
+        fun plus(other: Prefix) = Prefix(elements + other.elements, Math.max(lineBreaksBefore, other.lineBreaksBefore))
+
+        companion object {
+            val Empty = Prefix(emptyList(), 0)
+        }
+    }
+
+    private fun collectPrefixElements(
+            element: PsiElement,
+            inheritance: CommentsAndSpacesInheritance,
+            notInsideElements: MutableSet
+    ): Prefix {
         val before = ArrayList(1).collectCommentsAndSpacesBefore(element)
         val atStart = ArrayList(1).collectCommentsAndSpacesAtStart(element)
         notInsideElements.addAll(atStart)
 
-        if (!inheritance.blankLinesBefore && !inheritance.commentsBefore) return
+        if (inheritance.spacesBefore == SpacesInheritance.NONE && !inheritance.commentsBefore) return Prefix.Empty
 
         val firstSpace = before.lastOrNull() as? PsiWhiteSpace
-        if (!inheritance.commentsBefore) { // take only first whitespace
-            if (firstSpace != null) {
-                add(firstSpace)
+        var lineBreaks = 0
+        if (firstSpace != null) {
+            lineBreaks = firstSpace.newLinesCount()
+            when (inheritance.spacesBefore) {
+                SpacesInheritance.NONE -> lineBreaks = 0
+
+                SpacesInheritance.LINE_BREAKS -> commentsAndSpacesUsed.add(firstSpace)
+
+                SpacesInheritance.BLANK_LINES_ONLY -> {
+                    commentsAndSpacesUsed.add(firstSpace)
+                    if (lineBreaks == 1) lineBreaks = 0
+                }
             }
-            return
         }
 
-        if (!inheritance.blankLinesBefore && firstSpace != null) {
+        if (!inheritance.commentsBefore) { // take only whitespace
+            return Prefix(emptyList(), lineBreaks)
+        }
+
+        if (firstSpace != null) {
             before.remove(before.lastIndex)
         }
 
-        addAll(before.reverse())
-        addAll(atStart)
+        val elements = before.reverse() + atStart
+        commentsAndSpacesUsed.addAll(elements)
+        return Prefix(elements, lineBreaks)
     }
 
     private fun MutableList.collectPostfixElements(element: PsiElement, inheritance: CommentsAndSpacesInheritance, notInsideElements: MutableSet) {
@@ -205,6 +226,9 @@ class CodeBuilder(private val topElement: PsiElement?) {
 
         addAll(atEnd.reverse())
         addAll(after)
+
+        commentsAndSpacesUsed.addAll(atEnd)
+        commentsAndSpacesUsed.addAll(after)
     }
 
     private fun MutableList.collectCommentsAndSpacesBefore(element: PsiElement): MutableList {
@@ -253,14 +277,14 @@ class CodeBuilder(private val topElement: PsiElement?) {
     private fun MutableList.collectCommentsAndSpacesAtStart(element: PsiElement): MutableList {
         var child = element.getFirstChild()
         while(child != null) {
-            if (child!!.isCommentOrSpace()) {
-                if (child !in commentsAndSpacesUsed) add(child!!) else break
+            if (child.isCommentOrSpace()) {
+                if (child !in commentsAndSpacesUsed) add(child) else break
             }
-            else if (!child!!.isEmptyElement()) {
-                collectCommentsAndSpacesAtStart(child!!)
+            else if (!child.isEmptyElement()) {
+                collectCommentsAndSpacesAtStart(child)
                 break
             }
-            child = child!!.getNextSibling()
+            child = child.getNextSibling()
         }
         return this
     }
@@ -268,14 +292,14 @@ class CodeBuilder(private val topElement: PsiElement?) {
     private fun MutableList.collectCommentsAndSpacesAtEnd(element: PsiElement): MutableList {
         var child = element.getLastChild()
         while(child != null) {
-            if (child!!.isCommentOrSpace()) {
-                if (child !in commentsAndSpacesUsed) add(child!!) else break
+            if (child.isCommentOrSpace()) {
+                if (child !in commentsAndSpacesUsed) add(child) else break
             }
-            else if (!child!!.isEmptyElement()) {
-                collectCommentsAndSpacesAtEnd(child!!)
+            else if (!child.isEmptyElement()) {
+                collectCommentsAndSpacesAtEnd(child)
                 break
             }
-            child = child!!.getPrevSibling()
+            child = child.getPrevSibling()
         }
         return this
     }
@@ -289,5 +313,11 @@ class CodeBuilder(private val topElement: PsiElement?) {
     private fun PsiWhiteSpace.newLinesCount() = StringUtil.getLineBreakCount(getText()!!)
 
     private fun PsiWhiteSpace.hasNewLines() = StringUtil.containsLineBreak(getText()!!)
+
+    private fun CharSequence.trailingLineBreakCount(): Int {
+        val index = ((length()-1 downTo 0).firstOrNull { val c = this[it]; c != '\n' && c != '\r' } ?: -1) + 1
+        if (index == length()) return 0
+        return StringUtil.getLineBreakCount(subSequence(index, length()))
+    }
 }
 
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
index 38163250d37..09c6f85f92e 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
@@ -214,7 +214,7 @@ class ConstructorConverter(
                                   if (isVal(converter.referenceSearcher, field)) Parameter.VarValModifier.Val else Parameter.VarValModifier.Var,
                                   converter.convertAnnotations(parameter) + converter.convertAnnotations(field),
                                   accessModifiers,
-                                  default).assignPrototypes(listOf(parameter, field), CommentsAndSpacesInheritance(blankLinesBefore = false))
+                                  default).assignPrototypes(listOf(parameter, field), CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
                     }
                 },
                 correctCodeConverter = { correct() })
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index 33652d8e338..afd00265d4a 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -244,7 +244,7 @@ class Converter private constructor(
 
     private fun convertAnnotationType(psiClass: PsiClass): Class {
         val paramModifiers = Modifiers(listOf(Modifier.PUBLIC)).assignNoPrototype()
-        val noBlankLinesInheritance = CommentsAndSpacesInheritance(blankLinesBefore = false)
+        val noBlankLinesInheritance = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE)
         val annotationMethods = psiClass.getMethods().filterIsInstance()
         val (methodsNamedValue, otherMethods) = annotationMethods.partition { it.getName() == "value" }
 
@@ -313,13 +313,14 @@ class Converter private constructor(
         }
 
         val name = correction?.identifier ?: field.declarationIdentifier()
-        val converted = if (field is PsiEnumConstant) {
+        if (field is PsiEnumConstant) {
             val argumentList = field.getArgumentList()
             val params = deferredElement { codeConverter ->
                 ExpressionList(codeConverter.convertExpressions(argumentList?.getExpressions() ?: arrayOf())).assignPrototype(argumentList)
             }
             val body = field.getInitializingClass()?.let { convertAnonymousClassBody(it) }
-            EnumConstant(name, annotations, modifiers, params, body)
+            return EnumConstant(name, annotations, modifiers, params, body)
+                    .assignPrototype(field, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS))
         }
         else {
             val isVal = isVal(referenceSearcher, field)
@@ -330,7 +331,7 @@ class Converter private constructor(
 
             addUsageProcessing(FieldToPropertyProcessing(field, correction?.name ?: field.getName(), propertyType.isNullable))
 
-            Property(name,
+            return Property(name,
                   annotations,
                   modifiers,
                   propertyType,
@@ -338,9 +339,8 @@ class Converter private constructor(
                   isVal,
                   typeToDeclare != null,
                   shouldGenerateDefaultInitializer(referenceSearcher, field),
-                  if (correction != null) correction.setterAccess else modifiers.accessModifier())
+                  if (correction != null) correction.setterAccess else modifiers.accessModifier()).assignPrototype(field)
         }
-        return converted.assignPrototype(field)
     }
 
     public fun variableTypeToDeclare(variable: PsiVariable, specifyAlways: Boolean, canChangeType: Boolean): Type? {
@@ -556,7 +556,7 @@ class Converter private constructor(
 
     public fun convertModifiers(owner: PsiModifierListOwner): Modifiers {
         return Modifiers(MODIFIERS_MAP.filter { owner.hasModifierProperty(it.first) }.map { it.second })
-                .assignPrototype(owner.getModifierList(), CommentsAndSpacesInheritance(blankLinesBefore = false))
+                .assignPrototype(owner.getModifierList(), CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
     }
 
     public fun convertAnonymousClassBody(anonymousClass: PsiAnonymousClass): AnonymousClassBody {
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/ClassBody.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/ClassBody.kt
index 6296b1ae361..3e5212860b6 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/ClassBody.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/ClassBody.kt
@@ -45,7 +45,7 @@ class ClassBody (
         else {
             val (constants, otherMembers) = membersFiltered.partition { it is EnumConstant }
 
-            builder.append(constants, ",\n")
+            builder.append(constants, ", ")
 
             if (otherMembers.isNotEmpty() || companionObjectMembers.isNotEmpty()) {
                 builder.append(";\n")
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
index d2190cb2d1e..951a74315d7 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
@@ -43,7 +43,7 @@ class PrimaryConstructor(
 
         // assign prototypes later because we don't know yet whether the body is empty or not
         converter.addPostUnfoldDeferredElementsAction {
-            val inheritance = CommentsAndSpacesInheritance(blankLinesBefore = false, commentsAfter = body!!.isEmpty, commentsInside = body.isEmpty)
+            val inheritance = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE, commentsAfter = body!!.isEmpty, commentsInside = body.isEmpty)
             signature.assignPrototypesFrom(this, inheritance)
         }
 
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
index 7a9a5ade433..5a976644444 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
@@ -45,10 +45,16 @@ fun  TElement.assignPrototypesFrom(element: Element, inherita
 
 data class PrototypeInfo(val element: PsiElement, val commentsAndSpacesInheritance: CommentsAndSpacesInheritance)
 
-data class CommentsAndSpacesInheritance(val blankLinesBefore: Boolean = true,
-                                        val commentsBefore: Boolean = true,
-                                        val commentsAfter: Boolean = true,
-                                        val commentsInside: Boolean = true)
+enum class SpacesInheritance {
+    NONE, BLANK_LINES_ONLY, LINE_BREAKS
+}
+
+data class CommentsAndSpacesInheritance(
+        val spacesBefore: SpacesInheritance = SpacesInheritance.BLANK_LINES_ONLY,
+        val commentsBefore: Boolean = true,
+        val commentsAfter: Boolean = true,
+        val commentsInside: Boolean = true
+)
 
 fun Element.canonicalCode(): String {
     val builder = CodeBuilder(null)
diff --git a/j2k/testData/fileOrElement/annotations/annotationInterface3.kt b/j2k/testData/fileOrElement/annotations/annotationInterface3.kt
index 5bdc3a19d4c..79b2338b2aa 100644
--- a/j2k/testData/fileOrElement/annotations/annotationInterface3.kt
+++ b/j2k/testData/fileOrElement/annotations/annotationInterface3.kt
@@ -2,8 +2,7 @@
 annotation class Anon(public val value: String) {
 
     public enum class E {
-        A,
-        B
+        A, B
     }
 
     companion object {
diff --git a/j2k/testData/fileOrElement/enum/fieldsWithPrimaryPrivateConstructor.kt b/j2k/testData/fileOrElement/enum/fieldsWithPrimaryPrivateConstructor.kt
index ddb41f893bf..f0f503b4628 100644
--- a/j2k/testData/fileOrElement/enum/fieldsWithPrimaryPrivateConstructor.kt
+++ b/j2k/testData/fileOrElement/enum/fieldsWithPrimaryPrivateConstructor.kt
@@ -1,7 +1,3 @@
 enum class Color private constructor(public val code: Int) {
-    WHITE(21),
-    BLACK(22),
-    RED(23),
-    YELLOW(24),
-    BLUE(25)
+    WHITE(21), BLACK(22), RED(23), YELLOW(24), BLUE(25)
 }
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/enum/overrideToString.kt b/j2k/testData/fileOrElement/enum/overrideToString.kt
index 0e183306785..7398b2f16ad 100644
--- a/j2k/testData/fileOrElement/enum/overrideToString.kt
+++ b/j2k/testData/fileOrElement/enum/overrideToString.kt
@@ -1,9 +1,5 @@
 enum class Color {
-    WHITE,
-    BLACK,
-    RED,
-    YELLOW,
-    BLUE;
+    WHITE, BLACK, RED, YELLOW, BLUE;
     override fun toString(): String {
         return "COLOR"
     }
diff --git a/j2k/testData/fileOrElement/enum/runnableImplementation.kt b/j2k/testData/fileOrElement/enum/runnableImplementation.kt
index 8cccda48f33..b98ef8c5fcd 100644
--- a/j2k/testData/fileOrElement/enum/runnableImplementation.kt
+++ b/j2k/testData/fileOrElement/enum/runnableImplementation.kt
@@ -1,9 +1,5 @@
 enum class Color : Runnable {
-    WHITE,
-    BLACK,
-    RED,
-    YELLOW,
-    BLUE;
+    WHITE, BLACK, RED, YELLOW, BLUE;
 
     override fun run() {
         println("name()=" + name() + ", toString()=" + toString())
diff --git a/j2k/testData/fileOrElement/enum/typeSafeEnum.kt b/j2k/testData/fileOrElement/enum/typeSafeEnum.kt
index d6b5b5b6992..efd813b561a 100644
--- a/j2k/testData/fileOrElement/enum/typeSafeEnum.kt
+++ b/j2k/testData/fileOrElement/enum/typeSafeEnum.kt
@@ -1,6 +1,3 @@
 enum class Coin {
-    PENNY,
-    NICKEL,
-    DIME,
-    QUARTER
+    PENNY, NICKEL, DIME, QUARTER
 }
\ No newline at end of file

From 6679a6912e8338d679c4587794814b1692469f81 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 13:06:39 +0300
Subject: [PATCH 048/450] Memory optimizations + more clear code

---
 .../org/jetbrains/kotlin/j2k/CodeBuilder.kt   | 86 +++++++++++++------
 1 file changed, 60 insertions(+), 26 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
index 1568b628fe5..299e78f8254 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.j2k
 import com.intellij.openapi.util.text.StringUtil
 import com.intellij.psi.*
 import com.intellij.psi.javadoc.PsiDocComment
+import com.intellij.util.SmartList
 import org.jetbrains.kotlin.j2k.ast.CommentsAndSpacesInheritance
 import org.jetbrains.kotlin.j2k.ast.Element
 import org.jetbrains.kotlin.j2k.ast.SpacesInheritance
 import org.jetbrains.kotlin.name.FqName
 import org.jetbrains.kotlin.psi.psiUtil.isAncestor
-import org.jetbrains.kotlin.utils.addIfNotNull
 import java.util.ArrayList
 import java.util.HashSet
 import java.util.LinkedHashSet
@@ -122,13 +122,13 @@ class CodeBuilder(private val topElement: PsiElement?) {
 
         val notInsideElements = HashSet()
         var prefix = Prefix.Empty
-        val postfixElements = ArrayList(1)
+        var postfix = emptyList()
         for ((prototype, inheritance) in element.prototypes!!) {
             assert(prototype !is PsiComment)
             assert(prototype !is PsiWhiteSpace)
             if (!topElement.isAncestor(prototype)) continue
             prefix += collectPrefixElements(prototype, inheritance, notInsideElements)
-            postfixElements.collectPostfixElements(prototype, inheritance, notInsideElements)
+            postfix += collectPostfixElements(prototype, inheritance, notInsideElements)
         }
 
         if (prefix.lineBreaksBefore > 0) {
@@ -155,15 +155,23 @@ class CodeBuilder(private val topElement: PsiElement?) {
             }
         }
 
-        postfixElements.forEach { appendCommentOrWhiteSpace(it) }
+        postfix.forEach { appendCommentOrWhiteSpace(it) }
 
         element.postGenerateCode(this)
 
         return this
     }
 
-    private data class Prefix(val elements: Collection, val lineBreaksBefore: Int) {
-        fun plus(other: Prefix) = Prefix(elements + other.elements, Math.max(lineBreaksBefore, other.lineBreaksBefore))
+    private data class Prefix(val elements: List, val lineBreaksBefore: Int) {
+        fun plus(other: Prefix): Prefix {
+            return when {
+                isEmpty() -> other
+                other.isEmpty() -> this
+                else -> Prefix(elements + other.elements, Math.max(lineBreaksBefore, other.lineBreaksBefore))
+            }
+        }
+
+        private fun isEmpty() = elements.isEmpty() && lineBreaksBefore == 0
 
         companion object {
             val Empty = Prefix(emptyList(), 0)
@@ -175,8 +183,8 @@ class CodeBuilder(private val topElement: PsiElement?) {
             inheritance: CommentsAndSpacesInheritance,
             notInsideElements: MutableSet
     ): Prefix {
-        val before = ArrayList(1).collectCommentsAndSpacesBefore(element)
-        val atStart = ArrayList(1).collectCommentsAndSpacesAtStart(element)
+        val before = SmartList().collectCommentsAndSpacesBefore(element)
+        val atStart = SmartList().collectCommentsAndSpacesAtStart(element)
         notInsideElements.addAll(atStart)
 
         if (inheritance.spacesBefore == SpacesInheritance.NONE && !inheritance.commentsBefore) return Prefix.Empty
@@ -210,13 +218,17 @@ class CodeBuilder(private val topElement: PsiElement?) {
         return Prefix(elements, lineBreaks)
     }
 
-    private fun MutableList.collectPostfixElements(element: PsiElement, inheritance: CommentsAndSpacesInheritance, notInsideElements: MutableSet) {
-        val atEnd = ArrayList(1).collectCommentsAndSpacesAtEnd(element)
+    private fun collectPostfixElements(
+            element: PsiElement,
+            inheritance: CommentsAndSpacesInheritance,
+            notInsideElements: MutableSet
+    ): List {
+        val atEnd = SmartList().collectCommentsAndSpacesAtEnd(element)
         notInsideElements.addAll(atEnd)
 
-        if (!inheritance.commentsAfter) return
+        if (!inheritance.commentsAfter) return emptyList()
 
-        val after = ArrayList(1).collectCommentsAndSpacesAfter(element)
+        val after = SmartList().collectCommentsAndSpacesAfter(element)
         if (after.isNotEmpty()) {
             val last = after.last()
             if (last is PsiWhiteSpace) {
@@ -224,11 +236,9 @@ class CodeBuilder(private val topElement: PsiElement?) {
             }
         }
 
-        addAll(atEnd.reverse())
-        addAll(after)
-
-        commentsAndSpacesUsed.addAll(atEnd)
-        commentsAndSpacesUsed.addAll(after)
+        val result = atEnd.reverse() + after
+        commentsAndSpacesUsed.addAll(result)
+        return result
     }
 
     private fun MutableList.collectCommentsAndSpacesBefore(element: PsiElement): MutableList {
@@ -304,20 +314,44 @@ class CodeBuilder(private val topElement: PsiElement?) {
         return this
     }
 
-    private fun PsiElement.isCommentOrSpace() = this is PsiComment || this is PsiWhiteSpace
+    private companion object {
+        fun List.plus(other: List): List {
+            when {
+                isEmpty() -> return other
 
-    private fun PsiElement.isEndOfLineComment() = this is PsiComment && getTokenType() == JavaTokenType.END_OF_LINE_COMMENT
+                other.isEmpty() -> return this
 
-    private fun PsiElement.isEmptyElement() = getFirstChild() == null && getTextLength() == 0
+                else -> {
+                    val result = ArrayList(size() + other.size())
+                    result.addAll(this)
+                    result.addAll(other)
+                    return result
+                }
+            }
+        }
 
-    private fun PsiWhiteSpace.newLinesCount() = StringUtil.getLineBreakCount(getText()!!)
+        fun List.reverse(): List {
+            return if (size() <= 1)
+                this
+            else
+                (this as Iterable).reverse()
+        }
 
-    private fun PsiWhiteSpace.hasNewLines() = StringUtil.containsLineBreak(getText()!!)
+        fun PsiElement.isCommentOrSpace() = this is PsiComment || this is PsiWhiteSpace
 
-    private fun CharSequence.trailingLineBreakCount(): Int {
-        val index = ((length()-1 downTo 0).firstOrNull { val c = this[it]; c != '\n' && c != '\r' } ?: -1) + 1
-        if (index == length()) return 0
-        return StringUtil.getLineBreakCount(subSequence(index, length()))
+        fun PsiElement.isEndOfLineComment() = this is PsiComment && getTokenType() == JavaTokenType.END_OF_LINE_COMMENT
+
+        fun PsiElement.isEmptyElement() = getFirstChild() == null && getTextLength() == 0
+
+        fun PsiWhiteSpace.newLinesCount() = StringUtil.getLineBreakCount(getText()!!)
+
+        fun PsiWhiteSpace.hasNewLines() = StringUtil.containsLineBreak(getText()!!)
+
+        fun CharSequence.trailingLineBreakCount(): Int {
+            val index = ((length()-1 downTo 0).firstOrNull { val c = this[it]; c != '\n' && c != '\r' } ?: -1) + 1
+            if (index == length()) return 0
+            return StringUtil.getLineBreakCount(subSequence(index, length()))
+        }
     }
 }
 

From 403549b9244af30f83c1f528d723abfcab68437b Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 13:08:11 +0300
Subject: [PATCH 049/450] Renames

---
 j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
index 299e78f8254..caf49caa4ca 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
@@ -192,7 +192,7 @@ class CodeBuilder(private val topElement: PsiElement?) {
         val firstSpace = before.lastOrNull() as? PsiWhiteSpace
         var lineBreaks = 0
         if (firstSpace != null) {
-            lineBreaks = firstSpace.newLinesCount()
+            lineBreaks = firstSpace.lineBreakCount()
             when (inheritance.spacesBefore) {
                 SpacesInheritance.NONE -> lineBreaks = 0
 
@@ -268,7 +268,7 @@ class CodeBuilder(private val topElement: PsiElement?) {
         val next = element.getNextSibling()
         if (next != null) {
             if (next.isCommentOrSpace()) {
-                if (next is PsiWhiteSpace && next.hasNewLines()) return this // do not attach anything on next line after element
+                if (next is PsiWhiteSpace && next.hasLineBreaks()) return this // do not attach anything on next line after element
                 if (next !in commentsAndSpacesUsed) {
                     add(next)
                     collectCommentsAndSpacesAfter(next)
@@ -343,9 +343,9 @@ class CodeBuilder(private val topElement: PsiElement?) {
 
         fun PsiElement.isEmptyElement() = getFirstChild() == null && getTextLength() == 0
 
-        fun PsiWhiteSpace.newLinesCount() = StringUtil.getLineBreakCount(getText()!!)
+        fun PsiWhiteSpace.lineBreakCount() = StringUtil.getLineBreakCount(getText()!!)
 
-        fun PsiWhiteSpace.hasNewLines() = StringUtil.containsLineBreak(getText()!!)
+        fun PsiWhiteSpace.hasLineBreaks() = StringUtil.containsLineBreak(getText()!!)
 
         fun CharSequence.trailingLineBreakCount(): Int {
             val index = ((length()-1 downTo 0).firstOrNull { val c = this[it]; c != '\n' && c != '\r' } ?: -1) + 1

From 1e988028a9380d0bac8dc6a06c6b222536f0133c Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 13:18:16 +0300
Subject: [PATCH 050/450] Optimization

---
 j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
index caf49caa4ca..17c9f2a3af7 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
@@ -83,8 +83,10 @@ class CodeBuilder(private val topElement: PsiElement?) {
             return this
         }
 
+        assert(text.indexOf('\r') < 0, "No '\\r' allowed")
+
         if (endOfLineCommentAtEnd) {
-            if (text[0] != '\n' && text[0] != '\r') builder.append('\n')
+            if (text[0] != '\n') builder.append('\n')
             endOfLineCommentAtEnd = false
         }
 
@@ -343,14 +345,16 @@ class CodeBuilder(private val topElement: PsiElement?) {
 
         fun PsiElement.isEmptyElement() = getFirstChild() == null && getTextLength() == 0
 
-        fun PsiWhiteSpace.lineBreakCount() = StringUtil.getLineBreakCount(getText()!!)
+        fun PsiWhiteSpace.lineBreakCount() = StringUtil.getLineBreakCount(getText())
 
-        fun PsiWhiteSpace.hasLineBreaks() = StringUtil.containsLineBreak(getText()!!)
+        fun PsiWhiteSpace.hasLineBreaks() = StringUtil.containsLineBreak(getText())
 
         fun CharSequence.trailingLineBreakCount(): Int {
-            val index = ((length()-1 downTo 0).firstOrNull { val c = this[it]; c != '\n' && c != '\r' } ?: -1) + 1
-            if (index == length()) return 0
-            return StringUtil.getLineBreakCount(subSequence(index, length()))
+            var i = length() - 1
+            while (i >= 0 && this[i] == '\n') {
+                i--
+            }
+            return length() - i - 1
         }
     }
 }

From fefb828faeab904d383e3f50c0a492ceaf866cac Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 13:42:15 +0300
Subject: [PATCH 051/450] J2K: preserving line breaks between parameters

---
 .../kotlin/j2k/ConstructorConverter.kt        |  6 ++++-
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt |  2 +-
 .../org/jetbrains/kotlin/j2k/ast/Element.kt   |  4 ++--
 .../lineBreaksBetweenParameters.java          | 23 +++++++++++++++++++
 .../lineBreaksBetweenParameters.kt            | 12 ++++++++++
 .../function/lineBreaksBetweenParameters.java | 19 +++++++++++++++
 .../function/lineBreaksBetweenParameters.kt   | 18 +++++++++++++++
 .../mutableCollections/FunctionParameters.kt  |  5 +++-
 ...otlinConverterForWebDemoTestGenerated.java | 12 ++++++++++
 ...otlinConverterSingleFileTestGenerated.java | 12 ++++++++++
 10 files changed, 108 insertions(+), 5 deletions(-)
 create mode 100644 j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java
 create mode 100644 j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.kt
 create mode 100644 j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java
 create mode 100644 j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.kt

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
index 09c6f85f92e..e71df65d718 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
@@ -214,7 +214,11 @@ class ConstructorConverter(
                                   if (isVal(converter.referenceSearcher, field)) Parameter.VarValModifier.Val else Parameter.VarValModifier.Var,
                                   converter.convertAnnotations(parameter) + converter.convertAnnotations(field),
                                   accessModifiers,
-                                  default).assignPrototypes(listOf(parameter, field), CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
+                                  default)
+                                .assignPrototypes(
+                                        PrototypeInfo(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)),
+                                        PrototypeInfo(field, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
+                                )
                     }
                 },
                 correctCodeConverter = { correct() })
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index afd00265d4a..ebee5e0a566 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -545,7 +545,7 @@ class Converter private constructor(
             Nullability.Nullable -> type = type.toNullableType()
         }
         return Parameter(parameter.declarationIdentifier(), type, varValModifier,
-                         convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter)
+                         convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS))
     }
 
     public fun convertIdentifier(identifier: PsiIdentifier?): Identifier {
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
index 5a976644444..bda0d3eb029 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
@@ -24,8 +24,8 @@ fun  TElement.assignPrototype(prototype: PsiElement?, inherit
     return this
 }
 
-fun  TElement.assignPrototypes(prototypes: List, inheritance: CommentsAndSpacesInheritance): TElement {
-    this.prototypes = prototypes.map { PrototypeInfo(it, inheritance) }
+fun  TElement.assignPrototypes(vararg prototypes: PrototypeInfo): TElement {
+    this.prototypes = prototypes.asList()
     return this
 }
 
diff --git a/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java b/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java
new file mode 100644
index 00000000000..dcdc479bd2a
--- /dev/null
+++ b/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java
@@ -0,0 +1,23 @@
+class C1 {
+  C1(int arg1,
+     int arg2,
+     int arg3) {
+  }
+
+  C1(int x,
+     int y) {
+      this(x, x + y, 0);
+  }
+}
+
+class C2 {
+  private int arg1;
+  private int arg2;
+
+  C2(int arg1,
+     int arg2,
+     int arg3) {
+      this.arg1 = arg1;
+      this.arg2 = arg2;
+  }
+}
diff --git a/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.kt b/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.kt
new file mode 100644
index 00000000000..76d12031d20
--- /dev/null
+++ b/j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.kt
@@ -0,0 +1,12 @@
+class C1(arg1: Int,
+         arg2: Int,
+         arg3: Int) {
+
+    constructor(x: Int,
+                y: Int) : this(x, x + y, 0) {
+    }
+}
+
+class C2(private val arg1: Int,
+         private val arg2: Int,
+         arg3: Int)
diff --git a/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java b/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java
new file mode 100644
index 00000000000..57e90347270
--- /dev/null
+++ b/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java
@@ -0,0 +1,19 @@
+class C {
+    public void foo1(int p1, int p2) {
+    }
+
+    public void foo2(
+            int p1,
+            int p2) {
+    }
+
+    public void foo3(int p1,
+            int p2) {
+    }
+
+    public void foo4(
+            int p1, int p2,
+            int p3, int p4
+    ) {
+    }
+}
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.kt b/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.kt
new file mode 100644
index 00000000000..959616fa353
--- /dev/null
+++ b/j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.kt
@@ -0,0 +1,18 @@
+class C {
+    public fun foo1(p1: Int, p2: Int) {
+    }
+
+    public fun foo2(
+            p1: Int,
+            p2: Int) {
+    }
+
+    public fun foo3(p1: Int,
+                    p2: Int) {
+    }
+
+    public fun foo4(
+            p1: Int, p2: Int,
+            p3: Int, p4: Int) {
+    }
+}
diff --git a/j2k/testData/fileOrElement/mutableCollections/FunctionParameters.kt b/j2k/testData/fileOrElement/mutableCollections/FunctionParameters.kt
index d6f0a1f5546..0d7419538a0 100644
--- a/j2k/testData/fileOrElement/mutableCollections/FunctionParameters.kt
+++ b/j2k/testData/fileOrElement/mutableCollections/FunctionParameters.kt
@@ -2,7 +2,10 @@
 import java.util.*
 
 class A {
-    fun foo(nonMutableCollection: Collection, mutableCollection: MutableCollection, mutableSet: MutableSet, mutableMap: MutableMap) {
+    fun foo(nonMutableCollection: Collection,
+            mutableCollection: MutableCollection,
+            mutableSet: MutableSet,
+            mutableMap: MutableMap) {
         mutableCollection.addAll(nonMutableCollection)
         mutableSet.add(mutableMap.remove("a"))
     }
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
index aaa0fa2214b..aab181c0227 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
@@ -1162,6 +1162,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaksBetweenParameters.java")
+        public void testLineBreaksBetweenParameters() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("methodCallInFactoryFun.java")
         public void testMethodCallInFactoryFun() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/methodCallInFactoryFun.java");
@@ -2224,6 +2230,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaksBetweenParameters.java")
+        public void testLineBreaksBetweenParameters() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("main.java")
         public void testMain() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/main.java");
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
index 536b309d158..0f2bcfcf5e9 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
@@ -1162,6 +1162,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaksBetweenParameters.java")
+        public void testLineBreaksBetweenParameters() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/lineBreaksBetweenParameters.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("methodCallInFactoryFun.java")
         public void testMethodCallInFactoryFun() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/constructors/methodCallInFactoryFun.java");
@@ -2224,6 +2230,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaksBetweenParameters.java")
+        public void testLineBreaksBetweenParameters() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/lineBreaksBetweenParameters.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("main.java")
         public void testMain() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/function/main.java");

From 40fe680acf1fe74f5b1ef54f7266a27cf890b16f Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 14:01:38 +0300
Subject: [PATCH 052/450] J2K: preserving line breaks between arguments

---
 .../kotlin/j2k/ExpressionConverter.kt          | 18 ++++++++++++------
 .../formatting/lineBreaksBetweenArguments.java | 10 ++++++++++
 .../formatting/lineBreaksBetweenArguments.kt   | 10 ++++++++++
 .../newClassExpression/lineBreaks.java         | 11 +++++++++++
 .../newClassExpression/lineBreaks.kt           |  9 +++++++++
 ...KotlinConverterForWebDemoTestGenerated.java | 12 ++++++++++++
 ...KotlinConverterSingleFileTestGenerated.java | 12 ++++++++++++
 7 files changed, 76 insertions(+), 6 deletions(-)
 create mode 100644 j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java
 create mode 100644 j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.kt
 create mode 100644 j2k/testData/fileOrElement/newClassExpression/lineBreaks.java
 create mode 100644 j2k/testData/fileOrElement/newClassExpression/lineBreaks.kt

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
index 123bce71e6b..5563b1a7678 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
@@ -479,21 +479,27 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
         if (isExtension && arguments.isNotEmpty()) {
             arguments = arguments.drop(1)
         }
+
         val resolved = expression.resolveMethod()
         val parameters = resolved?.getParameterList()?.getParameters()
         val expectedTypes = parameters?.map { it.getType() } ?: listOf()
 
-        return if (arguments.size() == expectedTypes.size())
-            (0..arguments.lastIndex).map { i ->
+        val commentsAndSpacesInheritance = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)
+
+        return if (arguments.size() == expectedTypes.size()) {
+            arguments.indices.map { i ->
                 val argument = arguments[i]
                 val converted = codeConverter.convertExpression(argument, expectedTypes[i])
-                if (parameters != null && i == arguments.lastIndex && parameters[i].isVarArgs() && argument.getType() is PsiArrayType)
-                    StarExpression(converted).assignNoPrototype()
+                val result = if (parameters != null && i == arguments.lastIndex && parameters[i].isVarArgs() && argument.getType() is PsiArrayType)
+                    StarExpression(converted)
                 else
                     converted
+                result.assignPrototype(argument, commentsAndSpacesInheritance)
             }
-        else
-            arguments.map { codeConverter.convertExpression(it) }
+        }
+        else {
+            arguments.map { codeConverter.convertExpression(it).assignPrototype(it, commentsAndSpacesInheritance) }
+        }
     }
 
     private fun getOperatorString(tokenType: IElementType): String {
diff --git a/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java b/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java
new file mode 100644
index 00000000000..987e612778f
--- /dev/null
+++ b/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java
@@ -0,0 +1,10 @@
+class F {
+  void f1(int p1, int p2, int p3, int p4, int... p5) {
+  }
+
+  void f2(int[] array) {
+    f1(1, 2,
+       3, 4,
+       array);
+  }
+}
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.kt b/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.kt
new file mode 100644
index 00000000000..f9674a2a7eb
--- /dev/null
+++ b/j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.kt
@@ -0,0 +1,10 @@
+class F {
+    fun f1(p1: Int, p2: Int, p3: Int, p4: Int, vararg p5: Int) {
+    }
+
+    fun f2(array: IntArray) {
+        f1(1, 2,
+                3, 4,
+                *array)
+    }
+}
diff --git a/j2k/testData/fileOrElement/newClassExpression/lineBreaks.java b/j2k/testData/fileOrElement/newClassExpression/lineBreaks.java
new file mode 100644
index 00000000000..d146592c022
--- /dev/null
+++ b/j2k/testData/fileOrElement/newClassExpression/lineBreaks.java
@@ -0,0 +1,11 @@
+class C {
+  C(int p1, int p2, int p3){}
+}
+
+class User {
+  void foo() {
+    new C(1,
+          2,
+          3);
+  }
+}
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/newClassExpression/lineBreaks.kt b/j2k/testData/fileOrElement/newClassExpression/lineBreaks.kt
new file mode 100644
index 00000000000..0360b5286d6
--- /dev/null
+++ b/j2k/testData/fileOrElement/newClassExpression/lineBreaks.kt
@@ -0,0 +1,9 @@
+class C(p1: Int, p2: Int, p3: Int)
+
+class User {
+    fun foo() {
+        C(1,
+                2,
+                3)
+    }
+}
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
index aab181c0227..f8fa544604a 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
@@ -2155,6 +2155,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/formatting"), Pattern.compile("^(.+)\\.java$"), true);
         }
 
+        @TestMetadata("lineBreaksBetweenArguments.java")
+        public void testLineBreaksBetweenArguments() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("nonStaticMembers.java")
         public void testNonStaticMembers() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/formatting/nonStaticMembers.java");
@@ -3223,6 +3229,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaks.java")
+        public void testLineBreaks() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/newClassExpression/lineBreaks.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("newAnonymousClass.java")
         public void testNewAnonymousClass() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/newClassExpression/newAnonymousClass.java");
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
index 0f2bcfcf5e9..2446d95b0fc 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
@@ -2155,6 +2155,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("j2k/testData/fileOrElement/formatting"), Pattern.compile("^(.+)\\.java$"), true);
         }
 
+        @TestMetadata("lineBreaksBetweenArguments.java")
+        public void testLineBreaksBetweenArguments() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/formatting/lineBreaksBetweenArguments.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("nonStaticMembers.java")
         public void testNonStaticMembers() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/formatting/nonStaticMembers.java");
@@ -3223,6 +3229,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("lineBreaks.java")
+        public void testLineBreaks() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/newClassExpression/lineBreaks.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("newAnonymousClass.java")
         public void testNewAnonymousClass() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/newClassExpression/newAnonymousClass.java");

From e9b4045eace378d4da299eb24c96a976c0cc139a Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Mon, 22 Jun 2015 16:48:11 +0300
Subject: [PATCH 053/450] Fixed test data

---
 .../copyPaste/conversion/ClassWithNoDocComment.expected.kt   | 1 +
 .../copyPaste/conversion/SeveralMethodsSample.expected.kt    | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/idea/testData/copyPaste/conversion/ClassWithNoDocComment.expected.kt b/idea/testData/copyPaste/conversion/ClassWithNoDocComment.expected.kt
index 11ae5fc5a80..db736576254 100644
--- a/idea/testData/copyPaste/conversion/ClassWithNoDocComment.expected.kt
+++ b/idea/testData/copyPaste/conversion/ClassWithNoDocComment.expected.kt
@@ -2,5 +2,6 @@ package to
 
 public class JavaClass : Runnable {
     override fun run() {
+
     }
 }
diff --git a/idea/testData/copyPaste/conversion/SeveralMethodsSample.expected.kt b/idea/testData/copyPaste/conversion/SeveralMethodsSample.expected.kt
index 891dd895f64..e938d94ba9c 100644
--- a/idea/testData/copyPaste/conversion/SeveralMethodsSample.expected.kt
+++ b/idea/testData/copyPaste/conversion/SeveralMethodsSample.expected.kt
@@ -11,7 +11,10 @@ class A {
             if (declarationDescriptor is CallableMemberDescriptor) {
                 val containingDescriptor = declarationDescriptor.getContainingDeclaration()
                 if (containingDescriptor is ClassDescriptor) {
-                    return JetBundle.message("x.in.y", DescriptorRenderer.COMPACT.render(declarationDescriptor), IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor))
+                    return JetBundle.message(
+                            "x.in.y",
+                            DescriptorRenderer.COMPACT.render(declarationDescriptor),
+                            IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(containingDescriptor))
                 }
             }
         }

From d3402280c5eafc09675fa9609df435ad61538b52 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 16:22:44 +0300
Subject: [PATCH 054/450] Extracted methods

---
 .../kotlin/j2k/AnnotationConverter.kt         | 71 ++++++++++---------
 1 file changed, 39 insertions(+), 32 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
index c23ed641926..1c350af296e 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
@@ -120,47 +120,54 @@ class AnnotationConverter(private val converter: Converter) {
     }
 
     private fun convertAttributeValue(value: PsiAnnotationMemberValue?, expectedType: PsiType?, isVararg: Boolean, isUnnamed: Boolean): List<(CodeConverter) -> Expression> {
-        when (value) {
-            is PsiExpression -> {
-                return listOf({ codeConverter ->
-                                  val expression = if (value is PsiClassObjectAccessExpression) {
-                                      val typeElement = converter.convertTypeElement(value.getOperand())
-                                      ClassLiteralExpression(typeElement.type.toNotNullType())
-                                  }
-                                  else {
-                                      codeConverter.convertExpression(value, expectedType)
-                                  }
-                                  expression.assignPrototype(value)
-                              })
-            }
+        return when (value) {
+            is PsiExpression -> listOf({ codeConverter -> convertExpressionValue(codeConverter, value, expectedType) })
 
             is PsiArrayInitializerMemberValue -> {
                 val componentType = (expectedType as? PsiArrayType)?.getComponentType()
-                val componentsConverted = value.getInitializers().map { convertAttributeValue(it, componentType, false, true).single() }
+                val componentGenerators = value.getInitializers().map { convertAttributeValue(it, componentType, false, true).single() }
                 if (isVararg && isUnnamed) {
-                    return componentsConverted
+                    componentGenerators
                 }
                 else {
-                    val expressionGenerator = { codeConverter: CodeConverter ->
-                        val expectedTypeConverted = converter.typeConverter.convertType(expectedType)
-                        if (expectedTypeConverted is ArrayType) {
-                            val array = createArrayInitializerExpression(expectedTypeConverted, componentsConverted.map { it(codeConverter) }, needExplicitType = false)
-                            if (isVararg) {
-                                StarExpression(array.assignNoPrototype()).assignPrototype(value)
-                            }
-                            else {
-                                array.assignPrototype(value)
-                            }
-                        }
-                        else {
-                            DummyStringExpression(value.getText()!!).assignPrototype(value)
-                        }
-                    }
-                    return listOf(expressionGenerator)
+                    listOf({ codeConverter -> convertArrayInitializerValue(codeConverter, value, componentGenerators, expectedType, isVararg) })
                 }
             }
 
-            else -> return listOf({ codeConverter -> DummyStringExpression(value?.getText() ?: "").assignPrototype(value) })
+            else -> listOf({ codeConverter -> DummyStringExpression(value?.getText() ?: "").assignPrototype(value) })
+        }
+    }
+
+    private fun convertExpressionValue(codeConverter: CodeConverter, value: PsiExpression, expectedType: PsiType?): Expression {
+        val expression = if (value is PsiClassObjectAccessExpression) {
+            val typeElement = converter.convertTypeElement(value.getOperand())
+            ClassLiteralExpression(typeElement.type.toNotNullType())
+        }
+        else {
+            codeConverter.convertExpression(value, expectedType)
+        }
+        return expression.assignPrototype(value)
+    }
+
+    private fun convertArrayInitializerValue(
+            codeConverter: CodeConverter,
+            value: PsiArrayInitializerMemberValue,
+            componentGenerators: List<(CodeConverter) -> Expression>,
+            expectedType: PsiType?,
+            isVararg: Boolean
+    ): Expression {
+        val expectedTypeConverted = converter.typeConverter.convertType(expectedType)
+        return if (expectedTypeConverted is ArrayType) {
+            val array = createArrayInitializerExpression(expectedTypeConverted, componentGenerators.map { it(codeConverter) }, needExplicitType = false)
+            if (isVararg) {
+                StarExpression(array.assignNoPrototype()).assignPrototype(value)
+            }
+            else {
+                array.assignPrototype(value)
+            }
+        }
+        else {
+            DummyStringExpression(value.getText()!!).assignPrototype(value)
         }
     }
 }

From 67cf180abad4fd66e8373d25917dc3ee6da4d276 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 16:37:51 +0300
Subject: [PATCH 055/450] Code clarification

---
 .../org/jetbrains/kotlin/j2k/CodeBuilder.kt   |  4 ++--
 .../jetbrains/kotlin/j2k/ast/Annotation.kt    | 22 ++++++++++---------
 .../ArrayWithoutInitializationExpression.kt   |  1 -
 j2k/src/org/jetbrains/kotlin/j2k/ast/Class.kt |  5 ++++-
 .../jetbrains/kotlin/j2k/ast/LocalVariable.kt |  1 -
 .../kotlin/j2k/ast/TypeParameters.kt          |  5 ++++-
 6 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
index 17c9f2a3af7..3603fc5c1a9 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt
@@ -30,7 +30,7 @@ import java.util.HashSet
 import java.util.LinkedHashSet
 import kotlin.platform.platformName
 
-fun CodeBuilder.append(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
+fun CodeBuilder.buildList(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
     if (generators.isNotEmpty()) {
         append(prefix)
         var first = true
@@ -48,7 +48,7 @@ fun CodeBuilder.append(generators: Collection<() -> T>, separator: String, pr
 
 platformName("appendElements")
 fun CodeBuilder.append(elements: Collection, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
-    return append(elements.filter { !it.isEmpty }.map { { append(it) } }, separator, prefix, suffix)
+    return buildList(elements.filter { !it.isEmpty }.map { { append(it) } }, separator, prefix, suffix)
 }
 
 class ElementCreationStackTraceRequiredException : RuntimeException()
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
index 489ce3ec83b..b0854e517de 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
@@ -27,16 +27,18 @@ class Annotation(val name: Identifier, val arguments: List) : Expression() {
     override fun generateCode(builder: CodeBuilder) {
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Class.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Class.kt
index c116e104a7f..e0fae4b5f34 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Class.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Class.kt
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.j2k.ast
 
 import org.jetbrains.kotlin.j2k.CodeBuilder
 import org.jetbrains.kotlin.j2k.append
+import org.jetbrains.kotlin.j2k.buildList
 
 open class Class(
         val name: Identifier,
@@ -52,7 +53,9 @@ open class Class(
         get() = "class"
 
     protected fun appendBaseTypes(builder: CodeBuilder) {
-        builder.append(baseClassSignatureWithParams(builder) + implementsTypes.map { { builder.append(it) } }, ", ", ":")
+        builder.buildList(generators = baseClassSignatureWithParams(builder) + implementsTypes.map { { builder.append(it) } },
+                          separator = ", ",
+                          prefix = ":")
     }
 
     private fun baseClassSignatureWithParams(builder: CodeBuilder): List<() -> CodeBuilder> {
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/LocalVariable.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/LocalVariable.kt
index b0a99b91121..7405b75c015 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/LocalVariable.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/LocalVariable.kt
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.j2k.ast
 
 import org.jetbrains.kotlin.j2k.ConverterSettings
 import org.jetbrains.kotlin.j2k.CodeBuilder
-import org.jetbrains.kotlin.j2k.append
 
 class LocalVariable(
         private val identifier: Identifier,
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/TypeParameters.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/TypeParameters.kt
index 38db2f9827c..0c98ac4c477 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/TypeParameters.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/TypeParameters.kt
@@ -44,7 +44,10 @@ class TypeParameterList(val parameters: List) : Element() {
 
     fun appendWhere(builder: CodeBuilder): CodeBuilder {
         if (hasWhere()) {
-            builder.append( parameters.map { { it.whereToKotlin(builder) } }, ", ", " where ", "")
+            builder.buildList(generators = parameters.map { { it.whereToKotlin(builder) } },
+                              separator = ", ",
+                              prefix = " where ",
+                              suffix = "")
         }
         return builder
     }

From 8e3c79376092950b99edf38bb2c92fd2c0761657 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 16 Jun 2015 16:42:33 +0300
Subject: [PATCH 056/450] Used named arguments for clarity

---
 j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt | 6 +++---
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt           | 6 +++---
 j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt      | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
index 1c350af296e..cbfb430dce1 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/AnnotationConverter.kt
@@ -48,7 +48,7 @@ class AnnotationConverter(private val converter: Converter) {
                 if (child is PsiWhiteSpace) !child.isInSingleLine() else false
             }
 
-            annotations.map { convertAnnotation(it, owner is PsiLocalVariable, newLines) }.filterNotNull() //TODO: brackets are also needed for local classes
+            annotations.map { convertAnnotation(it, withAt = owner is PsiLocalVariable, newLineAfter = newLines) }.filterNotNull() //TODO: '@' is also needed for local classes
         }
         else {
             listOf()
@@ -70,14 +70,14 @@ class AnnotationConverter(private val converter: Converter) {
             LiteralExpression("\"" + StringUtil.escapeStringCharacters(deprecatedTag.content()) + "\"").assignNoPrototype()
         }
         return Annotation(Identifier("deprecated").assignPrototype(deprecatedTag.getNameElement()),
-                          listOf(null to deferredExpression), false, true)
+                          listOf(null to deferredExpression), withAt = false, newLineAfter = true)
                 .assignPrototype(deprecatedTag)
     }
 
     private fun convertModifiersToAnnotations(owner: PsiModifierListOwner): Annotations {
         val list = MODIFIER_TO_ANNOTATION
                 .filter { owner.hasModifierProperty(it.first) }
-                .map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), false, false).assignNoPrototype() }
+                .map { Annotation(Identifier(it.second).assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype() }
         return Annotations(list).assignNoPrototype()
     }
 
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index ebee5e0a566..d67ac3661c0 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -113,7 +113,7 @@ class Converter private constructor(
         is PsiExpression -> createDefaultCodeConverter().convertExpression(element)
         is PsiImportList -> convertImportList(element)
         is PsiImportStatementBase -> convertImport(element, false)
-        is PsiAnnotation -> annotationConverter.convertAnnotation(element, false, false)
+        is PsiAnnotation -> annotationConverter.convertAnnotation(element, withAt = false, newLineAfter = false)
         is PsiPackageStatement -> PackageStatement(quoteKeywords(element.getPackageName() ?: "")).assignPrototype(element)
         else -> null
     }
@@ -288,7 +288,7 @@ class Converter private constructor(
         classBody = ClassBody(constructorSignature, classBody.baseClassParams, classBody.members,
                               classBody.companionObjectMembers, classBody.lBrace, classBody.rBrace, classBody.isEnumBody)
 
-        val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), false, false).assignNoPrototype()
+        val annotationAnnotation = Annotation(Identifier("annotation").assignNoPrototype(), listOf(), withAt = false, newLineAfter = false).assignNoPrototype()
         return Class(psiClass.declarationIdentifier(),
                      convertAnnotations(psiClass) + Annotations(listOf(annotationAnnotation)),
                      convertModifiers(psiClass).without(Modifier.ABSTRACT),
@@ -581,7 +581,7 @@ class Converter private constructor(
             val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
             null to deferredElement { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) }
         }
-        val annotation = Annotation(Identifier("throws").assignNoPrototype(), arguments, false, true)
+        val annotation = Annotation(Identifier("throws").assignNoPrototype(), arguments, withAt = false, newLineAfter = true)
         return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList)
     }
 
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
index b0854e517de..8096dd9e840 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
@@ -65,4 +65,4 @@ class Annotations(val annotations: List) : Element() {
 }
 
 fun Annotations.withAt(): Annotations
-        = Annotations(annotations.map { Annotation(it.name, it.arguments, true, it.newLineAfter).assignPrototypesFrom(it) }).assignPrototypesFrom(this)
+        = Annotations(annotations.map { Annotation(it.name, it.arguments, withAt = true, newLineAfter = it.newLineAfter).assignPrototypesFrom(it) }).assignPrototypesFrom(this)

From 767e21db760409b32cad2f1f94b9191f6d0a9c8a Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Mon, 22 Jun 2015 15:54:16 +0300
Subject: [PATCH 057/450] J2K - no '@' required for primary constructor
 annnotations

---
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt               | 2 +-
 j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt          | 3 ---
 j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt        | 2 +-
 .../annotations/primaryConstructorAnnotation.java           | 5 +++++
 .../annotations/primaryConstructorAnnotation.kt             | 2 ++
 .../fileOrElement/comments/commentsForConstructors.kt       | 2 +-
 j2k/testData/fileOrElement/constructors/allCallsPrimary.kt  | 2 +-
 .../fileOrElement/constructors/constructorAnnotations.kt    | 6 +++---
 .../constructors/fieldsInitializedFromParams9.kt            | 2 +-
 .../constructors/nestedClassNameInParameterDefaults.kt      | 2 +-
 .../constructors/nestedClassNameInParameterDefaults2.kt     | 2 +-
 .../constructors/nestedClassNameInParameterDefaults3.kt     | 2 +-
 .../constructors/nestedClassNameInParameterDefaults4.kt     | 2 +-
 .../fileOrElement/constructors/parameterDefaults1.kt        | 2 +-
 .../fileOrElement/constructors/parameterDefaults2.kt        | 2 +-
 .../fileOrElement/constructors/parameterDefaults3.kt        | 2 +-
 .../fileOrElement/constructors/parameterDefaults4.kt        | 2 +-
 .../fileOrElement/constructors/parameterDefaults5.kt        | 2 +-
 .../fileOrElement/constructors/parameterModification.kt     | 2 +-
 .../fileOrElement/constructors/privateConstructors.kt       | 2 +-
 .../DifferentFieldNameAndDefaultParameterValue.kt           | 2 +-
 .../j2k/JavaToKotlinConverterForWebDemoTestGenerated.java   | 6 ++++++
 .../j2k/JavaToKotlinConverterSingleFileTestGenerated.java   | 6 ++++++
 23 files changed, 39 insertions(+), 23 deletions(-)
 create mode 100644 j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java
 create mode 100644 j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.kt

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index d67ac3661c0..1d4206866c7 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -431,7 +431,7 @@ class Converter private constructor(
             function.annotations += Annotations(
                     listOf(Annotation(Identifier("jvmOverloads").assignNoPrototype(),
                                       listOf(),
-                                      withAt = function is PrimaryConstructor,
+                                      withAt = false,
                                       newLineAfter = false).assignNoPrototype())).assignNoPrototype()
         }
 
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
index 8096dd9e840..70596948153 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Annotation.kt
@@ -63,6 +63,3 @@ class Annotations(val annotations: List) : Element() {
         val Empty = Annotations(listOf())
     }
 }
-
-fun Annotations.withAt(): Annotations
-        = Annotations(annotations.map { Annotation(it.name, it.arguments, withAt = true, newLineAfter = it.newLineAfter).assignPrototypesFrom(it) }).assignPrototypesFrom(this)
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
index 951a74315d7..55bfc95cf58 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Constructors.kt
@@ -61,7 +61,7 @@ class PrimaryConstructorSignature(val annotations: Annotations, private val modi
         var needConstructorKeyword = false
 
         if (!annotations.isEmpty) {
-            builder append " " append annotations.withAt()
+            builder append " " append annotations
             needConstructorKeyword = true
         }
 
diff --git a/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java b/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java
new file mode 100644
index 00000000000..d7884d7a6e0
--- /dev/null
+++ b/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java
@@ -0,0 +1,5 @@
+class C {
+    @Deprecated
+    public C() {
+    }
+}
diff --git a/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.kt b/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.kt
new file mode 100644
index 00000000000..6ec023e61cf
--- /dev/null
+++ b/j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.kt
@@ -0,0 +1,2 @@
+class C deprecated("")
+constructor()
diff --git a/j2k/testData/fileOrElement/comments/commentsForConstructors.kt b/j2k/testData/fileOrElement/comments/commentsForConstructors.kt
index 65143384217..d957586d9c2 100644
--- a/j2k/testData/fileOrElement/comments/commentsForConstructors.kt
+++ b/j2k/testData/fileOrElement/comments/commentsForConstructors.kt
@@ -1,5 +1,5 @@
 class A// this is a primary constructor
-@jvmOverloads constructor(p: Int = 1) {
+jvmOverloads constructor(p: Int = 1) {
     private val v: Int
 
     init {
diff --git a/j2k/testData/fileOrElement/constructors/allCallsPrimary.kt b/j2k/testData/fileOrElement/constructors/allCallsPrimary.kt
index 641f352b3e2..f27f523b4c2 100644
--- a/j2k/testData/fileOrElement/constructors/allCallsPrimary.kt
+++ b/j2k/testData/fileOrElement/constructors/allCallsPrimary.kt
@@ -1,6 +1,6 @@
 package pack
 
-class C @jvmOverloads constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0)
+class C jvmOverloads constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0)
 
 public object User {
     public fun main() {
diff --git a/j2k/testData/fileOrElement/constructors/constructorAnnotations.kt b/j2k/testData/fileOrElement/constructors/constructorAnnotations.kt
index 6f0536e2457..8c7fca9b05e 100644
--- a/j2k/testData/fileOrElement/constructors/constructorAnnotations.kt
+++ b/j2k/testData/fileOrElement/constructors/constructorAnnotations.kt
@@ -1,7 +1,7 @@
 import javaApi.Anon5
 
 class A
-@Anon5(10)
+Anon5(10)
 constructor(private val a: Int, private val b: Int) {
 
     deprecated("") // this constructor will not be replaced by default parameter value in primary because of this annotation
@@ -9,8 +9,8 @@ constructor(private val a: Int, private val b: Int) {
     }
 }
 
-class B @Anon5(11)
+class B Anon5(11)
 constructor()
 
-class C @Anon5(12)
+class C Anon5(12)
 private constructor()
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/constructors/fieldsInitializedFromParams9.kt b/j2k/testData/fileOrElement/constructors/fieldsInitializedFromParams9.kt
index 88d23a2e9b6..e4d9bad2519 100644
--- a/j2k/testData/fileOrElement/constructors/fieldsInitializedFromParams9.kt
+++ b/j2k/testData/fileOrElement/constructors/fieldsInitializedFromParams9.kt
@@ -1 +1 @@
-class C @jvmOverloads constructor(private val string: String, a: Int = string.length())
+class C jvmOverloads constructor(private val string: String, a: Int = string.length())
diff --git a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults.kt b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults.kt
index 4cfc913d2e3..76de64b2e04 100644
--- a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults.kt
+++ b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults.kt
@@ -1,4 +1,4 @@
-class A @jvmOverloads constructor(nested: A.Nested = A.Nested(A.Nested.FIELD)) {
+class A jvmOverloads constructor(nested: A.Nested = A.Nested(A.Nested.FIELD)) {
 
     class Nested(p: Int) {
         companion object {
diff --git a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults2.kt b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults2.kt
index 47b34921a92..574888bb3c2 100644
--- a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults2.kt
+++ b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults2.kt
@@ -1,7 +1,7 @@
 // ERROR: Property must be initialized or be abstract
 import A.Nested
 
-class A @jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
+class A jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
 
     class Nested(p: Int) {
         companion object {
diff --git a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults3.kt b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults3.kt
index 02974eb4e03..8b2dbc2204f 100644
--- a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults3.kt
+++ b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults3.kt
@@ -3,7 +3,7 @@ package pack
 
 import pack.A.Nested
 
-class A @jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
+class A jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
 
     class Nested(p: Int) {
         companion object {
diff --git a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults4.kt b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults4.kt
index 54cda87bb39..7b9aabf0fff 100644
--- a/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults4.kt
+++ b/j2k/testData/fileOrElement/constructors/nestedClassNameInParameterDefaults4.kt
@@ -3,7 +3,7 @@ package pack
 
 import pack.A.*
 
-class A @jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
+class A jvmOverloads constructor(nested: Nested = Nested(Nested.FIELD)) {
 
     class Nested(p: Int) {
         companion object {
diff --git a/j2k/testData/fileOrElement/constructors/parameterDefaults1.kt b/j2k/testData/fileOrElement/constructors/parameterDefaults1.kt
index 969d9e5859d..be71bc80587 100644
--- a/j2k/testData/fileOrElement/constructors/parameterDefaults1.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterDefaults1.kt
@@ -1,6 +1,6 @@
 package pack
 
-class C @jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
+class C jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
 
     constructor(a: Int) : this(a, 0, 0, 0, 1) {
     }
diff --git a/j2k/testData/fileOrElement/constructors/parameterDefaults2.kt b/j2k/testData/fileOrElement/constructors/parameterDefaults2.kt
index 06fd8dd541c..f78ffe62d4f 100644
--- a/j2k/testData/fileOrElement/constructors/parameterDefaults2.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterDefaults2.kt
@@ -1,6 +1,6 @@
 package pack
 
-class C @jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
+class C jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
 
     constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) {
     }
diff --git a/j2k/testData/fileOrElement/constructors/parameterDefaults3.kt b/j2k/testData/fileOrElement/constructors/parameterDefaults3.kt
index fb0f2dcd634..3ed89327e4c 100644
--- a/j2k/testData/fileOrElement/constructors/parameterDefaults3.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterDefaults3.kt
@@ -1,6 +1,6 @@
 package pack
 
-class C @jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
+class C jvmOverloads constructor(a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
 
     constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) {
     }
diff --git a/j2k/testData/fileOrElement/constructors/parameterDefaults4.kt b/j2k/testData/fileOrElement/constructors/parameterDefaults4.kt
index 66e6bbb9d8c..c37cbf22911 100644
--- a/j2k/testData/fileOrElement/constructors/parameterDefaults4.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterDefaults4.kt
@@ -1,3 +1,3 @@
 package pack
 
-class C @jvmOverloads constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
+class C jvmOverloads constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
diff --git a/j2k/testData/fileOrElement/constructors/parameterDefaults5.kt b/j2k/testData/fileOrElement/constructors/parameterDefaults5.kt
index 66e6bbb9d8c..c37cbf22911 100644
--- a/j2k/testData/fileOrElement/constructors/parameterDefaults5.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterDefaults5.kt
@@ -1,3 +1,3 @@
 package pack
 
-class C @jvmOverloads constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
+class C jvmOverloads constructor(a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
diff --git a/j2k/testData/fileOrElement/constructors/parameterModification.kt b/j2k/testData/fileOrElement/constructors/parameterModification.kt
index 242266a8493..913e836e98c 100644
--- a/j2k/testData/fileOrElement/constructors/parameterModification.kt
+++ b/j2k/testData/fileOrElement/constructors/parameterModification.kt
@@ -1,5 +1,5 @@
 // ERROR: Overload resolution ambiguity:  public constructor C(arg1: kotlin.Int, arg2: kotlin.Int) defined in C kotlin.jvm.jvmOverloads public constructor C(arg1: kotlin.Int, arg2: kotlin.Int = ..., arg3: kotlin.Int = ...) defined in C
-class C @jvmOverloads constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
+class C jvmOverloads constructor(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
     private val field: Int
 
     init {
diff --git a/j2k/testData/fileOrElement/constructors/privateConstructors.kt b/j2k/testData/fileOrElement/constructors/privateConstructors.kt
index 596457e9d9c..c3503175dd8 100644
--- a/j2k/testData/fileOrElement/constructors/privateConstructors.kt
+++ b/j2k/testData/fileOrElement/constructors/privateConstructors.kt
@@ -1,4 +1,4 @@
-class C @jvmOverloads private constructor(arg1: Int, arg2: Int, arg3: Int = 0) {
+class C jvmOverloads private constructor(arg1: Int, arg2: Int, arg3: Int = 0) {
 
     public constructor(arg1: Int) : this(arg1, 0, 0) {
     }
diff --git a/j2k/testData/fileOrElement/dropAccessors/DifferentFieldNameAndDefaultParameterValue.kt b/j2k/testData/fileOrElement/dropAccessors/DifferentFieldNameAndDefaultParameterValue.kt
index 28483976d56..6ea6a413b52 100644
--- a/j2k/testData/fileOrElement/dropAccessors/DifferentFieldNameAndDefaultParameterValue.kt
+++ b/j2k/testData/fileOrElement/dropAccessors/DifferentFieldNameAndDefaultParameterValue.kt
@@ -1 +1 @@
-public class C @jvmOverloads constructor(c: C, public val x: Int = c.x)
+public class C jvmOverloads constructor(c: C, public val x: Int = c.x)
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
index f8fa544604a..a12a7e4c0ad 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
@@ -102,6 +102,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/annotations/jetbrainsNullable.java");
             doTest(fileName);
         }
+
+        @TestMetadata("primaryConstructorAnnotation.java")
+        public void testPrimaryConstructorAnnotation() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java");
+            doTest(fileName);
+        }
     }
 
     @TestMetadata("j2k/testData/fileOrElement/anonymousBlock")
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
index 2446d95b0fc..8c1c28e6f50 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
@@ -102,6 +102,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/annotations/jetbrainsNullable.java");
             doTest(fileName);
         }
+
+        @TestMetadata("primaryConstructorAnnotation.java")
+        public void testPrimaryConstructorAnnotation() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/annotations/primaryConstructorAnnotation.java");
+            doTest(fileName);
+        }
     }
 
     @TestMetadata("j2k/testData/fileOrElement/anonymousBlock")

From 4c80db92497effccf064cf44b6dd435013f08b25 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 23 Jun 2015 17:36:59 +0300
Subject: [PATCH 058/450] KT-8110 J2K: Don't convert "==" to "===" for enum
 classes

 #KT-8110 Fixed
---
 j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt | 1 +
 j2k/testData/fileOrElement/equals/EqOperator.java       | 7 ++++++-
 j2k/testData/fileOrElement/equals/EqOperator.kt         | 7 ++++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
index 5563b1a7678..46b4ad0cdb1 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
@@ -137,6 +137,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
             is PsiClassType -> {
                 val psiClass = type.resolve() ?: return false
                 if (!psiClass.hasModifierProperty(PsiModifier.FINAL)) return false
+                if (psiClass.isEnum()) return true
 
                 val equalsSignature = GenerateEqualsHelper.getEqualsSignature(converter.project, GlobalSearchScope.allScope(converter.project))
                 val equalsMethod = MethodSignatureUtil.findMethodBySignature(psiClass, equalsSignature, true)
diff --git a/j2k/testData/fileOrElement/equals/EqOperator.java b/j2k/testData/fileOrElement/equals/EqOperator.java
index b531b011f7f..163a2caf999 100644
--- a/j2k/testData/fileOrElement/equals/EqOperator.java
+++ b/j2k/testData/fileOrElement/equals/EqOperator.java
@@ -20,8 +20,12 @@ class B {
 
 final class BB extends B {}
 
+enum EE {
+    A, B, C
+}
+
 class X {
-    void foo(I i1, I i2, String s1, String s2, C c1, C c2, int i, O o1, O o2, E e1, E e2, BB bb1, BB bb2, int[] arr1, int[] arr2) {
+    void foo(I i1, I i2, String s1, String s2, C c1, C c2, int i, O o1, O o2, E e1, E e2, BB bb1, BB bb2, int[] arr1, int[] arr2, EE ee1, EE ee2) {
         if (i1 == i2) return;
         if (s1 == s2) return;
         if (c1 == c2) return;
@@ -32,6 +36,7 @@ class X {
         if (e1 == e2) return;
         if (bb1 == bb2) return;
         if (arr1 == arr2) return;
+        if (ee1 == ee2 || ee1 == null) return;
 
         if (s1 != s2) return;
         if (c1 != c2) return;
diff --git a/j2k/testData/fileOrElement/equals/EqOperator.kt b/j2k/testData/fileOrElement/equals/EqOperator.kt
index a4c061231cd..b551d93ef08 100644
--- a/j2k/testData/fileOrElement/equals/EqOperator.kt
+++ b/j2k/testData/fileOrElement/equals/EqOperator.kt
@@ -18,8 +18,12 @@ open class B {
 
 class BB : B()
 
+enum class EE {
+    A, B, C
+}
+
 class X {
-    fun foo(i1: I?, i2: I?, s1: String, s2: String, c1: C, c2: C, i: Int, o1: O, o2: O, e1: E, e2: E, bb1: BB, bb2: BB, arr1: IntArray, arr2: IntArray) {
+    fun foo(i1: I?, i2: I?, s1: String, s2: String, c1: C, c2: C, i: Int, o1: O, o2: O, e1: E, e2: E, bb1: BB, bb2: BB, arr1: IntArray, arr2: IntArray, ee1: EE?, ee2: EE) {
         if (i1 === i2) return
         if (s1 === s2) return
         if (c1 == c2) return
@@ -30,6 +34,7 @@ class X {
         if (e1 === e2) return
         if (bb1 === bb2) return
         if (arr1 == arr2) return
+        if (ee1 == ee2 || ee1 == null) return
 
         if (s1 !== s2) return
         if (c1 != c2) return

From 2999aaf97446bee109abd08d44963d7c3d245cad Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 23 Jun 2015 17:39:35 +0300
Subject: [PATCH 059/450] KT-8034 J2K: save file before performing the
 conversion

 #KT-8034 Fixed
---
 .../org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
index 5f39de3725f..18d099e631a 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/JavaToKotlinAction.kt
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.actions
 import com.intellij.openapi.actionSystem.AnAction
 import com.intellij.openapi.actionSystem.AnActionEvent
 import com.intellij.openapi.actionSystem.CommonDataKeys
+import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.command.CommandProcessor
 import com.intellij.openapi.fileEditor.FileEditorManager
 import com.intellij.openapi.progress.ProgressManager
@@ -44,6 +45,8 @@ import java.util.ArrayList
 
 public class JavaToKotlinAction : AnAction() {
     override fun actionPerformed(e: AnActionEvent) {
+        ApplicationManager.getApplication().saveAll()
+
         val javaFiles = selectedJavaFiles(e).toList()
         val project = CommonDataKeys.PROJECT.getData(e.getDataContext())!!
 

From c75a18291cd029d58bcc3aaf709d047fc6450399 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Tue, 30 Jun 2015 13:55:32 +0300
Subject: [PATCH 060/450] KT-7918 J2K: don't generate jvmOverloads on private
 declarations

 #KT-7918 Fixed
---
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt          |  2 +-
 .../fileOrElement/constructors/privateConstructors.kt  |  2 +-
 j2k/testData/fileOrElement/overloads/Private.java      | 10 ++++++++++
 j2k/testData/fileOrElement/overloads/Private.kt        |  6 ++++++
 .../JavaToKotlinConverterForWebDemoTestGenerated.java  |  6 ++++++
 .../JavaToKotlinConverterSingleFileTestGenerated.java  |  6 ++++++
 6 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100644 j2k/testData/fileOrElement/overloads/Private.java
 create mode 100644 j2k/testData/fileOrElement/overloads/Private.kt

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index 1d4206866c7..34c3cec106f 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -427,7 +427,7 @@ class Converter private constructor(
 
         if (function == null) return null
 
-        if (function.parameterList.parameters.any { it.defaultValue != null }) {
+        if (function.parameterList.parameters.any { it.defaultValue != null } && !function.modifiers.isPrivate) {
             function.annotations += Annotations(
                     listOf(Annotation(Identifier("jvmOverloads").assignNoPrototype(),
                                       listOf(),
diff --git a/j2k/testData/fileOrElement/constructors/privateConstructors.kt b/j2k/testData/fileOrElement/constructors/privateConstructors.kt
index c3503175dd8..ab666511241 100644
--- a/j2k/testData/fileOrElement/constructors/privateConstructors.kt
+++ b/j2k/testData/fileOrElement/constructors/privateConstructors.kt
@@ -1,4 +1,4 @@
-class C jvmOverloads private constructor(arg1: Int, arg2: Int, arg3: Int = 0) {
+class C private constructor(arg1: Int, arg2: Int, arg3: Int = 0) {
 
     public constructor(arg1: Int) : this(arg1, 0, 0) {
     }
diff --git a/j2k/testData/fileOrElement/overloads/Private.java b/j2k/testData/fileOrElement/overloads/Private.java
new file mode 100644
index 00000000000..f064f32fe48
--- /dev/null
+++ b/j2k/testData/fileOrElement/overloads/Private.java
@@ -0,0 +1,10 @@
+class A {
+    private int bar(String s) {
+        System.out.println("s = " + s);
+        return 0;
+    }
+
+    private int bar() {
+        return bar(null);
+    }
+}
\ No newline at end of file
diff --git a/j2k/testData/fileOrElement/overloads/Private.kt b/j2k/testData/fileOrElement/overloads/Private.kt
new file mode 100644
index 00000000000..c4c1b0b9554
--- /dev/null
+++ b/j2k/testData/fileOrElement/overloads/Private.kt
@@ -0,0 +1,6 @@
+class A {
+    private fun bar(s: String? = null): Int {
+        println("s = " + s!!)
+        return 0
+    }
+}
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
index a12a7e4c0ad..3b2bfe64fb9 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterForWebDemoTestGenerated.java
@@ -3520,6 +3520,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("Private.java")
+        public void testPrivate() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/overloads/Private.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("Simple.java")
         public void testSimple() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/overloads/Simple.java");
diff --git a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
index 8c1c28e6f50..2112ee1469e 100644
--- a/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
+++ b/j2k/tests/org/jetbrains/kotlin/j2k/JavaToKotlinConverterSingleFileTestGenerated.java
@@ -3520,6 +3520,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
             doTest(fileName);
         }
 
+        @TestMetadata("Private.java")
+        public void testPrivate() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/overloads/Private.java");
+            doTest(fileName);
+        }
+
         @TestMetadata("Simple.java")
         public void testSimple() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/overloads/Simple.java");

From 26f72d093544937aba41e8ca6e853491a0ef03d3 Mon Sep 17 00:00:00 2001
From: Valentin Kipyatkov 
Date: Mon, 6 Jul 2015 13:47:51 +0300
Subject: [PATCH 061/450] MInor corrections after code review

---
 .../jetbrains/kotlin/j2k/ConstructorConverter.kt   |  4 ++--
 j2k/src/org/jetbrains/kotlin/j2k/Converter.kt      | 14 +++++++-------
 .../jetbrains/kotlin/j2k/ExpressionConverter.kt    |  5 ++---
 j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt    |  7 ++++++-
 4 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
index e71df65d718..8f562fa3213 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt
@@ -216,8 +216,8 @@ class ConstructorConverter(
                                   accessModifiers,
                                   default)
                                 .assignPrototypes(
-                                        PrototypeInfo(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)),
-                                        PrototypeInfo(field, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
+                                        PrototypeInfo(parameter, CommentsAndSpacesInheritance.LINE_BREAKS),
+                                        PrototypeInfo(field, CommentsAndSpacesInheritance.NO_SPACES)
                                 )
                     }
                 },
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
index 34c3cec106f..5b3a131f422 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt
@@ -244,19 +244,18 @@ class Converter private constructor(
 
     private fun convertAnnotationType(psiClass: PsiClass): Class {
         val paramModifiers = Modifiers(listOf(Modifier.PUBLIC)).assignNoPrototype()
-        val noBlankLinesInheritance = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE)
         val annotationMethods = psiClass.getMethods().filterIsInstance()
         val (methodsNamedValue, otherMethods) = annotationMethods.partition { it.getName() == "value" }
 
         fun createParameter(type: Type, method: PsiAnnotationMethod): Parameter {
-            type.assignPrototype(method.getReturnTypeElement(), noBlankLinesInheritance)
+            type.assignPrototype(method.getReturnTypeElement(), CommentsAndSpacesInheritance.NO_SPACES)
 
             return Parameter(method.declarationIdentifier(),
                       type,
                       Parameter.VarValModifier.Val,
                       convertAnnotations(method),
                       paramModifiers,
-                      annotationConverter.convertAnnotationMethodDefault(method)).assignPrototype(method, noBlankLinesInheritance)
+                      annotationConverter.convertAnnotationMethodDefault(method)).assignPrototype(method, CommentsAndSpacesInheritance.NO_SPACES)
         }
 
         fun convertType(psiType: PsiType?): Type {
@@ -320,7 +319,7 @@ class Converter private constructor(
             }
             val body = field.getInitializingClass()?.let { convertAnonymousClassBody(it) }
             return EnumConstant(name, annotations, modifiers, params, body)
-                    .assignPrototype(field, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS))
+                    .assignPrototype(field, CommentsAndSpacesInheritance.LINE_BREAKS)
         }
         else {
             val isVal = isVal(referenceSearcher, field)
@@ -339,7 +338,8 @@ class Converter private constructor(
                   isVal,
                   typeToDeclare != null,
                   shouldGenerateDefaultInitializer(referenceSearcher, field),
-                  if (correction != null) correction.setterAccess else modifiers.accessModifier()).assignPrototype(field)
+                  if (correction != null) correction.setterAccess else modifiers.accessModifier()
+            ).assignPrototype(field)
         }
     }
 
@@ -545,7 +545,7 @@ class Converter private constructor(
             Nullability.Nullable -> type = type.toNullableType()
         }
         return Parameter(parameter.declarationIdentifier(), type, varValModifier,
-                         convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter, CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS))
+                         convertAnnotations(parameter), modifiers, defaultValue).assignPrototype(parameter, CommentsAndSpacesInheritance.LINE_BREAKS)
     }
 
     public fun convertIdentifier(identifier: PsiIdentifier?): Identifier {
@@ -556,7 +556,7 @@ class Converter private constructor(
 
     public fun convertModifiers(owner: PsiModifierListOwner): Modifiers {
         return Modifiers(MODIFIERS_MAP.filter { owner.hasModifierProperty(it.first) }.map { it.second })
-                .assignPrototype(owner.getModifierList(), CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE))
+                .assignPrototype(owner.getModifierList(), CommentsAndSpacesInheritance.NO_SPACES)
     }
 
     public fun convertAnonymousClassBody(anonymousClass: PsiAnonymousClass): AnonymousClassBody {
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
index 46b4ad0cdb1..3f647481442 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt
@@ -485,11 +485,10 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
         val parameters = resolved?.getParameterList()?.getParameters()
         val expectedTypes = parameters?.map { it.getType() } ?: listOf()
 
-        val commentsAndSpacesInheritance = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)
+        val commentsAndSpacesInheritance = CommentsAndSpacesInheritance.LINE_BREAKS
 
         return if (arguments.size() == expectedTypes.size()) {
-            arguments.indices.map { i ->
-                val argument = arguments[i]
+            arguments.mapIndexed { i, argument ->
                 val converted = codeConverter.convertExpression(argument, expectedTypes[i])
                 val result = if (parameters != null && i == arguments.lastIndex && parameters[i].isVarArgs() && argument.getType() is PsiArrayType)
                     StarExpression(converted)
diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
index bda0d3eb029..818228c8bfb 100644
--- a/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
+++ b/j2k/src/org/jetbrains/kotlin/j2k/ast/Element.kt
@@ -54,7 +54,12 @@ data class CommentsAndSpacesInheritance(
         val commentsBefore: Boolean = true,
         val commentsAfter: Boolean = true,
         val commentsInside: Boolean = true
-)
+) {
+    companion object {
+        val NO_SPACES = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.NONE)
+        val LINE_BREAKS = CommentsAndSpacesInheritance(spacesBefore = SpacesInheritance.LINE_BREAKS)
+    }
+}
 
 fun Element.canonicalCode(): String {
     val builder = CodeBuilder(null)

From 222d4002accba819f04e1dfeaf62a64fb4f98f26 Mon Sep 17 00:00:00 2001
From: Ilya Gorbunov 
Date: Sun, 5 Jul 2015 03:13:16 +0300
Subject: [PATCH 062/450] Add char binary operations to JVM codegen tests.

---
 compiler/testData/codegen/box/binaryOp/call.kt              | 4 ++++
 compiler/testData/codegen/box/binaryOp/callNullable.kt      | 4 ++++
 compiler/testData/codegen/box/binaryOp/infixCall.kt         | 4 ++++
 compiler/testData/codegen/box/binaryOp/infixCallNullable.kt | 4 ++++
 compiler/testData/codegen/box/binaryOp/intrinsic.kt         | 4 ++++
 compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt | 4 ++++
 6 files changed, 24 insertions(+)

diff --git a/compiler/testData/codegen/box/binaryOp/call.kt b/compiler/testData/codegen/box/binaryOp/call.kt
index c7a2752f4bb..0f3d0139001 100644
--- a/compiler/testData/codegen/box/binaryOp/call.kt
+++ b/compiler/testData/codegen/box/binaryOp/call.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long = 1.plus(1)
     val a5: Double = 1.0.plus(1)
     val a6: Float = 1f.plus(1)
+    val a7: Char = 'A'.plus(1)
+    val a8: Int = 'B'.minus('A')
 
     if (a1 != 2.toByte()) return "fail 1"
     if (a2 != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4 != 2L) return "fail 4"
     if (a5 != 2.0) return "fail 5"
     if (a6 != 2f) return "fail 6"
+    if (a7 != 'B') return "fail 7"
+    if (a8 != 1) return "fail 8"
 
     return "OK"
 }
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/binaryOp/callNullable.kt b/compiler/testData/codegen/box/binaryOp/callNullable.kt
index 802bef63e31..0167a38ed04 100644
--- a/compiler/testData/codegen/box/binaryOp/callNullable.kt
+++ b/compiler/testData/codegen/box/binaryOp/callNullable.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long? = 1.plus(1)
     val a5: Double? = 1.0.plus(1)
     val a6: Float? = 1f.plus(1)
+    val a7: Char? = 'A'.plus(1)
+    val a8: Int? = 'B'.minus('A')
 
     if (a1!! != 2.toByte()) return "fail 1"
     if (a2!! != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4!! != 2L) return "fail 4"
     if (a5!! != 2.0) return "fail 5"
     if (a6!! != 2f) return "fail 6"
+    if (a7!! != 'B') return "fail 7"
+    if (a8!! != 1) return "fail 8"
 
     return "OK"
 }
diff --git a/compiler/testData/codegen/box/binaryOp/infixCall.kt b/compiler/testData/codegen/box/binaryOp/infixCall.kt
index f8f688298c4..76c0d070d01 100644
--- a/compiler/testData/codegen/box/binaryOp/infixCall.kt
+++ b/compiler/testData/codegen/box/binaryOp/infixCall.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long = 1 plus 1
     val a5: Double = 1.0 plus 1
     val a6: Float = 1f plus 1
+    val a7: Char = 'A' plus 1
+    val a8: Int = 'B' minus 'A'
 
     if (a1 != 2.toByte()) return "fail 1"
     if (a2 != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4 != 2L) return "fail 4"
     if (a5 != 2.0) return "fail 5"
     if (a6 != 2f) return "fail 6"
+    if (a7 != 'B') return "fail 7"
+    if (a8 != 1) return "fail 8"
 
     return "OK"
 }
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt b/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt
index 4a8ed98d307..9fbd75a5c27 100644
--- a/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt
+++ b/compiler/testData/codegen/box/binaryOp/infixCallNullable.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long? = 1 plus 1
     val a5: Double? = 1.0 plus 1
     val a6: Float? = 1f plus 1
+    val a7: Char? = 'A' plus 1
+    val a8: Int? = 'B' minus 'A'
 
     if (a1!! != 2.toByte()) return "fail 1"
     if (a2!! != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4!! != 2L) return "fail 4"
     if (a5!! != 2.0) return "fail 5"
     if (a6!! != 2f) return "fail 6"
+    if (a7!! != 'B') return "fail 7"
+    if (a8!! != 1) return "fail 8"
 
     return "OK"
 }
diff --git a/compiler/testData/codegen/box/binaryOp/intrinsic.kt b/compiler/testData/codegen/box/binaryOp/intrinsic.kt
index cd39565e450..7434a7848e5 100644
--- a/compiler/testData/codegen/box/binaryOp/intrinsic.kt
+++ b/compiler/testData/codegen/box/binaryOp/intrinsic.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long = 1 + 1
     val a5: Double = 1.0 + 1
     val a6: Float = 1f + 1
+    val a7: Char = 'A' + 1
+    val a8: Int = 'B' - 'A'
 
     if (a1 != 2.toByte()) return "fail 1"
     if (a2 != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4 != 2L) return "fail 4"
     if (a5 != 2.0) return "fail 5"
     if (a6 != 2f) return "fail 6"
+    if (a7 != 'B') return "fail 7"
+    if (a8 != 1) return "fail 8"
 
     return "OK"
 }
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt b/compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt
index 75288bc5be8..fdfc98f3bb4 100644
--- a/compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt
+++ b/compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt
@@ -5,6 +5,8 @@ fun box(): String {
     val a4: Long? = 1 + 1
     val a5: Double? = 1.0 + 1
     val a6: Float? = 1f + 1
+    val a7: Char? = 'A' + 1
+    val a8: Int? = 'B' - 'A'
 
     if (a1!! != 2.toByte()) return "fail 1"
     if (a2!! != 2.toShort()) return "fail 2"
@@ -12,6 +14,8 @@ fun box(): String {
     if (a4!! != 2L) return "fail 4"
     if (a5!! != 2.0) return "fail 5"
     if (a6!! != 2f) return "fail 6"
+    if (a7!! != 'B') return "fail 7"
+    if (a8!! != 1) return "fail 8"
 
     return "OK"
 }

From 456bab40d1d43261f800abcd2bbccfac4df1cc5e Mon Sep 17 00:00:00 2001
From: Ilya Gorbunov 
Date: Sun, 5 Jul 2015 03:15:29 +0300
Subject: [PATCH 063/450] Ensure value of correct return type is on stack after
 intrinsic `Char +/- Int` and `Char - Char` binary operations.

---
 .../kotlin/codegen/intrinsics/BinaryOp.kt     |  2 +-
 .../testData/codegen/box/binaryOp/callAny.kt  | 21 +++++++++++++++++++
 .../codegen/box/binaryOp/infixCallAny.kt      | 21 +++++++++++++++++++
 .../codegen/box/binaryOp/intrinsicAny.kt      | 21 +++++++++++++++++++
 .../BlackBoxCodegenTestGenerated.java         | 18 ++++++++++++++++
 5 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 compiler/testData/codegen/box/binaryOp/callAny.kt
 create mode 100644 compiler/testData/codegen/box/binaryOp/infixCallAny.kt
 create mode 100644 compiler/testData/codegen/box/binaryOp/intrinsicAny.kt

diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt
index f52c4cba9a4..8806c6cad2c 100644
--- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt
+++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt
@@ -34,7 +34,7 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() {
         val operandType = numberFunctionOperandType(returnType)
         val paramType = if (shift()) Type.INT_TYPE else operandType
 
-        return createBinaryIntrinsicCallable(operandType, paramType, operandType) {
+        return createBinaryIntrinsicCallable(returnType, paramType, operandType) {
             v -> v.visitInsn(returnType.getOpcode(opcode))
         }
     }
diff --git a/compiler/testData/codegen/box/binaryOp/callAny.kt b/compiler/testData/codegen/box/binaryOp/callAny.kt
new file mode 100644
index 00000000000..7969cb5ec79
--- /dev/null
+++ b/compiler/testData/codegen/box/binaryOp/callAny.kt
@@ -0,0 +1,21 @@
+fun box(): String {
+    val a1: Any = 1.toByte().plus(1)
+    val a2: Any = 1.toShort().plus(1)
+    val a3: Any = 1.plus(1)
+    val a4: Any = 1L.plus(1)
+    val a5: Any = 1.0.plus(1)
+    val a6: Any = 1f.plus(1)
+    val a7: Any = 'A'.plus(1)
+    val a8: Any = 'B'.minus('A')
+
+    if (a1 !is Int || a1 != 2) return "fail 1"
+    if (a2 !is Int || a2 != 2) return "fail 2"
+    if (a3 !is Int || a3 != 2) return "fail 3"
+    if (a4 !is Long || a4 != 2L) return "fail 4"
+    if (a5 !is Double || a5 != 2.0) return "fail 5"
+    if (a6 !is Float || a6 != 2f) return "fail 6"
+    if (a7 !is Char || a7 != 'B') return "fail 7"
+    if (a8 !is Int || a8 != 1) return "fail 8"
+
+    return "OK"
+}
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/binaryOp/infixCallAny.kt b/compiler/testData/codegen/box/binaryOp/infixCallAny.kt
new file mode 100644
index 00000000000..6056e74e00e
--- /dev/null
+++ b/compiler/testData/codegen/box/binaryOp/infixCallAny.kt
@@ -0,0 +1,21 @@
+fun box(): String {
+    val a1: Any = 1.toByte() plus 1
+    val a2: Any = 1.toShort() plus 1
+    val a3: Any = 1 plus 1
+    val a4: Any = 1L plus 1
+    val a5: Any = 1.0 plus 1
+    val a6: Any = 1f plus 1
+    val a7: Any = 'A' plus 1
+    val a8: Any = 'B' minus 'A'
+
+    if (a1 !is Int || a1 != 2) return "fail 1"
+    if (a2 !is Int || a2 != 2) return "fail 2"
+    if (a3 !is Int || a3 != 2) return "fail 3"
+    if (a4 !is Long || a4 != 2L) return "fail 4"
+    if (a5 !is Double || a5 != 2.0) return "fail 5"
+    if (a6 !is Float || a6 != 2f) return "fail 6"
+    if (a7 !is Char || a7 != 'B') return "fail 7"
+    if (a8 !is Int || a8 != 1) return "fail 8"
+
+    return "OK"
+}
\ No newline at end of file
diff --git a/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt b/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt
new file mode 100644
index 00000000000..fd240b08a58
--- /dev/null
+++ b/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt
@@ -0,0 +1,21 @@
+fun box(): String {
+    val a1: Any = 1.toByte() + 1
+    val a2: Any = 1.toShort() + 1
+    val a3: Any = 1 + 1
+    val a4: Any = 1L + 1
+    val a5: Any = 1.0 + 1
+    val a6: Any = 1f + 1
+    val a7: Any = 'A' + 1
+    val a8: Any = 'B' - 'A'
+
+    if (a1 !is Int || a1 != 2) return "fail 1"
+    if (a2 !is Int || a2 != 2) return "fail 2"
+    if (a3 !is Int || a3 != 2) return "fail 3"
+    if (a4 !is Long || a4 != 2L) return "fail 4"
+    if (a5 !is Double || a5 != 2.0) return "fail 5"
+    if (a6 !is Float || a6 != 2f) return "fail 6"
+    if (a7 !is Char || a7 != 'B') return "fail 7"
+    if (a8 !is Int || a8 != 1) return "fail 8"
+
+    return "OK"
+}
\ No newline at end of file
diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java
index f1b138005b2..357a6e933b2 100644
--- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java
+++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java
@@ -262,6 +262,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
             doTest(fileName);
         }
 
+        @TestMetadata("callAny.kt")
+        public void testCallAny() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/callAny.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("callNullable.kt")
         public void testCallNullable() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/callNullable.kt");
@@ -280,6 +286,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
             doTest(fileName);
         }
 
+        @TestMetadata("infixCallAny.kt")
+        public void testInfixCallAny() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallAny.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("infixCallNullable.kt")
         public void testInfixCallNullable() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallNullable.kt");
@@ -292,6 +304,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
             doTest(fileName);
         }
 
+        @TestMetadata("intrinsicAny.kt")
+        public void testIntrinsicAny() throws Exception {
+            String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/intrinsicAny.kt");
+            doTest(fileName);
+        }
+
         @TestMetadata("intrinsicNullable.kt")
         public void testIntrinsicNullable() throws Exception {
             String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt");

From f440d97e04acef8520a82f94969ca0f4b8b9bbd7 Mon Sep 17 00:00:00 2001
From: Ilya Gorbunov 
Date: Sun, 5 Jul 2015 03:18:29 +0300
Subject: [PATCH 064/450] Remove unnecessary Char.toChar from tests.

---
 .../ranges/expression/inexactDownToMinValue.kt         |  6 +++---
 .../ranges/expression/inexactToMaxValue.kt             |  6 +++---
 .../ranges/expression/maxValueMinusTwoToMaxValue.kt    |  6 +++---
 .../ranges/expression/progressionDownToMinValue.kt     |  6 +++---
 .../progressionMaxValueMinusTwoToMaxValue.kt           |  6 +++---
 .../ranges/literal/inexactDownToMinValue.kt            |  6 +++---
 .../boxWithStdlib/ranges/literal/inexactToMaxValue.kt  |  6 +++---
 .../ranges/literal/maxValueMinusTwoToMaxValue.kt       |  6 +++---
 .../ranges/literal/progressionDownToMinValue.kt        |  6 +++---
 .../literal/progressionMaxValueMinusTwoToMaxValue.kt   |  6 +++---
 libraries/stdlib/test/collections/ArraysJVMTest.kt     |  4 ++--
 .../stdlib/test/language/RangeIterationJVMTest.kt      | 10 +++++-----
 12 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt
index 2339845995d..f4d26ce7d35 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt
@@ -55,13 +55,13 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    val range5 = (MinC + 5).toChar() downTo MinC step 3
+    val range5 = (MinC + 5) downTo MinC step 3
     for (i in range5) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MinC + 5).toChar(), (MinC + 2).toChar())) {
-        return "Wrong elements for (MinC + 5).toChar() downTo MinC step 3: $list5"
+    if (list5 != listOf((MinC + 5), (MinC + 2))) {
+        return "Wrong elements for (MinC + 5) downTo MinC step 3: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt
index 5ae8ded829d..d5befa8aa5a 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt
@@ -55,13 +55,13 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    val range5 = (MaxC - 5).toChar()..MaxC step 3
+    val range5 = (MaxC - 5)..MaxC step 3
     for (i in range5) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 5).toChar(), (MaxC - 2).toChar())) {
-        return "Wrong elements for (MaxC - 5).toChar()..MaxC step 3: $list5"
+    if (list5 != listOf((MaxC - 5), (MaxC - 2))) {
+        return "Wrong elements for (MaxC - 5)..MaxC step 3: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt
index 13fbca1e1cb..3ee48b17dde 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt
@@ -55,13 +55,13 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    val range5 = (MaxC - 2).toChar()..MaxC
+    val range5 = (MaxC - 2)..MaxC
     for (i in range5) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 2).toChar(), (MaxC - 1).toChar(), MaxC)) {
-        return "Wrong elements for (MaxC - 2).toChar()..MaxC: $list5"
+    if (list5 != listOf((MaxC - 2), (MaxC - 1), MaxC)) {
+        return "Wrong elements for (MaxC - 2)..MaxC: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt
index 3d45cda9ea5..1531e67511c 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt
@@ -55,13 +55,13 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    val range5 = (MinC + 2).toChar() downTo MinC step 1
+    val range5 = (MinC + 2) downTo MinC step 1
     for (i in range5) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MinC + 2).toChar(), (MinC + 1).toChar(), MinC)) {
-        return "Wrong elements for (MinC + 2).toChar() downTo MinC step 1: $list5"
+    if (list5 != listOf((MinC + 2), (MinC + 1), MinC)) {
+        return "Wrong elements for (MinC + 2) downTo MinC step 1: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt
index f65cb237f61..9d9f13d7349 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt
@@ -55,13 +55,13 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    val range5 = (MaxC - 2).toChar()..MaxC step 2
+    val range5 = (MaxC - 2)..MaxC step 2
     for (i in range5) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 2).toChar(), MaxC)) {
-        return "Wrong elements for (MaxC - 2).toChar()..MaxC step 2: $list5"
+    if (list5 != listOf((MaxC - 2), MaxC)) {
+        return "Wrong elements for (MaxC - 2)..MaxC step 2: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt
index cb91d07024b..c8b9e14014d 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt
@@ -51,12 +51,12 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    for (i in (MinC + 5).toChar() downTo MinC step 3) {
+    for (i in (MinC + 5) downTo MinC step 3) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MinC + 5).toChar(), (MinC + 2).toChar())) {
-        return "Wrong elements for (MinC + 5).toChar() downTo MinC step 3: $list5"
+    if (list5 != listOf((MinC + 5), (MinC + 2))) {
+        return "Wrong elements for (MinC + 5) downTo MinC step 3: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt
index 453cc240062..fc4b412712b 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt
@@ -51,12 +51,12 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    for (i in (MaxC - 5).toChar()..MaxC step 3) {
+    for (i in (MaxC - 5)..MaxC step 3) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 5).toChar(), (MaxC - 2).toChar())) {
-        return "Wrong elements for (MaxC - 5).toChar()..MaxC step 3: $list5"
+    if (list5 != listOf((MaxC - 5), (MaxC - 2))) {
+        return "Wrong elements for (MaxC - 5)..MaxC step 3: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt
index 15d32a278cc..716ea1cc300 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt
@@ -51,12 +51,12 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    for (i in (MaxC - 2).toChar()..MaxC) {
+    for (i in (MaxC - 2)..MaxC) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 2).toChar(), (MaxC - 1).toChar(), MaxC)) {
-        return "Wrong elements for (MaxC - 2).toChar()..MaxC: $list5"
+    if (list5 != listOf((MaxC - 2), (MaxC - 1), MaxC)) {
+        return "Wrong elements for (MaxC - 2)..MaxC: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt
index 19f8e9f5078..89b997b8a0d 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt
@@ -51,12 +51,12 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    for (i in (MinC + 2).toChar() downTo MinC step 1) {
+    for (i in (MinC + 2) downTo MinC step 1) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MinC + 2).toChar(), (MinC + 1).toChar(), MinC)) {
-        return "Wrong elements for (MinC + 2).toChar() downTo MinC step 1: $list5"
+    if (list5 != listOf((MinC + 2), (MinC + 1), MinC)) {
+        return "Wrong elements for (MinC + 2) downTo MinC step 1: $list5"
     }
 
     return "OK"
diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt
index 408f69acf01..d4c93ce04ae 100644
--- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt
+++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt
@@ -51,12 +51,12 @@ fun box(): String {
     }
 
     val list5 = ArrayList()
-    for (i in (MaxC - 2).toChar()..MaxC step 2) {
+    for (i in (MaxC - 2)..MaxC step 2) {
         list5.add(i)
         if (list5.size() > 23) break
     }
-    if (list5 != listOf((MaxC - 2).toChar(), MaxC)) {
-        return "Wrong elements for (MaxC - 2).toChar()..MaxC step 2: $list5"
+    if (list5 != listOf((MaxC - 2), MaxC)) {
+        return "Wrong elements for (MaxC - 2)..MaxC step 2: $list5"
     }
 
     return "OK"
diff --git a/libraries/stdlib/test/collections/ArraysJVMTest.kt b/libraries/stdlib/test/collections/ArraysJVMTest.kt
index 32622573b0e..746198309dd 100644
--- a/libraries/stdlib/test/collections/ArraysJVMTest.kt
+++ b/libraries/stdlib/test/collections/ArraysJVMTest.kt
@@ -21,7 +21,7 @@ class ArraysJVMTest {
         checkContent(longArrayOf(0, 1, 2, 3, 4, 5).copyOf().iterator(), 6) { it.toLong() }
         checkContent(floatArrayOf(0.toFloat(), 1.toFloat(), 2.toFloat(), 3.toFloat()).copyOf().iterator(), 4) { it.toFloat() }
         checkContent(doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0).copyOf().iterator(), 6) { it.toDouble() }
-        checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOf().iterator(), 6) { ('0' + it).toChar() }
+        checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOf().iterator(), 6) { '0' + it }
     }
 
     test fun copyOfRange() {
@@ -32,7 +32,7 @@ class ArraysJVMTest {
         checkContent(longArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3).iterator(), 3) { it.toLong() }
         checkContent(floatArrayOf(0.toFloat(), 1.toFloat(), 2.toFloat(), 3.toFloat()).copyOfRange(0, 3).iterator(), 3) { it.toFloat() }
         checkContent(doubleArrayOf(0.0, 1.0, 2.0, 3.0, 4.0, 5.0).copyOfRange(0, 3).iterator(), 3) { it.toDouble() }
-        checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOfRange(0, 3).iterator(), 3) { ('0' + it).toChar() }
+        checkContent(charArrayOf('0', '1', '2', '3', '4', '5').copyOfRange(0, 3).iterator(), 3) { '0' + it }
     }
 
     test fun reduce() {
diff --git a/libraries/stdlib/test/language/RangeIterationJVMTest.kt b/libraries/stdlib/test/language/RangeIterationJVMTest.kt
index 873f5f3d921..cef97c40cda 100644
--- a/libraries/stdlib/test/language/RangeIterationJVMTest.kt
+++ b/libraries/stdlib/test/language/RangeIterationJVMTest.kt
@@ -75,7 +75,7 @@ public class RangeIterationJVMTest {
         doTest((MaxS - 2).toShort()..MaxS, (MaxS - 2).toShort(), MaxS, 1, listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS))
         doTest((MaxL - 2).toLong()..MaxL, (MaxL - 2).toLong(), MaxL, 1.toLong(), listOf((MaxL - 2).toLong(), (MaxL - 1).toLong(), MaxL))
 
-        doTest((MaxC - 2).toChar()..MaxC, (MaxC - 2).toChar(), MaxC, 1, listOf((MaxC - 2).toChar(), (MaxC - 1).toChar(), MaxC))
+        doTest((MaxC - 2)..MaxC, (MaxC - 2), MaxC, 1, listOf((MaxC - 2), (MaxC - 1), MaxC))
     }
 
     test fun maxValueToMinValue() {
@@ -102,7 +102,7 @@ public class RangeIterationJVMTest {
         doTest((MaxS - 2).toShort()..MaxS step 2, (MaxS - 2).toShort(), MaxS, 2, listOf((MaxS - 2).toShort(), MaxS))
         doTest((MaxL - 2).toLong()..MaxL step 2, (MaxL - 2).toLong(), MaxL, 2.toLong(), listOf((MaxL - 2).toLong(), MaxL))
 
-        doTest((MaxC - 2).toChar()..MaxC step 2, (MaxC - 2).toChar(), MaxC, 2, listOf((MaxC - 2).toChar(), MaxC))
+        doTest((MaxC - 2)..MaxC step 2, (MaxC - 2), MaxC, 2, listOf((MaxC - 2), MaxC))
     }
 
     test fun progressionMaxValueToMinValue() {
@@ -129,7 +129,7 @@ public class RangeIterationJVMTest {
         doTest((MaxS - 5).toShort()..MaxS step 3, (MaxS - 5).toShort(), MaxS, 3, listOf((MaxS - 5).toShort(), (MaxS - 2).toShort()))
         doTest((MaxL - 5).toLong()..MaxL step 3, (MaxL - 5).toLong(), MaxL, 3.toLong(), listOf((MaxL - 5).toLong(), (MaxL - 2).toLong()))
 
-        doTest((MaxC - 5).toChar()..MaxC step 3, (MaxC - 5).toChar(), MaxC, 3, listOf((MaxC - 5).toChar(), (MaxC - 2).toChar()))
+        doTest((MaxC - 5)..MaxC step 3, (MaxC - 5), MaxC, 3, listOf((MaxC - 5), (MaxC - 2)))
     }
 
     test fun progressionDownToMinValue() {
@@ -138,7 +138,7 @@ public class RangeIterationJVMTest {
         doTest((MinS + 2).toShort() downTo MinS step 1, (MinS + 2).toShort(), MinS, -1, listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS))
         doTest((MinL + 2).toLong() downTo MinL step 1, (MinL + 2).toLong(), MinL, -1.toLong(), listOf((MinL + 2).toLong(), (MinL + 1).toLong(), MinL))
 
-        doTest((MinC + 2).toChar() downTo MinC step 1, (MinC + 2).toChar(), MinC, -1, listOf((MinC + 2).toChar(), (MinC + 1).toChar(), MinC))
+        doTest((MinC + 2) downTo MinC step 1, (MinC + 2), MinC, -1, listOf((MinC + 2), (MinC + 1), MinC))
     }
 
     test fun inexactDownToMinValue() {
@@ -147,6 +147,6 @@ public class RangeIterationJVMTest {
         doTest((MinS + 5).toShort() downTo MinS step 3, (MinS + 5).toShort(), MinS, -3, listOf((MinS + 5).toShort(), (MinS + 2).toShort()))
         doTest((MinL + 5).toLong() downTo MinL step 3, (MinL + 5).toLong(), MinL, -3.toLong(), listOf((MinL + 5).toLong(), (MinL + 2).toLong()))
 
-        doTest((MinC + 5).toChar() downTo MinC step 3, (MinC + 5).toChar(), MinC, -3, listOf((MinC + 5).toChar(), (MinC + 2).toChar()))
+        doTest((MinC + 5) downTo MinC step 3, (MinC + 5), MinC, -3, listOf((MinC + 5), (MinC + 2)))
     }
 }
\ No newline at end of file

From 68384a9b4a48e24a00dcc11dedc376e3370941c3 Mon Sep 17 00:00:00 2001
From: Nikolay Krasko 
Date: Fri, 26 Jun 2015 18:09:17 +0300
Subject: [PATCH 065/450] Avoid looking for light methods if only Kotlin search
 needed

---
 .../KotlinReferencesSearcher.kt               | 22 ++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt
index 27d9aaa6e23..c5c6743cbcd 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinReferencesSearcher.kt
@@ -16,20 +16,21 @@
 
 package org.jetbrains.kotlin.idea.search.ideaExtensions
 
-import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.application.QueryExecutorBase
 import com.intellij.openapi.progress.ProgressManager
-import com.intellij.openapi.util.Computable
 import com.intellij.psi.*
+import com.intellij.psi.search.LocalSearchScope
 import com.intellij.psi.search.RequestResultProcessor
+import com.intellij.psi.search.SearchScope
 import com.intellij.psi.search.searches.ReferencesSearch
 import com.intellij.psi.util.PsiTreeUtil
 import com.intellij.util.Processor
 import org.jetbrains.kotlin.asJava.KotlinLightMethod
 import org.jetbrains.kotlin.asJava.LightClassUtil
 import org.jetbrains.kotlin.asJava.namedUnwrappedElement
-import org.jetbrains.kotlin.idea.references.matchesTarget
-import org.jetbrains.kotlin.idea.search.usagesSearch.*
+import org.jetbrains.kotlin.idea.JetFileType
+import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchLocation
+import org.jetbrains.kotlin.idea.search.usagesSearch.getSpecialNamesToSearch
 import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
 import org.jetbrains.kotlin.idea.util.application.runReadAction
 import org.jetbrains.kotlin.psi.*
@@ -66,7 +67,9 @@ public class KotlinReferencesSearcher : QueryExecutorBase {
                     val propertyMethods = runReadAction { LightClassUtil.getLightClassPropertyMethods(element) }
-                    searchNamedElement(queryParameters, propertyMethods.getGetter())
-                    searchNamedElement(queryParameters, propertyMethods.getSetter())
-                }
+                            searchNamedElement(queryParameters, propertyMethods.getGetter())
+                            searchNamedElement(queryParameters, propertyMethods.getSetter())
+                        }
                 is KotlinLightMethod -> {
                     val declaration = element.getOrigin()
                     if (declaration is JetProperty || (declaration is JetParameter && declaration.hasValOrVar())) {
@@ -115,6 +118,9 @@ public class KotlinReferencesSearcher : QueryExecutorBase
Date: Tue, 30 Jun 2015 13:54:24 +0300
Subject: [PATCH 066/450] Usage highlighting test

---
 .../kotlin/generators/tests/GenerateTests.kt  |  9 +--
 idea/testData/usageHighlighter/localVal.kt    |  8 +++
 .../AbstractUsageHighlightingTest.kt          | 68 +++++++++++++++++++
 .../UsageHighlightingTestGenerated.java       | 43 ++++++++++++
 4 files changed, 124 insertions(+), 4 deletions(-)
 create mode 100644 idea/testData/usageHighlighter/localVal.kt
 create mode 100644 idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt
 create mode 100644 idea/tests/org/jetbrains/kotlin/idea/highlighter/UsageHighlightingTestGenerated.java

diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
index 792e0fcd107..bd33facd22e 100644
--- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
+++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt
@@ -66,10 +66,7 @@ import org.jetbrains.kotlin.idea.decompiler.textBuilder.AbstractDecompiledTextTe
 import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractJetQuickDocProviderTest
 import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
 import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest
-import org.jetbrains.kotlin.idea.highlighter.AbstractDiagnosticMessageJsTest
-import org.jetbrains.kotlin.idea.highlighter.AbstractDiagnosticMessageTest
-import org.jetbrains.kotlin.idea.highlighter.AbstractHighlightExitPointsTest
-import org.jetbrains.kotlin.idea.highlighter.AbstractHighlightingTest
+import org.jetbrains.kotlin.idea.highlighter.*
 import org.jetbrains.kotlin.idea.imports.AbstractOptimizeImportsTest
 import org.jetbrains.kotlin.idea.intentions.AbstractIntentionTest
 import org.jetbrains.kotlin.idea.intentions.AbstractMultiFileIntentionTest
@@ -395,6 +392,10 @@ fun main(args: Array) {
             model("highlighter")
         }
 
+        testClass(javaClass()) {
+            model("usageHighlighter")
+        }
+
         testClass(javaClass()) {
             model("folding/noCollapse")
             model("folding/checkCollapse", testMethod = "doSettingsFoldingTest")
diff --git a/idea/testData/usageHighlighter/localVal.kt b/idea/testData/usageHighlighter/localVal.kt
new file mode 100644
index 00000000000..a3779680ec8
--- /dev/null
+++ b/idea/testData/usageHighlighter/localVal.kt
@@ -0,0 +1,8 @@
+fun test() {
+    val a = 12
+    foo(~a)
+}
+
+fun foo(a: Int) = a
+
+val a = 1
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt
new file mode 100644
index 00000000000..73a6015a33f
--- /dev/null
+++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/AbstractUsageHighlightingTest.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2010-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.idea.highlighter
+
+import com.intellij.codeInsight.daemon.impl.HighlightInfo
+import com.intellij.codeInsight.daemon.impl.HighlightInfoType
+import com.intellij.codeInsight.highlighting.actions.HighlightUsagesAction
+import com.intellij.openapi.command.WriteCommandAction
+import com.intellij.testFramework.ExpectedHighlightingData
+import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase
+import org.jetbrains.kotlin.idea.test.JetLightProjectDescriptor
+
+public abstract class AbstractUsageHighlightingTest: JetLightCodeInsightFixtureTestCase() {
+    companion object {
+        // Not standard  to leave it in text after configureByFile and remove manually after collecting highlighting information
+        val CARET_TAG = "~"
+    }
+
+    protected fun doTest(filePath: String) {
+        myFixture.configureByFile(filePath)
+        val document = myFixture.getEditor().getDocument()
+        val data = ExpectedHighlightingData(document, false, false, true, false, myFixture.getFile())
+        data.init()
+
+        val caret = document.getText().indexOf(CARET_TAG)
+        assert(caret != -1, "Caret marker '$CARET_TAG' expected")
+
+        WriteCommandAction.runWriteCommandAction(myFixture.getProject()) {
+            document.deleteString(caret, caret + CARET_TAG.length())
+        }
+
+        getEditor().getCaretModel().moveToOffset(caret)
+
+        myFixture.testAction(HighlightUsagesAction())
+        val highlighters = myFixture.getEditor().getMarkupModel().getAllHighlighters()
+
+        val infos = highlighters.map { highlighter ->
+            var startOffset = highlighter.getStartOffset()
+            var endOffset = highlighter.getEndOffset()
+
+            if (startOffset > caret) startOffset += CARET_TAG.length()
+            if (endOffset > caret) endOffset += CARET_TAG.length()
+
+            HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(startOffset, endOffset).create()
+        }
+
+        data.checkResult(infos, StringBuilder(document.getText()).insert(caret, CARET_TAG).toString())
+    }
+
+
+
+    override fun getProjectDescriptor() = JetLightProjectDescriptor.INSTANCE
+    override fun getTestDataPath() = ""
+}
diff --git a/idea/tests/org/jetbrains/kotlin/idea/highlighter/UsageHighlightingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/highlighter/UsageHighlightingTestGenerated.java
new file mode 100644
index 00000000000..ddc2363033f
--- /dev/null
+++ b/idea/tests/org/jetbrains/kotlin/idea/highlighter/UsageHighlightingTestGenerated.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2010-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.idea.highlighter;
+
+import com.intellij.testFramework.TestDataPath;
+import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
+import org.jetbrains.kotlin.test.JetTestUtils;
+import org.jetbrains.kotlin.test.TestMetadata;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.util.regex.Pattern;
+
+/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
+@SuppressWarnings("all")
+@TestMetadata("idea/testData/usageHighlighter")
+@TestDataPath("$PROJECT_ROOT")
+@RunWith(JUnit3RunnerWithInners.class)
+public class UsageHighlightingTestGenerated extends AbstractUsageHighlightingTest {
+    public void testAllFilesPresentInUsageHighlighter() throws Exception {
+        JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/usageHighlighter"), Pattern.compile("^(.+)\\.kt$"), true);
+    }
+
+    @TestMetadata("localVal.kt")
+    public void testLocalVal() throws Exception {
+        String fileName = JetTestUtils.navigationMetadata("idea/testData/usageHighlighter/localVal.kt");
+        doTest(fileName);
+    }
+}

From 534154e20d3e1e6011248e309af8603c606b6ed5 Mon Sep 17 00:00:00 2001
From: Nikolay Krasko 
Date: Mon, 6 Jul 2015 16:36:11 +0300
Subject: [PATCH 067/450] Replace trait to interface icons

 #KT-8319 Fixed
---
 .../src/org/jetbrains/kotlin/idea/JetIcons.java  |   2 +-
 .../kotlin/idea/icons/interfaceKotlin.png        | Bin 0 -> 1503 bytes
 .../kotlin/idea/icons/interfaceKotlin@2x.png     | Bin 0 -> 2360 bytes
 .../idea/icons/interfaceKotlin@2x_dark.png       | Bin 0 -> 2350 bytes
 .../kotlin/idea/icons/interfaceKotlin_dark.png   | Bin 0 -> 1504 bytes
 .../jetbrains/kotlin/idea/icons/traitKotlin.png  | Bin 671 -> 0 bytes
 .../kotlin/idea/icons/traitKotlin@2x.png         | Bin 1488 -> 0 bytes
 .../kotlin/idea/icons/traitKotlin@2x_dark.png    | Bin 1484 -> 0 bytes
 .../kotlin/idea/icons/traitKotlin_dark.png       | Bin 631 -> 0 bytes
 9 files changed, 1 insertion(+), 1 deletion(-)
 create mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin.png
 create mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x.png
 create mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x_dark.png
 create mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin_dark.png
 delete mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin.png
 delete mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin@2x.png
 delete mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin@2x_dark.png
 delete mode 100644 idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin_dark.png

diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIcons.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIcons.java
index 92b1e51c537..49d0151a479 100644
--- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIcons.java
+++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetIcons.java
@@ -31,7 +31,7 @@ public interface JetIcons {
     Icon ENUM = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/enumKotlin.png");
     Icon FILE = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/kotlin_file.png");
     Icon OBJECT = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/objectKotlin.png");
-    Icon TRAIT = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/traitKotlin.png");
+    Icon TRAIT = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/interfaceKotlin.png");
     Icon FUNCTION = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/function.png");
     Icon EXTENSION_FUNCTION = PlatformIcons.FUNCTION_ICON;
     Icon LAMBDA = IconLoader.getIcon("/org/jetbrains/kotlin/idea/icons/lambda.png");
diff --git a/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin.png b/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin.png
new file mode 100644
index 0000000000000000000000000000000000000000..24f2572f35dee91865d232a71612392c40b1f861
GIT binary patch
literal 1503
zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk?
zp1FzXsX?iUDV2pMQ*9U+nAI{vB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+*
zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn
zQK2F?C$HG5!d3}vt`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4VC0+gXyjGk7z0vCV$aqW){cw=Ukjmw7)L>g>X|`41JtCTXo)YEjfAFB;^^
zC2p?oFmY?~(Z?qqNB#H7*cA8g*0PCzInM6oIbCtD-{2?fKl}Zcs?ubC2R_l9^jG-+
Y!vsx{8_d0VpyHds)78&qol`;+0E;O*$^ZZW

literal 0
HcmV?d00001

diff --git a/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x.png b/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x.png
new file mode 100644
index 0000000000000000000000000000000000000000..54dd8814fb4d5f3b66816422e3c835c9486c6d8b
GIT binary patch
literal 2360
zcmaJ@dpwi-A0Mf?B&GVvZDtt?yD@C$Xtt@Txh!f#neAbVXItB&&81u`$076LM>&Lw
z(nankwdOgqg@_N7DpWFM7=Vw2kwfedyx-b|_
zpSh0CRur`o+Vi3cf#b6YmM9qf5C>{z4mlp*<$Z#N1C~`-=X=z6xg?x9^W+Ds6lF$Hw
za9x}f*cj&%z>ACGk@zT&pO6#!P1P42fj|u>?t@eeD|3
zcC%2#7t3Xg7yuCE+~hxO6cu1_VUV9GCwO*Yk(mSv!Cdb!0jq748K1UQ#iL{8~0y_~Tq$f2jA3
z%l~mMq#tsz>SVC9!~NH==dRQan%#c4uKMuZ{D4U9c&Xaj#O`;dFxdR#Ogc3{asOgL
zeDpGgSyy69{O7Z6Z6ghB()wlhZ?S{5bu`cvy1gOcVS8HVmZfK|Eg=uxH&0CBp+;kbhaR0)#1{Wyj5!eqjm
z@{*QPnnAVI+n3dh?hFa#%wPEox9gbl{foXqEr|+qqS;Tk
z%x%5wRZJtr+hN`$W&>JvsLXkvE+=Kfa}vVKD08y+5}dHBAnDCTCkNny%#e*gb2iGG
zTC*_J0LJ$2Q5;*~}5!Wcc9_#WGYUR9V@)fnWto#bM9-Ou1*_8q@+ODL%E
zokLaD8byNDfHMD&wrDV*NSV-Xv|ahRb#K!31V8lMm|u(cpqyM~BdriExMHHVp{!{Q
z8(wJt)+FWN*xLU*%dG0jlb*)v?M^zorDzl#R@Acf2J6$PvgzK-AZ{sV7=2D(wy=9j
zj0g*gC|z-7MF#wE&{l-1CTnwBhvrZ|`Fy>$#J->a*3FE6V#DAIpG|dawT}nskB6L{UtmyQamKfOm)QwKuf@xlTCvYa=Y^dr=5nLsdgty#6QQ?-iayMWVZlp@7pHDYd_*&0yOMTl|feH=w*wCw8m;GwLH+G26w
zCgI`1YJDMnyt5%K=@E>$_^PWJEjOcX%YP^1S-IEWx<~5Sj6B-;lr&KDaeCY`@+9+A
zV6M?l*ZxK2+mP9o7B(@Vc-B(Q+LTeV-LaF^y?0!F2%m#X$5i{iMEcC!3z|N<&2aVn
zc7uhfr(Un`lf0^XALwV`)41_n!B~q{KiEH>_vrVn>AbXM3=Ks|(q7lhk?DbY&@>%L
z7MhI4Wab`$>sd^WNxF(i-l|XQ3_l*5Hp~V&a*t~JsB(rjWh(CWiNW9X?z2&c%8#MV
z_Pl{P3mZ^LWQDTu&L5;ME3;@Ia?okzS=c@Mgx7hDOtq`@51u%u*EH}@Ag
zyCs2@4tcxnTK5#uzpU9{B37EJt$n7
z9vQtD&(Wd$cB!DZN>4&zT(Wxq6N+a*f{6H$ZMXJi#TFa^;cH#ip=OA26-AwIv#6EX
zpU!yn7=h7+cHO9H>t}{KZ95)MmfOHR5~r@2KlQt~6}ljB;M&iuPtt(Z8I*6yy(*lV
P{g+`feCSo4VJUwB*Tl)s

literal 0
HcmV?d00001

diff --git a/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x_dark.png b/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin@2x_dark.png
new file mode 100644
index 0000000000000000000000000000000000000000..af7dd90b81ccca6113f8a7419b1bd548b465a7ba
GIT binary patch
literal 2350
zcmaJ@dsI?+9>;enKC{Wxod8R%M4pClG#`LTiYbs{zCySP$tx~CpfohiwVDQZT1|3I
zdyLiEW6IJ}t2t?EspA7P8+A23QCezRT3gm)lg<9I?LFt--{X8fp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)Bt*Sud=j`I$veuQXjg4%t(3ia)+@
z7D8wCC&F}$(zy16Gyd74fpN=K{@1m?Xex}zIO=kA72MjHn)XA+hf>_907B}_UR3v#
ztLg=t+oN=(gt>PckqzhO=8i_jOr%F*4=}-z_fc%*
z)oVR_!6vCeb8FVcB-U{Bty+iLmAPHd-gHhF^ruK5g(+<_GX;eByH7TZZ2ghF(0in4
z=Xpud+TlqA!)9A_%mE9STS;$g8{}=n*7*Hh2_JJq@^9u}tQ(qCY4V-mHdclcwhyR+
z%SIYb?wuBgl?lRx@P~VTjvfiU)VGCWmY>r_h=r^^ap-16UlWryZO#ZYSkS!}+TJxO
z+_SaTJ}ORwfO8_opPMS9Vls4dKN#Smb+d+6$ULTP^8t_9XZTY4<32U*t}1%V^+*2D
zjkD}R*~;(+Z{h6xn>)sXohO~atf|b(hmmG3#Zj$>==cJ|4z80kbjOM;x*#&-&H1;5
zg>~@$wKt(Xs$i@pUC>Tt$`&SX{AHV8d`WG+`!l0^DBEIdM}n%mha^0F?&08+@7r

tbf)li=<|j>o4bdCdtlDmZJHRbcK!v;ZteYa_XViJ z{vG=7Vej#Dqf28(*-n{C<>kIcZ_^S*Q_RpUzenA@t5TGVqTB)>(?HUxOZ6q;Bi*lv z7dn?k-eSJejnx_VbB{f(W+O~#v2aD%-E;RU;HG_Zzlt@k%QqY0k=%sl)#oaa)nh-6 z{^ItOrc65FQSg9wLM7r4hZ|pX+DJd#2>gEJ+L5_9X@~7A4`4oV65Pok?qa$cB|pcWQ%qGGCy7z zHs%;f0S(OTr@%iE(42>E_xfr-J F=Rdl%(;ff- literal 0 HcmV?d00001 diff --git a/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin_dark.png b/idea/resources/org/jetbrains/kotlin/idea/icons/interfaceKotlin_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..107044ac0a4148f6e50b2f79715ba276e7ad4300 GIT binary patch literal 1504 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|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 zSK0m(ty_Ed@7Pz`v8bf&p@|-gfq-<;uU7svtMdsL4S3HgS7)*Qh)?W}{_-{Xdg`$q zvM)XS-~IixYiaqvlMF#@tC=?MH{*)(xV7u*&i3~&j(g3!r+(>6w0^+hfA40rU*mG0 zJo#_$uOj}(F*)~-x@a#JKD=Yr`NaCk@zb7E$yzVj_prRmDEw?}m>8!<>&|yOch;_~ z>R7$#@TP3beR;VHUR>gPbl=@W=Um0D47H-iSKmfNeW|~9v-5Jp=fS?83{1ORpeL*oDd literal 0 HcmV?d00001 diff --git a/idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin.png b/idea/resources/org/jetbrains/kotlin/idea/icons/traitKotlin.png deleted file mode 100644 index fe77edfa20a9a3d0ceacbab4d47ca31d2dd1178b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 671 zcmV;Q0$}}#P)?SZlU36h693e85+f)^|Y!UJW zd%xwg3#y?`+9E^wqeyV*_z=X-9<>5_Ovo4L&2Micu{mRBaJt{y4+hS{IUJ9{`9~MQAMS&5^B1hP z-N)gvtxeupLc}fN?96C`VcG5D@L06LYoBKSZ6Z&dU~w92`O&7Ge%ujWY0f>!R@6#V zqEfp6rmHjE`d?Xs6d_<98Hd^M&ky^OYfEu-PuT*?rRr9cinQaV@sznWs;-Dk8^4cb z<|g+Pf1DtU@#PEl9?YS@c1^9ft@Y%cGduso!WXzI+z13VzmH;S#2_wylrdXigWs@R zah=t*2CmxdV46MvKa^a*%>6L0Csvd7`?qo2ALmV6Gz=r2E3Bs#ui{g@GKf8*)uHJc zG{Fro^fB!{8~LmoBEJ-wMC0Me?ziw1Gs%>z1uy!EP)V1%DukAsT`t#%PHABT^w0M1v+OKZ6kj z#TY^YXi6*x779uP+Vpz2x4-?)bz83Gu6L&`UR@{VkM{aOkXAd&}5!CFw0qfUj-Oz;Y51#Cpy zfjd~|`2>sud%(TyK^9~h5-g>#q~Ts732?Y9*CyT8DQ){U4J-%G_=1WS zFb8}F%9x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H~ZVdwp zC&6@V0>v{v1OEMHS7vAU^u_(~v{13P_njI4{|9-W2^I!Ze*F0H>CfLkD4N_meBf-Q zuLl_79t5(Bzq#ki_@9CCFC+6jps)ql0AR{`^`GH?(#OxA{-YZL1Afo*8MyzvVSUZ6 z&ahFs|L|nxb8SH3_wbYmN}m7z{R?~l@x$jY-@Y>Z`SXVXl+i#K#Qx31#c)(4>)mqM zMThQlI@$rX9GIYTQ5nV4Ktt95Q`iAuA}Io5Ur2LyHIW;!xt7YK_J@`h&KSS zD-iF1C1p4U0uWIJ#JWJt#{4vr2N>V$fSQj2`G*Sb=zjy!0YJPRh@Sxj7yz41&gxcl R;WhvO002ovPDHLkV1hf}A+-Pi From 4e42cc6b812e486ddf5e77b0416da82f317ed781 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 26 Jun 2015 10:18:42 +0300 Subject: [PATCH 068/450] Save/restore stack in try-expressions (and statements). Parse TryCatchBlockNode's in generated bytecode, infer stack save/restore points. Save stack to local variables before 'try'. Restore stack after the beginning of try-block, catch-block, and default handler. Integrate before/after inline markers rewriting (otherwise it'll break our stacks). #KT-3309 Fixed --- .../jetbrains/kotlin/codegen/BranchedValue.kt | 1 - .../kotlin/codegen/ExpressionCodegen.java | 8 +- .../codegen/inline/InlineCodegenUtil.java | 26 +++ .../kotlin/codegen/inline/MethodInliner.java | 3 + .../FixStackBeforeJumpTransformer.kt | 156 ------------- .../LabelNormalizationMethodTransformer.kt | 155 ++++++++++++ .../MandatoryMethodTransforker.kt | 28 +++ .../OptimizationMethodVisitor.java | 12 +- ...StoreStackBeforeInlineMethodTransformer.kt | 220 ------------------ .../optimization/common/MethodAnalyzer.kt | 22 +- .../codegen/optimization/common/Util.kt | 25 +- .../fixStack/AnalyzeTryCatchBlocks.kt | 97 ++++++++ .../optimization/fixStack/FixStackAnalyzer.kt | 157 +++++++++++++ .../optimization/fixStack/FixStackContext.kt | 142 +++++++++++ .../fixStack/FixStackMethodTransformer.kt | 213 +++++++++++++++++ .../fixStack/LocalVariablesManager.kt | 97 ++++++++ .../fixStack/StackTransformationUtils.kt | 153 ++++++++++++ .../kotlin/codegen/pseudoInsns/PseudoInsns.kt | 74 ++---- .../tryCatchInExpressions/catch.kt | 2 + .../tryCatchInExpressions/complexChain.kt | 52 +++++ .../tryCatchInExpressions/differentTypes.kt | 8 + .../tryCatchInExpressions/expectException.kt | 35 +++ .../tryCatchInExpressions/finally.kt | 2 + .../tryCatchInExpressions/inlineTryCatch.kt | 17 ++ .../tryCatchInExpressions/inlineTryExpr.kt | 14 ++ .../tryCatchInExpressions/inlineTryFinally.kt | 22 ++ .../multipleCatchBlocks.kt | 20 ++ .../tryCatchInExpressions/splitTry.kt | 25 ++ .../tryCatchInExpressions/splitTryCorner1.kt | 11 + .../tryCatchInExpressions/splitTryCorner2.kt | 22 ++ .../tryCatchInExpressions/try.kt | 2 + .../tryCatchInExpressions/tryAfterTry.kt | 4 + .../tryCatchInExpressions/tryAndBreak.kt | 19 ++ .../tryCatchInExpressions/tryAndContinue.kt | 17 ++ .../tryCatchInExpressions/tryInsideCatch.kt | 8 + .../tryCatchInExpressions/tryInsideTry.kt | 10 + .../unmatchedInlineMarkers.kt | 17 ++ .../unreachableMarker.kt | 4 +- .../codegen/AbstractBytecodeTextTest.java | 2 +- .../kotlin/codegen/CodegenTestCase.java | 2 +- .../BlackBoxCodegenTestGenerated.java | 123 ++++++++++ 41 files changed, 1572 insertions(+), 455 deletions(-) delete mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackBeforeJumpTransformer.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt delete mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/StoreStackBeforeInlineMethodTransformer.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/AnalyzeTryCatchBlocks.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/catch.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/complexChain.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/differentTypes.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/expectException.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/finally.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryCatch.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryExpr.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryFinally.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/multipleCatchBlocks.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTry.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner1.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner2.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/try.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAfterTry.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndBreak.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndContinue.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideCatch.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideTry.kt create mode 100644 compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/unmatchedInlineMarkers.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt index decb9bc8b46..4c23e5bb50f 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.codegen import com.intellij.psi.tree.IElementType -import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsnOpcode import org.jetbrains.kotlin.codegen.pseudoInsns.fakeAlwaysFalseIfeq import org.jetbrains.kotlin.codegen.pseudoInsns.fakeAlwaysTrueIfeq import org.jetbrains.kotlin.lexer.JetTokens diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 99be45477c4..384cfe537f0 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2045,7 +2045,8 @@ public class ExpressionCodegen extends JetVisitor implem ClassDescriptor scriptClass = bindingContext.get(CLASS_FOR_SCRIPT, scriptDescriptor); StackValue script = StackValue.thisOrOuter(this, scriptClass, false, false); Type fieldType = typeMapper.mapType(valueParameterDescriptor); - return StackValue.field(fieldType, scriptClassType, valueParameterDescriptor.getName().getIdentifier(), false, script, valueParameterDescriptor); + return StackValue.field(fieldType, scriptClassType, valueParameterDescriptor.getName().getIdentifier(), false, script, + valueParameterDescriptor); } throw new UnsupportedOperationException("don't know how to generate reference " + descriptor); @@ -3596,14 +3597,14 @@ The "returned" value of try expression with no finally is either the last expres return StackValue.operation(expectedAsmType, new Function1() { @Override public Unit invoke(InstructionAdapter v) { - - JetFinallySection finallyBlock = expression.getFinallyBlock(); + JetFinallySection finallyBlock = expression.getFinallyBlock(); FinallyBlockStackElement finallyBlockStackElement = null; if (finallyBlock != null) { finallyBlockStackElement = new FinallyBlockStackElement(expression); blockStackElements.push(finallyBlockStackElement); } + //PseudoInsnsPackage.saveStackBeforeTryExpr(v); Label tryStart = new Label(); v.mark(tryStart); @@ -3667,6 +3668,7 @@ The "returned" value of try expression with no finally is either the last expres v.mark(defaultCatchStart); int savedException = myFrameMap.enterTemp(JAVA_THROWABLE_TYPE); v.store(savedException, JAVA_THROWABLE_TYPE); + Label defaultCatchEnd = new Label(); v.mark(defaultCatchEnd); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java index 8db898e6d26..d5f142da4e1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java @@ -471,6 +471,32 @@ public class InlineCodegenUtil { "()V", false); } + public static boolean isInlineMarker(AbstractInsnNode insn) { + return isInlineMarker(insn, null); + } + + public static boolean isInlineMarker(AbstractInsnNode insn, String name) { + if (insn instanceof MethodInsnNode) { + MethodInsnNode methodInsnNode = (MethodInsnNode) insn; + return insn.getOpcode() == Opcodes.INVOKESTATIC && + methodInsnNode.owner.equals(INLINE_MARKER_CLASS_NAME) && + (name != null ? methodInsnNode.name.equals(name) + : methodInsnNode.name.equals(INLINE_MARKER_BEFORE_METHOD_NAME) || + methodInsnNode.name.equals(INLINE_MARKER_AFTER_METHOD_NAME)); + } + else { + return false; + } + } + + public static boolean isBeforeInlineMarker(AbstractInsnNode insn) { + return isInlineMarker(insn, INLINE_MARKER_BEFORE_METHOD_NAME); + } + + public static boolean isAfterInlineMarker(AbstractInsnNode insn) { + return isInlineMarker(insn, INLINE_MARKER_AFTER_METHOD_NAME); + } + public static int getLoadStoreArgSize(int opcode) { return opcode == Opcodes.DSTORE || opcode == Opcodes.LSTORE || opcode == Opcodes.DLOAD || opcode == Opcodes.LLOAD ? 2 : 1; } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java index 684f3808526..b687a7ccca3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.codegen.ClosureCodegen; import org.jetbrains.kotlin.codegen.StackValue; import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods; +import org.jetbrains.kotlin.codegen.optimization.MandatoryMethodTransformer; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass; import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache; @@ -373,6 +374,8 @@ public class MethodInliner { protected MethodNode markPlacesForInlineAndRemoveInlinable(@NotNull MethodNode node, int finallyDeepShift) { node = prepareNode(node, finallyDeepShift); + MandatoryMethodTransformer.INSTANCE$.transform("fake", node); + Analyzer analyzer = new Analyzer(new SourceInterpreter()) { @NotNull @Override diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackBeforeJumpTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackBeforeJumpTransformer.kt deleted file mode 100644 index 1e39ae7eef0..00000000000 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/FixStackBeforeJumpTransformer.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.codegen.optimization - -import org.jetbrains.kotlin.codegen.optimization.common.MethodAnalyzer -import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter -import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer -import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsnOpcode -import org.jetbrains.kotlin.codegen.pseudoInsns.parseOrNull -import org.jetbrains.org.objectweb.asm.Opcodes -import org.jetbrains.org.objectweb.asm.tree.* -import org.jetbrains.org.objectweb.asm.tree.analysis.* -import java.util.* -import kotlin.properties.Delegates -import kotlin.test.assertEquals - -class FixStackBeforeJumpTransformer : MethodTransformer() { - public override fun transform(internalClassName: String, methodNode: MethodNode) { - val jumpsToFix = linkedSetOf() - val fakesToGotos = arrayListOf() - val fakesToRemove = arrayListOf() - - methodNode.instructions.forEach { insnNode -> - when { - PseudoInsnOpcode.FIX_STACK_BEFORE_JUMP.isa(insnNode) -> { - val next = insnNode.getNext() - assert(next.getOpcode() == Opcodes.GOTO, - "Instruction after ${PseudoInsnOpcode.FIX_STACK_BEFORE_JUMP} should be GOTO") - jumpsToFix.add(next as JumpInsnNode) - } - PseudoInsnOpcode.FAKE_ALWAYS_TRUE_IFEQ.isa(insnNode) -> { - assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ, - "Instruction after ${PseudoInsnOpcode.FAKE_ALWAYS_TRUE_IFEQ} should be IFEQ") - fakesToGotos.add(insnNode) - } - PseudoInsnOpcode.FAKE_ALWAYS_FALSE_IFEQ.isa(insnNode) -> { - assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ, - "Instruction after ${PseudoInsnOpcode.FAKE_ALWAYS_FALSE_IFEQ} should be IFEQ") - fakesToRemove.add(insnNode) - } - } - } - - if (jumpsToFix.isEmpty() && fakesToGotos.isEmpty() && fakesToRemove.isEmpty()) { - return - } - - if (jumpsToFix.isNotEmpty()) { - val analyzer = StackDepthAnalyzer(internalClassName, methodNode, jumpsToFix) - val frames = analyzer.analyze() - - val actions = arrayListOf<() -> Unit>() - - for (jumpNode in jumpsToFix) { - val jumpIndex = methodNode.instructions.indexOf(jumpNode) - val labelIndex = methodNode.instructions.indexOf(jumpNode.label) - - val DEAD_CODE = -1 // Stack size is always non-negative for live code - val actualStackSize = frames[jumpIndex]?.getStackSize() ?: DEAD_CODE - val expectedStackSize = frames[labelIndex]?.getStackSize() ?: DEAD_CODE - - if (actualStackSize != DEAD_CODE && expectedStackSize != DEAD_CODE) { - assert(expectedStackSize <= actualStackSize, - "Label at $labelIndex, jump at $jumpIndex: stack underflow: $expectedStackSize > $actualStackSize") - val frame = frames[jumpIndex]!! - actions.add({ replaceMarkerWithPops(methodNode, jumpNode.getPrevious(), expectedStackSize, frame) }) - } - else if (actualStackSize != DEAD_CODE && expectedStackSize == DEAD_CODE) { - throw AssertionError("Live jump $jumpIndex to dead label $labelIndex") - } - else { - val marker = jumpNode.getPrevious() - actions.add({ methodNode.instructions.remove(marker) }) - } - } - - actions.forEach { it() } - } - - for (marker in fakesToGotos) { - replaceAlwaysTrueIfeqWithGoto(methodNode, marker) - } - - for (marker in fakesToRemove) { - removeAlwaysFalseIfeq(methodNode, marker) - } - } - - private fun removeAlwaysFalseIfeq(methodNode: MethodNode, nodeToReplace: AbstractInsnNode) { - with (methodNode.instructions) { - remove(nodeToReplace.getNext()) - remove(nodeToReplace) - } - } - - private fun replaceAlwaysTrueIfeqWithGoto(methodNode: MethodNode, nodeToReplace: AbstractInsnNode) { - with (methodNode.instructions) { - val next = nodeToReplace.getNext() as JumpInsnNode - insertBefore(nodeToReplace, JumpInsnNode(Opcodes.GOTO, next.label)) - remove(nodeToReplace) - remove(next) - } - } - - private fun replaceMarkerWithPops(methodNode: MethodNode, nodeToReplace: AbstractInsnNode, expectedStackSize: Int, frame: Frame) { - with (methodNode.instructions) { - while (frame.getStackSize() > expectedStackSize) { - val top = frame.pop() - insertBefore(nodeToReplace, getPopInstruction(top)) - } - remove(nodeToReplace) - } - } - - private fun getPopInstruction(top: BasicValue) = - InsnNode(when (top.getSize()) { - 1 -> Opcodes.POP - 2 -> Opcodes.POP2 - else -> throw AssertionError("Unexpected value type size") - }) - - private class StackDepthAnalyzer( - owner: String, - methodNode: MethodNode, - val markedJumps: Set - ) : MethodAnalyzer(owner, methodNode, OptimizationBasicInterpreter()) { - protected override fun visitControlFlowEdge(insn: Int, successor: Int): Boolean { - val insnNode = instructions[insn] - return !(insnNode is JumpInsnNode && markedJumps.contains(insnNode)) - } - } - -} - -private inline fun InsnList.forEach(block: (AbstractInsnNode) -> Unit) { - val iter = this.iterator() - while (iter.hasNext()) { - val insn = iter.next() - block(insn) - } -} - diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt new file mode 100644 index 00000000000..0ff23c89494 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt @@ -0,0 +1,155 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization + +import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer +import org.jetbrains.org.objectweb.asm.Label +import org.jetbrains.org.objectweb.asm.tree.* + +public object LabelNormalizationMethodTransformer : MethodTransformer() { + val newLabelNodes = hashMapOf() + val removedLabelNodes = hashSetOf() + + public override fun transform(internalClassName: String, methodNode: MethodNode) { + newLabelNodes.clear() + removedLabelNodes.clear() + + with(methodNode.instructions) { + insertBefore(getFirst(), LabelNode(Label())) + insert(getLast(), LabelNode(Label())) + } + + rewriteLabelInsns(methodNode) + if (removedLabelNodes.isEmpty()) return + + rewriteInsns(methodNode) + rewriteTryCatchBlocks(methodNode) + rewriteLocalVars(methodNode) + } + + private fun rewriteLabelInsns(methodNode: MethodNode) { + var prevLabelNode: LabelNode? = null + var thisNode = methodNode.instructions.getFirst() + while (thisNode != null) { + if (thisNode is LabelNode) { + if (prevLabelNode != null) { + newLabelNodes[thisNode] = prevLabelNode + removedLabelNodes.add(thisNode) + thisNode = methodNode.instructions.removeNodeGetNext(thisNode) + } + else { + prevLabelNode = thisNode + newLabelNodes[thisNode] = thisNode + thisNode = thisNode.getNext() + } + } + else { + prevLabelNode = null + thisNode = thisNode.getNext() + } + } + } + + private fun rewriteInsns(methodNode: MethodNode) { + var thisNode = methodNode.instructions.getFirst() + while (thisNode != null) { + thisNode = when (thisNode) { + is JumpInsnNode -> + rewriteJumpInsn(methodNode, thisNode) + is LineNumberNode -> + rewriteLineNumberNode(methodNode, thisNode) + is LookupSwitchInsnNode -> + rewriteLookupSwitchInsn(methodNode, thisNode) + is TableSwitchInsnNode -> + rewriteTableSwitchInsn(methodNode, thisNode) + is FrameNode -> + rewriteFrameNode(methodNode, thisNode) + else -> + thisNode.getNext() + } + } + } + + private fun rewriteLineNumberNode(methodNode: MethodNode, oldLineNode: LineNumberNode): AbstractInsnNode? { + if (isRemoved(oldLineNode.start)) { + val newLineNode = oldLineNode.clone(newLabelNodes) + return methodNode.instructions.replaceNodeGetNext(oldLineNode, newLineNode) + } + else { + return oldLineNode.getNext() + } + } + + private fun rewriteJumpInsn(methodNode: MethodNode, oldJumpNode: JumpInsnNode): AbstractInsnNode? { + if (isRemoved(oldJumpNode.label)) { + val newJumpNode = oldJumpNode.clone(newLabelNodes) + return methodNode.instructions.replaceNodeGetNext(oldJumpNode, newJumpNode) + } + else { + return oldJumpNode.getNext() + } + } + + private fun rewriteLookupSwitchInsn(methodNode: MethodNode, oldSwitchNode: LookupSwitchInsnNode): AbstractInsnNode? = + methodNode.instructions.replaceNodeGetNext(oldSwitchNode, oldSwitchNode.clone(newLabelNodes)) + + private fun rewriteTableSwitchInsn(methodNode: MethodNode, oldSwitchNode: TableSwitchInsnNode): AbstractInsnNode? = + methodNode.instructions.replaceNodeGetNext(oldSwitchNode, oldSwitchNode.clone(newLabelNodes)) + + private fun rewriteFrameNode(methodNode: MethodNode, oldFrameNode: FrameNode): AbstractInsnNode? = + methodNode.instructions.replaceNodeGetNext(oldFrameNode, oldFrameNode.clone(newLabelNodes)) + + private fun rewriteTryCatchBlocks(methodNode: MethodNode) { + methodNode.tryCatchBlocks = methodNode.tryCatchBlocks.map { oldTcb -> + if (isRemoved(oldTcb.start) || isRemoved(oldTcb.end) || isRemoved(oldTcb.handler)) { + val newTcb = TryCatchBlockNode(getNew(oldTcb.start), getNew(oldTcb.end), getNew(oldTcb.handler), oldTcb.type) + newTcb.visibleTypeAnnotations = oldTcb.visibleTypeAnnotations + newTcb.invisibleTypeAnnotations = oldTcb.invisibleTypeAnnotations + newTcb + } + else { + oldTcb + } + } + } + + private fun rewriteLocalVars(methodNode: MethodNode) { + methodNode.localVariables = methodNode.localVariables.map { oldVar -> + if (isRemoved(oldVar.start) || isRemoved(oldVar.end)) { + LocalVariableNode(oldVar.name, oldVar.desc, oldVar.signature, getNew(oldVar.start), getNew(oldVar.end), oldVar.index) + } + else { + oldVar + } + } + } + + private fun isRemoved(labelNode: LabelNode): Boolean = removedLabelNodes.contains(labelNode) + private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode] +} + +private fun InsnList.replaceNodeGetNext(oldNode: AbstractInsnNode, newNode: AbstractInsnNode): AbstractInsnNode? { + insertBefore(oldNode, newNode) + remove(oldNode) + return newNode.getNext() +} + +private fun InsnList.removeNodeGetNext(oldNode: AbstractInsnNode): AbstractInsnNode? { + val next = oldNode.getNext() + remove(oldNode) + return next +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt new file mode 100644 index 00000000000..2772abf06c2 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/MandatoryMethodTransforker.kt @@ -0,0 +1,28 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization + +import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer +import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer +import org.jetbrains.org.objectweb.asm.tree.MethodNode + +public object MandatoryMethodTransformer : MethodTransformer() { + public override fun transform(internalClassName: String, methodNode: MethodNode) { + LabelNormalizationMethodTransformer.transform(internalClassName, methodNode) + FixStackMethodTransformer.transform(internalClassName, methodNode) + } +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.java index 6cf98fb407c..8027d2e79e3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.java @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil; import org.jetbrains.kotlin.codegen.optimization.boxing.RedundantBoxingMethodTransformer; import org.jetbrains.kotlin.codegen.optimization.boxing.RedundantNullCheckMethodTransformer; import org.jetbrains.kotlin.codegen.optimization.common.CommonPackage; +import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer; import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Opcodes; @@ -36,16 +37,11 @@ import java.util.List; public class OptimizationMethodVisitor extends MethodVisitor { private static final int MEMORY_LIMIT_BY_METHOD_MB = 50; - private static final MethodTransformer[] MANDATORY_TRANSFORMERS = new MethodTransformer[] { - new FixStackBeforeJumpTransformer() - }; - private static final MethodTransformer[] OPTIMIZATION_TRANSFORMERS = new MethodTransformer[] { new RedundantNullCheckMethodTransformer(), new RedundantBoxingMethodTransformer(), new DeadCodeEliminationMethodTransformer(), - new RedundantGotoMethodTransformer(), - new StoreStackBeforeInlineMethodTransformer() + new RedundantGotoMethodTransformer() }; private final MethodNode methodNode; @@ -79,9 +75,7 @@ public class OptimizationMethodVisitor extends MethodVisitor { super.visitEnd(); if (shouldBeTransformed(methodNode)) { - for (MethodTransformer transformer : MANDATORY_TRANSFORMERS) { - transformer.transform("fake", methodNode); - } + MandatoryMethodTransformer.INSTANCE$.transform("fake", methodNode); if (canBeOptimized(methodNode) && !disableOptimization) { for (MethodTransformer transformer : OPTIMIZATION_TRANSFORMERS) { transformer.transform("fake", methodNode); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/StoreStackBeforeInlineMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/StoreStackBeforeInlineMethodTransformer.kt deleted file mode 100644 index e3bae6ebae2..00000000000 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/StoreStackBeforeInlineMethodTransformer.kt +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.codegen.optimization - -import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer -import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter -import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil -import org.jetbrains.org.objectweb.asm.tree.MethodNode -import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode -import org.jetbrains.org.objectweb.asm.Opcodes -import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode -import org.jetbrains.org.objectweb.asm.tree.analysis.Frame -import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue -import org.jetbrains.org.objectweb.asm.tree.VarInsnNode -import org.jetbrains.org.objectweb.asm.Type -import com.intellij.util.containers.Stack - -class StoreStackBeforeInlineMethodTransformer : MethodTransformer() { - override fun transform(internalClassName: String, methodNode: MethodNode) { - val frames = MethodTransformer.analyze(internalClassName, methodNode, OptimizationBasicInterpreter()) - if (needToProcess(methodNode, frames)) { - process(methodNode, frames) - } - else { - removeInlineMarkers(methodNode) - } - } -} - -private fun needToProcess(node: MethodNode, frames: Array?>): Boolean { - val insns = node.instructions.toArray() - var balance = 0 - var isThereAnyInlineMarker = false - - for ((insn, frame) in insns.zip(frames)) { - if (isInlineMarker(insn)) { - isThereAnyInlineMarker = true - - // inline marker is not available - if (frame == null) return false - } - - if (isBeforeInlineMarker(insn)) { - balance++ - } - else if(isAfterInlineMarker(insn)) { - balance-- - } - - if (balance < 0) return false - } - - return balance == 0 && isThereAnyInlineMarker -} - -private fun isBeforeInlineMarker(insn: AbstractInsnNode) = isInlineMarker(insn, InlineCodegenUtil.INLINE_MARKER_BEFORE_METHOD_NAME) - -private fun isAfterInlineMarker(insn: AbstractInsnNode) = isInlineMarker(insn, InlineCodegenUtil.INLINE_MARKER_AFTER_METHOD_NAME) - -private fun isInlineMarker(insn: AbstractInsnNode, markerName: String? = null): Boolean { - return insn.getOpcode() == Opcodes.INVOKESTATIC && - insn is MethodInsnNode && - insn.owner == InlineCodegenUtil.INLINE_MARKER_CLASS_NAME && - if (markerName != null) markerName == insn.name else ( - insn.name == InlineCodegenUtil.INLINE_MARKER_BEFORE_METHOD_NAME || - insn.name == InlineCodegenUtil.INLINE_MARKER_AFTER_METHOD_NAME - ) -} - -private fun process(methodNode: MethodNode, frames: Array?>) { - val insns = methodNode.instructions.toArray() - - val storedValuesDescriptorsStack = Stack() - var firstAvailableVarIndex = methodNode.maxLocals - var currentStoredValuesCount = 0 - - for ((insn, frame) in insns.zip(frames)) { - if (isBeforeInlineMarker(insn)) { - frame ?: throw AssertionError("process method shouldn't be called if frame is null before inline marker") - - val desc = storeStackValues(methodNode, frame, insn, firstAvailableVarIndex, currentStoredValuesCount) - - firstAvailableVarIndex += desc.storedStackSize - currentStoredValuesCount += desc.storedValuesCount - storedValuesDescriptorsStack.push(desc) - } - else if (isAfterInlineMarker(insn)) { - frame ?: throw AssertionError("process method shouldn't be called if frame is null before inline marker") - - val desc = storedValuesDescriptorsStack.pop() ?: - throw AssertionError("should be non null becase markers are balanced") - - loadStackValues(methodNode, frame, insn, desc) - firstAvailableVarIndex -= desc.storedStackSize - currentStoredValuesCount -= desc.storedValuesCount - } - - if (isInlineMarker(insn)) { - methodNode.instructions.remove(insn) - } - } -} - -private class StoredStackValuesDescriptor( - val values: List, - val firstVariableIndex: Int, - val storedStackSize: Int, - alreadyStoredValuesCount: Int -) { - val nextFreeVarIndex : Int get() = firstVariableIndex + storedStackSize - val storedValuesCount: Int get() = values.size() - val isStored: Boolean get() = storedValuesCount > 0 - val totalValuesCountOnStackBeforeInline = alreadyStoredValuesCount + storedValuesCount -} - -private fun removeInlineMarkers(node: MethodNode) { - for (insn in node.instructions.toArray()) { - if (isInlineMarker(insn)) { - node.instructions.remove(insn) - } - } -} - -private fun storeStackValues( - node: MethodNode, - frame: Frame, - beforeInlineMarker: AbstractInsnNode, - firstAvailableVarIndex: Int, - alreadyStoredValuesCount: Int -) : StoredStackValuesDescriptor { - var stackSize = 0 - - val values = frame.getStackValuesStartingFrom(alreadyStoredValuesCount) - - for (value in values.reverse()) { - node.instructions.insertBefore( - beforeInlineMarker, - VarInsnNode( - value.getType()!!.getOpcode(Opcodes.ISTORE), - firstAvailableVarIndex + stackSize - ) - ) - stackSize += value.getSize() - } - - node.updateMaxLocals(firstAvailableVarIndex + stackSize) - - return StoredStackValuesDescriptor(values, firstAvailableVarIndex, stackSize, alreadyStoredValuesCount) -} - -private fun loadStackValues( - node: MethodNode, - frame: Frame, - afterInlineMarker: AbstractInsnNode, - desc: StoredStackValuesDescriptor -) { - if (!desc.isStored) return - - val insns = node.instructions - var returnValueVarIndex = -1 - var returnType : Type? = null - - if (frame.getStackSize() != desc.totalValuesCountOnStackBeforeInline) { - // only returned value - assert( - (frame.getStackSize() - desc.totalValuesCountOnStackBeforeInline) == 1, - "Stack sizes should not differ by more than 1 (returned value)" - ) - - returnValueVarIndex = desc.nextFreeVarIndex - returnType = frame.getStack(frame.getStackSize() - 1)!!.getType() - node.updateMaxLocals(returnValueVarIndex + returnType!!.getSize()) - - insns.insertBefore( - afterInlineMarker, - VarInsnNode(returnType!!.getOpcode(Opcodes.ISTORE), returnValueVarIndex) - ) - } - - var currentVarIndex = desc.firstVariableIndex + desc.storedStackSize - - for (value in desc.values) { - currentVarIndex -= value.getSize() - insns.insertBefore( - afterInlineMarker, - VarInsnNode( - value.getType()!!.getOpcode(Opcodes.ILOAD), - currentVarIndex - ) - ) - } - - if (returnValueVarIndex != -1) { - insns.insertBefore( - afterInlineMarker, - VarInsnNode(returnType!!.getOpcode(Opcodes.ILOAD), returnValueVarIndex) - ) - } -} - -private fun Frame.getStackValuesStartingFrom(from: Int): List = - IntRange(from, getStackSize() - 1).map { getStack(it) }.requireNoNulls() - -private fun MethodNode.updateMaxLocals(newMaxLocals: Int) { - maxLocals = Math.max(maxLocals, newMaxLocals) -} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt index 2e78f8a251a..6d9a214ece3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/MethodAnalyzer.kt @@ -44,7 +44,11 @@ public open class MethodAnalyzer( protected open fun newFrame(nLocals: Int, nStack: Int): Frame = Frame(nLocals, nStack) - protected open fun newFrame(src: Frame): Frame = Frame(src) + protected open fun newFrame(src: Frame): Frame { + val frame = newFrame(src.getLocals(), src.getMaxStackSize()) + frame.init(src) + return frame + } protected open fun visitControlFlowEdge(insn: Int, successor: Int): Boolean = true @@ -94,12 +98,12 @@ public open class MethodAnalyzer( } handlers[insn]?.forEach { tcb -> - val type = Type.getObjectType(tcb.type?:"java/lang/Throwable") + val exnType = Type.getObjectType(tcb.type?:"java/lang/Throwable") val jump = instructions.indexOf(tcb.handler) if (visitControlFlowExceptionEdge(insn, tcb)) { handler.init(f) handler.clearStack() - handler.push(interpreter.newValue(type)) + handler.push(interpreter.newValue(exnType)) mergeControlFlowEdge(jump, handler) } } @@ -117,6 +121,9 @@ public open class MethodAnalyzer( return frames } + public fun getFrame(insn: AbstractInsnNode): Frame? = + frames[instructions.indexOf(insn)] + private fun checkAssertions() { if (instructions.toArray() any { it.getOpcode() == Opcodes.JSR || it.getOpcode() == Opcodes.RET }) throw AssertionError("Subroutines are deprecated since Java 6") @@ -170,9 +177,9 @@ public open class MethodAnalyzer( val ctype = Type.getObjectType(owner) current.setLocal(local++, interpreter.newValue(ctype)) } - for (i in args.indices) { - current.setLocal(local++, interpreter.newValue(args[i])) - if (args[i].getSize() == 2) { + for (arg in args) { + current.setLocal(local++, interpreter.newValue(arg)) + if (arg.getSize() == 2) { current.setLocal(local++, interpreter.newValue(null)) } } @@ -185,8 +192,7 @@ public open class MethodAnalyzer( } private fun computeExceptionHandlersForEachInsn(m: MethodNode) { - for (i in m.tryCatchBlocks.indices) { - val tcb = m.tryCatchBlocks.get(i) + for (tcb in m.tryCatchBlocks) { val begin = instructions.indexOf(tcb.start) val end = instructions.indexOf(tcb.end) for (j in begin..end - 1) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt index 565cbdc2d2d..b291df1fc78 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/common/Util.kt @@ -18,6 +18,8 @@ package org.jetbrains.kotlin.codegen.optimization.common import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.tree.InsnList +import org.jetbrains.org.objectweb.asm.tree.LabelNode import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue import org.jetbrains.org.objectweb.asm.tree.MethodNode @@ -28,7 +30,9 @@ val AbstractInsnNode.isMeaningful : Boolean get() = else -> true } -class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequence { +public class InsnSequence(val from: AbstractInsnNode, val to: AbstractInsnNode?) : Sequence { + public constructor(insnList: InsnList) : this(insnList.getFirst(), null) + override fun iterator(): Iterator { return object : Iterator { var current: AbstractInsnNode? = from @@ -77,3 +81,22 @@ abstract class BasicValueWrapper(val wrappedValue: BasicValue?) : BasicValue(wra return super.equals(other) && this.javaClass == other?.javaClass } } + +inline fun AbstractInsnNode.findNextOrNull(predicate: (AbstractInsnNode) -> Boolean): AbstractInsnNode? { + var finger = this.getNext() + while (finger != null && !predicate(finger)) { + finger = finger.getNext() + } + return finger +} + +inline fun AbstractInsnNode.findPreviousOrNull(predicate: (AbstractInsnNode) -> Boolean): AbstractInsnNode? { + var finger = this.getPrevious() + while (finger != null && !predicate(finger)) { + finger = finger.getPrevious() + } + return finger +} + +fun AbstractInsnNode.hasOpcode(): Boolean = + getOpcode() >= 0 diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/AnalyzeTryCatchBlocks.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/AnalyzeTryCatchBlocks.kt new file mode 100644 index 00000000000..ac330676925 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/AnalyzeTryCatchBlocks.kt @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import com.sun.xml.internal.ws.org.objectweb.asm.Opcodes +import org.jetbrains.kotlin.codegen.optimization.common.findNextOrNull +import org.jetbrains.kotlin.codegen.optimization.common.hasOpcode +import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer +import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn +import org.jetbrains.org.objectweb.asm.tree.* +import org.jetbrains.org.objectweb.asm.util.Printer + +private class DecompiledTryDescriptor(val tryStartLabel: LabelNode) { + var defaultHandlerTcb : TryCatchBlockNode? = null + val handlerStartLabels = hashSetOf() +} + +private fun TryCatchBlockNode.isDefaultHandlerNode(): Boolean = + start == handler + +private fun MethodNode.debugString(tcb: TryCatchBlockNode): String = + "TCB<${instructions.indexOf(tcb.start)}, ${instructions.indexOf(tcb.end)}, ${instructions.indexOf(tcb.handler)}>" + +internal fun insertTryCatchBlocksMarkers(methodNode: MethodNode) { + if (methodNode.tryCatchBlocks.isEmpty()) return + + val decompiledTryDescriptorForStart = linkedMapOf() + val decompiledTryDescriptorForHandler = hashMapOf() + + for (tcb in methodNode.tryCatchBlocks) { + if (tcb.isDefaultHandlerNode()) { + assert(decompiledTryDescriptorForHandler.containsKey(tcb.start), + "${methodNode.debugString(tcb)}: default handler should occur after some regular handler") + } + + val decompiledTryDescriptor = decompiledTryDescriptorForHandler.getOrPut(tcb.handler) { + decompiledTryDescriptorForStart.getOrPut(tcb.start) { + DecompiledTryDescriptor(tcb.start) + } + } + with(decompiledTryDescriptor) { + handlerStartLabels.add(tcb.handler) + + if (tcb.isDefaultHandlerNode()) { + assert(defaultHandlerTcb == null) { + "${methodNode.debugString(tcb)}: default handler is already found: ${methodNode.debugString(defaultHandlerTcb!!)}" + } + + defaultHandlerTcb = tcb + } + } + } + + val doneTryStartLabels = hashSetOf() + val doneHandlerLabels = hashSetOf() + + for (decompiledTryDescriptor in decompiledTryDescriptorForStart.values()) { + with(decompiledTryDescriptor) { + if (!doneTryStartLabels.contains(tryStartLabel)) { + doneTryStartLabels.add(tryStartLabel) + + val nopNode = tryStartLabel.findNextOrNull { it.hasOpcode() }!! + assert(nopNode.getOpcode() == Opcodes.NOP, + "${methodNode.instructions.indexOf(nopNode)}: try block should start with NOP") + + methodNode.instructions.insertBefore(tryStartLabel, PseudoInsn.SAVE_STACK_BEFORE_TRY.createInsnNode()) + methodNode.instructions.insert(nopNode, PseudoInsn.RESTORE_STACK_IN_TRY_CATCH.createInsnNode()) + } + + for (handlerStartLabel in handlerStartLabels) { + if (!doneHandlerLabels.contains(handlerStartLabel)) { + doneHandlerLabels.add(handlerStartLabel) + + val storeNode = handlerStartLabel.findNextOrNull { it.hasOpcode() }!! + assert(storeNode.getOpcode() == Opcodes.ASTORE, + "${methodNode.instructions.indexOf(storeNode)}: handler should start with ASTORE") + + methodNode.instructions.insert(storeNode, PseudoInsn.RESTORE_STACK_IN_TRY_CATCH.createInsnNode()) + } + } + } + } +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt new file mode 100644 index 00000000000..e1001342b5a --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -0,0 +1,157 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import com.intellij.util.SmartList +import com.intellij.util.containers.Stack +import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil +import org.jetbrains.kotlin.codegen.optimization.common.MethodAnalyzer +import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter +import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn +import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode +import org.jetbrains.org.objectweb.asm.tree.JumpInsnNode +import org.jetbrains.org.objectweb.asm.tree.MethodNode +import org.jetbrains.org.objectweb.asm.tree.TryCatchBlockNode +import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue +import org.jetbrains.org.objectweb.asm.tree.analysis.Frame +import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter +import java.util.* + +public class FixStackAnalyzer( + owner: String, + methodNode: MethodNode, + val context: FixStackContext +) : MethodAnalyzer(owner, methodNode, OptimizationBasicInterpreter()) { + val savedStacks = hashMapOf>() + var maxExtraStackSize = 0; private set + + protected override fun visitControlFlowEdge(insn: Int, successor: Int): Boolean { + val insnNode = instructions[insn] + return !(insnNode is JumpInsnNode && context.breakContinueGotoNodes.contains(insnNode)) + } + + protected override fun newFrame(nLocals: Int, nStack: Int): Frame = + FixStackFrame(nLocals, nStack) + + private fun indexOf(node: AbstractInsnNode) = method.instructions.indexOf(node) + + public inner class FixStackFrame(nLocals: Int, nStack: Int) : Frame(nLocals, nStack) { + val extraStack = Stack() + + public override fun init(src: Frame): Frame { + extraStack.clear() + extraStack.addAll((src as FixStackFrame).extraStack) + return super.init(src) + } + + public override fun clearStack() { + extraStack.clear() + super.clearStack() + } + + public override fun execute(insn: AbstractInsnNode, interpreter: Interpreter) { + when { + PseudoInsn.SAVE_STACK_BEFORE_TRY.isa(insn) -> + executeSaveStackBeforeTry(insn) + PseudoInsn.RESTORE_STACK_IN_TRY_CATCH.isa(insn) -> + executeRestoreStackInTryCatch(insn) + InlineCodegenUtil.isBeforeInlineMarker(insn) -> + executeBeforeInlineCallMarker(insn) + InlineCodegenUtil.isAfterInlineMarker(insn) -> + executeAfterInlineCallMarker(insn) + } + + super.execute(insn, interpreter) + } + + public fun getStackContent(): List { + val savedStack = arrayListOf() + IntRange(0, super.getStackSize() - 1).mapTo(savedStack) { super.getStack(it) } + savedStack.addAll(extraStack) + return savedStack + } + + public override fun push(value: BasicValue) { + if (super.getStackSize() < getMaxStackSize()) { + super.push(value) + } + else { + extraStack.add(value) + maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size()) + } + } + + public fun pushAll(values: Collection) { + values.forEach { push(it) } + } + + public override fun pop(): BasicValue { + if (extraStack.isNotEmpty()) { + return extraStack.pop() + } + else { + return super.pop() + } + } + + public override fun getStack(i: Int): BasicValue { + if (i < super.getMaxStackSize()) { + return super.getStack(i) + } + else { + return extraStack[i - getMaxStackSize()] + } + } + } + + private fun FixStackFrame.executeBeforeInlineCallMarker(insn: AbstractInsnNode) { + saveStackAndClear(insn) + } + + private fun FixStackFrame.saveStackAndClear(insn: AbstractInsnNode) { + val savedValues = getStackContent() + savedStacks[insn] = savedValues + clearStack() + } + + private fun FixStackFrame.executeAfterInlineCallMarker(insn: AbstractInsnNode) { + val beforeInlineMarker = context.openingInlineMethodMarker[insn] + if (getStackSize() > 0) { + val returnValue = pop() + clearStack() + val savedValues = savedStacks[beforeInlineMarker] + pushAll(savedValues) + push(returnValue) + } + else { + val savedValues = savedStacks[beforeInlineMarker] + pushAll(savedValues) + } + } + + private fun FixStackFrame.executeRestoreStackInTryCatch(insn: AbstractInsnNode) { + val saveNode = context.saveStackMarkerForRestoreMarker[insn] + val savedValues = savedStacks.getOrElse(saveNode) { + throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode)}") + } + pushAll(savedValues) + } + + private fun FixStackFrame.executeSaveStackBeforeTry(insn: AbstractInsnNode) { + saveStackAndClear(insn) + } +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt new file mode 100644 index 00000000000..418d801aada --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackContext.kt @@ -0,0 +1,142 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import com.intellij.util.SmartList +import com.intellij.util.containers.SmartHashSet +import com.intellij.util.containers.Stack +import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil +import org.jetbrains.kotlin.codegen.optimization.common.InsnSequence +import org.jetbrains.kotlin.codegen.optimization.common.findPreviousOrNull +import org.jetbrains.kotlin.codegen.optimization.common.hasOpcode +import org.jetbrains.kotlin.codegen.optimization.fixStack.forEachPseudoInsn +import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn +import org.jetbrains.kotlin.codegen.pseudoInsns.parsePseudoInsnOrNull +import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.tree.* +import java.util.* +import kotlin.properties.Delegates + +internal class FixStackContext(val methodNode: MethodNode) { + val breakContinueGotoNodes = linkedSetOf() + val fakeAlwaysTrueIfeqMarkers = arrayListOf() + val fakeAlwaysFalseIfeqMarkers = arrayListOf() + + val saveStackNodesForTryStartLabel = hashMapOf() + val saveStackMarkerForRestoreMarker = hashMapOf() + val restoreStackMarkersForSaveMarker = hashMapOf>() + + val openingInlineMethodMarker = hashMapOf() + var consistentInlineMarkers: Boolean = true; private set + + init { + insertTryCatchBlocksMarkers(methodNode) + + val inlineMarkersStack = Stack() + + InsnSequence(methodNode.instructions).forEach { insnNode -> + val pseudoInsn = parsePseudoInsnOrNull(insnNode) + when { + pseudoInsn == PseudoInsn.FIX_STACK_BEFORE_JUMP -> + visitFixStackBeforeJump(insnNode) + pseudoInsn == PseudoInsn.FAKE_ALWAYS_TRUE_IFEQ -> + visitFakeAlwaysTrueIfeq(insnNode) + pseudoInsn == PseudoInsn.FAKE_ALWAYS_FALSE_IFEQ -> + visitFakeAlwaysFalseIfeq(insnNode) + pseudoInsn == PseudoInsn.SAVE_STACK_BEFORE_TRY -> + visitSaveStackBeforeTry(insnNode) + pseudoInsn == PseudoInsn.RESTORE_STACK_IN_TRY_CATCH -> + visitRestoreStackInTryCatch(insnNode) + InlineCodegenUtil.isBeforeInlineMarker(insnNode) -> { + inlineMarkersStack.push(insnNode) + } + InlineCodegenUtil.isAfterInlineMarker(insnNode) -> { + assert(inlineMarkersStack.isNotEmpty(), "Mismatching after inline method marker at ${indexOf(insnNode)}") + openingInlineMethodMarker[insnNode] = inlineMarkersStack.pop() + } + } + } + + if (inlineMarkersStack.isNotEmpty()) { + consistentInlineMarkers = false + } + } + + private fun visitFixStackBeforeJump(insnNode: AbstractInsnNode) { + val next = insnNode.getNext() + assert(next.getOpcode() == Opcodes.GOTO, "${indexOf(insnNode)}: should be followed by GOTO") + breakContinueGotoNodes.add(next as JumpInsnNode) + } + + private fun visitFakeAlwaysTrueIfeq(insnNode: AbstractInsnNode) { + assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ, "${indexOf(insnNode)}: should be followed by IFEQ") + fakeAlwaysTrueIfeqMarkers.add(insnNode) + } + + private fun visitFakeAlwaysFalseIfeq(insnNode: AbstractInsnNode) { + assert(insnNode.getNext().getOpcode() == Opcodes.IFEQ, "${indexOf(insnNode)}: should be followed by IFEQ") + fakeAlwaysFalseIfeqMarkers.add(insnNode) + } + + private fun visitSaveStackBeforeTry(insnNode: AbstractInsnNode) { + val tryStartLabel = insnNode.getNext() + assert(tryStartLabel is LabelNode, "${indexOf(insnNode)}: save should be followed by a label") + saveStackNodesForTryStartLabel[tryStartLabel as LabelNode] = insnNode + } + + private fun visitRestoreStackInTryCatch(insnNode: AbstractInsnNode) { + val restoreLabel = insnNode.findPreviousOrNull { it.hasOpcode() }!!.findPreviousOrNull { it is LabelNode || it.hasOpcode() }!! + if (restoreLabel !is LabelNode) { + throw AssertionError("${indexOf(insnNode)}: restore should be preceded by a catch block label") + } + val saveNodes = findMatchingSaveNodes(insnNode, restoreLabel) + if (saveNodes.isEmpty()) { + throw AssertionError("${indexOf(insnNode)}: in handler ${indexOf(restoreLabel)} restore is not matched with save") + } + else if (saveNodes.size() > 1) { + throw AssertionError("${indexOf(insnNode)}: in handler ${indexOf(restoreLabel)} restore is matched with several saves") + } + val saveNode = saveNodes.first() + saveStackMarkerForRestoreMarker[insnNode] = saveNode + restoreStackMarkersForSaveMarker.getOrPut(saveNode, { SmartList() }).add(insnNode) + } + + private fun findMatchingSaveNodes(insnNode: AbstractInsnNode, restoreLabel: LabelNode): List { + val saveNodes = SmartHashSet() + methodNode.tryCatchBlocks.forEach { tcb -> + if (restoreLabel == tcb.start || restoreLabel == tcb.handler) { + saveStackNodesForTryStartLabel[tcb.start]?.let { saveNodes.add(it) } + } + } + return SmartList(saveNodes) + } + + private fun indexOf(node: AbstractInsnNode) = methodNode.instructions.indexOf(node) + + fun hasAnyMarkers(): Boolean = + breakContinueGotoNodes.isNotEmpty() || + fakeAlwaysTrueIfeqMarkers.isNotEmpty() || + fakeAlwaysFalseIfeqMarkers.isNotEmpty() || + saveStackNodesForTryStartLabel.isNotEmpty() || + openingInlineMethodMarker.isNotEmpty() + + fun isAnalysisRequired(): Boolean = + breakContinueGotoNodes.isNotEmpty() || + saveStackNodesForTryStartLabel.isNotEmpty() || + openingInlineMethodMarker.isNotEmpty() + +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt new file mode 100644 index 00000000000..c01bc2985f6 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackMethodTransformer.kt @@ -0,0 +1,213 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import com.intellij.util.containers.Stack +import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil +import org.jetbrains.kotlin.codegen.optimization.common.InsnSequence +import org.jetbrains.kotlin.codegen.optimization.common.MethodAnalyzer +import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter +import org.jetbrains.kotlin.codegen.optimization.fixStack.forEachPseudoInsn +import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer +import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn +import org.jetbrains.kotlin.codegen.pseudoInsns.parsePseudoInsnOrNull +import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.tree.* +import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue +import org.jetbrains.org.objectweb.asm.tree.analysis.Frame +import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter +import java.util.* +import kotlin.properties.Delegates + +public object FixStackMethodTransformer : MethodTransformer() { + public override fun transform(internalClassName: String, methodNode: MethodNode) { + val context = FixStackContext(methodNode) + + if (!context.hasAnyMarkers()) return + + // If inline method markers are inconsistent, remove them now + if (!context.consistentInlineMarkers) { + InsnSequence(methodNode.instructions).forEach { insnNode -> + if (InlineCodegenUtil.isInlineMarker(insnNode)) + methodNode.instructions.remove(insnNode) + } + } + + if (context.isAnalysisRequired()) { + val analyzer = FixStackAnalyzer(internalClassName, methodNode, context) + analyzer.analyze() + + methodNode.maxStack = methodNode.maxStack + analyzer.maxExtraStackSize + + val actions = arrayListOf<() -> Unit>() + + transformBreakContinueGotos(methodNode, context, actions, analyzer) + + transformSaveRestoreStackMarkers(methodNode, context, actions, analyzer) + + actions.forEach { it() } + } + + context.fakeAlwaysTrueIfeqMarkers.forEach { marker -> + replaceAlwaysTrueIfeqWithGoto(methodNode, marker) + } + + context.fakeAlwaysFalseIfeqMarkers.forEach { marker -> + removeAlwaysFalseIfeq(methodNode, marker) + } + } + + private fun transformBreakContinueGotos( + methodNode: MethodNode, + fixStackContext: FixStackContext, + actions: MutableList<() -> Unit>, + analyzer: FixStackAnalyzer + ) { + fixStackContext.breakContinueGotoNodes.forEach { gotoNode -> + val gotoIndex = methodNode.instructions.indexOf(gotoNode) + val labelIndex = methodNode.instructions.indexOf(gotoNode.label) + + val DEAD_CODE = -1 // Stack size is always non-negative + val actualStackSize = analyzer.frames[gotoIndex]?.getStackSize() ?: DEAD_CODE + val expectedStackSize = analyzer.frames[labelIndex]?.getStackSize() ?: DEAD_CODE + + if (actualStackSize != DEAD_CODE && expectedStackSize != DEAD_CODE) { + assert(expectedStackSize <= actualStackSize, + "Label at $labelIndex, jump at $gotoIndex: stack underflow: $expectedStackSize > $actualStackSize") + val frame = analyzer.frames[gotoIndex]!! + actions.add({ replaceMarkerWithPops(methodNode, gotoNode.getPrevious(), expectedStackSize, frame) }) + } + else if (actualStackSize != DEAD_CODE && expectedStackSize == DEAD_CODE) { + throw AssertionError("Live jump $gotoIndex to dead label $labelIndex") + } + else { + val marker = gotoNode.getPrevious() + actions.add({ methodNode.instructions.remove(marker) }) + } + } + } + + private fun transformSaveRestoreStackMarkers( + methodNode: MethodNode, + context: FixStackContext, + actions: MutableList<() -> Unit>, + analyzer: FixStackAnalyzer + ) { + val localVariablesManager = LocalVariablesManager(context, methodNode) + InsnSequence(methodNode.instructions).forEach { marker -> + val pseudoInsn = parsePseudoInsnOrNull(marker) + when { + pseudoInsn == PseudoInsn.SAVE_STACK_BEFORE_TRY -> + transformSaveStackMarker(methodNode, actions, analyzer, marker, localVariablesManager) + pseudoInsn == PseudoInsn.RESTORE_STACK_IN_TRY_CATCH -> + transformRestoreStackMarker(methodNode, actions, marker, localVariablesManager) + InlineCodegenUtil.isBeforeInlineMarker(marker) -> + transformBeforeInlineCallMarker(methodNode, actions, analyzer, marker, localVariablesManager) + InlineCodegenUtil.isAfterInlineMarker(marker) -> + transformAfterInlineCallMarker(methodNode, actions, analyzer, marker, localVariablesManager) + } + } + } + + private fun transformSaveStackMarker( + methodNode: MethodNode, + actions: MutableList<() -> Unit>, + analyzer: FixStackAnalyzer, + marker: AbstractInsnNode, + localVariablesManager: LocalVariablesManager + ) { + val savedStackValues = analyzer.savedStacks[marker] + if (savedStackValues != null) { + val savedStackDescriptor = localVariablesManager.allocateVariablesForSaveStackMarker(marker, savedStackValues) + actions.add({ saveStack(methodNode, marker, savedStackDescriptor, false) }) + } + else { + // marker is dead code + localVariablesManager.allocateVariablesForSaveStackMarker(marker, emptyList()) + actions.add({ methodNode.instructions.remove(marker) }) + } + } + + private fun transformRestoreStackMarker( + methodNode: MethodNode, + actions: MutableList<() -> Unit>, + marker: AbstractInsnNode, + localVariablesManager: LocalVariablesManager + ) { + val savedStackDescriptor = localVariablesManager.getSavedStackDescriptorOrNull(marker) + if (savedStackDescriptor != null) { + actions.add({ restoreStack(methodNode, marker, savedStackDescriptor) }) + } + else { + // marker is dead code + actions.add({ methodNode.instructions.remove(marker) }) + } + localVariablesManager.markRestoreStackMarkerEmitted(marker) + } + + private fun transformAfterInlineCallMarker( + methodNode: MethodNode, + actions: MutableList<() -> Unit>, + analyzer: FixStackAnalyzer, + inlineMarker: AbstractInsnNode, + localVariablesManager: LocalVariablesManager + ) { + val savedStackDescriptor = localVariablesManager.getBeforeInlineDescriptor(inlineMarker) + val afterInlineFrame = analyzer.getFrame(inlineMarker) as FixStackAnalyzer.FixStackFrame? + if (afterInlineFrame != null && savedStackDescriptor.isNotEmpty()) { + assert(afterInlineFrame.getStackSize() <= 1, "Inline method should not leave more than 1 value on stack") + if (afterInlineFrame.getStackSize() == 1) { + val afterInlineStackValues = afterInlineFrame.getStackContent() + val returnValue = afterInlineStackValues.last() + val returnValueLocalVarIndex = localVariablesManager.createReturnValueVariable(returnValue) + actions.add({ + restoreStackWithReturnValue(methodNode, inlineMarker, savedStackDescriptor, + returnValue, returnValueLocalVarIndex) + }) + } + else { + actions.add({ restoreStack(methodNode, inlineMarker, savedStackDescriptor) }) + } + } + else { + // after inline marker is dead code + actions.add({ methodNode.instructions.remove(inlineMarker) }) + } + localVariablesManager.markAfterInlineMarkerEmitted(inlineMarker) + } + + private fun transformBeforeInlineCallMarker( + methodNode: MethodNode, + actions: MutableList<() -> Unit>, + analyzer: FixStackAnalyzer, + inlineMarker: AbstractInsnNode, + localVariablesManager: LocalVariablesManager + ) { + val savedStackValues = analyzer.savedStacks[inlineMarker] + if (savedStackValues != null) { + val savedStackDescriptor = localVariablesManager.allocateVariablesForBeforeInlineMarker(inlineMarker, savedStackValues) + actions.add({ saveStack(methodNode, inlineMarker, savedStackDescriptor, false) }) + } + else { + // before inline marker is dead code + localVariablesManager.allocateVariablesForBeforeInlineMarker(inlineMarker, emptyList()) + actions.add({ methodNode.instructions.remove(inlineMarker) }) + } + } + + +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt new file mode 100644 index 00000000000..90e74c3d96c --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt @@ -0,0 +1,97 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode +import org.jetbrains.org.objectweb.asm.tree.MethodNode +import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue + +internal class LocalVariablesManager(val context: FixStackContext, val methodNode: MethodNode) { + private class AllocatedHandle(val savedStackDescriptor: SavedStackDescriptor, var numRestoreMarkers: Int) { + fun isFullyEmitted(): Boolean = + numRestoreMarkers == 0 + + fun markRestoreNodeEmitted() { + assert(numRestoreMarkers > 0, "Emitted more restore markers than expected for $savedStackDescriptor") + numRestoreMarkers-- + } + } + + private val initialMaxLocals = methodNode.maxLocals + private val allocatedHandles = hashMapOf() + + private fun updateMaxLocals(newValue: Int) { + methodNode.maxLocals = Math.max(methodNode.maxLocals, newValue) + } + + fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { + val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker].size() + return allocateNewHandle(numRestoreStackMarkers, saveStackMarker, savedStackValues) + } + + private fun allocateNewHandle(numRestoreStackMarkers: Int, saveStackMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { + val firstUnusedLocalVarIndex = getFirstUnusedLocalVariableIndex() + val savedStackDescriptor = SavedStackDescriptor(savedStackValues, firstUnusedLocalVarIndex) + updateMaxLocals(savedStackDescriptor.firstUnusedLocalVarIndex) + val allocatedHandle = AllocatedHandle(savedStackDescriptor, numRestoreStackMarkers) + allocatedHandles[saveStackMarker] = allocatedHandle + return savedStackDescriptor + } + + fun getSavedStackDescriptorOrNull(restoreStackMarker: AbstractInsnNode): SavedStackDescriptor { + val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] + return allocatedHandles[saveStackMarker].savedStackDescriptor + } + + private fun getFirstUnusedLocalVariableIndex(): Int = + allocatedHandles.values().fold(initialMaxLocals) { + index, handle -> Math.max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex) + } + + fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) { + val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] + markEmitted(saveStackMarker) + } + + fun allocateVariablesForBeforeInlineMarker(beforeInlineMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { + return allocateNewHandle(1, beforeInlineMarker, savedStackValues) + } + + fun getBeforeInlineDescriptor(afterInlineMarker: AbstractInsnNode): SavedStackDescriptor { + val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] + return allocatedHandles[beforeInlineMarker].savedStackDescriptor + } + + fun markAfterInlineMarkerEmitted(afterInlineMarker: AbstractInsnNode) { + val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] + markEmitted(beforeInlineMarker) + } + + private fun markEmitted(saveStackMarker: AbstractInsnNode) { + val allocatedHandle = allocatedHandles[saveStackMarker] + allocatedHandle.markRestoreNodeEmitted() + if (allocatedHandle.isFullyEmitted()) { + allocatedHandles.remove(saveStackMarker) + } + } + + fun createReturnValueVariable(returnValue: BasicValue): Int { + val returnValueIndex = getFirstUnusedLocalVariableIndex() + updateMaxLocals(returnValueIndex + returnValue.getSize()) + return returnValueIndex + } +} \ No newline at end of file diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt new file mode 100644 index 00000000000..01541346128 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/StackTransformationUtils.kt @@ -0,0 +1,153 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.optimization.fixStack + +import org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil +import org.jetbrains.kotlin.codegen.optimization.common.InsnSequence +import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn +import org.jetbrains.kotlin.codegen.pseudoInsns.parsePseudoInsnOrNull +import org.jetbrains.org.objectweb.asm.Opcodes +import org.jetbrains.org.objectweb.asm.tree.* +import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue +import org.jetbrains.org.objectweb.asm.tree.analysis.Frame +import org.jetbrains.org.objectweb.asm.tree.analysis.Value + +public inline fun InsnList.forEachPseudoInsn(block: (PseudoInsn, AbstractInsnNode) -> Unit) { + InsnSequence(this).forEach { insn -> + parsePseudoInsnOrNull(insn)?.let { block(it, insn) } + } +} + +public inline fun InsnList.forEachInlineMarker(block: (String, MethodInsnNode) -> Unit) { + InsnSequence(this).forEach { insn -> + if (InlineCodegenUtil.isInlineMarker(insn)) { + val methodInsnNode = insn as MethodInsnNode + block(methodInsnNode.name, methodInsnNode) + } + } +} + +public fun Frame.top(): V? { + val stackSize = getStackSize() + if (stackSize == 0) + return null + else + return getStack(stackSize - 1) +} + +public fun MethodNode.updateMaxLocals(newMaxLocals: Int) { + maxLocals = Math.max(maxLocals, newMaxLocals) +} + +class SavedStackDescriptor( + val savedValues: List, + val firstLocalVarIndex: Int +) { + val savedValuesSize = savedValues.fold(0, { size, value -> size + value.getSize() }) + val firstUnusedLocalVarIndex = firstLocalVarIndex + savedValuesSize + + public override fun toString(): String = + "@$firstLocalVarIndex: [$savedValues]" + + fun isNotEmpty(): Boolean = savedValues.isNotEmpty() +} + + +fun saveStack(methodNode: MethodNode, nodeToReplace: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor, + restoreImmediately: Boolean) { + with(methodNode.instructions) { + generateStoreInstructions(methodNode, nodeToReplace, savedStackDescriptor) + if (restoreImmediately) { + generateLoadInstructions(methodNode, nodeToReplace, savedStackDescriptor) + } + remove(nodeToReplace) + } +} + +fun restoreStack(methodNode: MethodNode, location: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor) { + with(methodNode.instructions) { + generateLoadInstructions(methodNode, location, savedStackDescriptor) + remove(location) + } +} + +fun restoreStackWithReturnValue( + methodNode: MethodNode, + nodeToReplace: AbstractInsnNode, + savedStackDescriptor: SavedStackDescriptor, + returnValue: BasicValue, + returnValueLocalVarIndex: Int +) { + with(methodNode.instructions) { + insertBefore(nodeToReplace, VarInsnNode(returnValue.getType().getOpcode(Opcodes.ISTORE), returnValueLocalVarIndex)) + generateLoadInstructions(methodNode, nodeToReplace, savedStackDescriptor) + insertBefore(nodeToReplace, VarInsnNode(returnValue.getType().getOpcode(Opcodes.ILOAD), returnValueLocalVarIndex)) + remove(nodeToReplace) + } +} + +fun generateLoadInstructions(methodNode: MethodNode, location: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor) { + var localVarIndex = savedStackDescriptor.firstLocalVarIndex + for (value in savedStackDescriptor.savedValues) { + methodNode.instructions.insertBefore(location, + VarInsnNode(value.getType().getOpcode(Opcodes.ILOAD), localVarIndex)) + localVarIndex += value.getSize() + } +} + +fun generateStoreInstructions(methodNode: MethodNode, location: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor) { + var localVarIndex = savedStackDescriptor.firstUnusedLocalVarIndex + for (value in savedStackDescriptor.savedValues.reverse()) { + localVarIndex -= value.getSize() + methodNode.instructions.insertBefore(location, + VarInsnNode(value.getType().getOpcode(Opcodes.ISTORE), localVarIndex)) + } +} + +fun getPopInstruction(top: BasicValue) = + InsnNode(when (top.getSize()) { + 1 -> Opcodes.POP + 2 -> Opcodes.POP2 + else -> throw AssertionError("Unexpected value type size") + }) + +fun removeAlwaysFalseIfeq(methodNode: MethodNode, node: AbstractInsnNode) { + with (methodNode.instructions) { + remove(node.getNext()) + remove(node) + } +} + +fun replaceAlwaysTrueIfeqWithGoto(methodNode: MethodNode, node: AbstractInsnNode) { + with (methodNode.instructions) { + val next = node.getNext() as JumpInsnNode + insertBefore(node, JumpInsnNode(Opcodes.GOTO, next.label)) + remove(node) + remove(next) + } +} + +fun replaceMarkerWithPops(methodNode: MethodNode, node: AbstractInsnNode, expectedStackSize: Int, frame: Frame) { + with (methodNode.instructions) { + while (frame.getStackSize() > expectedStackSize) { + val top = frame.pop() + insertBefore(node, getPopInstruction(top)) + } + remove(node) + } +} + diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt index d1608dfe2a8..112c259daf4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/pseudoInsns/PseudoInsns.kt @@ -24,78 +24,46 @@ import org.jetbrains.org.objectweb.asm.tree.InsnList import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode import kotlin.platform.platformStatic -public val PSEUDO_INSN_CALL_OWNER: String = "kotlin.jvm.\$PseudoInsn" -public val PSEUDO_INSN_PARTS_SEPARATOR: String = ":" +public val PSEUDO_INSN_CALL_OWNER: String = "kotlin/jvm/internal/\$PseudoInsn" -public enum class PseudoInsnOpcode(val signature: String = "()V") { +public enum class PseudoInsn(val signature: String = "()V") { FIX_STACK_BEFORE_JUMP(), FAKE_ALWAYS_TRUE_IFEQ("()I"), - FAKE_ALWAYS_FALSE_IFEQ("()I") + FAKE_ALWAYS_FALSE_IFEQ("()I"), + SAVE_STACK_BEFORE_TRY(), + RESTORE_STACK_IN_TRY_CATCH() ; - public fun insnOf(): PseudoInsn = PseudoInsn(this, emptyList()) - public fun insnOf(args: List): PseudoInsn = PseudoInsn(this, args) - - public fun parseOrNull(insn: AbstractInsnNode): PseudoInsn? { - val pseudo = parseOrNull(insn) - return if (pseudo?.opcode == this) pseudo else null - } - - public fun isa(insn: AbstractInsnNode): Boolean = - if (isPseudoInsn(insn)) { - val methodName = (insn as MethodInsnNode).name - methodName == this.toString() || methodName.startsWith(this.toString() + PSEUDO_INSN_PARTS_SEPARATOR) - } - else false - public fun emit(iv: InstructionAdapter) { - insnOf().emit(iv) + iv.invokestatic(PSEUDO_INSN_CALL_OWNER, toString(), signature, false) } + + public fun createInsnNode(): MethodInsnNode = + MethodInsnNode(Opcodes.INVOKESTATIC, PSEUDO_INSN_CALL_OWNER, toString(), signature, false) + + public fun isa(node: AbstractInsnNode): Boolean = + this == parsePseudoInsnOrNull(node) } -public class PseudoInsn(public val opcode: PseudoInsnOpcode, public val args: List) { - public val encodedMethodName: String = - if (args.isEmpty()) - opcode.toString() - else - opcode.toString() + PSEUDO_INSN_PARTS_SEPARATOR + args.join(PSEUDO_INSN_PARTS_SEPARATOR) +public fun isPseudoInsn(insn: AbstractInsnNode): Boolean = + insn is MethodInsnNode && insn.getOpcode() == Opcodes.INVOKESTATIC && insn.owner == PSEUDO_INSN_CALL_OWNER - public fun emit(iv: InstructionAdapter) { - iv.invokestatic(PSEUDO_INSN_CALL_OWNER, encodedMethodName, opcode.signature, false) - } -} +public fun parsePseudoInsnOrNull(insn: AbstractInsnNode): PseudoInsn? = + if (isPseudoInsn(insn)) + PseudoInsn.valueOf((insn as MethodInsnNode).name) + else null public fun InstructionAdapter.fixStackAndJump(label: Label) { - PseudoInsnOpcode.FIX_STACK_BEFORE_JUMP.emit(this) + PseudoInsn.FIX_STACK_BEFORE_JUMP.emit(this) this.goTo(label) } public fun InstructionAdapter.fakeAlwaysTrueIfeq(label: Label) { - PseudoInsnOpcode.FAKE_ALWAYS_TRUE_IFEQ.emit(this) + PseudoInsn.FAKE_ALWAYS_TRUE_IFEQ.emit(this) this.ifeq(label) } public fun InstructionAdapter.fakeAlwaysFalseIfeq(label: Label) { - PseudoInsnOpcode.FAKE_ALWAYS_FALSE_IFEQ.emit(this) + PseudoInsn.FAKE_ALWAYS_FALSE_IFEQ.emit(this) this.ifeq(label) } - -public fun parseOrNull(insn: AbstractInsnNode): PseudoInsn? = - if (isPseudoInsn(insn)) - parseParts(getPseudoInsnParts(insn as MethodInsnNode)) - else null - -private fun isPseudoInsn(insn: AbstractInsnNode) = - insn is MethodInsnNode && insn.getOpcode() == Opcodes.INVOKESTATIC && insn.owner == PSEUDO_INSN_CALL_OWNER - -private fun getPseudoInsnParts(insn: MethodInsnNode): List = - insn.name.splitBy(PSEUDO_INSN_PARTS_SEPARATOR) - -private fun parseParts(parts: List): PseudoInsn? { - try { - return PseudoInsnOpcode.valueOf(parts[0]).insnOf(parts.subList(1, parts.size())) - } - catch (e: IllegalArgumentException) { - return null - } -} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/catch.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/catch.kt new file mode 100644 index 00000000000..cb00faf1fe3 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/catch.kt @@ -0,0 +1,2 @@ +fun box(): String = + "O" + try { throw Exception("oops!") } catch (e: Exception) { "K" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/complexChain.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/complexChain.kt new file mode 100644 index 00000000000..36f2e84f29f --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/complexChain.kt @@ -0,0 +1,52 @@ +fun cleanup() {} + +inline fun concat(x: String, y: String): String = x + y + +inline fun throws() { + try { + throw Exception() + } + finally { + cleanup() + } +} + +inline fun first(x: String, y: String): String = x + +fun box(): String = + "" + concat( + try { "" } finally { "0" }, + "" + concat( + first( + try { + try { + "O" + } + finally { + "1" + } + } + catch (e: Exception) { + throw e + } + finally { + cleanup() + }, + "2" + ), + first( + try { + throws() + throw Exception() + "3" + } + catch (e: Exception) { + "K" + } + finally { + cleanup() + }, + "4" + ) + ) + ) diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/differentTypes.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/differentTypes.kt new file mode 100644 index 00000000000..44fa018cce5 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/differentTypes.kt @@ -0,0 +1,8 @@ +fun foo(b: Byte, s: String, i: Int, d: Double, li: Long): String = "$b $s $i $d $li" + +fun box(): String { + val test = foo(1, "abc", 1, 1.0, try { 1L } catch (e: Exception) { 10L }) + if (test != "1 abc 1 1.0 1") return "Failed, test==$test" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/expectException.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/expectException.kt new file mode 100644 index 00000000000..63bd4900c12 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/expectException.kt @@ -0,0 +1,35 @@ +public inline fun fails(block: () -> Unit): Throwable? { + var thrown: Throwable? = null + try { + block() + } catch (e: Throwable) { + thrown = e + } + if (thrown == null) + throw Exception("Expected an exception to be thrown") + return thrown +} + +public inline fun throwIt(msg: String) { + throw Exception(msg) +} + +fun box(): String { + fails { + throwIt("oops!") + } + + var x = 0 + try { + fails { + x = 1 + } + } + catch (e: Exception) { + x = 2 + } + + if (x != 2) return "Failed: x==$x" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/finally.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/finally.kt new file mode 100644 index 00000000000..2d4b9f825a7 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/finally.kt @@ -0,0 +1,2 @@ +fun box(): String = + "O" + try { "K" } finally { "hmmm" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryCatch.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryCatch.kt new file mode 100644 index 00000000000..dd3a181348a --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryCatch.kt @@ -0,0 +1,17 @@ +inline fun tryOrElse(f1: () -> T, f2: () -> T): T { + try { + return f1() + } + catch (e: Exception) { + return f2() + } +} + +fun testIt() = "abc" + tryOrElse({ "def" }, { "oops" }) + "ghi" + +fun box(): String { + val test = testIt() + if (test != "abcdefghi") return "Failed, test==$test" + + return "OK" +} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryExpr.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryExpr.kt new file mode 100644 index 00000000000..8205200452a --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryExpr.kt @@ -0,0 +1,14 @@ +inline fun tryOrElse(f1: () -> T, f2: () -> T): T = + try { f1() } catch (e: Exception) { f2() } + +fun testIt() = + "abc" + + tryOrElse({ try { "def" } catch(e: Exception) { "oops!" } }, { "hmmm..." }) + + "ghi" + +fun box(): String { + val test = testIt() + if (test != "abcdefghi") return "Failed, test==$test" + + return "OK" +} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryFinally.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryFinally.kt new file mode 100644 index 00000000000..eb488beb689 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryFinally.kt @@ -0,0 +1,22 @@ +inline fun tryAndThen(f1: () -> Unit, f2: () -> Unit, f3: () -> T): T { + try { + f1() + } + catch (e: Exception) { + f2() + } + finally { + return f3() + } +} + +fun testIt() = "abc" + + tryAndThen({}, {}, { "def" }) + + "ghi" + +fun box(): String { + val test = testIt() + if (test != "abcdefghi") return "Failed, test==$test" + + return "OK" +} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/multipleCatchBlocks.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/multipleCatchBlocks.kt new file mode 100644 index 00000000000..45dd6ead838 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/multipleCatchBlocks.kt @@ -0,0 +1,20 @@ +class Exception1(msg: String): Exception(msg) +class Exception2(msg: String): Exception(msg) +class Exception3(msg: String): Exception(msg) + +fun box(): String = + "O" + try { + throw Exception3("K") + } + catch (e1: Exception1) { + "e1" + } + catch (e2: Exception2) { + "e2" + } + catch (e3: Exception3) { + e3.getMessage() + } + catch (e: Exception) { + "e" + } diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTry.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTry.kt new file mode 100644 index 00000000000..c60bde586a1 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTry.kt @@ -0,0 +1,25 @@ +inline fun test(s: () -> Int): Int = + try { + val i = s() + i + 10 + } + finally { + 0 + } + +fun box() : String { + test { + try { + val p = 1 + return "OK" + } + catch(e: Exception) { + -2 + } + finally { + -3 + } + } + + return "Failed" +} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner1.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner1.kt new file mode 100644 index 00000000000..bbf5ad07064 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner1.kt @@ -0,0 +1,11 @@ +fun shouldReturnFalse() : Boolean { + try { + return true + } finally { + if (true) + return false + } +} + +fun box(): String = + if (shouldReturnFalse()) "Failed" else "OK" \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner2.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner2.kt new file mode 100644 index 00000000000..7c0c3e81c55 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner2.kt @@ -0,0 +1,22 @@ +fun shouldReturn11() : Int { + var x = 0 + while (true) { + try { + if(x < 10) + x++ + else + break + } + finally { + x++ + } + } + return x +} + +fun box(): String { + val test = shouldReturn11() + if (test != 11) return "Failed, test=$test" + + return "OK" +} diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/try.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/try.kt new file mode 100644 index 00000000000..695e324988e --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/try.kt @@ -0,0 +1,2 @@ +fun box(): String = + "O" + try { "K" } catch (e: Exception) { "oops!" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAfterTry.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAfterTry.kt new file mode 100644 index 00000000000..7d6dcc3d2a3 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAfterTry.kt @@ -0,0 +1,4 @@ +fun box(): String = + "" + + try { "O" } catch (e: Exception) { "1" } + + try { throw Exception("oops!") } catch (e: Exception) { "K" } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndBreak.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndBreak.kt new file mode 100644 index 00000000000..a1f867b1c3d --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndBreak.kt @@ -0,0 +1,19 @@ +fun idiv(a: Int, b: Int): Int = + if (b == 0) throw Exception("Division by zero") else a / b + +fun foo(): Int { + var sum = 0 + var i = 2 + while (i > -10) { + sum += try { idiv(100, i) } catch (e: Exception) { break } + i-- + } + return sum +} + +fun box(): String { + val test = foo() + if (test != 150) return "Failed, test=$test" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndContinue.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndContinue.kt new file mode 100644 index 00000000000..120d463b00c --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndContinue.kt @@ -0,0 +1,17 @@ +fun idiv(a: Int, b: Int): Int = + if (b == 0) throw Exception("Division by zero") else a / b + +fun foo(): Int { + var sum = 0 + for (i in -10 .. 10) { + sum += try { idiv(100, i) } catch (e: Exception) { continue } + } + return sum +} + +fun box(): String { + val test = foo() + if (test != 0) return "Failed, test=$test" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideCatch.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideCatch.kt new file mode 100644 index 00000000000..09f9857b57c --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideCatch.kt @@ -0,0 +1,8 @@ +fun box(): String = + "O" + + try { + throw Exception("oops!") + } + catch (e: Exception) { + try { "K" } catch (e: Exception) { "2" } + } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideTry.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideTry.kt new file mode 100644 index 00000000000..3d1ccd9e7ae --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideTry.kt @@ -0,0 +1,10 @@ +class MyException(message: String): Exception(message) + +fun box(): String = + "O" + + try { + try { throw Exception("oops!") } catch (mye: MyException) { "1" } + } + catch (e: Exception) { + "K" + } \ No newline at end of file diff --git a/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/unmatchedInlineMarkers.kt b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/unmatchedInlineMarkers.kt new file mode 100644 index 00000000000..015b4137f65 --- /dev/null +++ b/compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/unmatchedInlineMarkers.kt @@ -0,0 +1,17 @@ +inline fun catchAll(x: String, block: () -> Unit): String { + try { + block() + } catch (e: Throwable) { + } + return x +} + +inline fun throwIt(msg: String) { + throw Exception(msg) +} + +inline fun bar(x: String): String = + x + catchAll("") { throwIt("oops!") } + +fun box(): String = + bar("OK") diff --git a/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/unreachableMarker.kt b/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/unreachableMarker.kt index 0b68ac9f93b..255dbcccba6 100644 --- a/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/unreachableMarker.kt +++ b/compiler/testData/codegen/bytecodeText/storeStackBeforeInline/unreachableMarker.kt @@ -16,6 +16,6 @@ fun foo() : String { ) } -// 12 ALOAD -// 0 ASTORE +// 14 ALOAD +// 2 ASTORE // 0 InlineMarker diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.java index 42a6b8713fe..389b1c2b915 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.java @@ -50,7 +50,7 @@ public abstract class AbstractBytecodeTextTest extends CodegenTestCase { } try { - assertEquals(expected.toString(), actual.toString()); + assertEquals(text, expected.toString(), actual.toString()); } catch (Throwable e) { System.out.println(text); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java index f3eca85f790..de6bfde4436 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CodegenTestCase.java @@ -246,7 +246,7 @@ public abstract class CodegenTestCase extends UsefulTestCase { analyzer.analyze(classNode.name, method); } catch (Throwable e) { - System.out.println(file.asText()); + System.err.println(file.asText()); System.err.println(classNode.name + "::" + method.name + method.desc); //noinspection InstanceofCatchParameter diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 357a6e933b2..fe9d48e3f7d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -2289,6 +2289,129 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } } + + @TestMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TryCatchInExpressions extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInTryCatchInExpressions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("catch.kt") + public void testCatch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/catch.kt"); + doTest(fileName); + } + + @TestMetadata("complexChain.kt") + public void testComplexChain() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/complexChain.kt"); + doTest(fileName); + } + + @TestMetadata("differentTypes.kt") + public void testDifferentTypes() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/differentTypes.kt"); + doTest(fileName); + } + + @TestMetadata("expectException.kt") + public void testExpectException() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/expectException.kt"); + doTest(fileName); + } + + @TestMetadata("finally.kt") + public void testFinally() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/finally.kt"); + doTest(fileName); + } + + @TestMetadata("inlineTryCatch.kt") + public void testInlineTryCatch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryCatch.kt"); + doTest(fileName); + } + + @TestMetadata("inlineTryExpr.kt") + public void testInlineTryExpr() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryExpr.kt"); + doTest(fileName); + } + + @TestMetadata("inlineTryFinally.kt") + public void testInlineTryFinally() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/inlineTryFinally.kt"); + doTest(fileName); + } + + @TestMetadata("multipleCatchBlocks.kt") + public void testMultipleCatchBlocks() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/multipleCatchBlocks.kt"); + doTest(fileName); + } + + @TestMetadata("splitTry.kt") + public void testSplitTry() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTry.kt"); + doTest(fileName); + } + + @TestMetadata("splitTryCorner1.kt") + public void testSplitTryCorner1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner1.kt"); + doTest(fileName); + } + + @TestMetadata("splitTryCorner2.kt") + public void testSplitTryCorner2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/splitTryCorner2.kt"); + doTest(fileName); + } + + @TestMetadata("try.kt") + public void testTry() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/try.kt"); + doTest(fileName); + } + + @TestMetadata("tryAfterTry.kt") + public void testTryAfterTry() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAfterTry.kt"); + doTest(fileName); + } + + @TestMetadata("tryAndBreak.kt") + public void testTryAndBreak() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndBreak.kt"); + doTest(fileName); + } + + @TestMetadata("tryAndContinue.kt") + public void testTryAndContinue() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryAndContinue.kt"); + doTest(fileName); + } + + @TestMetadata("tryInsideCatch.kt") + public void testTryInsideCatch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideCatch.kt"); + doTest(fileName); + } + + @TestMetadata("tryInsideTry.kt") + public void testTryInsideTry() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/tryInsideTry.kt"); + doTest(fileName); + } + + @TestMetadata("unmatchedInlineMarkers.kt") + public void testUnmatchedInlineMarkers() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/tryCatchInExpressions/unmatchedInlineMarkers.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/codegen/box/deadCodeElimination") From fed264580d8db73c9995502a59e218135d41c463 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 6 Jul 2015 20:58:15 +0300 Subject: [PATCH 069/450] Update to 142.2887.3 --- update_dependencies.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_dependencies.xml b/update_dependencies.xml index 2c0d60b5712..f775fc2efbe 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -1,5 +1,5 @@ - + From 002bca2f019567d299bad016b3c36b6edb32217a Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Fri, 26 Jun 2015 11:29:56 +0300 Subject: [PATCH 070/450] Fix compilation --- .../kotlin/idea/debugger/AbstractKotlinSteppingTest.kt | 4 ++-- .../jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt | 4 ---- .../debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt index ca491a4df8a..897163a5f8c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/AbstractKotlinSteppingTest.kt @@ -55,7 +55,7 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() { File(path).readLines().forEach { when { - it.startsWith("// STEP_INTO") -> repeat("// STEP_INTO: ") { stepInto() } + it.startsWith("// STEP_INTO") -> repeat("// STEP_INTO: ") { stepInto(this) } it.startsWith("// STEP_OUT") -> repeat("// STEP_OUT: ") { stepOut() } it.startsWith("// SMART_STEP_INTO") -> repeat("// SMART_STEP_INTO: ") { smartStepInto() } it.startsWith("// RESUME") -> repeat("// RESUME: ") { resume(this) } @@ -75,7 +75,7 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() { for (i in 1..(getPrefixedInt(fileText, "// $command: ") ?: 1)) { doOnBreakpoint { when(command) { - "STEP_INTO" -> stepInto() + "STEP_INTO" -> stepInto(this) "STEP_OUT" -> stepOut() "SMART_STEP_INTO" -> smartStepInto() } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt index 88eccc6dafd..1b16d323ada 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinDebuggerTestBase.kt @@ -117,10 +117,6 @@ abstract class KotlinDebuggerTestBase : KotlinDebuggerTestCase() { } } - protected fun SuspendContextImpl.stepInto() { - this.stepInto(false, null) - } - protected var evaluationContext: EvaluationContextImpl by Delegates.notNull() protected var debuggerContext: DebuggerContextImpl by Delegates.notNull() diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index bc35fd78481..2a3dc421c34 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -110,7 +110,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB val count = InTextDirectivesUtils.getPrefixedInt(fileText, "// STEP_INTO: ") ?: 0 if (count > 0) { for (i in 1..count) { - doOnBreakpoint { stepInto() } + doOnBreakpoint { this@AbstractKotlinEvaluateExpressionTest.stepInto(this) } } } From 23ae5ae57c7c59a00355e8e5bf56c77c07c470a9 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 3 Jul 2015 10:40:48 +0300 Subject: [PATCH 071/450] Remove own idea runtime and reflect jars --- update_dependencies.xml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/update_dependencies.xml b/update_dependencies.xml index f775fc2efbe..10ca0e8ca2d 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -652,6 +652,19 @@ + + + + + + + @@ -705,13 +718,6 @@ - - - From 65c6bad542f5ff0e360328cec37fca37dd95f5e7 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 7 Jul 2015 14:45:52 +0300 Subject: [PATCH 072/450] Remove bundled plugin from ideaSDK --- update_dependencies.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/update_dependencies.xml b/update_dependencies.xml index 10ca0e8ca2d..e4f8ac0aeb3 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -664,6 +664,7 @@ --> + From cdf9025f38b58c515478fb822c0199cb22c07a81 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 14:32:19 +0200 Subject: [PATCH 073/450] JetColorSettingsPage: rename to .kt --- .../{JetColorSettingsPage.java => KotlinColorSettingsPage.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/highlighter/{JetColorSettingsPage.java => KotlinColorSettingsPage.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/JetColorSettingsPage.java b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/highlighter/JetColorSettingsPage.java rename to idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt From c5ea13e5a6366b883dd5deab1bb833df8952a662 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 15:03:54 +0200 Subject: [PATCH 074/450] KotlinColorSettingsPage: J2L --- idea/src/META-INF/plugin.xml | 2 +- .../highlighter/KotlinColorSettingsPage.kt | 294 ++++++++---------- 2 files changed, 131 insertions(+), 165 deletions(-) diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index d2207a7ac84..4be55c90633 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -290,7 +290,7 @@ - + diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt index 9973ee92441..bb0d7aa1dd3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt @@ -14,175 +14,141 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.highlighter; +package org.jetbrains.kotlin.idea.highlighter -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.options.OptionsBundle; -import com.intellij.openapi.options.colors.AttributesDescriptor; -import com.intellij.openapi.options.colors.ColorDescriptor; -import com.intellij.openapi.options.colors.ColorSettingsPage; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.JetBundle; -import org.jetbrains.kotlin.idea.JetIcons; -import org.jetbrains.kotlin.idea.JetLanguage; +import com.intellij.openapi.editor.colors.TextAttributesKey +import com.intellij.openapi.fileTypes.SyntaxHighlighter +import com.intellij.openapi.options.OptionsBundle +import com.intellij.openapi.options.colors.AttributesDescriptor +import com.intellij.openapi.options.colors.ColorDescriptor +import com.intellij.openapi.options.colors.ColorSettingsPage +import org.jetbrains.kotlin.idea.JetBundle +import org.jetbrains.kotlin.idea.JetIcons +import org.jetbrains.kotlin.idea.JetLanguage -import javax.swing.*; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Map; +import javax.swing.* +import java.lang.reflect.Field +import java.lang.reflect.Modifier +import java.util.HashMap -public class JetColorSettingsPage implements ColorSettingsPage { - @Override - public Icon getIcon() { - return JetIcons.SMALL_LOGO; - } +public class KotlinColorSettingsPage : ColorSettingsPage { + override fun getIcon() = JetIcons.SMALL_LOGO + override fun getHighlighter(): SyntaxHighlighter = JetHighlighter() - @NotNull - @Override - public SyntaxHighlighter getHighlighter() { - return new JetHighlighter(); - } + override fun getDemoText(): String { + return """/* Block comment */ +package hello +import kotlin.util.* // line comment - @NotNull - @Override - public String getDemoText() { - return "/* Block comment */\n" + - "package hello\n" + - "import kotlin.util.* // line comment\n" + - "\n" + - "/**\n" + - " * Doc comment here for `SomeClass`\n" + - " * @see Iterator#next()\n" + - " */\n" + - "@deprecated(\"Deprecated class\")\n" + - "public class MyClass<out T : Iterable<T>>(var prop1 : Int) {\n" + - " fun foo(nullable : String?, r : Runnable, f : () -> Int, fl : FunctionLike, dyn: dynamic) {\n" + - " println(\"length\\nis ${nullable?.length} \\e\")\n" + - " val ints = java.util.ArrayList(2)\n" + - " ints[0] = 102 + f() + fl()\n" + - " val myFun = { -> \"\" };\n" + - " var ref = ints.size()\n" + - " if (!ints.empty) {\n" + - " ints.forEach {\n" + - " if (it == null) return\n" + - " println(it + ref)\n" + - " }\n" + - " }\n" + - " dyn.dynamicCall()\n" + - " dyn.dynamicProp = 5\n" + - " }\n" + - "}\n" + - "\n" + - "var globalCounter : Int = 5\n" + - " get() {\n" + - " return $globalCounter\n" + - " }\n" + - "\n" + - "public abstract class Abstract {\n" + - "}\n" + - "\n" + - "object Obj\n" + - "\n" + - "enum class E { A }\n" + - " Bad character: \\n\n"; - } - - @Override - public Map getAdditionalHighlightingTagToDescriptorMap() { - Map map = new HashMap(); - for (Field field : JetHighlightingColors.class.getFields()) { - if (Modifier.isStatic(field.getModifiers())) { - try { - map.put(field.getName(), (TextAttributesKey) field.get(null)); - } - catch (IllegalAccessException e) { - assert false; - } - } +/** + * Doc comment here for `SomeClass` + * @see Iterator#next() + */ +@deprecated("Deprecated class") +public class MyClass<out T : Iterable<T>>(var prop1 : Int) + fun foo(nullable : String?, r : Runnable, f : () -> Int, fl : FunctionLike, dyn: dynamic) { + println("length\nis ${"$"}{nullable?.length} \e") + val ints = java.util.ArrayList(2) + ints[0] = 102 + f() + fl() + val myFun = { -> "" }; + var ref = ints.size() + if (!ints.empty) { + ints.forEach { + if (it == null) return + println(it + ref) + } } - return map; - } - - @NotNull - @Override - public AttributesDescriptor[] getAttributeDescriptors() { - return new AttributesDescriptor[]{ - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.keyword"), JetHighlightingColors.KEYWORD), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.builtin.annotation"), JetHighlightingColors.BUILTIN_ANNOTATION), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.number"), JetHighlightingColors.NUMBER), - - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.string"), JetHighlightingColors.STRING), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.string.escape"), JetHighlightingColors.STRING_ESCAPE), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.invalid.escape.in.string"), JetHighlightingColors.INVALID_STRING_ESCAPE), - - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.operator.sign"), JetHighlightingColors.OPERATOR_SIGN), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.parentheses"), JetHighlightingColors.PARENTHESIS), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.braces"), JetHighlightingColors.BRACES), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.closure.braces"), JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.arrow"), JetHighlightingColors.ARROW), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.brackets"), JetHighlightingColors.BRACKETS), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.comma"), JetHighlightingColors.COMMA), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.semicolon"), JetHighlightingColors.SEMICOLON), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.dot"), JetHighlightingColors.DOT), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.safe.access"), JetHighlightingColors.SAFE_ACCESS), - - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.line.comment"), JetHighlightingColors.LINE_COMMENT), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.block.comment"), JetHighlightingColors.BLOCK_COMMENT), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.kdoc.comment"), JetHighlightingColors.DOC_COMMENT), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.kdoc.tag"), JetHighlightingColors.KDOC_TAG), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.kdoc.value"), JetHighlightingColors.KDOC_LINK), - - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.class"), JetHighlightingColors.CLASS), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.type.parameter"), JetHighlightingColors.TYPE_PARAMETER), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.abstract.class"), JetHighlightingColors.ABSTRACT_CLASS), - new AttributesDescriptor("Interface", JetHighlightingColors.TRAIT), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.annotation"), JetHighlightingColors.ANNOTATION), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.object"), JetHighlightingColors.OBJECT), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.enumEntry"), JetHighlightingColors.ENUM_ENTRY), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.var"), JetHighlightingColors.MUTABLE_VARIABLE), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.local.variable"), JetHighlightingColors.LOCAL_VARIABLE), - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.parameter"), JetHighlightingColors.PARAMETER), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.captured.variable"), JetHighlightingColors.WRAPPED_INTO_REF), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.instance.property"), JetHighlightingColors.INSTANCE_PROPERTY), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.package.property"), JetHighlightingColors.PACKAGE_PROPERTY), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.property.with.backing"), JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.backing.field.access"), JetHighlightingColors.BACKING_FIELD_ACCESS), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.extension.property"), JetHighlightingColors.EXTENSION_PROPERTY), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.dynamic.property"), JetHighlightingColors.DYNAMIC_PROPERTY_CALL), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.it"), JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.fun"), JetHighlightingColors.FUNCTION_DECLARATION), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.fun.call"), JetHighlightingColors.FUNCTION_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.dynamic.fun.call"), JetHighlightingColors.DYNAMIC_FUNCTION_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.package.fun.call"), JetHighlightingColors.PACKAGE_FUNCTION_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.extension.fun.call"), JetHighlightingColors.EXTENSION_FUNCTION_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.constructor.call"), JetHighlightingColors.CONSTRUCTOR_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.variable.as.function.call"), JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL), - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.variable.as.function.like.call"), JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL), - - new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.bad.character"), JetHighlightingColors.BAD_CHARACTER), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.smart.cast"), JetHighlightingColors.SMART_CAST_VALUE), - - new AttributesDescriptor(JetBundle.message("options.kotlin.attribute.descriptor.label"), JetHighlightingColors.LABEL), - }; - } - - @NotNull - @Override - public ColorDescriptor[] getColorDescriptors() { - return ColorDescriptor.EMPTY_ARRAY; - } - - @NotNull - @Override - public String getDisplayName() { - return JetLanguage.NAME; + dyn.dynamicCall() + dyn.dynamicProp = 5 } } + +var globalCounter : Int = 5 + get() { + return ${"$"}globalCounter + } + +public abstract class Abstract { +} + +object Obj + +enum class E { A } + Bad character: \n +""" + } + + override fun getAdditionalHighlightingTagToDescriptorMap(): Map { + val map = HashMap() + for (field in javaClass().getFields()) { + if (Modifier.isStatic(field.getModifiers())) { + try { + map.put(field.getName(), field.get(null) as TextAttributesKey) + } + catch (e: IllegalAccessException) { + assert(false) + } + + } + } + return map + } + + override fun getAttributeDescriptors(): Array { + fun String.to(key: TextAttributesKey) = AttributesDescriptor(this, key) + + return arrayOf(OptionsBundle.message("options.java.attribute.descriptor.keyword") to JetHighlightingColors.KEYWORD, + JetBundle.message("options.kotlin.attribute.descriptor.builtin.annotation") to JetHighlightingColors.BUILTIN_ANNOTATION, + OptionsBundle.message("options.java.attribute.descriptor.number") to JetHighlightingColors.NUMBER, + OptionsBundle.message("options.java.attribute.descriptor.string") to JetHighlightingColors.STRING, + JetBundle.message("options.kotlin.attribute.descriptor.string.escape") to JetHighlightingColors.STRING_ESCAPE, + OptionsBundle.message("options.java.attribute.descriptor.invalid.escape.in.string") to JetHighlightingColors.INVALID_STRING_ESCAPE, + OptionsBundle.message("options.java.attribute.descriptor.operator.sign") to JetHighlightingColors.OPERATOR_SIGN, + OptionsBundle.message("options.java.attribute.descriptor.parentheses") to JetHighlightingColors.PARENTHESIS, + OptionsBundle.message("options.java.attribute.descriptor.braces") to JetHighlightingColors.BRACES, + JetBundle.message("options.kotlin.attribute.descriptor.closure.braces") to JetHighlightingColors.FUNCTION_LITERAL_BRACES_AND_ARROW, + JetBundle.message("options.kotlin.attribute.descriptor.arrow") to JetHighlightingColors.ARROW, + OptionsBundle.message("options.java.attribute.descriptor.brackets") to JetHighlightingColors.BRACKETS, + OptionsBundle.message("options.java.attribute.descriptor.comma") to JetHighlightingColors.COMMA, + OptionsBundle.message("options.java.attribute.descriptor.semicolon") to JetHighlightingColors.SEMICOLON, + OptionsBundle.message("options.java.attribute.descriptor.dot") to JetHighlightingColors.DOT, + JetBundle.message("options.kotlin.attribute.descriptor.safe.access") to JetHighlightingColors.SAFE_ACCESS, + OptionsBundle.message("options.java.attribute.descriptor.line.comment") to JetHighlightingColors.LINE_COMMENT, + OptionsBundle.message("options.java.attribute.descriptor.block.comment") to JetHighlightingColors.BLOCK_COMMENT, + JetBundle.message("options.kotlin.attribute.descriptor.kdoc.comment") to JetHighlightingColors.DOC_COMMENT, + JetBundle.message("options.kotlin.attribute.descriptor.kdoc.tag") to JetHighlightingColors.KDOC_TAG, + JetBundle.message("options.kotlin.attribute.descriptor.kdoc.value") to JetHighlightingColors.KDOC_LINK, + OptionsBundle.message("options.java.attribute.descriptor.class") to JetHighlightingColors.CLASS, + OptionsBundle.message("options.java.attribute.descriptor.type.parameter") to JetHighlightingColors.TYPE_PARAMETER, + OptionsBundle.message("options.java.attribute.descriptor.abstract.class") to JetHighlightingColors.ABSTRACT_CLASS, + "Interface" to JetHighlightingColors.TRAIT, + JetBundle.message("options.kotlin.attribute.descriptor.annotation") to JetHighlightingColors.ANNOTATION, + JetBundle.message("options.kotlin.attribute.descriptor.object") to JetHighlightingColors.OBJECT, + JetBundle.message("options.kotlin.attribute.descriptor.enumEntry") to JetHighlightingColors.ENUM_ENTRY, + JetBundle.message("options.kotlin.attribute.descriptor.var") to JetHighlightingColors.MUTABLE_VARIABLE, + JetBundle.message("options.kotlin.attribute.descriptor.local.variable") to JetHighlightingColors.LOCAL_VARIABLE, + OptionsBundle.message("options.java.attribute.descriptor.parameter") to JetHighlightingColors.PARAMETER, + JetBundle.message("options.kotlin.attribute.descriptor.captured.variable") to JetHighlightingColors.WRAPPED_INTO_REF, + JetBundle.message("options.kotlin.attribute.descriptor.instance.property") to JetHighlightingColors.INSTANCE_PROPERTY, + JetBundle.message("options.kotlin.attribute.descriptor.package.property") to JetHighlightingColors.PACKAGE_PROPERTY, + JetBundle.message("options.kotlin.attribute.descriptor.property.with.backing") to JetHighlightingColors.PROPERTY_WITH_BACKING_FIELD, + JetBundle.message("options.kotlin.attribute.descriptor.backing.field.access") to JetHighlightingColors.BACKING_FIELD_ACCESS, + JetBundle.message("options.kotlin.attribute.descriptor.extension.property") to JetHighlightingColors.EXTENSION_PROPERTY, + JetBundle.message("options.kotlin.attribute.descriptor.dynamic.property") to JetHighlightingColors.DYNAMIC_PROPERTY_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.it") to JetHighlightingColors.FUNCTION_LITERAL_DEFAULT_PARAMETER, + JetBundle.message("options.kotlin.attribute.descriptor.fun") to JetHighlightingColors.FUNCTION_DECLARATION, + JetBundle.message("options.kotlin.attribute.descriptor.fun.call") to JetHighlightingColors.FUNCTION_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.dynamic.fun.call") to JetHighlightingColors.DYNAMIC_FUNCTION_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.package.fun.call") to JetHighlightingColors.PACKAGE_FUNCTION_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.extension.fun.call") to JetHighlightingColors.EXTENSION_FUNCTION_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.constructor.call") to JetHighlightingColors.CONSTRUCTOR_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.variable.as.function.call") to JetHighlightingColors.VARIABLE_AS_FUNCTION_CALL, + JetBundle.message("options.kotlin.attribute.descriptor.variable.as.function.like.call") to JetHighlightingColors.VARIABLE_AS_FUNCTION_LIKE_CALL, + OptionsBundle.message("options.java.attribute.descriptor.bad.character") to JetHighlightingColors.BAD_CHARACTER, + JetBundle.message("options.kotlin.attribute.descriptor.smart.cast") to JetHighlightingColors.SMART_CAST_VALUE, + JetBundle.message("options.kotlin.attribute.descriptor.label") to JetHighlightingColors.LABEL) + } + + override fun getColorDescriptors(): Array = ColorDescriptor.EMPTY_ARRAY + override fun getDisplayName(): String = JetLanguage.NAME +} From d6e37ad8c5eb0d135669c5ab10258d3045eb1174 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 15:07:52 +0200 Subject: [PATCH 075/450] add markup for KDOC_LINK --- .../kotlin/idea/highlighter/KotlinColorSettingsPage.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt index bb0d7aa1dd3..7dacdb5ac6b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinColorSettingsPage.kt @@ -42,7 +42,7 @@ public class KotlinColorSettingsPage : ColorSettingsPage { /** * Doc comment here for `SomeClass` - * @see Iterator#next() + * @see Iterator#next() */ @deprecated("Deprecated class") public class MyClass<out T : Iterable<T>>(var prop1 : Int) From 09c3bd869943e3ad6ce35f8503655a0ab35387d0 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 16:45:09 +0300 Subject: [PATCH 076/450] kapt: Support inherited annotations in Kotlin plugin --- .../AnnotationCollectorExtension.kt | 35 +++++++++++++++---- .../annotation/AnnotationCollectorPlugin.kt | 16 +++++++-- .../AbstractAnnotationProcessorBoxTest.kt | 6 ++-- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorExtension.kt b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorExtension.kt index 0fc57f6dfbe..b49e063f65b 100644 --- a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorExtension.kt +++ b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorExtension.kt @@ -33,7 +33,7 @@ import java.util.regex.Pattern import java.util.regex.PatternSyntaxException import kotlin.properties.Delegates -public abstract class AnnotationCollectorExtensionBase() : ClassBuilderInterceptorExtension { +public abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations: Boolean) : ClassBuilderInterceptorExtension { private object RecordTypes { val ANNOTATED_CLASS = "c" @@ -42,6 +42,8 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept val SHORTENED_ANNOTATION = "a" val SHORTENED_PACKAGE_NAME = "p" + + val CLASS_DECLARATION = "d" } protected abstract val annotationFilterList: List? @@ -126,8 +128,15 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept superName: String, interfaces: Array ) { - currentClassSimpleName = name.substringAfterLast('/') - currentPackageName = name.substringBeforeLast('/', "").replace('/', '.') + val currentClassSimpleName = name.substringAfterLast('/') + val currentPackageName = name.substringBeforeLast('/', "").replace('/', '.') + + this.currentClassSimpleName = currentClassSimpleName + this.currentPackageName = currentPackageName + + if (supportInheritedAnnotations) { + recordClass(currentPackageName, currentClassSimpleName) + } super.defineClass(origin, version, access, name, signature, superName, interfaces) } @@ -170,6 +179,15 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept else !annotationFqName.startsWith("kotlin.jvm.internal.") //apply to all } + private fun recordClass(packageName: String, className: String) { + val packageNameId = if (!packageName.isEmpty()) + shortenedPackageNameCache.save(packageName, writer) + else null + + val outputClassName = getOutputClassName(packageNameId, className) + writer.write("${RecordTypes.CLASS_DECLARATION} $outputClassName\n") + } + private fun recordAnnotation(name: String?, type: String, annotationDesc: String) { val annotationFqName = Type.getType(annotationDesc).getClassName() if (!isAnnotationHandled(annotationFqName)) return @@ -183,7 +201,7 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept else null val className = this.currentClassSimpleName!! - val outputClassName = if (packageNameId == null) className else "$packageNameId/$className" + val outputClassName = getOutputClassName(packageNameId, className) val elementName = if (name != null) " $name" else "" writer.write("$type $annotationId $outputClassName$elementName\n") @@ -193,6 +211,10 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept } } + private fun getOutputClassName(packageNameId: String?, className: String): String { + return if (packageNameId == null) className else "$packageNameId/$className" + } + private fun String.compilePatternOpt(): Pattern? { return try { Pattern.compile(this) @@ -220,8 +242,9 @@ public abstract class AnnotationCollectorExtensionBase() : ClassBuilderIntercept public class AnnotationCollectorExtension( override val annotationFilterList: List? = null, - val outputFilename: String? = null -) : AnnotationCollectorExtensionBase() { + val outputFilename: String? = null, + supportInheritedAnnotations: Boolean +) : AnnotationCollectorExtensionBase(supportInheritedAnnotations) { private var writerInternal: Writer? = null diff --git a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorPlugin.kt b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorPlugin.kt index 8043e90d8bb..76f13614d0f 100644 --- a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorPlugin.kt +++ b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/AnnotationCollectorPlugin.kt @@ -51,6 +51,8 @@ public object AnnotationCollectorConfigurationKeys { CompilerConfigurationKey.create("annotation file name") public val STUBS_PATH: CompilerConfigurationKey = CompilerConfigurationKey.create("stubs output directory") + public val INHERITED: CompilerConfigurationKey = + CompilerConfigurationKey.create("support inherited annotations") } public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor { @@ -64,12 +66,17 @@ public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor { CliOption("output", "", "File in which annotated declarations will be placed", required = false) public val STUBS_PATH_OPTION: CliOption = - CliOption("stubs", "", "Output path for stubs.", required = false) + CliOption("stubs", "", "Output path for stubs", required = false) + + public val INHERITED_ANNOTATIONS_OPTION: CliOption = + CliOption("inherited", "", + "True if collecting Kotlin class names for inherited annotations is needed", required = false) } override val pluginId: String = ANNOTATION_COLLECTOR_COMPILER_PLUGIN_ID - override val pluginOptions: Collection = listOf(ANNOTATION_FILTER_LIST_OPTION, OUTPUT_FILENAME_OPTION, STUBS_PATH_OPTION) + override val pluginOptions: Collection = + listOf(ANNOTATION_FILTER_LIST_OPTION, OUTPUT_FILENAME_OPTION, STUBS_PATH_OPTION, INHERITED_ANNOTATIONS_OPTION) override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) { when (option) { @@ -79,6 +86,7 @@ public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor { } OUTPUT_FILENAME_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.OUTPUT_FILENAME, value) STUBS_PATH_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.STUBS_PATH, value) + INHERITED_ANNOTATIONS_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.INHERITED, value) else -> throw CliOptionProcessingException("Unknown option: ${option.name}") } } @@ -86,10 +94,12 @@ public class AnnotationCollectorCommandLineProcessor : CommandLineProcessor { public class AnnotationCollectorComponentRegistrar : ComponentRegistrar { public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) { + val supportInheritedAnnotations = "true" == (configuration.get(AnnotationCollectorConfigurationKeys.INHERITED) ?: "true") + val annotationFilterList = configuration.get(AnnotationCollectorConfigurationKeys.ANNOTATION_FILTER_LIST) val outputFilename = configuration.get(AnnotationCollectorConfigurationKeys.OUTPUT_FILENAME) if (outputFilename != null) { - val collectorExtension = AnnotationCollectorExtension(annotationFilterList, outputFilename) + val collectorExtension = AnnotationCollectorExtension(annotationFilterList, outputFilename, supportInheritedAnnotations) ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension) } diff --git a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt index 8c6acf8fb14..f24f713cf10 100644 --- a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt +++ b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt @@ -55,7 +55,7 @@ public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() { val environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val project = environment.project - val collectorExtension = AnnotationCollectorExtensionForTests() + val collectorExtension = AnnotationCollectorExtensionForTests(false) ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension) myEnvironment = environment @@ -63,7 +63,9 @@ public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() { return collectorExtension } - private class AnnotationCollectorExtensionForTests : AnnotationCollectorExtensionBase() { + private class AnnotationCollectorExtensionForTests( + supportInheritedAnnotations: Boolean + ) : AnnotationCollectorExtensionBase(supportInheritedAnnotations) { val stringWriter = StringWriter() override fun getWriter(diagnostic: DiagnosticSink) = stringWriter From afa3ae4439aaa8bdbb386275f8e68588f46c154f Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 17:38:28 +0300 Subject: [PATCH 077/450] Add tests for inherited annotations (class declarations) --- .../AbstractAnnotationProcessorBoxTest.kt | 13 ++++++++----- .../AnnotationProcessorBoxTestGenerated.java | 12 ++++++++++++ .../collectToFile/inheritedSimple/annotations.txt | 4 ++++ .../inheritedSimple/inheritedSimple.kt | 5 +++++ .../collectToFile/inheritedTopLevel/annotations.txt | 6 ++++++ .../inheritedTopLevel/inheritedTopLevel.kt | 8 ++++++++ 6 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt create mode 100644 plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt create mode 100644 plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt create mode 100644 plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/inheritedTopLevel.kt diff --git a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt index f24f713cf10..493eb875114 100644 --- a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt +++ b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AbstractAnnotationProcessorBoxTest.kt @@ -35,12 +35,15 @@ import org.junit.Assert.* public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() { public fun doTest(path: String) { - val fileName = path + getTestName(true) + ".kt" - val collectorExtension = createTestEnvironment() + val testName = getTestName(true) + val fileName = path + testName + ".kt" + val supportInheritedAnnotations = testName.startsWith("inherited") + + val collectorExtension = createTestEnvironment(supportInheritedAnnotations) loadFileByFullPath(fileName) CodegenTestUtil.generateFiles(myEnvironment, myFiles) - val actualAnnotations = collectorExtension.stringWriter.toString() + val actualAnnotations = JetTestUtils.replaceHashWithStar(collectorExtension.stringWriter.toString()) val expectedAnnotationsFile = File(path + "annotations.txt") JetTestUtils.assertEqualsToFile(expectedAnnotationsFile, actualAnnotations) @@ -50,12 +53,12 @@ public abstract class AbstractAnnotationProcessorBoxTest : CodegenTestCase() { return "plugins/annotation-collector/testData/codegen/" } - fun createTestEnvironment(): AnnotationCollectorExtensionForTests { + fun createTestEnvironment(supportInheritedAnnotations: Boolean): AnnotationCollectorExtensionForTests { val configuration = JetTestUtils.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK) val environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val project = environment.project - val collectorExtension = AnnotationCollectorExtensionForTests(false) + val collectorExtension = AnnotationCollectorExtensionForTests(supportInheritedAnnotations) ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension) myEnvironment = environment diff --git a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java index 4a793f4facd..32982d7ac5c 100644 --- a/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java +++ b/plugins/annotation-collector/test/org/jetbrains/kotlin/annotation/AnnotationProcessorBoxTestGenerated.java @@ -77,6 +77,18 @@ public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProce doTest(fileName); } + @TestMetadata("inheritedSimple") + public void testInheritedSimple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedSimple/"); + doTest(fileName); + } + + @TestMetadata("inheritedTopLevel") + public void testInheritedTopLevel() throws Exception { + String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/"); + doTest(fileName); + } + @TestMetadata("localClasses") public void testLocalClasses() throws Exception { String fileName = JetTestUtils.navigationMetadata("plugins/annotation-collector/testData/collectToFile/localClasses/"); diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt new file mode 100644 index 00000000000..72c4041b2e2 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/annotations.txt @@ -0,0 +1,4 @@ +p org.test 0 +d 0/SomeInterface +d 0/SomeInterface$$TImpl +d 0/SomeClass diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt new file mode 100644 index 00000000000..4ffaa0a8b8b --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedSimple/inheritedSimple.kt @@ -0,0 +1,5 @@ +package org.test + +public interface SomeInterface + +public class SomeClass \ No newline at end of file diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt new file mode 100644 index 00000000000..f74c7345e7e --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/annotations.txt @@ -0,0 +1,6 @@ +p org.test 0 +d 0/TestPackage$inheritedTopLevel$* +a org.jetbrains.annotations.NotNull 0 +m 0 0/TestPackage$inheritedTopLevel$* getTopLevelProperty +d 0/TestPackage +m 0 0/TestPackage getTopLevelProperty diff --git a/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/inheritedTopLevel.kt b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/inheritedTopLevel.kt new file mode 100644 index 00000000000..56923d97754 --- /dev/null +++ b/plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/inheritedTopLevel.kt @@ -0,0 +1,8 @@ +package org.test + +fun topLevelFunction() { + +} + +val topLevelProperty: String + get() = "text" \ No newline at end of file From a90f175fc2868ce8b4bd80406ab3eb12c390bdf6 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 18:14:27 +0300 Subject: [PATCH 078/450] kapt: Support inherited annotations in AP wrapper --- .../annotation/AnnotationProcessorWrapper.kt | 4 +- .../annotation/KotlinAnnotationProvider.kt | 17 ++++++++- .../annotation/RoundEnvironmentWrapper.kt | 37 +++++++++++++++++-- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper.kt b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper.kt index dec2c68a12c..4f38d40eb30 100644 --- a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper.kt +++ b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/AnnotationProcessorWrapper.kt @@ -108,8 +108,8 @@ public abstract class AnnotationProcessorWrapper( override fun process(annotations: MutableSet?, roundEnv: RoundEnvironment): Boolean { roundCounter += 1 - val annotatedKotlinElements = kotlinAnnotationsProvider.annotatedKotlinElements - val roundEnvironmentWrapper = RoundEnvironmentWrapper(processingEnv, roundEnv, roundCounter, annotatedKotlinElements) + val roundEnvironmentWrapper = RoundEnvironmentWrapper( + processingEnv, roundEnv, roundCounter, kotlinAnnotationsProvider) processor.process(annotations, roundEnvironmentWrapper) return false } diff --git a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt index d4b44b19089..bd7fe065133 100644 --- a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt +++ b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/KotlinAnnotationProvider.kt @@ -20,7 +20,6 @@ import java.io.File import java.io.Reader import java.io.StringReader import javax.tools.FileObject -import kotlin.properties.Delegates public abstract class KotlinAnnotationProvider { @@ -31,12 +30,22 @@ public abstract class KotlinAnnotationProvider { val SHORTENED_ANNOTATION = "a" val SHORTENED_PACKAGE_NAME = "p" + + val CLASS_DECLARATION = "d" } - public val annotatedKotlinElements: Map> by Delegates.lazy { + public val annotatedKotlinElements: Map> by lazy { readAnnotations() } + private val kotlinClassesInternal = hashSetOf() + + public val kotlinClasses: Set + get() = kotlinClassesInternal + + public val supportInheritedAnnotations: Boolean + get() = kotlinClassesInternal.isNotEmpty() + protected abstract val serializedAnnotations: Reader private fun readAnnotations(): MutableMap> { @@ -65,6 +74,10 @@ public abstract class KotlinAnnotationProvider { when (type) { SHORTENED_ANNOTATION -> handleShortenedName(shortenedAnnotationCache, lineParts) SHORTENED_PACKAGE_NAME -> handleShortenedName(shortenedPackageNameCache, lineParts) + CLASS_DECLARATION -> { + val classFqName = expandClassName(lineParts[1]).replace('$', '.') + kotlinClassesInternal.add(classFqName) + } ANNOTATED_CLASS, ANNOTATED_FIELD, ANNOTATED_METHOD -> { val annotationName = expandAnnotation(lineParts[1]) diff --git a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/RoundEnvironmentWrapper.kt b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/RoundEnvironmentWrapper.kt index c6571d1dc52..3c02d7d1325 100644 --- a/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/RoundEnvironmentWrapper.kt +++ b/libraries/tools/kotlin-annotation-processing/src/main/kotlin/org/jetbrains/kotlin/annotation/RoundEnvironmentWrapper.kt @@ -1,16 +1,19 @@ package org.jetbrains.kotlin.annotation +import java.lang.annotation.Inherited import javax.annotation.processing.ProcessingEnvironment import javax.annotation.processing.RoundEnvironment import javax.lang.model.element.Element import javax.lang.model.element.ElementKind import javax.lang.model.element.TypeElement +import javax.lang.model.type.NoType +import javax.lang.model.type.TypeVisitor private class RoundEnvironmentWrapper( val processingEnv: ProcessingEnvironment, val parent: RoundEnvironment, val roundNumber: Int, - val annotatedElementDescriptors: Map> + val kotlinAnnotationsProvider: KotlinAnnotationProvider ) : RoundEnvironment { override fun getRootElements(): MutableSet? { @@ -45,11 +48,23 @@ private class RoundEnvironmentWrapper( return getAnnotationMirrors().any { annotationFqName == it.getAnnotationType().asElement().toString() } } + private fun TypeElement.hasInheritedAnnotation(annotationFqName: String): Boolean { + if (hasAnnotation(annotationFqName)) return true + + val superclassMirror = getSuperclass() + if (superclassMirror is NoType) return false + + val superClass = processingEnv.getTypeUtils().asElement(superclassMirror) + if (superClass !is TypeElement) return false + + return superClass.hasInheritedAnnotation(annotationFqName) + } + private fun resolveKotlinElements(annotationFqName: String): Set { if (roundNumber > 1) return setOf() - val descriptors = annotatedElementDescriptors.get(annotationFqName) ?: setOf() - return descriptors.fold(hashSetOf()) { set, descriptor -> + val descriptors = kotlinAnnotationsProvider.annotatedKotlinElements.get(annotationFqName) ?: setOf() + val descriptorsWithKotlin = descriptors.fold(hashSetOf()) { set, descriptor -> val clazz = processingEnv.getElementUtils().getTypeElement(descriptor.classFqName) ?: return@fold set when (descriptor) { is AnnotatedClassDescriptor -> set.add(clazz) @@ -68,5 +83,21 @@ private class RoundEnvironmentWrapper( } set } + + if (kotlinAnnotationsProvider.supportInheritedAnnotations) { + val isInherited = processingEnv.getElementUtils().getTypeElement(annotationFqName) + ?.hasAnnotation(javaClass().getCanonicalName()) ?: false + + if (isInherited) { + kotlinAnnotationsProvider.kotlinClasses.forEach { classFqName -> + val clazz = processingEnv.getElementUtils().getTypeElement(classFqName) ?: return@forEach + if (clazz.hasInheritedAnnotation(annotationFqName)) { + descriptorsWithKotlin.add(clazz) + } + } + } + } + + return descriptorsWithKotlin } } From 700d495d7f821a3369ee63b239e2bfa4bac54842 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 18:26:04 +0300 Subject: [PATCH 079/450] kapt: Support inherited annotations in Gradle --- .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 30 ++++++++++++------- .../kotlin/gradle/plugin/KaptExtension.kt | 2 ++ .../kotlin/gradle/plugin/KotlinPlugin.kt | 13 ++++++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index a82506ecb22..7808697de49 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -131,17 +131,7 @@ public open class KotlinCompile() : AbstractKotlinCompile>("compilerPluginArguments") ?: arrayOf() val pluginOptions = arrayListOf(*basePluginOptions) - - val kaptAnnotationsFile = extraProperties.getOrNull("kaptAnnotationsFile") - if (kaptAnnotationsFile != null) { - if (kaptAnnotationsFile.exists()) kaptAnnotationsFile.delete() - pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:output=" + kaptAnnotationsFile) - } - - val kaptClassFileStubsDir = extraProperties.getOrNull("stubsDir") - if (kaptClassFileStubsDir != null) { - pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:stubs=" + kaptClassFileStubsDir) - } + handleKaptProperties(extraProperties, pluginOptions) args.pluginOptions = pluginOptions.toTypedArray() getLogger().kotlinDebug("args.pluginOptions = ${args.pluginOptions.joinToString(File.pathSeparator)}") @@ -162,6 +152,24 @@ public open class KotlinCompile() : AbstractKotlinCompile) { + val kaptAnnotationsFile = extraProperties.getOrNull("kaptAnnotationsFile") + if (kaptAnnotationsFile != null) { + if (kaptAnnotationsFile.exists()) kaptAnnotationsFile.delete() + pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:output=" + kaptAnnotationsFile) + } + + val kaptClassFileStubsDir = extraProperties.getOrNull("kaptStubsDir") + if (kaptClassFileStubsDir != null) { + pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:stubs=" + kaptClassFileStubsDir) + } + + val supportInheritedAnnotations = extraProperties.getOrNull("kaptInheritedAnnotations") + if (supportInheritedAnnotations != null && supportInheritedAnnotations) { + pluginOptions.add("plugin:$ANNOTATIONS_PLUGIN_NAME:inherited=true") + } + } + private fun getJavaSourceRoots(): Set = getSource() .filter { it.isJavaFile() } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KaptExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KaptExtension.kt index 024feeb6ed6..6dda5469d6c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KaptExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KaptExtension.kt @@ -23,6 +23,8 @@ public open class KaptExtension { public open var generateStubs: Boolean = false + public open var inheritedAnnotations: Boolean = true + private var closure: Closure<*>? = null public open fun arguments(closure: Closure<*>) { diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index 55de4ff3b47..bc462afbd93 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -536,7 +536,7 @@ private class SubpluginEnvironment( } } - val extraProperties = compileTask.getExtensions().getExtraProperties() + val extraProperties = compileTask.extraProperties extraProperties.set("compilerPluginClasspaths", realPluginClasspaths.toTypedArray()) extraProperties.set("compilerPluginArguments", pluginArguments.toTypedArray()) } @@ -563,7 +563,7 @@ open class GradleUtils(val scriptHandler: ScriptHandler, val project: ProjectInt } private fun AbstractCompile.storeKaptAnnotationsFile(kapt: AnnotationProcessingManager) { - getExtensions().getExtraProperties().set("kaptAnnotationsFile", kapt.getAnnotationFile()) + extraProperties.set("kaptAnnotationsFile", kapt.getAnnotationFile()) } private fun Project.getAptDirsForSourceSet(kotlinTask: AbstractCompile, sourceSetName: String): Pair { @@ -607,7 +607,7 @@ private fun Project.initKapt( kotlinTask.getLogger().kotlinDebug("kapt: Using class file stubs") val stubsDir = File(getBuildDir(), "tmp/kapt/$variantName/classFileStubs") - kotlinTask.getExtensions().getExtraProperties().set("stubsDir", stubsDir) + kotlinTask.extraProperties.set("kaptStubsDir", stubsDir) javaTask.setClasspath(javaTask.getClasspath() + files(stubsDir)) @@ -621,6 +621,10 @@ private fun Project.initKapt( kotlinTask.getLogger().kotlinDebug("kapt: Class file stubs are not used") } + if (kaptExtension.inheritedAnnotations) { + kotlinTask.extraProperties.set("kaptInheritedAnnotations", true) + } + kotlinTask.doFirst { kaptManager.generateJavaHackFile() } @@ -682,6 +686,9 @@ private fun loadAndroidPluginVersion(): String? { } } +private val AbstractCompile.extraProperties: ExtraPropertiesExtension + get() = getExtensions().getExtraProperties() + //Copied from StringUtil.compareVersionNumbers private fun compareVersionNumbers(v1: String?, v2: String?): Int { if (v1 == null && v2 == null) { From cf08390e045c33128526a184c7cdd903f45284ae Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 18:38:40 +0300 Subject: [PATCH 080/450] Minor: fix deprecations in Kotlin Android Extensions code --- .../src/AndroidComponentRegistrar.kt | 2 +- .../src/AndroidExpressionCodegenExtension.kt | 3 ++- .../kotlin/lang/resolve/android/AndroidResourceManager.kt | 7 +++---- .../jetbrains/kotlin/lang/resolve/android/KotlinWriter.kt | 2 +- .../kotlin/lang/resolve/android/test/CompilerTestUtils.kt | 6 +++++- .../plugin/android/AndroidPsiTreeChangePreprocessor.kt | 4 ++-- .../kotlin/plugin/android/AndroidRenameProcessor.kt | 6 ++---- .../plugin/android/AndroidSimpleNameReferenceExtension.kt | 6 ++---- .../android/IDEAndroidExternalDeclarationsProvider.kt | 2 +- .../kotlin/android/AbstractAndroidCompletionTest.kt | 1 + .../jetbrains/kotlin/android/AbstractAndroidRenameTest.kt | 4 ++-- plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt | 6 ++---- .../kotlin/jps/build/android/AbstractAndroidJpsTestCase.kt | 7 +++---- 13 files changed, 27 insertions(+), 29 deletions(-) diff --git a/plugins/android-compiler-plugin/src/AndroidComponentRegistrar.kt b/plugins/android-compiler-plugin/src/AndroidComponentRegistrar.kt index dd80d5eebe9..7ed48ec76b8 100644 --- a/plugins/android-compiler-plugin/src/AndroidComponentRegistrar.kt +++ b/plugins/android-compiler-plugin/src/AndroidComponentRegistrar.kt @@ -68,7 +68,7 @@ public class AndroidCommandLineProcessor : CommandLineProcessor { public class CliAndroidDeclarationsProvider(private val project: Project) : ExternalDeclarationsProvider { override fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection { - val parser = ServiceManager.getService(project, javaClass()) + val parser = ServiceManager.getService(project, javaClass()) return parser.parseToPsi() ?: listOf() } } diff --git a/plugins/android-compiler-plugin/src/AndroidExpressionCodegenExtension.kt b/plugins/android-compiler-plugin/src/AndroidExpressionCodegenExtension.kt index b73a963c725..8230cbc22ba 100644 --- a/plugins/android-compiler-plugin/src/AndroidExpressionCodegenExtension.kt +++ b/plugins/android-compiler-plugin/src/AndroidExpressionCodegenExtension.kt @@ -199,7 +199,7 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension { } private fun CallableDescriptor.getAndroidPackage(): String? { - return DescriptorToSourceUtils.getContainingFile(this)?.getUserData(AndroidConst.ANDROID_USER_PACKAGE) + return DescriptorToSourceUtils.getContainingFile(this)?.getUserData(AndroidConst.ANDROID_USER_PACKAGE) } private fun ResolvedCall<*>.getReceiverDeclarationDescriptor(): ClassifierDescriptor? { @@ -337,6 +337,7 @@ public class AndroidExpressionCodegenExtension : ExpressionCodegenExtension { loadId() iv.invokevirtual("android/view/View", "findViewById", "(I)Landroid/view/View;", false) } + else -> throw IllegalStateException("Can't generate code for $androidClassType") } iv.store(2, viewType) diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt index 665ccd8c44d..d0259e509f3 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt @@ -35,8 +35,7 @@ public abstract class AndroidResourceManager(val project: Project) { public open fun propertyToXmlAttributes(property: JetProperty): List = listOf() public fun getLayoutXmlFiles(): Map> { - val info = androidModuleInfo - if (info == null) return mapOf() + val info = androidModuleInfo ?: return mapOf() val psiManager = PsiManager.getInstance(project) val fileManager = VirtualFileManager.getInstance() @@ -68,8 +67,8 @@ public abstract class AndroidResourceManager(val project: Project) { companion object { public fun getInstance(module: Module): AndroidResourceManager { - val service = ModuleServiceManager.getService(module, javaClass()) - return service ?: module.getComponent(javaClass()) + val service = ModuleServiceManager.getService(module, javaClass()) + return service ?: module.getComponent(javaClass()) } } diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/KotlinWriter.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/KotlinWriter.kt index 3d6f6705a65..0156959f0ab 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/KotlinWriter.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/KotlinWriter.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.lang.resolve.android -trait KotlinWriter { +interface KotlinWriter { fun toStringBuffer(): StringBuffer } diff --git a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt index 9af61fbf437..af853702ed9 100644 --- a/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt +++ b/plugins/android-compiler-plugin/tests/org/jetbrains/kotlin/lang/resolve/android/test/CompilerTestUtils.kt @@ -53,10 +53,14 @@ fun UsefulTestCase.createAndroidTestEnvironment( ): KotlinCoreEnvironment { configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, resPaths) configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, manifestPath) + val myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES) val project = myEnvironment.project - ExternalDeclarationsProvider.registerExtension(project, AndroidTestExternalDeclarationsProvider(project, resPaths, manifestPath, supportV4)) + + val declarationsProvider = AndroidTestExternalDeclarationsProvider(project, resPaths, manifestPath, supportV4) + ExternalDeclarationsProvider.registerExtension(project, declarationsProvider) ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegenExtension()) + return myEnvironment } diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt index 8704a38363e..a9ba2ba774b 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt @@ -61,8 +61,8 @@ public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, Simpl } private fun AndroidResourceManager.getModuleResDirectories(): List { - val info = androidModuleInfo - if (info == null) return listOf() + val info = androidModuleInfo ?: return listOf() + val fileManager = VirtualFileManager.getInstance() return info.resDirectories.map { fileManager.findFileByUrl("file://" + it) } } diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt index e47aaa450e0..a60c00b3b36 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt @@ -91,8 +91,7 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() { newName: String, allRenames: MutableMap ) { - val module = jetProperty.getModule() - if (module == null) return + val module = jetProperty.getModule() ?: return val processor = ModuleServiceManager.getService(module, javaClass()) val resourceManager = processor.resourceManager @@ -119,8 +118,7 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() { ) { val element = LazyValueResourceElementWrapper.computeLazyElement(attribute) val module = attribute.getModule() ?: ModuleUtilCore.findModuleForFile( - attribute.getContainingFile().getVirtualFile(), attribute.getProject()) - if (module == null) return + attribute.getContainingFile().getVirtualFile(), attribute.getProject()) ?: return val processor = ModuleServiceManager.getService(module, javaClass()) if (element == null) return diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidSimpleNameReferenceExtension.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidSimpleNameReferenceExtension.kt index 440be54c065..2e51648ce12 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidSimpleNameReferenceExtension.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidSimpleNameReferenceExtension.kt @@ -26,10 +26,8 @@ import org.jetbrains.kotlin.lang.resolve.android.isAndroidSyntheticElement public class AndroidSimpleNameReferenceExtension : SimpleNameReferenceExtension { override fun isReferenceTo(reference: JetSimpleNameReference, element: PsiElement): Boolean? { - val resolvedElement = reference.resolve() - if (resolvedElement == null) { - return null - } + val resolvedElement = reference.resolve() ?: return null + if (isAndroidSyntheticElement(resolvedElement)) { if (element is ValueResourceElementWrapper) { val resource = element.getValue() diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/IDEAndroidExternalDeclarationsProvider.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/IDEAndroidExternalDeclarationsProvider.kt index e776c7ba05f..bdf62868896 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/IDEAndroidExternalDeclarationsProvider.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/IDEAndroidExternalDeclarationsProvider.kt @@ -30,7 +30,7 @@ public class IDEAndroidExternalDeclarationsProvider(private val project: Project if (moduleInfo !is ModuleSourceInfo) return listOf() val module = moduleInfo.module - val parser = ModuleServiceManager.getService(module, javaClass()) + val parser = ModuleServiceManager.getService(module, javaClass()) val syntheticFiles = parser.parseToPsi() syntheticFiles?.forEach { it.moduleInfo = moduleInfo } diff --git a/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidCompletionTest.kt b/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidCompletionTest.kt index 5ac0dba4912..dd81e0194f2 100644 --- a/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidCompletionTest.kt +++ b/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidCompletionTest.kt @@ -34,6 +34,7 @@ public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() { codeCompletionOldValue = settings.AUTOCOMPLETE_ON_CODE_COMPLETION smartTypeCompletionOldValue = settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION + @suppress("NON_EXHAUSTIVE_WHEN") when (completionType()) { CompletionType.SMART -> settings.AUTOCOMPLETE_ON_SMART_TYPE_COMPLETION = false CompletionType.BASIC -> settings.AUTOCOMPLETE_ON_CODE_COMPLETION = false diff --git a/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidRenameTest.kt b/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidRenameTest.kt index d4e8c93a44c..b39d268762e 100644 --- a/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidRenameTest.kt +++ b/plugins/android-idea-plugin/tests/org/jetbrains/kotlin/android/AbstractAndroidRenameTest.kt @@ -37,8 +37,8 @@ public abstract class AbstractAndroidRenameTest : KotlinAndroidTestCase() { val editor = f.getEditor() val file = f.getFile() val completionEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file) - val element = TargetElementUtilBase.findTargetElement(completionEditor, - TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED or TargetElementUtilBase.ELEMENT_NAME_ACCEPTED) + val element = TargetElementUtilBase.findTargetElement( + completionEditor, TargetElementUtilBase.REFERENCED_ELEMENT_ACCEPTED or TargetElementUtilBase.ELEMENT_NAME_ACCEPTED) assert(element != null) assertTrue(element is JetProperty) diff --git a/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt b/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt index 66945231713..a4ec2391754 100644 --- a/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt +++ b/plugins/android-jps-plugin/src/KotlinAndroidJpsPlugin.kt @@ -72,15 +72,13 @@ public class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider { } private fun getAndroidResPath(module: JpsModule): String? { - val extension = AndroidJpsUtil.getExtension(module) - if (extension == null) return null + val extension = AndroidJpsUtil.getExtension(module) ?: return null val path = AndroidJpsUtil.getResourceDirForCompilationPath(extension) return File(path!!.getAbsolutePath() + "/layout").getAbsolutePath() } private fun getAndroidManifest(module: JpsModule): String? { - val extension = AndroidJpsUtil.getExtension(module) - if (extension == null) return null + val extension = AndroidJpsUtil.getExtension(module) ?: return null return AndroidJpsUtil.getManifestFileForCompilationPath(extension)!!.getAbsolutePath() } diff --git a/plugins/android-jps-plugin/tests/org/jetbrains/kotlin/jps/build/android/AbstractAndroidJpsTestCase.kt b/plugins/android-jps-plugin/tests/org/jetbrains/kotlin/jps/build/android/AbstractAndroidJpsTestCase.kt index 1319e7a45a6..6a13411fffc 100644 --- a/plugins/android-jps-plugin/tests/org/jetbrains/kotlin/jps/build/android/AbstractAndroidJpsTestCase.kt +++ b/plugins/android-jps-plugin/tests/org/jetbrains/kotlin/jps/build/android/AbstractAndroidJpsTestCase.kt @@ -44,7 +44,7 @@ public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() { public fun deleteDirectory(path: File): Boolean { if (path.exists() && path.isDirectory()) { - val files = path.listFiles()!! + val files = path.listFiles() for (i in files.indices) { if (files[i].isDirectory()) { deleteDirectory(files[i]) @@ -62,9 +62,8 @@ public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() { addJdk(jdkName) val properties = JpsAndroidSdkProperties("android-21", jdkName) val sdkPath = getHomePath() + "/../dependencies/androidSDK" - val library = myModel!!.getGlobal().addSdk>(SDK_NAME, sdkPath, "", - JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties)) - library!!.addRoot(File(sdkPath + "/platforms/android-21/android.jar"), JpsOrderRootType.COMPILED) + val library = myModel.getGlobal().addSdk(SDK_NAME, sdkPath, "", JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties)) + library.addRoot(File(sdkPath + "/platforms/android-21/android.jar"), JpsOrderRootType.COMPILED) return library.getProperties() } } From c6ac878cf0e58a124c194ec7ce61f13051e0a6b2 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 20:15:45 +0300 Subject: [PATCH 081/450] kapt: Add inherited annotations test --- .../main/kotlin/example/ExampleAnnotation.kt | 2 ++ .../kotlin/gradle/KotlinGradlePluginIT.kt | 10 ++++++ .../kaptInheritedAnnotations/build.gradle | 35 +++++++++++++++++++ .../src/main/java/test.kt | 22 ++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/build.gradle create mode 100644 libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/src/main/java/test.kt diff --git a/libraries/examples/annotation-processor-example/src/main/kotlin/example/ExampleAnnotation.kt b/libraries/examples/annotation-processor-example/src/main/kotlin/example/ExampleAnnotation.kt index a88da9823f6..0da7a817597 100644 --- a/libraries/examples/annotation-processor-example/src/main/kotlin/example/ExampleAnnotation.kt +++ b/libraries/examples/annotation-processor-example/src/main/kotlin/example/ExampleAnnotation.kt @@ -1,6 +1,8 @@ package example import java.lang.annotation.ElementType +import java.lang.annotation.Inherited import java.lang.annotation.Target +@Inherited annotation public class ExampleAnnotation \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index ae73ce254b4..037f19fe7db 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -98,4 +98,14 @@ class KotlinGradleIT: BaseGradleIT() { } } + Test fun testKaptInheritedAnnotations() { + Project("kaptInheritedAnnotations", "1.12").build("build") { + assertSuccessful() + assertFileExists("build/generated/source/kapt/main/TestClassGenerated.java") + assertFileExists("build/generated/source/kapt/main/AncestorClassGenerated.java") + assertFileExists("build/classes/main/example/TestClassGenerated.class") + assertFileExists("build/classes/main/example/AncestorClassGenerated.class") + } + } + } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/build.gradle b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/build.gradle new file mode 100644 index 00000000000..78b978e9dd7 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/build.gradle @@ -0,0 +1,35 @@ +buildscript { + repositories { + mavenCentral() + maven { + url 'file://' + pathToKotlinPlugin + } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT" + } +} + +apply plugin: "java" +apply plugin: "kotlin" + +repositories { + maven { + url 'file://' + pathToKotlinPlugin + } + mavenCentral() +} + +dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT" + compile "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT" + kapt "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT" +} + +task show << { + buildscript.configurations.classpath.each { println it } +} + +task wrapper(type: Wrapper) { + gradleVersion="1.12" +} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/src/main/java/test.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/src/main/java/test.kt new file mode 100644 index 00000000000..7eff7b126c0 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kaptInheritedAnnotations/src/main/java/test.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package example + +@example.ExampleAnnotation +public open class TestClass + +public class AncestorClass : TestClass() \ No newline at end of file From 441e72abed0b555f50fbc283bb3cf50906557d76 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Tue, 23 Jun 2015 20:27:38 +0300 Subject: [PATCH 082/450] kapt: Add class declarations test in AP wrapper --- .../kotlin/annotation/AnnotationListParseTest.kt | 9 ++++++--- .../resources/parse/classDeclarations/annotations.txt | 5 +++++ .../test/resources/parse/classDeclarations/parsed.txt | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/annotations.txt create mode 100644 libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/parsed.txt diff --git a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt index b7565f2628b..906c3c6d2a9 100644 --- a/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt +++ b/libraries/tools/kotlin-annotation-processing/src/test/kotlin/org/jetbrains/kotlin/annotation/AnnotationListParseTest.kt @@ -32,6 +32,8 @@ public class AnnotationListParseTest { Test fun testSimple() = doTest("simple") + Test fun testDeclarations() = doTest("classDeclarations") + private val resourcesRootFile = File("src/test/resources/parse") @@ -59,10 +61,11 @@ public class AnnotationListParseTest { } } - val actualAnnotationsSorted = actualAnnotations.toString() - .lines().filter { it.isNotEmpty() }.sort().joinToString("\n") + val actualAnnotationsSorted = actualAnnotations.toString().lines().filter { it.isNotEmpty() }.sort() + val classDeclarationsSorted = annotationProvider.kotlinClasses.sort() - assertEqualsToFile(expectedFile, actualAnnotationsSorted) + val fileContents = (actualAnnotationsSorted + classDeclarationsSorted).joinToString("\n") + assertEqualsToFile(expectedFile, fileContents) } // JetTestUtils.assertEqualsToFile() is not reachable from here diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/annotations.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/annotations.txt new file mode 100644 index 00000000000..583f2226280 --- /dev/null +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/annotations.txt @@ -0,0 +1,5 @@ +p example 0 +d 0/TestClass +a example.ExampleAnnotation 0 +c 0 0/TestClass +d 0/AncestorClass \ No newline at end of file diff --git a/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/parsed.txt b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/parsed.txt new file mode 100644 index 00000000000..a8f1156e72a --- /dev/null +++ b/libraries/tools/kotlin-annotation-processing/src/test/resources/parse/classDeclarations/parsed.txt @@ -0,0 +1,3 @@ +example.ExampleAnnotation example.TestClass +example.AncestorClass +example.TestClass \ No newline at end of file From bffb24b0757a155717e27b1fe62d594c2ee47d3c Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 25 Jun 2015 01:50:07 +0300 Subject: [PATCH 083/450] Add publicField annotation --- .../kotlin/codegen/PropertyCodegen.java | 16 +++++++++++++- .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../kotlin/resolve/AnnotationUtil.kt | 4 ++++ .../kotlin/resolve/ModifiersChecker.java | 21 +++++++++++++++++++ .../src/kotlin/jvm/JvmPlatformAnnotations.kt | 6 ++++++ 6 files changed, 48 insertions(+), 1 deletion(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java index 672ffac46aa..94acfe9cb26 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; +import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; @@ -256,9 +257,19 @@ public class PropertyCodegen { ClassBuilder builder = v; + boolean hasPublicFieldAnnotation = AnnotationsPackage.findPublicFieldAnnotation(propertyDescriptor) != null; + FieldOwnerContext backingFieldContext = context; if (AsmUtil.isInstancePropertyWithStaticBackingField(propertyDescriptor) ) { - modifiers |= ACC_STATIC | getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate); + modifiers |= ACC_STATIC; + + if (hasPublicFieldAnnotation && !isDelegate) { + modifiers |= ACC_PUBLIC; + } + else { + modifiers |= getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate); + } + if (AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) { ImplementationBodyCodegen codegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen(); builder = codegen.v; @@ -266,6 +277,9 @@ public class PropertyCodegen { v.getSerializationBindings().put(STATIC_FIELD_IN_OUTER_CLASS, propertyDescriptor); } } + else if (!isDelegate && hasPublicFieldAnnotation) { + modifiers |= ACC_PUBLIC; + } else if (kind != OwnerKind.PACKAGE || isDelegate) { modifiers |= ACC_PRIVATE; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 078556686d8..7a440bd1f1e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -114,6 +114,7 @@ public interface Errors { DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING); DiagnosticFactory0 INAPPLICABLE_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INAPPLICABLE_PLATFORM_NAME = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR); // Annotations diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 5eed0c12740..587e4c7f0ec 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -137,6 +137,7 @@ public class DefaultErrorMessages { MAP.put(REPEATED_MODIFIER, "Repeated ''{0}''", TO_STRING); MAP.put(INAPPLICABLE_ANNOTATION, "This annotation is only applicable to top level functions"); MAP.put(INAPPLICABLE_PLATFORM_NAME, "platformName annotation is not applicable to this declaration"); + MAP.put(INAPPLICABLE_PUBLIC_FIELD, "publicField annotation is not applicable to this declaration"); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt index 74ea88afe34..390c2556b0a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt @@ -32,6 +32,10 @@ public fun DeclarationDescriptor.hasPlatformStaticAnnotation(): Boolean { return getAnnotations().findAnnotation(FqName("kotlin.platform.platformStatic")) != null } +public fun DeclarationDescriptor.findPublicFieldAnnotation(): AnnotationDescriptor? { + return getAnnotations().findAnnotation(FqName("kotlin.jvm.publicField")) +} + public fun DeclarationDescriptor.hasIntrinsicAnnotation(): Boolean { return getAnnotations().findAnnotation(FqName("kotlin.jvm.internal.Intrinsic")) != null } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java index 18154c9e66c..dd667a41bbc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java @@ -32,6 +32,7 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; +import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.StringValue; @@ -149,6 +150,7 @@ public class ModifiersChecker { checkVarargsModifiers(modifierListOwner, descriptor); } checkPlatformNameApplicability(descriptor); + checkPublicFieldApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); } @@ -162,6 +164,7 @@ public class ModifiersChecker { reportIllegalModalityModifiers(modifierListOwner); reportIllegalVisibilityModifiers(modifierListOwner); checkPlatformNameApplicability(descriptor); + checkPublicFieldApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); } @@ -320,6 +323,24 @@ public class ModifiersChecker { } + private void checkPublicFieldApplicability(@NotNull DeclarationDescriptor descriptor) { + AnnotationDescriptor annotation = AnnotationsPackage.findPublicFieldAnnotation(descriptor); + if (annotation == null) return; + + JetAnnotationEntry annotationEntry = trace.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation); + if (annotationEntry == null) return; + + if (!(descriptor instanceof PropertyDescriptor)) { + trace.report(INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry)); + return; + } + + PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; + if (Boolean.FALSE.equals(trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) { + trace.report(INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry)); + } + } + private static boolean isRenamableDeclaration(@NotNull DeclarationDescriptor descriptor) { DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration(); diff --git a/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt b/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt index aa5ebf2d062..b4f75925e36 100644 --- a/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt +++ b/libraries/stdlib/src/kotlin/jvm/JvmPlatformAnnotations.kt @@ -27,3 +27,9 @@ import java.lang.annotation.RetentionPolicy */ Retention(RetentionPolicy.CLASS) public annotation class jvmOverloads + +/** + * Instructs the Kotlin compiler to generate a public backing field for this property. + */ +Retention(RetentionPolicy.SOURCE) +public annotation class publicField \ No newline at end of file From 74f44dddb01f407736648daba8699568a757f43b Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Thu, 25 Jun 2015 16:39:31 +0300 Subject: [PATCH 084/450] Add tests for publicField --- .../nullabilityAnnotations/PublicField.java | 6 ++++++ .../nullabilityAnnotations/PublicField.kt | 5 +++++ .../boxWithJava/publicField/simple/Test.java | 6 ++++++ .../boxWithJava/publicField/simple/simple.kt | 7 +++++++ .../publicField/publicFieldNotOnProperty.kt | 16 ++++++++++++++ .../publicField/publicFieldNotOnProperty.txt | 12 +++++++++++ .../publicFieldOnDelegatedProperty.kt | 3 +++ .../publicFieldOnDelegatedProperty.txt | 9 ++++++++ .../asJava/KotlinLightClassTestGenerated.java | 6 ++++++ ...JetDiagnosticsTestWithStdLibGenerated.java | 21 +++++++++++++++++++ .../BlackBoxWithJavaCodegenTestGenerated.java | 16 ++++++++++++++ 11 files changed, 107 insertions(+) create mode 100644 compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java create mode 100644 compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt create mode 100644 compiler/testData/codegen/boxWithJava/publicField/simple/Test.java create mode 100644 compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java new file mode 100644 index 00000000000..96daa4f378a --- /dev/null +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java @@ -0,0 +1,6 @@ +public final class C { + @kotlin.jvm.publicField + public final java.lang.String foo = "A"; + + public C() { /* compiled code */ } +} \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt new file mode 100644 index 00000000000..d6225c5a956 --- /dev/null +++ b/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt @@ -0,0 +1,5 @@ +// C + +class C { + @[kotlin.jvm.publicField] private val foo: String = "A" +} diff --git a/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java b/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java new file mode 100644 index 00000000000..846c2246310 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/publicField/simple/Test.java @@ -0,0 +1,6 @@ +public class Test { + public static String invokeMethodWithPublicField() { + C c = new C(); + return c.foo; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt b/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt new file mode 100644 index 00000000000..798704c4d84 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/publicField/simple/simple.kt @@ -0,0 +1,7 @@ +class C { + @publicField private val foo: String = "OK" +} + +fun box(): String { + return Test.invokeMethodWithPublicField() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt new file mode 100644 index 00000000000..40e65a437de --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +class C { + + @kotlin.jvm.publicField constructor(s: String) { + + } + + @kotlin.jvm.publicField private fun foo(s: String = "OK") { + + } +} + +@kotlin.jvm.publicField +fun foo() { + @kotlin.jvm.publicField val x = "A" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt new file mode 100644 index 00000000000..2cc82a65623 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.txt @@ -0,0 +1,12 @@ +package + +kotlin.jvm.publicField() internal fun foo(): kotlin.Unit + +internal final class C { + kotlin.jvm.publicField() public constructor C(/*0*/ s: kotlin.String) + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + kotlin.jvm.publicField() private final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt new file mode 100644 index 00000000000..b230058cb9e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt @@ -0,0 +1,3 @@ +class C { + private @publicField val a: String by lazy { "A" } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt new file mode 100644 index 00000000000..2bffb955537 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.txt @@ -0,0 +1,9 @@ +package + +internal final class C { + public constructor C() + kotlin.jvm.publicField() private final val a: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java index 15bd3924d0a..802450251db 100644 --- a/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java @@ -148,6 +148,12 @@ public class KotlinLightClassTestGenerated extends AbstractKotlinLightClassTest doTest(fileName); } + @TestMetadata("PublicField.kt") + public void testPublicField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt"); + doTest(fileName); + } + @TestMetadata("Synthetic.kt") public void testSynthetic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/Synthetic.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index d42fea42f26..ed32fc97ab0 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -429,6 +429,27 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest(fileName); } } + + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicField extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInPublicField() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("publicFieldNotOnProperty.kt") + public void testPublicFieldNotOnProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldNotOnProperty.kt"); + doTest(fileName); + } + + @TestMetadata("publicFieldOnDelegatedProperty.kt") + public void testPublicFieldOnDelegatedProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/annotations/publicField/publicFieldOnDelegatedProperty.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/duplicateJvmSignature") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 1b873ebae00..590575d2c01 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -249,6 +249,22 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege } + @TestMetadata("compiler/testData/codegen/boxWithJava/publicField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicField extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInPublicField() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/publicField"), Pattern.compile("^([^\\.]+)$"), true); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/publicField/simple/"); + doTestWithJava(fileName); + } + + } + @TestMetadata("compiler/testData/codegen/boxWithJava/reflection") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 3bcdee2a202b04db63f7e330cde733bcd2ee7c08 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Fri, 3 Jul 2015 22:15:47 +0300 Subject: [PATCH 085/450] publicField & field in companion object --- .../publicField/CompanionObject.java | 13 +++++++++ .../publicField/CompanionObject.kt | 7 +++++ .../Simple.java} | 0 .../PublicField.kt => publicField/Simple.kt} | 0 .../asJava/KotlinLightClassTestGenerated.java | 27 ++++++++++++++----- 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/asJava/lightClasses/publicField/CompanionObject.java create mode 100644 compiler/testData/asJava/lightClasses/publicField/CompanionObject.kt rename compiler/testData/asJava/lightClasses/{nullabilityAnnotations/PublicField.java => publicField/Simple.java} (100%) rename compiler/testData/asJava/lightClasses/{nullabilityAnnotations/PublicField.kt => publicField/Simple.kt} (100%) diff --git a/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java new file mode 100644 index 00000000000..dcd3d456f9c --- /dev/null +++ b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.java @@ -0,0 +1,13 @@ +public final class C { + @kotlin.jvm.publicField + public static final java.lang.String foo = "A"; + public static final C.Companion Companion; + + public C() { /* compiled code */ } + + public static final class Companion { + private final java.lang.String getFoo() { /* compiled code */ } + + private Companion() { /* compiled code */ } + } +} \ No newline at end of file diff --git a/compiler/testData/asJava/lightClasses/publicField/CompanionObject.kt b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.kt new file mode 100644 index 00000000000..d51b5963d95 --- /dev/null +++ b/compiler/testData/asJava/lightClasses/publicField/CompanionObject.kt @@ -0,0 +1,7 @@ +// C + +class C { + companion object { + @[publicField] private val foo: String = "A" + } +} diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java b/compiler/testData/asJava/lightClasses/publicField/Simple.java similarity index 100% rename from compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.java rename to compiler/testData/asJava/lightClasses/publicField/Simple.java diff --git a/compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt b/compiler/testData/asJava/lightClasses/publicField/Simple.kt similarity index 100% rename from compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt rename to compiler/testData/asJava/lightClasses/publicField/Simple.kt diff --git a/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java index 802450251db..01d5419a21c 100644 --- a/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/asJava/KotlinLightClassTestGenerated.java @@ -148,12 +148,6 @@ public class KotlinLightClassTestGenerated extends AbstractKotlinLightClassTest doTest(fileName); } - @TestMetadata("PublicField.kt") - public void testPublicField() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/PublicField.kt"); - doTest(fileName); - } - @TestMetadata("Synthetic.kt") public void testSynthetic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/Synthetic.kt"); @@ -196,4 +190,25 @@ public class KotlinLightClassTestGenerated extends AbstractKotlinLightClassTest doTest(fileName); } } + + @TestMetadata("compiler/testData/asJava/lightClasses/publicField") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PublicField extends AbstractKotlinLightClassTest { + public void testAllFilesPresentInPublicField() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses/publicField"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("CompanionObject.kt") + public void testCompanionObject() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/publicField/CompanionObject.kt"); + doTest(fileName); + } + + @TestMetadata("Simple.kt") + public void testSimple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/publicField/Simple.kt"); + doTest(fileName); + } + } } From 9c8ea54946e87fe7688f9d9f0a35e4ebd4d924f7 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Fri, 3 Jul 2015 21:47:46 +0300 Subject: [PATCH 086/450] Use KotlinJvmCheckerProvider to check @publicField --- .../load/kotlin/KotlinJvmCheckerProvider.kt | 59 ++++++++++++++++--- .../jetbrains/kotlin/load/kotlin/native.kt | 8 ++- .../diagnostics/DefaultErrorMessagesJvm.java | 2 + .../resolve/jvm/diagnostics/ErrorsJvm.java | 2 + .../jetbrains/kotlin/diagnostics/Errors.java | 1 - .../rendering/DefaultErrorMessages.java | 1 - .../resolve/DataClassAnnotationChecker.kt | 7 ++- .../kotlin/resolve/DeclarationChecker.kt | 8 ++- .../kotlin/resolve/ModifiersChecker.java | 23 +------- .../js/resolve/nativeAnnotationCheckers.kt | 11 +++- .../js/resolve/unsupportedFeatureCheckers.kt | 9 ++- 11 files changed, 89 insertions(+), 42 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index 35b6fe8c2f4..a2088456c69 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -26,10 +26,8 @@ import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNullable import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeFunChecker import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider -import org.jetbrains.kotlin.resolve.DeclarationChecker -import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.* +import org.jetbrains.kotlin.resolve.annotations.findPublicFieldAnnotation import org.jetbrains.kotlin.resolve.annotations.hasInlineAnnotation import org.jetbrains.kotlin.resolve.annotations.hasIntrinsicAnnotation import org.jetbrains.kotlin.resolve.annotations.hasPlatformStaticAnnotation @@ -57,7 +55,8 @@ public class KotlinJvmCheckerProvider(private val module: ModuleDescriptor) : Ad LocalFunInlineChecker(), ReifiedTypeParameterAnnotationChecker(), NativeFunChecker(), - OverloadsAnnotationChecker()), + OverloadsAnnotationChecker(), + PublicFieldAnnotationChecker()), additionalCallCheckers = listOf(NeedSyntheticChecker(), JavaAnnotationCallChecker(), JavaAnnotationMethodCallChecker(), TraitDefaultMethodCallChecker()), @@ -68,7 +67,11 @@ public class KotlinJvmCheckerProvider(private val module: ModuleDescriptor) : Ad public class LocalFunInlineChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext) { if (descriptor.hasInlineAnnotation() && declaration is JetNamedFunction && descriptor is FunctionDescriptor && @@ -80,7 +83,12 @@ public class LocalFunInlineChecker : DeclarationChecker { public class PlatformStaticAnnotationChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (descriptor.hasPlatformStaticAnnotation()) { if (declaration is JetNamedFunction || declaration is JetProperty || declaration is JetPropertyAccessor) { checkDeclaration(declaration, descriptor, diagnosticHolder) @@ -119,7 +127,12 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker { } public class OverloadsAnnotationChecker: DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (descriptor.getAnnotations().findAnnotation(FqName("kotlin.jvm.jvmOverloads")) != null) { checkDeclaration(declaration, descriptor, diagnosticHolder) } @@ -142,9 +155,37 @@ public class OverloadsAnnotationChecker: DeclarationChecker { } } +public class PublicFieldAnnotationChecker: DeclarationChecker { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { + val annotation = descriptor.findPublicFieldAnnotation() ?: return + + fun report() { + val annotationEntry = bindingContext.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation) ?: return + diagnosticHolder.report(ErrorsJvm.INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry)) + } + + if (descriptor !is PropertyDescriptor) { + report() + } + else if (!bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)) { + report() + } + } +} + public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (descriptor.hasIntrinsicAnnotation()) return if (descriptor is CallableDescriptor && !descriptor.hasInlineAnnotation()) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt index 38b2d42bd8a..0a71b4aa01e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.psi.JetDeclarationWithBody +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.annotations.hasInlineAnnotation import org.jetbrains.kotlin.resolve.diagnostics.SuppressDiagnosticsByAnnotations import org.jetbrains.kotlin.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS @@ -41,7 +42,12 @@ public fun DeclarationDescriptor.hasNativeAnnotation(): Boolean { public class SuppressNoBodyErrorsForNativeDeclarations : SuppressDiagnosticsByAnnotations(FUNCTION_NO_BODY_ERRORS, NATIVE_ANNOTATION_CLASS_NAME) public class NativeFunChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (!descriptor.hasNativeAnnotation()) return if (DescriptorUtils.isTrait(descriptor.getContainingDeclaration())) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 8a96d821c42..3f3c39dd126 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -68,6 +68,8 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(ErrorsJvm.TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER, "Interfaces can't call Java default methods via super"); MAP.put(ErrorsJvm.WHEN_ENUM_CAN_BE_NULL_IN_JAVA, "Enum argument can be null in Java, but exhaustive when contains no null branch"); + + MAP.put(ErrorsJvm.INAPPLICABLE_PUBLIC_FIELD, "publicField annotation is not applicable to this declaration"); } @NotNull diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 3e16df39687..9fddc2d9a71 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -56,6 +56,8 @@ public interface ErrorsJvm { DiagnosticFactory0 TRAIT_CANT_CALL_DEFAULT_METHOD_VIA_SUPER = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR); + // TODO: make this a warning DiagnosticFactory1 NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory1.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 7a440bd1f1e..078556686d8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -114,7 +114,6 @@ public interface Errors { DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING); DiagnosticFactory0 INAPPLICABLE_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INAPPLICABLE_PLATFORM_NAME = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR); // Annotations diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 587e4c7f0ec..5eed0c12740 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -137,7 +137,6 @@ public class DefaultErrorMessages { MAP.put(REPEATED_MODIFIER, "Repeated ''{0}''", TO_STRING); MAP.put(INAPPLICABLE_ANNOTATION, "This annotation is only applicable to top level functions"); MAP.put(INAPPLICABLE_PLATFORM_NAME, "platformName annotation is not applicable to this declaration"); - MAP.put(INAPPLICABLE_PUBLIC_FIELD, "publicField annotation is not applicable to this declaration"); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt index 6815253427e..68e44ff29c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DataClassAnnotationChecker.kt @@ -23,7 +23,12 @@ import org.jetbrains.kotlin.builtins.* public class DataClassAnnotationChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (descriptor !is ClassDescriptor) return if (declaration !is JetClassOrObject) return diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationChecker.kt index 47c9cb1e1f5..897ea5c6126 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationChecker.kt @@ -20,8 +20,12 @@ import org.jetbrains.kotlin.psi.JetDeclaration import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -public trait DeclarationChecker { +public interface DeclarationChecker { - public fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink); + public fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java index dd667a41bbc..bea60497b7c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java @@ -32,7 +32,6 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.StringValue; @@ -150,7 +149,6 @@ public class ModifiersChecker { checkVarargsModifiers(modifierListOwner, descriptor); } checkPlatformNameApplicability(descriptor); - checkPublicFieldApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); } @@ -164,7 +162,6 @@ public class ModifiersChecker { reportIllegalModalityModifiers(modifierListOwner); reportIllegalVisibilityModifiers(modifierListOwner); checkPlatformNameApplicability(descriptor); - checkPublicFieldApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); } @@ -323,24 +320,6 @@ public class ModifiersChecker { } - private void checkPublicFieldApplicability(@NotNull DeclarationDescriptor descriptor) { - AnnotationDescriptor annotation = AnnotationsPackage.findPublicFieldAnnotation(descriptor); - if (annotation == null) return; - - JetAnnotationEntry annotationEntry = trace.get(BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT, annotation); - if (annotationEntry == null) return; - - if (!(descriptor instanceof PropertyDescriptor)) { - trace.report(INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry)); - return; - } - - PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor; - if (Boolean.FALSE.equals(trace.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) { - trace.report(INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry)); - } - } - private static boolean isRenamableDeclaration(@NotNull DeclarationDescriptor descriptor) { DeclarationDescriptor containingDescriptor = descriptor.getContainingDeclaration(); @@ -442,7 +421,7 @@ public class ModifiersChecker { private void runDeclarationCheckers(@NotNull JetDeclaration declaration, @NotNull DeclarationDescriptor descriptor) { for (DeclarationChecker checker : additionalCheckerProvider.getDeclarationCheckers()) { - checker.check(declaration, descriptor, trace); + checker.check(declaration, descriptor, trace, trace.getBindingContext()); } } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt index fdebcbd3f77..dff2309a3a7 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/nativeAnnotationCheckers.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.psi.JetDeclaration import org.jetbrains.kotlin.psi.JetNamedFunction +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DeclarationChecker import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.types.TypeUtils @@ -35,9 +36,13 @@ private abstract class AbstractNativeAnnotationsChecker(private val requiredAnno open fun additionalCheck(declaration: JetNamedFunction, descriptor: FunctionDescriptor, diagnosticHolder: DiagnosticSink) {} - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { - val annotationDescriptor = descriptor.getAnnotations().findAnnotation(requiredAnnotation.fqName) - if (annotationDescriptor == null) return + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { + val annotationDescriptor = descriptor.getAnnotations().findAnnotation(requiredAnnotation.fqName) ?: return if (declaration !is JetNamedFunction || descriptor !is FunctionDescriptor) { diagnosticHolder.report(ErrorsJs.NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN.on(declaration, annotationDescriptor.getType())) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/unsupportedFeatureCheckers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/unsupportedFeatureCheckers.kt index 8ac9a876d8a..dcefa7fd311 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/unsupportedFeatureCheckers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/unsupportedFeatureCheckers.kt @@ -26,12 +26,17 @@ import org.jetbrains.kotlin.diagnostics.rendering.renderKindWithName import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DeclarationChecker import org.jetbrains.kotlin.resolve.DescriptorUtils class ClassDeclarationChecker : DeclarationChecker { - override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { - + override fun check( + declaration: JetDeclaration, + descriptor: DeclarationDescriptor, + diagnosticHolder: DiagnosticSink, + bindingContext: BindingContext + ) { if (declaration !is JetClassOrObject || declaration is JetObjectDeclaration || declaration is JetEnumEntry) return // hack to avoid to get diagnostics when compile kotlin builtins From 9cb88a9c21a2c87e213ace43f54eaace4e88c0f5 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Wed, 1 Jul 2015 14:38:10 +0300 Subject: [PATCH 087/450] Fix muted completion test for the @file keyword --- .../testData/handlers/keywords/FileKeyword.kt.after | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/idea-completion/testData/handlers/keywords/FileKeyword.kt.after b/idea/idea-completion/testData/handlers/keywords/FileKeyword.kt.after index 65e3a90a0a1..bd66ff5d579 100644 --- a/idea/idea-completion/testData/handlers/keywords/FileKeyword.kt.after +++ b/idea/idea-completion/testData/handlers/keywords/FileKeyword.kt.after @@ -1 +1 @@ -@final +@fi From 2a48a97853e7d27790a7c9c097797df7ef0a2d6d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 15:30:19 +0200 Subject: [PATCH 088/450] JetJUnitRunConfigurationProducer: rename to .kt --- ...rationProducer.java => KotlinJUnitRunConfigurationProducer.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/run/{JetJUnitConfigurationProducer.java => KotlinJUnitRunConfigurationProducer.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetJUnitConfigurationProducer.java b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/run/JetJUnitConfigurationProducer.java rename to idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt From a206ff7406b706b74aa04cac7e0d31602e8a4098 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 15:34:29 +0200 Subject: [PATCH 089/450] JetJUnitConfigurationProducer: J2K --- idea/src/META-INF/junit.xml | 2 +- .../run/JetTestNgConfigurationProducer.java | 2 +- .../KotlinJUnitRunConfigurationProducer.kt | 166 +++++++++--------- 3 files changed, 81 insertions(+), 89 deletions(-) diff --git a/idea/src/META-INF/junit.xml b/idea/src/META-INF/junit.xml index fe8cea18191..099716d030a 100644 --- a/idea/src/META-INF/junit.xml +++ b/idea/src/META-INF/junit.xml @@ -1,5 +1,5 @@ - + diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java b/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java index 8ee7a4ec3ec..a2662807dc6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java @@ -90,7 +90,7 @@ public class JetTestNgConfigurationProducer extends TestNGConfigurationProducer JetClass jetClass = PsiTreeUtil.getParentOfType(leaf, JetClass.class, false); if (jetClass == null) { - jetClass = JetJUnitConfigurationProducer.getClassDeclarationInFile(jetFile); + jetClass = KotlinJUnitRunConfigurationProducer.Companion.getClassDeclarationInFile(jetFile); } if (jetClass == null) { diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt index 480f8c8db3b..dc6d8d021ec 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt @@ -14,142 +14,134 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.run; +package org.jetbrains.kotlin.idea.run -import com.intellij.execution.JavaRunConfigurationExtensionManager; -import com.intellij.execution.Location; -import com.intellij.execution.PsiLocation; -import com.intellij.execution.RunnerAndConfigurationSettings; -import com.intellij.execution.actions.ConfigurationContext; -import com.intellij.execution.junit.JUnitConfiguration; -import com.intellij.execution.junit.JUnitConfigurationType; -import com.intellij.execution.junit.JUnitUtil; -import com.intellij.execution.junit.RuntimeConfigurationProducer; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.project.DumbService; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.util.PsiTreeUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.asJava.LightClassUtil; -import org.jetbrains.kotlin.idea.project.ProjectStructureUtil; -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil; -import org.jetbrains.kotlin.psi.*; +import com.intellij.execution.JavaRunConfigurationExtensionManager +import com.intellij.execution.Location +import com.intellij.execution.PsiLocation +import com.intellij.execution.RunnerAndConfigurationSettings +import com.intellij.execution.actions.ConfigurationContext +import com.intellij.execution.junit.JUnitConfiguration +import com.intellij.execution.junit.JUnitConfigurationType +import com.intellij.execution.junit.JUnitUtil +import com.intellij.execution.junit.RuntimeConfigurationProducer +import com.intellij.openapi.module.Module +import com.intellij.openapi.project.DumbService +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.asJava.LightClassUtil +import org.jetbrains.kotlin.idea.project.ProjectStructureUtil +import org.jetbrains.kotlin.idea.util.ProjectRootsUtil +import org.jetbrains.kotlin.psi.* -public class JetJUnitConfigurationProducer extends RuntimeConfigurationProducer { - private JetElement myElement; +public class KotlinJUnitRunConfigurationProducer : RuntimeConfigurationProducer(JUnitConfigurationType.getInstance()) { + private var myElement: JetElement? = null - public JetJUnitConfigurationProducer() { - super(JUnitConfigurationType.getInstance()); + override fun getSourceElement(): PsiElement? { + return myElement } - @Override - public PsiElement getSourceElement() { - return myElement; - } + override fun createConfigurationByElement(location: Location<*>, context: ConfigurationContext): RunnerAndConfigurationSettings? { + if (DumbService.getInstance(location.getProject()).isDumb()) return null - @Override - protected RunnerAndConfigurationSettings createConfigurationByElement(Location location, ConfigurationContext context) { - if (DumbService.getInstance(location.getProject()).isDumb()) return null; - - PsiElement leaf = location.getPsiElement(); + val leaf = location.getPsiElement() if (!ProjectRootsUtil.isInProjectOrLibSource(leaf)) { - return null; + return null } - if (!(leaf.getContainingFile() instanceof JetFile)) { - return null; + if (leaf.getContainingFile() !is JetFile) { + return null } - JetFile jetFile = (JetFile) leaf.getContainingFile(); + val jetFile = leaf.getContainingFile() as JetFile if (ProjectStructureUtil.isJsKotlinModule(jetFile)) { - return null; + return null } - JetNamedFunction function = PsiTreeUtil.getParentOfType(leaf, JetNamedFunction.class, false); + val function = PsiTreeUtil.getParentOfType(leaf, javaClass(), false) if (function != null) { - myElement = function; + myElement = function @SuppressWarnings("unchecked") - JetElement owner = PsiTreeUtil.getParentOfType(function, JetFunction.class, JetClass.class); + val owner = PsiTreeUtil.getParentOfType(function, javaClass(), javaClass()) - if (owner instanceof JetClass) { - PsiClass delegate = LightClassUtil.getPsiClass((JetClass) owner); + if (owner is JetClass) { + val delegate = LightClassUtil.getPsiClass(owner) if (delegate != null) { - for (PsiMethod method : delegate.getMethods()) { - if (method.getNavigationElement() == function) { - Location methodLocation = PsiLocation.fromPsiElement(method); + for (method in delegate.getMethods()) { + if (method.getNavigationElement() === function) { + val methodLocation = PsiLocation.fromPsiElement(method) if (JUnitUtil.isTestMethod(methodLocation, false)) { - RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context.getProject(), context); - JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration(); + val settings = cloneTemplateConfiguration(context.getProject(), context) + val configuration = settings.getConfiguration() as JUnitConfiguration - Module originalModule = configuration.getConfigurationModule().getModule(); - configuration.beMethodConfiguration(methodLocation); - configuration.restoreOriginalModule(originalModule); - JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location); + val originalModule = configuration.getConfigurationModule().getModule() + configuration.beMethodConfiguration(methodLocation) + configuration.restoreOriginalModule(originalModule) + JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) - return settings; + return settings } - break; + break } } } } } - JetClass jetClass = PsiTreeUtil.getParentOfType(leaf, JetClass.class, false); + var jetClass = PsiTreeUtil.getParentOfType(leaf, javaClass(), false) if (jetClass == null) { - jetClass = getClassDeclarationInFile(jetFile); + jetClass = getClassDeclarationInFile(jetFile) } if (jetClass != null) { - myElement = jetClass; - PsiClass delegate = LightClassUtil.getPsiClass(jetClass); + myElement = jetClass + val delegate = LightClassUtil.getPsiClass(jetClass) if (delegate != null && JUnitUtil.isTestClass(delegate)) { - RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context.getProject(), context); - JUnitConfiguration configuration = (JUnitConfiguration) settings.getConfiguration(); + val settings = cloneTemplateConfiguration(context.getProject(), context) + val configuration = settings.getConfiguration() as JUnitConfiguration - Module originalModule = configuration.getConfigurationModule().getModule(); - configuration.beClassConfiguration(delegate); - configuration.restoreOriginalModule(originalModule); - JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location); + val originalModule = configuration.getConfigurationModule().getModule() + configuration.beClassConfiguration(delegate) + configuration.restoreOriginalModule(originalModule) + JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) - return settings; + return settings } } - return null; + return null } - @Nullable - static JetClass getClassDeclarationInFile(JetFile jetFile) { - JetClass tempSingleDeclaration = null; + override fun compareTo(o: Any?): Int { + return 0 + } - for (JetDeclaration jetDeclaration : jetFile.getDeclarations()) { - if (jetDeclaration instanceof JetClass) { - JetClass declaration = (JetClass) jetDeclaration; + companion object { - if (tempSingleDeclaration == null) { - tempSingleDeclaration = declaration; - } - else { - // There are several class declarations in file - return null; + fun getClassDeclarationInFile(jetFile: JetFile): JetClass? { + var tempSingleDeclaration: JetClass? = null + + for (jetDeclaration in jetFile.getDeclarations()) { + if (jetDeclaration is JetClass) { + + if (tempSingleDeclaration == null) { + tempSingleDeclaration = jetDeclaration + } + else { + // There are several class declarations in file + return null + } } } + + return tempSingleDeclaration } - - return tempSingleDeclaration; - } - - @Override - public int compareTo(@NotNull Object o) { - return 0; } } From bd36b5e3d8d4039d99f503a4eeaa88260509a965 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 17:02:20 +0200 Subject: [PATCH 090/450] rewrite JUnit run configuration producer with a non-deprecated API; correctly detect configuration created from context (KT-8038); allow running test if file contains multiple classes (KT-8272) #KT-8038 Fixed #KT-8272 FIxed --- idea/src/META-INF/junit.xml | 2 +- .../run/JetTestNgConfigurationProducer.java | 23 ++- .../KotlinJUnitRunConfigurationProducer.kt | 175 +++++++++--------- 3 files changed, 111 insertions(+), 89 deletions(-) diff --git a/idea/src/META-INF/junit.xml b/idea/src/META-INF/junit.xml index 099716d030a..7484657e0f0 100644 --- a/idea/src/META-INF/junit.xml +++ b/idea/src/META-INF/junit.xml @@ -1,5 +1,5 @@ - + diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java b/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java index a2662807dc6..a3f73d4211e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetTestNgConfigurationProducer.java @@ -90,7 +90,7 @@ public class JetTestNgConfigurationProducer extends TestNGConfigurationProducer JetClass jetClass = PsiTreeUtil.getParentOfType(leaf, JetClass.class, false); if (jetClass == null) { - jetClass = KotlinJUnitRunConfigurationProducer.Companion.getClassDeclarationInFile(jetFile); + jetClass = getClassDeclarationInFile(jetFile); } if (jetClass == null) { @@ -128,4 +128,25 @@ public class JetTestNgConfigurationProducer extends TestNGConfigurationProducer private static boolean isTestNGClass(PsiClass psiClass) { return psiClass != null && PsiClassUtil.isRunnableClass(psiClass, true, false) && TestNGUtil.hasTest(psiClass); } + + @Nullable + static JetClass getClassDeclarationInFile(JetFile jetFile) { + JetClass tempSingleDeclaration = null; + + for (JetDeclaration jetDeclaration : jetFile.getDeclarations()) { + if (jetDeclaration instanceof JetClass) { + JetClass declaration = (JetClass) jetDeclaration; + + if (tempSingleDeclaration == null) { + tempSingleDeclaration = declaration; + } + else { + // There are several class declarations in file + return null; + } + } + } + + return tempSingleDeclaration; + } } diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt index dc6d8d021ec..015201848b5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt @@ -16,17 +16,16 @@ package org.jetbrains.kotlin.idea.run -import com.intellij.execution.JavaRunConfigurationExtensionManager -import com.intellij.execution.Location -import com.intellij.execution.PsiLocation -import com.intellij.execution.RunnerAndConfigurationSettings +import com.intellij.execution.* import com.intellij.execution.actions.ConfigurationContext +import com.intellij.execution.actions.RunConfigurationProducer +import com.intellij.execution.configurations.ModuleBasedConfiguration import com.intellij.execution.junit.JUnitConfiguration import com.intellij.execution.junit.JUnitConfigurationType import com.intellij.execution.junit.JUnitUtil -import com.intellij.execution.junit.RuntimeConfigurationProducer -import com.intellij.openapi.module.Module +import com.intellij.execution.junit.PatternConfigurationProducer import com.intellij.openapi.project.DumbService +import com.intellij.openapi.util.Ref import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod @@ -34,114 +33,116 @@ import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.asJava.LightClassUtil import org.jetbrains.kotlin.idea.project.ProjectStructureUtil import org.jetbrains.kotlin.idea.util.ProjectRootsUtil -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.JetClass +import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.JetNamedFunction +import org.jetbrains.kotlin.psi.psiUtil.getParentOfType -public class KotlinJUnitRunConfigurationProducer : RuntimeConfigurationProducer(JUnitConfigurationType.getInstance()) { - private var myElement: JetElement? = null +public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer(JUnitConfigurationType.getInstance()) { + override fun isConfigurationFromContext(configuration: JUnitConfiguration, + context: ConfigurationContext): Boolean { + if (RunConfigurationProducer.getInstance(javaClass()).isMultipleElementsSelected(context)) { + return false + } - override fun getSourceElement(): PsiElement? { - return myElement + val leaf = context.getLocation()?.getPsiElement() ?: return false + val methodLocation = getTestMethodLocation(leaf) + val testClass = getTestClass(leaf) + val testObject = configuration.getTestObject() + + if (!testObject.isConfiguredByElement(configuration, testClass, methodLocation?.getPsiElement(), null, null)) { + return false + } + + return settingsMatchTemplate(configuration, context) } - override fun createConfigurationByElement(location: Location<*>, context: ConfigurationContext): RunnerAndConfigurationSettings? { - if (DumbService.getInstance(location.getProject()).isDumb()) return null + // copied from JUnitConfigurationProducer in IDEA + private fun settingsMatchTemplate(configuration: JUnitConfiguration, context: ConfigurationContext): Boolean { + val predefinedConfiguration = context.getOriginalConfiguration(JUnitConfigurationType.getInstance()) + val vmParameters = (predefinedConfiguration as? CommonJavaRunConfigurationParameters)?.getVMParameters() + if (vmParameters != null && configuration.getVMParameters() != vmParameters) return false + + val template = RunManager.getInstance(configuration.getProject()).getConfigurationTemplate(getConfigurationFactory()) + val predefinedModule = (template.getConfiguration() as ModuleBasedConfiguration<*>).getConfigurationModule().getModule() + val configurationModule = configuration.getConfigurationModule().getModule() + return configurationModule == context.getLocation()?.getModule() || configurationModule == predefinedModule + } + + override fun setupConfigurationFromContext(configuration: JUnitConfiguration, + context: ConfigurationContext, + sourceElement: Ref): Boolean { + if (DumbService.getInstance(context.getProject()).isDumb()) return false + + val location = context.getLocation() ?: return false val leaf = location.getPsiElement() if (!ProjectRootsUtil.isInProjectOrLibSource(leaf)) { - return null + return false } if (leaf.getContainingFile() !is JetFile) { - return null + return false } val jetFile = leaf.getContainingFile() as JetFile if (ProjectStructureUtil.isJsKotlinModule(jetFile)) { - return null + return false } - val function = PsiTreeUtil.getParentOfType(leaf, javaClass(), false) - if (function != null) { - myElement = function + val methodLocation = getTestMethodLocation(leaf) + if (methodLocation != null) { + val originalModule = configuration.getConfigurationModule().getModule() + configuration.beMethodConfiguration(methodLocation) + configuration.restoreOriginalModule(originalModule) + JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) + return true + } - @SuppressWarnings("unchecked") - val owner = PsiTreeUtil.getParentOfType(function, javaClass(), javaClass()) + val testClass = getTestClass(leaf) + if (testClass != null) { + val originalModule = configuration.getConfigurationModule().getModule() + configuration.beClassConfiguration(testClass) + configuration.restoreOriginalModule(originalModule) + JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) + return true + } - if (owner is JetClass) { - val delegate = LightClassUtil.getPsiClass(owner) - if (delegate != null) { - for (method in delegate.getMethods()) { - if (method.getNavigationElement() === function) { - val methodLocation = PsiLocation.fromPsiElement(method) - if (JUnitUtil.isTestMethod(methodLocation, false)) { - val settings = cloneTemplateConfiguration(context.getProject(), context) - val configuration = settings.getConfiguration() as JUnitConfiguration + return false + } - val originalModule = configuration.getConfigurationModule().getModule() - configuration.beMethodConfiguration(methodLocation) - configuration.restoreOriginalModule(originalModule) - JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) + private fun getTestMethodLocation(leaf: PsiElement): Location? { + val function = leaf.getParentOfType(false) ?: return null + val owner = PsiTreeUtil.getParentOfType(function, javaClass(), javaClass()) - return settings - } - break - } - } - } + if (owner is JetClass) { + val delegate = LightClassUtil.getPsiClass(owner) ?: return null + val method = delegate.getMethods().firstOrNull() { it.getNavigationElement() == function } ?: return null + val methodLocation = PsiLocation.fromPsiElement(method) + if (JUnitUtil.isTestMethod(methodLocation, false)) { + return methodLocation } } - - var jetClass = PsiTreeUtil.getParentOfType(leaf, javaClass(), false) - - if (jetClass == null) { - jetClass = getClassDeclarationInFile(jetFile) - } - - if (jetClass != null) { - myElement = jetClass - val delegate = LightClassUtil.getPsiClass(jetClass) - - if (delegate != null && JUnitUtil.isTestClass(delegate)) { - val settings = cloneTemplateConfiguration(context.getProject(), context) - val configuration = settings.getConfiguration() as JUnitConfiguration - - val originalModule = configuration.getConfigurationModule().getModule() - configuration.beClassConfiguration(delegate) - configuration.restoreOriginalModule(originalModule) - JavaRunConfigurationExtensionManager.getInstance().extendCreatedConfiguration(configuration, location) - - return settings - } - } - return null } - override fun compareTo(o: Any?): Int { - return 0 - } - - companion object { - - fun getClassDeclarationInFile(jetFile: JetFile): JetClass? { - var tempSingleDeclaration: JetClass? = null - - for (jetDeclaration in jetFile.getDeclarations()) { - if (jetDeclaration is JetClass) { - - if (tempSingleDeclaration == null) { - tempSingleDeclaration = jetDeclaration - } - else { - // There are several class declarations in file - return null - } - } - } - - return tempSingleDeclaration + private fun getTestClass(leaf: PsiElement): PsiClass? { + var jetClass = leaf.getParentOfType(false) + if (!jetClass.isJUnitTestClass()) { + jetClass = getTestClassInFile(leaf.getContainingFile() as JetFile) } + if (jetClass != null) { + return LightClassUtil.getPsiClass(jetClass) + } + return null } + + private fun JetClass?.isJUnitTestClass() = + LightClassUtil.getPsiClass(this)?.let { JUnitUtil.isTestClass(it) } ?: false + + private fun getTestClassInFile(jetFile: JetFile) = + jetFile.getDeclarations().filterIsInstance().singleOrNull { it.isJUnitTestClass() } } From 3ca30af6159bb13c6fa7c42cb7f866b161a3841b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 17:11:01 +0200 Subject: [PATCH 091/450] JetRunConfigurationProducer: rename to .kt --- ...nfigurationProducer.java => KotlinRunConfigurationProducer.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/run/{JetRunConfigurationProducer.java => KotlinRunConfigurationProducer.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationProducer.java b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/run/JetRunConfigurationProducer.java rename to idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt From 9d650b61546e0057fb68117a5a14ac5170f14f91 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 17:18:20 +0200 Subject: [PATCH 092/450] JetRunConfigurationProducer: J2K --- idea/src/META-INF/plugin.xml | 2 +- .../run/KotlinRunConfigurationProducer.kt | 200 ++++++++---------- 2 files changed, 85 insertions(+), 117 deletions(-) diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 4be55c90633..f8090e618c0 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -391,7 +391,7 @@ - + .clone() as KotlinRunConfigurationProducer } - @Nullable - @Override - public PsiElement getSourceElement() { - return mySourceElement; + private var mySourceElement: PsiElement? = null + + override fun getSourceElement(): PsiElement? { + return mySourceElement } - @Override - protected RunnerAndConfigurationSettings createConfigurationByElement(@NotNull Location location, ConfigurationContext configurationContext) { - JetDeclarationContainer container = getEntryPointContainer(location); - if (container == null) return null; + override fun createConfigurationByElement(location: Location<*>, configurationContext: ConfigurationContext): RunnerAndConfigurationSettings? { + val container = getEntryPointContainer(location) ?: return null - mySourceElement = (PsiElement) container; + mySourceElement = container as PsiElement? - FqName startClassFQName = getStartClassFqName(container); - if (startClassFQName == null) return null; + val startClassFQName = getStartClassFqName(container) + if (startClassFQName == null) return null - Module module = location.getModule(); - assert module != null; + val module = location.getModule() + assert(module != null) - return createConfigurationByQName(module, configurationContext, startClassFQName); + return createConfigurationByQName(module, configurationContext, startClassFQName) } - @Nullable - private static FqName getStartClassFqName(@Nullable JetDeclarationContainer container) { - if (container == null) return null; - if (container instanceof JetFile) return PackageClassUtils.getPackageClassFqName(((JetFile) container).getPackageFqName()); - if (container instanceof JetClassOrObject) { - JetClassOrObject classOrObject = (JetClassOrObject) container; - if (classOrObject instanceof JetObjectDeclaration && ((JetObjectDeclaration) classOrObject).isCompanion()) { - classOrObject = PsiTreeUtil.getParentOfType(classOrObject, JetClass.class); + private fun getStartClassFqName(container: JetDeclarationContainer?): FqName? { + if (container == null) return null + if (container is JetFile) return PackageClassUtils.getPackageClassFqName((container as JetFile?).getPackageFqName()) + if (container is JetClassOrObject) { + if (container is JetObjectDeclaration && container.isCompanion()) { + val containerClass = PsiTreeUtil.getParentOfType(container, javaClass()) + return containerClass?.getFqName() } - return classOrObject != null ? classOrObject.getFqName() : null; + return container?.getFqName() } - throw new IllegalArgumentException("Invalid entry-point container: " + ((PsiElement) container).getText()); + throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement?).getText()) } - @Nullable - private static JetDeclarationContainer getEntryPointContainer(@NotNull Location location) { - if (DumbService.getInstance(location.getProject()).isDumb()) return null; + private fun getEntryPointContainer(location: Location<*>): JetDeclarationContainer? { + if (DumbService.getInstance(location.getProject()).isDumb()) return null - Module module = location.getModule(); - if (module == null) return null; + val module = location.getModule() ?: return null - if (ProjectStructureUtil.isJsKotlinModule(module)) return null; + if (ProjectStructureUtil.isJsKotlinModule(module)) return null - PsiElement locationElement = location.getPsiElement(); + val locationElement = location.getPsiElement() - PsiFile psiFile = locationElement.getContainingFile(); - if (!(psiFile instanceof JetFile && ProjectRootsUtil.isInProjectOrLibSource(psiFile))) return null; + val psiFile = locationElement.getContainingFile() + if (!(psiFile is JetFile && ProjectRootsUtil.isInProjectOrLibSource(psiFile))) return null - JetFile jetFile = (JetFile) psiFile; - final ResolutionFacade resolutionFacade = ResolvePackage.getResolutionFacade(jetFile); - MainFunctionDetector mainFunctionDetector = new MainFunctionDetector( - new NotNullFunction() { - @NotNull - @Override - public FunctionDescriptor fun(JetNamedFunction function) { - return (FunctionDescriptor) resolutionFacade.resolveToDescriptor(function); - } - }); - - for (JetDeclarationContainer currentElement = PsiTreeUtil.getNonStrictParentOfType(locationElement, JetClassOrObject.class, - JetFile.class); - currentElement != null; - currentElement = PsiTreeUtil.getParentOfType((PsiElement) currentElement, JetClassOrObject.class, JetFile.class)) { - JetDeclarationContainer entryPointContainer = currentElement; - if (entryPointContainer instanceof JetClass) { - entryPointContainer = singleOrNull(((JetClass) currentElement).getCompanionObjects()); + val resolutionFacade = psiFile.getResolutionFacade() + val mainFunctionDetector = MainFunctionDetector(object : NotNullFunction { + override fun `fun`(function: JetNamedFunction): FunctionDescriptor { + return resolutionFacade.resolveToDescriptor(function) as FunctionDescriptor } - if (entryPointContainer != null && mainFunctionDetector.hasMain(entryPointContainer.getDeclarations())) return entryPointContainer; + }) + + var currentElement = PsiTreeUtil.getNonStrictParentOfType(locationElement, javaClass(), javaClass()) as JetDeclarationContainer + while (currentElement != null) { + var entryPointContainer = currentElement + if (entryPointContainer is JetClass) { + entryPointContainer = entryPointContainer.getCompanionObjects().singleOrNull() as JetDeclarationContainer + } + if (entryPointContainer != null && mainFunctionDetector.hasMain(entryPointContainer.getDeclarations())) return entryPointContainer + currentElement = PsiTreeUtil.getParentOfType(currentElement as PsiElement?, javaClass(), javaClass()) as JetDeclarationContainer } - return null; + return null } - @NotNull - private RunnerAndConfigurationSettings createConfigurationByQName( - @NotNull Module module, - ConfigurationContext context, - @NotNull FqName fqName - ) { - RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(module.getProject(), context); - JetRunConfiguration configuration = (JetRunConfiguration) settings.getConfiguration(); - configuration.setModule(module); - configuration.setName(StringUtil.trimEnd(fqName.asString(), "." + PackageClassUtils.getPackageClassName(fqName))); - configuration.setRunClass(fqName.asString()); - return settings; + private fun createConfigurationByQName(module: Module, context: ConfigurationContext, fqName: FqName): RunnerAndConfigurationSettings { + val settings = cloneTemplateConfiguration(module.getProject(), context) + val configuration = settings.getConfiguration() as JetRunConfiguration + configuration.setModule(module) + configuration.setName(StringUtil.trimEnd(fqName.asString(), "." + PackageClassUtils.getPackageClassName(fqName))) + configuration.setRunClass(fqName.asString()) + return settings } - @Override - protected RunnerAndConfigurationSettings findExistingByElement( - Location location, - @NotNull List existingConfigurations, - ConfigurationContext context - ) { - FqName startClassFQName = getStartClassFqName(getEntryPointContainer(location)); - if (startClassFQName == null) return null; + override fun findExistingByElement(location: Location<*>?, existingConfigurations: List, context: ConfigurationContext?): RunnerAndConfigurationSettings? { + val startClassFQName = getStartClassFqName(getEntryPointContainer(location)) ?: return null - for (RunnerAndConfigurationSettings existingConfiguration : existingConfigurations) { - if (existingConfiguration.getType() instanceof JetRunConfigurationType) { - JetRunConfiguration jetConfiguration = (JetRunConfiguration)existingConfiguration.getConfiguration(); + for (existingConfiguration in existingConfigurations) { + if (existingConfiguration.getType() is JetRunConfigurationType) { + val jetConfiguration = existingConfiguration.getConfiguration() as JetRunConfiguration if (Comparing.equal(jetConfiguration.getRunClass(), startClassFQName.asString())) { - if (Comparing.equal(location.getModule(), jetConfiguration.getConfigurationModule().getModule())) { - return existingConfiguration; + if (Comparing.equal(location!!.getModule(), jetConfiguration.getConfigurationModule().getModule())) { + return existingConfiguration } } } } - return null; + return null } - @Override - public int compareTo(Object o) { - return PREFERED; + override fun compareTo(o: Any?): Int { + return RuntimeConfigurationProducer.PREFERED } } From 49714d08170fb7b99c9a08ca3d956b425582e1b3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 17:50:22 +0200 Subject: [PATCH 093/450] convert KotlinRunConfigurationProducer to new API, allowing it to coexist with KotlinJUnitRunConfigurationProducer correctly #KT-2604 Fixed --- idea/src/META-INF/plugin.xml | 2 +- .../run/KotlinRunConfigurationProducer.kt | 107 ++++++++---------- 2 files changed, 46 insertions(+), 63 deletions(-) diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index f8090e618c0..75d442a17af 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -391,7 +391,7 @@ - + .clone() as KotlinRunConfigurationProducer +public class KotlinRunConfigurationProducer : RunConfigurationProducer(JetRunConfigurationType.getInstance()) { + + override fun setupConfigurationFromContext(configuration: JetRunConfiguration, + context: ConfigurationContext, + sourceElement: Ref): Boolean { + val location = context.getLocation() ?: return false + val module = context.getModule() ?: return false + val container = getEntryPointContainer(location) + val startClassFQName = getStartClassFqName(container) ?: return false + + setupConfigurationByQName(module, configuration, startClassFQName) + return true } - private var mySourceElement: PsiElement? = null - - override fun getSourceElement(): PsiElement? { - return mySourceElement - } - - override fun createConfigurationByElement(location: Location<*>, configurationContext: ConfigurationContext): RunnerAndConfigurationSettings? { - val container = getEntryPointContainer(location) ?: return null - - mySourceElement = container as PsiElement? - - val startClassFQName = getStartClassFqName(container) - if (startClassFQName == null) return null - - val module = location.getModule() - assert(module != null) - - return createConfigurationByQName(module, configurationContext, startClassFQName) - } - - private fun getStartClassFqName(container: JetDeclarationContainer?): FqName? { - if (container == null) return null - if (container is JetFile) return PackageClassUtils.getPackageClassFqName((container as JetFile?).getPackageFqName()) - if (container is JetClassOrObject) { + private fun getStartClassFqName(container: JetDeclarationContainer?): FqName? = when(container) { + null -> null + is JetFile -> PackageClassUtils.getPackageClassFqName(container.getPackageFqName()) + is JetClassOrObject -> { if (container is JetObjectDeclaration && container.isCompanion()) { - val containerClass = PsiTreeUtil.getParentOfType(container, javaClass()) - return containerClass?.getFqName() + val containerClass = container.getParentOfType(true) + containerClass?.getFqName() + } else { + container.getFqName() } - return container?.getFqName() } - throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement?).getText()) + else -> throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement).getText()) } - private fun getEntryPointContainer(location: Location<*>): JetDeclarationContainer? { + private fun getEntryPointContainer(location: Location<*>?): JetDeclarationContainer? { + if (location == null) return null if (DumbService.getInstance(location.getProject()).isDumb()) return null val module = location.getModule() ?: return null @@ -88,51 +81,41 @@ public class KotlinRunConfigurationProducer : RuntimeConfigurationProducer(JetRu if (!(psiFile is JetFile && ProjectRootsUtil.isInProjectOrLibSource(psiFile))) return null val resolutionFacade = psiFile.getResolutionFacade() - val mainFunctionDetector = MainFunctionDetector(object : NotNullFunction { - override fun `fun`(function: JetNamedFunction): FunctionDescriptor { - return resolutionFacade.resolveToDescriptor(function) as FunctionDescriptor - } - }) + val mainFunctionDetector = MainFunctionDetector { resolutionFacade.resolveToDescriptor(it) as FunctionDescriptor } - var currentElement = PsiTreeUtil.getNonStrictParentOfType(locationElement, javaClass(), javaClass()) as JetDeclarationContainer + var currentElement = locationElement.declarationContainer(false) while (currentElement != null) { var entryPointContainer = currentElement if (entryPointContainer is JetClass) { - entryPointContainer = entryPointContainer.getCompanionObjects().singleOrNull() as JetDeclarationContainer + entryPointContainer = entryPointContainer.getCompanionObjects().singleOrNull() } if (entryPointContainer != null && mainFunctionDetector.hasMain(entryPointContainer.getDeclarations())) return entryPointContainer - currentElement = PsiTreeUtil.getParentOfType(currentElement as PsiElement?, javaClass(), javaClass()) as JetDeclarationContainer + currentElement = (currentElement as PsiElement).declarationContainer(true) } return null } - private fun createConfigurationByQName(module: Module, context: ConfigurationContext, fqName: FqName): RunnerAndConfigurationSettings { - val settings = cloneTemplateConfiguration(module.getProject(), context) - val configuration = settings.getConfiguration() as JetRunConfiguration + private fun PsiElement.declarationContainer(strict: Boolean): JetDeclarationContainer? { + val element = if (strict) + PsiTreeUtil.getParentOfType(this, javaClass(), javaClass()) + else + PsiTreeUtil.getNonStrictParentOfType(this, javaClass(), javaClass()) + return element as JetDeclarationContainer? + } + + private fun setupConfigurationByQName(module: Module, + configuration: JetRunConfiguration, + fqName: FqName) { configuration.setModule(module) configuration.setName(StringUtil.trimEnd(fqName.asString(), "." + PackageClassUtils.getPackageClassName(fqName))) configuration.setRunClass(fqName.asString()) - return settings } - override fun findExistingByElement(location: Location<*>?, existingConfigurations: List, context: ConfigurationContext?): RunnerAndConfigurationSettings? { - val startClassFQName = getStartClassFqName(getEntryPointContainer(location)) ?: return null + override fun isConfigurationFromContext(configuration: JetRunConfiguration, context: ConfigurationContext): Boolean { + val startClassFQName = getStartClassFqName(getEntryPointContainer(context.getLocation())) ?: return false - for (existingConfiguration in existingConfigurations) { - if (existingConfiguration.getType() is JetRunConfigurationType) { - val jetConfiguration = existingConfiguration.getConfiguration() as JetRunConfiguration - if (Comparing.equal(jetConfiguration.getRunClass(), startClassFQName.asString())) { - if (Comparing.equal(location!!.getModule(), jetConfiguration.getConfigurationModule().getModule())) { - return existingConfiguration - } - } - } - } - return null - } - - override fun compareTo(o: Any?): Int { - return RuntimeConfigurationProducer.PREFERED + return configuration.getRunClass() == startClassFQName.asString() && + context.getModule() == configuration.getConfigurationModule().getModule() } } From d29e63e2b8da1646d11d7ab64807938757a5c1fa Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 18:01:41 +0200 Subject: [PATCH 094/450] check type of containing file in getTestClass() --- .../kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt index 015201848b5..e6e387ca2ea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinJUnitRunConfigurationProducer.kt @@ -130,9 +130,10 @@ public class KotlinJUnitRunConfigurationProducer : RunConfigurationProducer(false) if (!jetClass.isJUnitTestClass()) { - jetClass = getTestClassInFile(leaf.getContainingFile() as JetFile) + jetClass = getTestClassInFile(containingFile) } if (jetClass != null) { return LightClassUtil.getPsiClass(jetClass) From 4fbd982059f48be59ffa04048cf9741f8a88ee15 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 18:10:39 +0200 Subject: [PATCH 095/450] fix RunConfiguratioTest: use location.getModule() instead of context.getModule() --- .../jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt index b9c3d1aa168..beee59b38b3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/run/KotlinRunConfigurationProducer.kt @@ -45,7 +45,7 @@ public class KotlinRunConfigurationProducer : RunConfigurationProducer): Boolean { val location = context.getLocation() ?: return false - val module = context.getModule() ?: return false + val module = location.getModule() ?: return false val container = getEntryPointContainer(location) val startClassFQName = getStartClassFqName(container) ?: return false From 247ffdccbe1127cdaa5a954dd87a91455ae1a874 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 2 Jul 2015 19:17:24 +0200 Subject: [PATCH 096/450] updating run configuration on class rename (KT-6731) --- .../kotlin/idea/run/JetRunConfiguration.java | 36 +++++++- .../run/KotlinRunConfigurationProducer.kt | 85 ++++++++++--------- .../run/UpdateOnClassRename/module/src/Foo.kt | 8 ++ .../kotlin/idea/run/RunConfigurationTest.kt | 38 ++++++++- 4 files changed, 124 insertions(+), 43 deletions(-) create mode 100644 idea/testData/run/UpdateOnClassRename/module/src/Foo.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java index 57a41b23f6a..ae2407f1958 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java @@ -36,7 +36,10 @@ import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; +import com.intellij.refactoring.listeners.RefactoringElementAdapter; +import com.intellij.refactoring.listeners.RefactoringElementListener; import kotlin.KotlinPackage; import kotlin.jvm.functions.Function1; import org.jdom.Element; @@ -51,6 +54,7 @@ import org.jetbrains.kotlin.idea.stubindex.JetTopLevelFunctionFqnNameIndex; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.JetDeclaration; +import org.jetbrains.kotlin.psi.JetDeclarationContainer; import org.jetbrains.kotlin.psi.JetNamedFunction; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; @@ -58,7 +62,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import java.util.*; public class JetRunConfiguration extends ModuleBasedConfiguration - implements CommonJavaRunConfigurationParameters { + implements CommonJavaRunConfigurationParameters, RefactoringListenerProvider { public String MAIN_CLASS_NAME; public String VM_PARAMETERS; @@ -218,6 +222,36 @@ public class JetRunConfiguration extends ModuleBasedConfiguration null - is JetFile -> PackageClassUtils.getPackageClassFqName(container.getPackageFqName()) - is JetClassOrObject -> { - if (container is JetObjectDeclaration && container.isCompanion()) { - val containerClass = container.getParentOfType(true) - containerClass?.getFqName() - } else { - container.getFqName() - } - } - else -> throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement).getText()) - } - private fun getEntryPointContainer(location: Location<*>?): JetDeclarationContainer? { if (location == null) return null if (DumbService.getInstance(location.getProject()).isDumb()) return null @@ -77,31 +63,7 @@ public class KotlinRunConfigurationProducer : RunConfigurationProducer(), javaClass()) - else - PsiTreeUtil.getNonStrictParentOfType(this, javaClass(), javaClass()) - return element as JetDeclarationContainer? + return getEntryPointContainer(locationElement) } private fun setupConfigurationByQName(module: Module, @@ -118,4 +80,49 @@ public class KotlinRunConfigurationProducer : RunConfigurationProducer null + is JetFile -> PackageClassUtils.getPackageClassFqName(container.getPackageFqName()) + is JetClassOrObject -> { + if (container is JetObjectDeclaration && container.isCompanion()) { + val containerClass = container.getParentOfType(true) + containerClass?.getFqName() + } else { + container.getFqName() + } + } + else -> throw IllegalArgumentException("Invalid entry-point container: " + (container as PsiElement).getText()) + } + + private fun PsiElement.declarationContainer(strict: Boolean): JetDeclarationContainer? { + val element = if (strict) + PsiTreeUtil.getParentOfType(this, javaClass(), javaClass()) + else + PsiTreeUtil.getNonStrictParentOfType(this, javaClass(), javaClass()) + return element as JetDeclarationContainer? + } + + } } diff --git a/idea/testData/run/UpdateOnClassRename/module/src/Foo.kt b/idea/testData/run/UpdateOnClassRename/module/src/Foo.kt new file mode 100644 index 00000000000..80d6fcfffb5 --- /dev/null +++ b/idea/testData/run/UpdateOnClassRename/module/src/Foo.kt @@ -0,0 +1,8 @@ +package renameTest + +import kotlin.platform.platformStatic + +object Foo { + platformStatic fun main(args: Array) { + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt index a56fa702f2c..4cf597846c3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt @@ -20,6 +20,7 @@ import com.intellij.codeInsight.CodeInsightTestCase import com.intellij.execution.Executor import com.intellij.execution.Location import com.intellij.execution.PsiLocation +import com.intellij.execution.RunManagerEx import com.intellij.execution.actions.ConfigurationContext import com.intellij.execution.configurations.JavaCommandLine import com.intellij.execution.configurations.JavaParameters @@ -34,17 +35,21 @@ import com.intellij.openapi.roots.ModuleRootModificationUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiComment import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.PsiElement import com.intellij.psi.PsiManager +import com.intellij.refactoring.RefactoringFactory import com.intellij.testFramework.MapDataContext import com.intellij.testFramework.PlatformTestCase import com.intellij.testFramework.PsiTestUtil import org.jetbrains.kotlin.idea.search.allScope +import org.jetbrains.kotlin.idea.stubindex.JetFullClassNameIndex import org.jetbrains.kotlin.idea.stubindex.JetTopLevelFunctionFqnNameIndex import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil.configureKotlinJsRuntimeAndSdk import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil.configureKotlinRuntimeAndSdk import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.util.application.runWriteAction +import org.jetbrains.kotlin.psi.JetFunction import org.jetbrains.kotlin.psi.JetNamedDeclaration import org.jetbrains.kotlin.psi.JetTreeVisitorVoid import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -98,6 +103,19 @@ class RunConfigurationTest: CodeInsightTestCase() { doTest(ConfigLibraryUtil::configureKotlinJsRuntimeAndSdk) } + fun testUpdateOnClassRename() { + val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!) + ConfigLibraryUtil.configureKotlinRuntimeAndSdk(createModuleResult.module, PluginTestCaseBase.mockJdk()) + + val runConfiguration = createConfigurationFromObject("renameTest.Foo", save = true) + + val obj = JetFullClassNameIndex.getInstance().get("renameTest.Foo", getTestProject(), getTestProject().allScope()).single() + val rename = RefactoringFactory.getInstance(getTestProject()).createRename(obj, "Bar") + rename.run() + + Assert.assertEquals("renameTest.Bar", runConfiguration.MAIN_CLASS_NAME) + } + private fun doTest(configureRuntime: (Module, Sdk) -> Unit) { val baseDir = getTestProject().getBaseDir()!! val createModuleResult = configureModule(moduleDirPath("module"), baseDir) @@ -140,10 +158,24 @@ class RunConfigurationTest: CodeInsightTestCase() { private fun createConfigurationFromMain(mainFqn: String): JetRunConfiguration { val mainFunction = JetTopLevelFunctionFqnNameIndex.getInstance().get(mainFqn, getTestProject(), getTestProject().allScope()).first() - val dataContext = MapDataContext() - dataContext.put(Location.DATA_KEY, PsiLocation(getTestProject(), mainFunction)) + return createConfigurationFromElement(mainFunction) + } - return ConfigurationContext.getFromContext(dataContext)!!.getConfiguration()!!.getConfiguration() as JetRunConfiguration + private fun createConfigurationFromObject(objectFqn: String, save: Boolean = false): JetRunConfiguration { + val obj = JetFullClassNameIndex.getInstance().get(objectFqn, getTestProject(), getTestProject().allScope()).single() + val mainFunction = obj.getDeclarations().single { it is JetFunction && it.getName() == "main" } + return createConfigurationFromElement(mainFunction, save) + } + + private fun createConfigurationFromElement(element: PsiElement?, save: Boolean = false): JetRunConfiguration { + val dataContext = MapDataContext() + dataContext.put(Location.DATA_KEY, PsiLocation(getTestProject(), element)) + + val runnerAndConfigurationSettings = ConfigurationContext.getFromContext(dataContext)!!.getConfiguration() + if (save) { + RunManagerEx.getInstanceEx(myProject).setTemporaryConfiguration(runnerAndConfigurationSettings) + } + return runnerAndConfigurationSettings!!.getConfiguration() as JetRunConfiguration } private fun configureModule(moduleDir: String, outputParentDir: VirtualFile, configModule: Module = getModule()): CreateModuleResult { From 9cfc6b39053b08a2dfcbd77517e4f899c8eb4054 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 3 Jul 2015 18:05:13 +0200 Subject: [PATCH 097/450] correctly update name of run configuration on class rename --- .../jetbrains/kotlin/idea/run/JetRunConfiguration.java | 10 ++++++++++ .../kotlin/idea/run/KotlinRunConfigurationProducer.kt | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java index ae2407f1958..d0ad98c1b96 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java @@ -34,6 +34,7 @@ import com.intellij.openapi.roots.*; import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; @@ -51,6 +52,7 @@ import org.jetbrains.kotlin.asJava.KotlinLightMethod; import org.jetbrains.kotlin.idea.MainFunctionDetector; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.stubindex.JetTopLevelFunctionFqnNameIndex; +import org.jetbrains.kotlin.load.kotlin.PackageClassUtils; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.JetDeclaration; @@ -252,6 +254,14 @@ public class JetRunConfiguration extends ModuleBasedConfiguration Date: Fri, 3 Jul 2015 18:38:39 +0200 Subject: [PATCH 098/450] validate more run configuration attributes; use correct CommandLineState base class to allow shutdown hooks to work (KT-7489) #KT-7489 Fixed --- .../kotlin/idea/run/JetRunConfiguration.java | 100 ++++++++++-------- 1 file changed, 58 insertions(+), 42 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java index d0ad98c1b96..c6599b07b0b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.run; import com.intellij.diagnostic.logging.LogConfigurationPanel; import com.intellij.execution.*; +import com.intellij.execution.application.BaseJavaApplicationCommandLineState; import com.intellij.execution.configuration.EnvironmentVariablesComponent; import com.intellij.execution.configurations.*; import com.intellij.execution.filters.TextConsoleBuilderFactory; @@ -214,6 +215,24 @@ public class JetRunConfiguration extends ModuleBasedConfiguration getMainFunCandidates(@NotNull Module module, @NotNull PsiClass psiClass) { + if (psiClass instanceof KotlinLightClassForPackage) { + String qualifiedName = psiClass.getQualifiedName(); + if (qualifiedName == null) return Collections.emptyList(); + FqName mainFunFqName = new FqName(qualifiedName).parent().child(Name.identifier("main")); + return JetTopLevelFunctionFqnNameIndex.getInstance().get( + mainFunFqName.asString(), module.getProject(), module.getModuleRuntimeScope(true) + ); + } + return KotlinPackage.filterNotNull( + KotlinPackage.map( + psiClass.findMethodsByName("main", false), + new Function1() { + @Override + public JetNamedFunction invoke(PsiMethod method) { + if (!(method instanceof KotlinLightMethod)) return null; - private final JetRunConfiguration myConfiguration; + JetDeclaration declaration = ((KotlinLightMethod) method).getOrigin(); + return declaration instanceof JetNamedFunction ? (JetNamedFunction) declaration : null; + } + } + ) + ); + } + @Nullable + private static JetNamedFunction findMainFun(@NotNull Module module, @NotNull PsiClass psiClass) throws CantRunException { + for (JetNamedFunction function : getMainFunCandidates(module, psiClass)) { + BindingContext bindingContext = ResolvePackage.analyze(function, BodyResolveMode.FULL); + MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext); + if (mainFunctionDetector.isMain(function)) return function; + } + return null; + } + + private static class MyJavaCommandLineState extends BaseJavaApplicationCommandLineState { public MyJavaCommandLineState(@NotNull JetRunConfiguration configuration, ExecutionEnvironment environment) { - super(environment); - myConfiguration = configuration; + super(environment, configuration); } @Override @@ -297,7 +349,7 @@ public class JetRunConfiguration extends ModuleBasedConfiguration getMainFunCandidates(@NotNull Module module, @NotNull PsiClass psiClass) { - if (psiClass instanceof KotlinLightClassForPackage) { - String qualifiedName = psiClass.getQualifiedName(); - if (qualifiedName == null) return Collections.emptyList(); - FqName mainFunFqName = new FqName(qualifiedName).parent().child(Name.identifier("main")); - return JetTopLevelFunctionFqnNameIndex.getInstance().get( - mainFunFqName.asString(), module.getProject(), module.getModuleRuntimeScope(true) - ); - } - return KotlinPackage.filterNotNull( - KotlinPackage.map( - psiClass.findMethodsByName("main", false), - new Function1() { - @Override - public JetNamedFunction invoke(PsiMethod method) { - if (!(method instanceof KotlinLightMethod)) return null; - - JetDeclaration declaration = ((KotlinLightMethod) method).getOrigin(); - return declaration instanceof JetNamedFunction ? (JetNamedFunction) declaration : null; - } - } - ) - ); - } - - @Nullable - private JetNamedFunction findMainFun(@NotNull Module module, @NotNull PsiClass psiClass) throws CantRunException { - for (JetNamedFunction function : getMainFunCandidates(module, psiClass)) { - BindingContext bindingContext = ResolvePackage.analyze(function, BodyResolveMode.FULL); - MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(bindingContext); - if (mainFunctionDetector.isMain(function)) return function; - } - return null; - } } } From 79602163a3e6dde86d388f99052df0af60172399 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 3 Jul 2015 19:30:38 +0200 Subject: [PATCH 099/450] update run configuration on package rename --- .../kotlin/idea/run/JetRunConfiguration.java | 32 +++++++++++++++++-- .../module/src/renameTest/Foo.kt | 8 +++++ .../kotlin/idea/run/RunConfigurationTest.kt | 18 ++++++++--- 3 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 idea/testData/run/UpdateOnPackageRename/module/src/renameTest/Foo.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java index c6599b07b0b..bcec8cd6725 100644 --- a/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java +++ b/idea/src/org/jetbrains/kotlin/idea/run/JetRunConfiguration.java @@ -40,6 +40,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiPackage; import com.intellij.refactoring.listeners.RefactoringElementAdapter; import com.intellij.refactoring.listeners.RefactoringElementListener; import kotlin.KotlinPackage; @@ -246,9 +247,16 @@ public class JetRunConfiguration extends ModuleBasedConfiguration) { + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt index 4cf597846c3..506285369f9 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/run/RunConfigurationTest.kt @@ -33,10 +33,7 @@ import com.intellij.openapi.module.Module import com.intellij.openapi.projectRoots.Sdk import com.intellij.openapi.roots.ModuleRootModificationUtil import com.intellij.openapi.vfs.VirtualFile -import com.intellij.psi.PsiComment -import com.intellij.psi.PsiDocumentManager -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiManager +import com.intellij.psi.* import com.intellij.refactoring.RefactoringFactory import com.intellij.testFramework.MapDataContext import com.intellij.testFramework.PlatformTestCase @@ -116,6 +113,19 @@ class RunConfigurationTest: CodeInsightTestCase() { Assert.assertEquals("renameTest.Bar", runConfiguration.MAIN_CLASS_NAME) } + fun testUpdateOnPackageRename() { + val createModuleResult = configureModule(moduleDirPath("module"), getTestProject().getBaseDir()!!) + ConfigLibraryUtil.configureKotlinRuntimeAndSdk(createModuleResult.module, PluginTestCaseBase.mockJdk()) + + val runConfiguration = createConfigurationFromObject("renameTest.Foo", save = true) + + val pkg = JavaPsiFacade.getInstance(getTestProject()).findPackage("renameTest") + val rename = RefactoringFactory.getInstance(getTestProject()).createRename(pkg, "afterRenameTest") + rename.run() + + Assert.assertEquals("afterRenameTest.Foo", runConfiguration.MAIN_CLASS_NAME) + } + private fun doTest(configureRuntime: (Module, Sdk) -> Unit) { val baseDir = getTestProject().getBaseDir()!! val createModuleResult = configureModule(moduleDirPath("module"), baseDir) From 30ec88129ccbbd76f6f3e9986a8b5cee84ebc5ef Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 7 Jul 2015 16:10:45 +0300 Subject: [PATCH 100/450] Clarify docs for capitalize and decapitalize methods. --- libraries/stdlib/src/kotlin/text/StringsJVM.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index a990d99b124..e9952c366b3 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -455,8 +455,8 @@ public val String.reader: StringReader get() = StringReader(this) /** - * Returns a copy of this string capitalised if it is not empty or already starting with an upper case letter, - * otherwise returns this. + * Returns a copy of this string having its first letter uppercased, or the original string, + * if it's empty or already starts with an upper case letter. * * @sample test.text.StringTest.capitalize */ @@ -465,8 +465,8 @@ public fun String.capitalize(): String { } /** - * Returns a copy of this string with the first letter lowercased if it is not empty or already starting with - * a lower case letter, otherwise returns this. + * Returns a copy of this string having its first letter lowercased, or the original string, + * if it's empty or already starts with a lower case letter. * * @sample test.text.StringTest.decapitalize */ From 2a0817a4d14e87ffd4bdcf3879c4e92ad08b4d57 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Fri, 20 Feb 2015 21:34:01 +0300 Subject: [PATCH 101/450] Minor. Added word to dictionary. --- .idea/dictionaries/geevee.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.idea/dictionaries/geevee.xml b/.idea/dictionaries/geevee.xml index 7891ab0ccaa..c83493eb226 100644 --- a/.idea/dictionaries/geevee.xml +++ b/.idea/dictionaries/geevee.xml @@ -2,6 +2,7 @@ builtins + callables klass proto protoc From 5c56bc455eb7e3511733ace379c4a07d8724e5ad Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Mon, 6 Jul 2015 23:01:57 +0300 Subject: [PATCH 102/450] Supported excluded packages/classes in auto-import quick fix. #KT-2413 in progress --- .../kotlin/idea/core/KotlinIndicesHelper.kt | 8 +++++++ .../kotlin/idea/quickfix/AutoImportFix.kt | 4 +++- ...tsForClassInExcludedPackage.before.Main.kt | 6 +++++ ...assInExcludedPackage.before.data.Sample.kt | 3 +++ .../noImportsForExcludedClass.before.Main.kt | 6 +++++ ...ortsForExcludedClass.before.data.Sample.kt | 3 +++ ...orFunctionInExcludedPackage.before.Main.kt | 5 ++++ ...ionInExcludedPackage.before.data.Sample.kt | 5 ++++ .../autoImports/notExcludedClass.after.kt | 6 +++++ .../notExcludedClass.before.Main.kt | 4 ++++ .../notExcludedClass.before.data.Sample.kt | 3 +++ .../AbstractQuickFixMultiFileTest.java | 13 ++++++++++ .../QuickFixMultiFileTestGenerated.java | 24 +++++++++++++++++++ 13 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.Main.kt create mode 100644 idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.data.Sample.kt create mode 100644 idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.Main.kt create mode 100644 idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.data.Sample.kt create mode 100644 idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.Main.kt create mode 100644 idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.data.Sample.kt create mode 100644 idea/testData/quickfix/autoImports/notExcludedClass.after.kt create mode 100644 idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt create mode 100644 idea/testData/quickfix/autoImports/notExcludedClass.before.data.Sample.kt diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt index f66331389cd..0dba554ed58 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.core +import com.intellij.codeInsight.CodeInsightSettings import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.stubs.StringStubIndexExtension @@ -198,3 +199,10 @@ public class KotlinIndicesHelper( .filter { it.getExtensionReceiverParameter() == null } } } + +public fun isInExcludedPackage(descriptor: DeclarationDescriptor): Boolean { + val fqName = DescriptorUtils.getFqName(descriptor).asString() + + return CodeInsightSettings.getInstance().EXCLUDED_PACKAGES + .any { excluded -> fqName == excluded || fqName.startsWith(excluded + ".") } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt index d9ae0e1215a..e19b1d325f9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt @@ -48,6 +48,8 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.CachedValueProperty import java.util.ArrayList +import com.intellij.codeInsight.* +import org.jetbrains.kotlin.idea.core.isInExcludedPackage /** * Check possibility and perform fix for unresolved references. @@ -152,7 +154,7 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction !isInExcludedPackage(it) } } private fun getClasses(name: String, file: JetFile, searchScope: GlobalSearchScope): Collection diff --git a/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.Main.kt b/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.Main.kt new file mode 100644 index 00000000000..92f2354e6c0 --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.Main.kt @@ -0,0 +1,6 @@ +// "class com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase" "false" +// ACTION: Create class 'SomeClass' +// ACTION: Create function 'SomeClass' +// ERROR: Unresolved reference: SomeClass + +val x = SomeClass() \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.data.Sample.kt b/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.data.Sample.kt new file mode 100644 index 00000000000..00f79598da5 --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.data.Sample.kt @@ -0,0 +1,3 @@ +package excludedPackage + +class SomeClass \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.Main.kt b/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.Main.kt new file mode 100644 index 00000000000..1f3fc10ef1e --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.Main.kt @@ -0,0 +1,6 @@ +// "class com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase" "false" +// ACTION: Create class 'ExcludedClass' +// ACTION: Create function 'ExcludedClass' +// ERROR: Unresolved reference: ExcludedClass + +val x = ExcludedClass() \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.data.Sample.kt b/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.data.Sample.kt new file mode 100644 index 00000000000..59299eb163c --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.data.Sample.kt @@ -0,0 +1,3 @@ +package somePackage + +class ExcludedClass \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.Main.kt b/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.Main.kt new file mode 100644 index 00000000000..081b55d7691 --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.Main.kt @@ -0,0 +1,5 @@ +// "class com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase" "false" +// ACTION: Create function 'someFunction' +// ERROR: Unresolved reference: someFunction + +val x = someFunction() \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.data.Sample.kt b/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.data.Sample.kt new file mode 100644 index 00000000000..c6bd1606f7f --- /dev/null +++ b/idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.data.Sample.kt @@ -0,0 +1,5 @@ +package excludedPackage + +fun someFunction() { + +} \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/notExcludedClass.after.kt b/idea/testData/quickfix/autoImports/notExcludedClass.after.kt new file mode 100644 index 00000000000..b34d2bb4756 --- /dev/null +++ b/idea/testData/quickfix/autoImports/notExcludedClass.after.kt @@ -0,0 +1,6 @@ +import somePackage.NotExcludedClass + +// "Import" "true" +// ERROR: Unresolved reference: NotExcludedClass + +val x = NotExcludedClass() \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt b/idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt new file mode 100644 index 00000000000..860bc03f0cf --- /dev/null +++ b/idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt @@ -0,0 +1,4 @@ +// "Import" "true" +// ERROR: Unresolved reference: NotExcludedClass + +val x = NotExcludedClass() \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/notExcludedClass.before.data.Sample.kt b/idea/testData/quickfix/autoImports/notExcludedClass.before.data.Sample.kt new file mode 100644 index 00000000000..55afe2de2a1 --- /dev/null +++ b/idea/testData/quickfix/autoImports/notExcludedClass.before.data.Sample.kt @@ -0,0 +1,3 @@ +package somePackage + +class NotExcludedClass \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.java index 694977bce05..ca35d7439d4 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.quickfix; +import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; import com.intellij.codeInsight.intention.IntentionAction; @@ -67,6 +68,18 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer doTest(beforeFileName, true); } + @Override + protected void setUp() throws Exception { + super.setUp(); + CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = new String[]{"excludedPackage", "somePackage.ExcludedClass"}; + } + + @Override + protected void tearDown() throws Exception { + CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = ArrayUtil.EMPTY_STRING_ARRAY; + super.tearDown(); + } + private void doTest(final String beforeFileName, boolean withExtraFile) throws Exception { String testDataPath = getTestDataPath(); File mainFile = new File(testDataPath + beforeFileName); diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index 8ea878b8edd..638f8cd5a74 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -185,6 +185,30 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes doTestWithExtraFile(fileName); } + @TestMetadata("noImportsForClassInExcludedPackage.before.Main.kt") + public void testNoImportsForClassInExcludedPackage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noImportsForClassInExcludedPackage.before.Main.kt"); + doTestWithExtraFile(fileName); + } + + @TestMetadata("noImportsForExcludedClass.before.Main.kt") + public void testNoImportsForExcludedClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noImportsForExcludedClass.before.Main.kt"); + doTestWithExtraFile(fileName); + } + + @TestMetadata("noImportsForFunctionInExcludedPackage.before.Main.kt") + public void testNoImportsForFunctionInExcludedPackage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/noImportsForFunctionInExcludedPackage.before.Main.kt"); + doTestWithExtraFile(fileName); + } + + @TestMetadata("notExcludedClass.before.Main.kt") + public void testNotExcludedClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/notExcludedClass.before.Main.kt"); + doTestWithExtraFile(fileName); + } + @TestMetadata("objectImport.before.Main.kt") public void testObjectImport() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/autoImports/objectImport.before.Main.kt"); From 0451debda4eed2297dda6a2973071f0231bbd667 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Mon, 6 Jul 2015 23:27:46 +0300 Subject: [PATCH 103/450] Supported excluded packages/classes in completion. #KT-2413 in progress --- .../idea/completion/AllClassesCompletion.kt | 9 +++++-- .../idea/completion/CompletionSession.kt | 14 +++++------ .../CallablesInExcludedPackage.dependency1.kt | 6 +++++ .../CallablesInExcludedPackage.dependency2.kt | 6 +++++ .../CallablesInExcludedPackage.kt | 5 ++++ .../ClassInExcludedPackage.dependency1.kt | 3 +++ .../ClassInExcludedPackage.dependency2.kt | 3 +++ .../ClassInExcludedPackage.kt | 5 ++++ .../ExcludedClass/ExcludedClass.dependency.kt | 5 ++++ .../multifile/ExcludedClass/ExcludedClass.kt | 4 ++++ .../ExcludedJavaClass/ExcludedJavaClass.kt | 4 ++++ .../somePackage/ExcludedClass.java | 5 ++++ .../somePackage/ExtraClass.java | 5 ++++ .../CallablesInExcludedPackage.dependency1.kt | 6 +++++ .../CallablesInExcludedPackage.dependency2.kt | 6 +++++ .../CallablesInExcludedPackage.kt | 6 +++++ .../test/KotlinCompletionTestCase.java | 4 ++++ ...tiFileJvmBasicCompletionTestGenerated.java | 24 +++++++++++++++++++ ...MultiFileSmartCompletionTestGenerated.java | 6 +++++ 19 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt create mode 100644 idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt create mode 100644 idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency1.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency2.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.dependency.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/ExcludedJavaClass.kt create mode 100644 idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExcludedClass.java create mode 100644 idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExtraClass.java create mode 100644 idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt create mode 100644 idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt create mode 100644 idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt index e85703308ea..eb38be9e9d4 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper +import org.jetbrains.kotlin.idea.core.isInExcludedPackage import org.jetbrains.kotlin.idea.project.ProjectStructureUtil import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.psi.JetFile @@ -40,10 +41,14 @@ class AllClassesCompletion(private val parameters: CompletionParameters, fun collect(classDescriptorCollector: (ClassDescriptor) -> Unit, javaClassCollector: (PsiClass) -> Unit) { //TODO: this is a temporary hack until we have built-ins in indices val builtIns = JavaToKotlinClassMap.INSTANCE.allKotlinClasses() - val filteredBuiltIns = builtIns.filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) } + val filteredBuiltIns = builtIns + .filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) && !isInExcludedPackage(it) } filteredBuiltIns.forEach { classDescriptorCollector(it) } - kotlinIndicesHelper.getClassDescriptors({ prefixMatcher.prefixMatches(it) }, kindFilter).forEach { classDescriptorCollector(it) } + kotlinIndicesHelper + .getClassDescriptors({ prefixMatcher.prefixMatches(it) }, kindFilter) + .filter { !isInExcludedPackage(it) } + .forEach { classDescriptorCollector(it) } if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) { addAdaptedJavaCompletion(javaClassCollector) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 445a2f6d240..0536e5f1642 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -37,10 +37,7 @@ import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper import org.jetbrains.kotlin.idea.completion.smart.LambdaItems import org.jetbrains.kotlin.idea.completion.smart.SmartCompletion -import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper -import org.jetbrains.kotlin.idea.core.comparePossiblyOverridingDescriptors -import org.jetbrains.kotlin.idea.core.getResolutionScope -import org.jetbrains.kotlin.idea.core.isVisible +import org.jetbrains.kotlin.idea.core.* import org.jetbrains.kotlin.idea.references.JetSimpleNameReference import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter @@ -250,16 +247,17 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected fun getTopLevelCallables(): Collection { val descriptors = indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) }) - return filterShadowedNonImported(descriptors, reference!!) + return filterShadowedNonImportedAndExcluded(descriptors, reference!!) } protected fun getTopLevelExtensions(): Collection { val descriptors = indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression, bindingContext) - return filterShadowedNonImported(descriptors, reference) + return filterShadowedNonImportedAndExcluded(descriptors, reference) } - private fun filterShadowedNonImported(descriptors: Collection, reference: JetSimpleNameReference): Collection { - return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(descriptors, referenceVariants, reference.expression) + private fun filterShadowedNonImportedAndExcluded(descriptors: Collection, reference: JetSimpleNameReference): Collection { + val notExcluded = descriptors.filter { !isInExcludedPackage(it) } + return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(notExcluded, referenceVariants, reference.expression) } protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) { diff --git a/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt new file mode 100644 index 00000000000..76bd2d486f0 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt @@ -0,0 +1,6 @@ +package excludedPackage + +fun someFunction() { +} + +val someProperty: Int = 5 \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt new file mode 100644 index 00000000000..9729ec11a82 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt @@ -0,0 +1,6 @@ +package notExcludedPackage + +fun someOtherFunction() { +} + +val someOtherProperty: Int = 5 \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt new file mode 100644 index 00000000000..9c3bf15ce5f --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt @@ -0,0 +1,5 @@ +val x = some + +// NUMBER: 2 +// ABSENT: someFunction, someProperty +// EXIST: someOtherFunction, someOtherProperty \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency1.kt b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency1.kt new file mode 100644 index 00000000000..00f79598da5 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency1.kt @@ -0,0 +1,3 @@ +package excludedPackage + +class SomeClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency2.kt b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency2.kt new file mode 100644 index 00000000000..d578d706eb3 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.dependency2.kt @@ -0,0 +1,3 @@ +package notExcludedPackage + +class SomeOtherClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.kt b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.kt new file mode 100644 index 00000000000..5baec3ae0c8 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/ClassInExcludedPackage.kt @@ -0,0 +1,5 @@ +val x = Some + +// NUMBER: 1 +// ABSENT: SomeClass +// EXIST: SomeOtherClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.dependency.kt b/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.dependency.kt new file mode 100644 index 00000000000..4983cec7adf --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.dependency.kt @@ -0,0 +1,5 @@ +package somePackage + +class ExcludedClass + +class ExtraClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.kt b/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.kt new file mode 100644 index 00000000000..f342359fe2d --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExcludedClass/ExcludedClass.kt @@ -0,0 +1,4 @@ +val x = Ex + +// ABSENT: ExcludedClass +// EXIST: ExtraClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/ExcludedJavaClass.kt b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/ExcludedJavaClass.kt new file mode 100644 index 00000000000..f342359fe2d --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/ExcludedJavaClass.kt @@ -0,0 +1,4 @@ +val x = Ex + +// ABSENT: ExcludedClass +// EXIST: ExtraClass \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExcludedClass.java b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExcludedClass.java new file mode 100644 index 00000000000..a3272a3f71f --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExcludedClass.java @@ -0,0 +1,5 @@ +package somePackage; + +public class ExcludedClass { + +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExtraClass.java b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExtraClass.java new file mode 100644 index 00000000000..8e27c9baf5d --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/somePackage/ExtraClass.java @@ -0,0 +1,5 @@ +package somePackage; + +public class ExtraClass { + +} \ No newline at end of file diff --git a/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt new file mode 100644 index 00000000000..49700a0c597 --- /dev/null +++ b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency1.kt @@ -0,0 +1,6 @@ +package excludedPackage + +fun someFunction(): Int { +} + +val someProperty: Int = 5 \ No newline at end of file diff --git a/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt new file mode 100644 index 00000000000..d1f7be0696e --- /dev/null +++ b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.dependency2.kt @@ -0,0 +1,6 @@ +package notExcludedPackage + +fun someOtherFunction(): Int { +} + +val someOtherProperty: Int = 5 \ No newline at end of file diff --git a/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt new file mode 100644 index 00000000000..4df799939b6 --- /dev/null +++ b/idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/CallablesInExcludedPackage.kt @@ -0,0 +1,6 @@ +val x: Int = some + +// INVOCATION_COUNT: 2 +// NUMBER: 2 +// ABSENT: someFunction, someProperty +// EXIST: someOtherFunction, someOtherProperty \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java index bc050dda1d3..97f1ca6afb4 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/KotlinCompletionTestCase.java @@ -16,8 +16,10 @@ package org.jetbrains.kotlin.idea.completion.test; +import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.completion.CompletionTestCase; import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess; +import com.intellij.util.ArrayUtil; import org.jetbrains.kotlin.test.JetTestUtils; abstract public class KotlinCompletionTestCase extends CompletionTestCase { @@ -25,10 +27,12 @@ abstract public class KotlinCompletionTestCase extends CompletionTestCase { protected void setUp() throws Exception { super.setUp(); VfsRootAccess.allowRootAccess(JetTestUtils.getHomeDirectory()); + CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = new String[]{"excludedPackage", "somePackage.ExcludedClass"}; } @Override protected void tearDown() throws Exception { + CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = ArrayUtil.EMPTY_STRING_ARRAY; VfsRootAccess.disallowRootAccess(JetTestUtils.getHomeDirectory()); super.tearDown(); } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index a4427324377..5712c7300b2 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -35,6 +35,18 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/multifile"), Pattern.compile("^([^\\.]+)$"), false); } + @TestMetadata("CallablesInExcludedPackage") + public void testCallablesInExcludedPackage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/CallablesInExcludedPackage/"); + doTest(fileName); + } + + @TestMetadata("ClassInExcludedPackage") + public void testClassInExcludedPackage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ClassInExcludedPackage/"); + doTest(fileName); + } + @TestMetadata("CompleteFunctionWithNoSpecifiedType") public void testCompleteFunctionWithNoSpecifiedType() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/CompleteFunctionWithNoSpecifiedType/"); @@ -65,6 +77,18 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("ExcludedClass") + public void testExcludedClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExcludedClass/"); + doTest(fileName); + } + + @TestMetadata("ExcludedJavaClass") + public void testExcludedJavaClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExcludedJavaClass/"); + doTest(fileName); + } + @TestMetadata("ExtensionFunction") public void testExtensionFunction() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/ExtensionFunction/"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileSmartCompletionTestGenerated.java index 44a8e4b6f6c..7caa52e3573 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileSmartCompletionTestGenerated.java @@ -41,6 +41,12 @@ public class MultiFileSmartCompletionTestGenerated extends AbstractMultiFileSmar doTest(fileName); } + @TestMetadata("CallablesInExcludedPackage") + public void testCallablesInExcludedPackage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smartMultiFile/CallablesInExcludedPackage/"); + doTest(fileName); + } + @TestMetadata("FunctionFromAnotherPackage") public void testFunctionFromAnotherPackage() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/smartMultiFile/FunctionFromAnotherPackage/"); From b98aa76325514c6e90f3cf7c4c91a20c105c6abe Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 7 Jul 2015 13:53:01 +0300 Subject: [PATCH 104/450] Added completion action to exclude classes/packages. #KT-2413 fixed --- ...cludeFromCompletionLookupActionProvider.kt | 68 +++++++++++++++++++ idea/src/META-INF/plugin.xml | 1 + 2 files changed, 69 insertions(+) create mode 100644 idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt new file mode 100644 index 00000000000..657d949850b --- /dev/null +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.kotlin.idea.completion + +import com.intellij.codeInsight.completion.ExcludeFromCompletionLookupActionProvider +import com.intellij.codeInsight.daemon.impl.actions.AddImportAction +import com.intellij.codeInsight.lookup.Lookup +import com.intellij.codeInsight.lookup.LookupActionProvider +import com.intellij.codeInsight.lookup.LookupElement +import com.intellij.codeInsight.lookup.LookupElementAction +import com.intellij.openapi.project.Project +import com.intellij.psi.* +import com.intellij.psi.util.PsiUtil +import com.intellij.util.Consumer +import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject +import org.jetbrains.kotlin.idea.imports.importableFqName +import org.jetbrains.kotlin.name.FqName + +public class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvider { + override fun fillActions(element: LookupElement, lookup: Lookup, consumer: Consumer) { + val lookupObject = element.getObject() as? DeclarationLookupObject ?: return + + lookupObject.descriptor?.let { + it.importableFqName?.let { + addExcludes(consumer, lookup.getPsiFile().getProject(), it) + return + } + } + + lookupObject.psiElement?.let { + val fakeLookupElement = object : LookupElement() { + override fun getLookupString() = "" + override fun getObject() = it + } + + ExcludeFromCompletionLookupActionProvider().fillActions(fakeLookupElement, lookup, consumer) + } + } + + private fun addExcludes(consumer: Consumer, project: Project, fqName: FqName) { + for (s in AddImportAction.getAllExcludableStrings(fqName.asString())) { + consumer.consume(ExcludeFromCompletionAction(project, s)) + } + } + + private class ExcludeFromCompletionAction( + private val project: Project, + private val exclude: String + ) : LookupElementAction(null, "Exclude '$exclude' from completion") { + override fun performLookupAction(): LookupElementAction.Result { + AddImportAction.excludeFromImport(project, exclude) + return LookupElementAction.Result.HIDE_LOOKUP + } + } +} diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 75d442a17af..9c6af2334ef 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -322,6 +322,7 @@ + From 0d5dbdfa0ca6aeb07a11dbbb7ff9eddb73ddaf24 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 7 Jul 2015 13:53:01 +0300 Subject: [PATCH 105/450] Added completion action to exclude classes/packages. #KT-2413 fixed --- ...cludeFromCompletionLookupActionProvider.kt | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt index 657d949850b..2277782fa35 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt @@ -33,25 +33,22 @@ public class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvi override fun fillActions(element: LookupElement, lookup: Lookup, consumer: Consumer) { val lookupObject = element.getObject() as? DeclarationLookupObject ?: return - lookupObject.descriptor?.let { - it.importableFqName?.let { - addExcludes(consumer, lookup.getPsiFile().getProject(), it) - return - } + val project = lookup.getPsiFile().getProject() + + lookupObject.descriptor?.importableFqName?.let { + addExcludes(consumer, project, it.asString()) + return } - lookupObject.psiElement?.let { - val fakeLookupElement = object : LookupElement() { - override fun getLookupString() = "" - override fun getObject() = it - } - - ExcludeFromCompletionLookupActionProvider().fillActions(fakeLookupElement, lookup, consumer) + val psiElement = lookupObject.psiElement + if (psiElement is PsiClass) { + val qualifiedName = psiElement.getQualifiedName() ?: return + addExcludes(consumer, project, qualifiedName) } } - private fun addExcludes(consumer: Consumer, project: Project, fqName: FqName) { - for (s in AddImportAction.getAllExcludableStrings(fqName.asString())) { + private fun addExcludes(consumer: Consumer, project: Project, fqName: String) { + for (s in AddImportAction.getAllExcludableStrings(fqName)) { consumer.consume(ExcludeFromCompletionAction(project, s)) } } From 60a3ab548cc52347e307d6207d75d3e6bf602c6a Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Tue, 7 Jul 2015 19:12:41 +0300 Subject: [PATCH 106/450] Moved filtering of excluded symbols to KotlinIndicesHelper --- .../idea/completion/AllClassesCompletion.kt | 6 +-- .../idea/completion/CompletionSession.kt | 11 +++-- .../kotlin/idea/core/KotlinIndicesHelper.kt | 42 +++++++++++++------ .../kotlin/idea/quickfix/AutoImportFix.kt | 21 ++-------- 4 files changed, 41 insertions(+), 39 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt index eb38be9e9d4..8bc74b494db 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper -import org.jetbrains.kotlin.idea.core.isInExcludedPackage import org.jetbrains.kotlin.idea.project.ProjectStructureUtil import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.psi.JetFile @@ -42,12 +41,11 @@ class AllClassesCompletion(private val parameters: CompletionParameters, //TODO: this is a temporary hack until we have built-ins in indices val builtIns = JavaToKotlinClassMap.INSTANCE.allKotlinClasses() val filteredBuiltIns = builtIns - .filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) && !isInExcludedPackage(it) } + .filter { kindFilter(it.getKind()) && prefixMatcher.prefixMatches(it.getName().asString()) } filteredBuiltIns.forEach { classDescriptorCollector(it) } kotlinIndicesHelper - .getClassDescriptors({ prefixMatcher.prefixMatches(it) }, kindFilter) - .filter { !isInExcludedPackage(it) } + .getKotlinClasses({ prefixMatcher.prefixMatches(it) }, kindFilter) .forEach { classDescriptorCollector(it) } if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 0536e5f1642..a4051bab04b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -165,7 +165,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } protected val indicesHelper: KotlinIndicesHelper - get() = KotlinIndicesHelper(project, resolutionFacade, searchScope, moduleDescriptor, isVisibleFilter) + get() = KotlinIndicesHelper(project, resolutionFacade, searchScope, moduleDescriptor, isVisibleFilter, true) protected fun isVisibleDescriptor(descriptor: DeclarationDescriptor): Boolean { if (descriptor is TypeParameterDescriptor && !isTypeParameterVisible(descriptor)) return false @@ -247,17 +247,16 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected fun getTopLevelCallables(): Collection { val descriptors = indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) }) - return filterShadowedNonImportedAndExcluded(descriptors, reference!!) + return filterShadowedNonImported(descriptors, reference!!) } protected fun getTopLevelExtensions(): Collection { val descriptors = indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression, bindingContext) - return filterShadowedNonImportedAndExcluded(descriptors, reference) + return filterShadowedNonImported(descriptors, reference) } - private fun filterShadowedNonImportedAndExcluded(descriptors: Collection, reference: JetSimpleNameReference): Collection { - val notExcluded = descriptors.filter { !isInExcludedPackage(it) } - return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(notExcluded, referenceVariants, reference.expression) + private fun filterShadowedNonImported(descriptors: Collection, reference: JetSimpleNameReference): Collection { + return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(descriptors, referenceVariants, reference.expression) } protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) { diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt index 0dba554ed58..09f9f8b248b 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinIndicesHelper.kt @@ -19,10 +19,13 @@ package org.jetbrains.kotlin.idea.core import com.intellij.codeInsight.CodeInsightSettings import com.intellij.openapi.project.Project import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.search.PsiShortNamesCache import com.intellij.psi.stubs.StringStubIndexExtension import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade +import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper +import org.jetbrains.kotlin.idea.imports.importableFqName import org.jetbrains.kotlin.idea.stubindex.* import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance @@ -49,8 +52,15 @@ public class KotlinIndicesHelper( private val resolutionFacade: ResolutionFacade, private val scope: GlobalSearchScope, private val moduleDescriptor: ModuleDescriptor, - private val visibilityFilter: (DeclarationDescriptor) -> Boolean + visibilityFilter: (DeclarationDescriptor) -> Boolean, + applyExcludeSettings: Boolean ) { + private val descriptorFilter = + if (applyExcludeSettings) + { d -> visibilityFilter(d) && !isExcludedFromAutoImport(d) } + else + visibilityFilter + public fun getTopLevelCallablesByName(name: String): Collection { val declarations = HashSet() declarations.addTopLevelNonExtensionCallablesByName(JetFunctionShortNameIndex.getInstance(), name) @@ -62,7 +72,7 @@ public class KotlinIndicesHelper( else { (resolutionFacade.resolveToDescriptor(it) as? CallableDescriptor).singletonOrEmptyList() } - }.filter { it.getExtensionReceiverParameter() == null && visibilityFilter(it) } + }.filter { it.getExtensionReceiverParameter() == null && descriptorFilter(it) } } private fun MutableSet.addTopLevelNonExtensionCallablesByName( @@ -78,7 +88,7 @@ public class KotlinIndicesHelper( .map { FqName(it) } .filter { nameFilter(it.shortName().asString()) } .toSet() - .flatMap { findTopLevelCallables(it).filter(visibilityFilter) } + .flatMap { findTopLevelCallables(it).filter(descriptorFilter) } } public fun getCallableTopLevelExtensions(nameFilter: (String) -> Boolean, expression: JetSimpleNameExpression, bindingContext: BindingContext): Collection { @@ -148,7 +158,7 @@ public class KotlinIndicesHelper( val result = LinkedHashSet() fun processDescriptor(descriptor: CallableDescriptor) { - if (visibilityFilter(descriptor)) { + if (descriptorFilter(descriptor)) { for ((receiverValue, callType) in receiverValues) { result.addAll(descriptor.substituteExtensionIfCallable(receiverValue, callType, bindingContext, dataFlowInfo, moduleDescriptor)) } @@ -172,7 +182,14 @@ public class KotlinIndicesHelper( return result } - public fun getClassDescriptors(nameFilter: (String) -> Boolean, kindFilter: (ClassKind) -> Boolean): Collection { + public fun getJvmClassesByName(name: String): Collection + = PsiShortNamesCache.getInstance(project).getClassesByName(name, scope) + .map { resolutionFacade.psiClassToDescriptor(it) } + .filterNotNull() + .filter(descriptorFilter) + .toSet() + + public fun getKotlinClasses(nameFilter: (String) -> Boolean, kindFilter: (ClassKind) -> Boolean): Collection { return JetFullClassNameIndex.getInstance().getAllKeys(project).asSequence() .map { FqName(it) } .filter { nameFilter(it.shortName().asString()) } @@ -190,7 +207,7 @@ public class KotlinIndicesHelper( // Note: Can't search with psi element as analyzer could be built over temp files return ResolveSessionUtils.getClassOrObjectDescriptorsByFqName(moduleDescriptor, classFQName) { kindFilter(it.getKind()) } - .filter(visibilityFilter) + .filter(descriptorFilter) } private fun findTopLevelCallables(fqName: FqName): Collection { @@ -198,11 +215,12 @@ public class KotlinIndicesHelper( .filterIsInstance() .filter { it.getExtensionReceiverParameter() == null } } + + private fun isExcludedFromAutoImport(descriptor: DeclarationDescriptor): Boolean { + val fqName = descriptor.importableFqName?.asString() ?: return false + + return CodeInsightSettings.getInstance().EXCLUDED_PACKAGES + .any { excluded -> fqName == excluded || (fqName.startsWith(excluded) && fqName[excluded.length()] == '.') } + } } -public fun isInExcludedPackage(descriptor: DeclarationDescriptor): Boolean { - val fqName = DescriptorUtils.getFqName(descriptor).asString() - - return CodeInsightSettings.getInstance().EXCLUDED_PACKAGES - .any { excluded -> fqName == excluded || fqName.startsWith(excluded + ".") } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt index e19b1d325f9..ed285d81bb6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AutoImportFix.kt @@ -24,8 +24,6 @@ import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.editor.Editor import com.intellij.openapi.project.Project import com.intellij.psi.PsiFile -import com.intellij.psi.search.GlobalSearchScope -import com.intellij.psi.search.PsiShortNamesCache import com.intellij.psi.util.PsiModificationTracker import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility @@ -37,7 +35,6 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.core.KotlinIndicesHelper import org.jetbrains.kotlin.idea.core.isVisible -import org.jetbrains.kotlin.idea.core.psiClassToDescriptor import org.jetbrains.kotlin.idea.project.ProjectStructureUtil import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.psi.JetPsiUtil @@ -48,8 +45,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.CachedValueProperty import java.util.ArrayList -import com.intellij.codeInsight.* -import org.jetbrains.kotlin.idea.core.isInExcludedPackage /** * Check possibility and perform fix for unresolved references. @@ -140,31 +135,23 @@ public class AutoImportFix(element: JetSimpleNameExpression) : JetHintAction() val moduleDescriptor = resolutionFacade.findModuleDescriptor(element) - val indicesHelper = KotlinIndicesHelper(file.getProject(), resolutionFacade, searchScope, moduleDescriptor, ::isVisible) + val indicesHelper = KotlinIndicesHelper(file.getProject(), resolutionFacade, searchScope, moduleDescriptor, ::isVisible, true) if (!element.isImportDirectiveExpression() && !JetPsiUtil.isSelectorInQualified(element)) { if (ProjectStructureUtil.isJsKotlinModule(file)) { - result.addAll(indicesHelper.getClassDescriptors({ it == referenceName }, { true })) + result.addAll(indicesHelper.getKotlinClasses({ it == referenceName }, { true })) } else { - getClasses(referenceName, file, searchScope).filterTo(result, ::isVisible) + result.addAll(indicesHelper.getJvmClassesByName(referenceName)) } result.addAll(indicesHelper.getTopLevelCallablesByName(referenceName)) } result.addAll(indicesHelper.getCallableTopLevelExtensions({ it == referenceName }, element, bindingContext)) - return result.filter { it -> !isInExcludedPackage(it) } + return result } - private fun getClasses(name: String, file: JetFile, searchScope: GlobalSearchScope): Collection - = getShortNamesCache(file).getClassesByName(name, searchScope) - .map { element.getResolutionFacade().psiClassToDescriptor(it) } - .filterNotNull() - .toSet() - - private fun getShortNamesCache(jetFile: JetFile): PsiShortNamesCache = PsiShortNamesCache.getInstance(jetFile.getProject()) - companion object { private val ERRORS = setOf(Errors.UNRESOLVED_REFERENCE, Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER) From 60ea98f8701deed5f9ea219b33327159f37d4553 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 20:05:57 +0300 Subject: [PATCH 107/450] Moved/renamed test data --- .../{InFunctionLiteral.kt => InLambda.kt} | 0 .../{ => backingFields}/BackingFields1.kt | 0 .../{ => backingFields}/BackingFields2.kt | 0 .../{ => backingFields}/BackingFields3.kt | 0 .../{ => backingFields}/BackingFields4.kt | 0 .../{ => backingFields}/BackingFields5.kt | 0 .../{ => backingFields}/BackingFields6.kt | 0 .../BackingFieldsInStringTemplate.kt | 0 .../ImmediateExtensionMembers1.kt | 0 .../ImmediateExtensionMembers2.kt | 0 .../ImmediateExtensionMembers3.kt | 0 .../ImmediateExtensionMembers4.kt | 0 .../ImmediateMembers1.kt | 0 .../ImmediateMembers2.kt | 0 .../ImmediateMembers3.kt | 0 .../ImmediateMembers4.kt | 0 .../ImmediateMembers5.kt | 0 .../ParameterName0.kt} | 0 .../ParameterName1.kt} | 0 .../ParameterName2.kt} | 0 .../ParameterName3.kt} | 0 .../ParameterName4.kt} | 0 .../ParameterName5.kt} | 0 .../ParameterType1.kt} | 0 .../ParameterType2.kt} | 0 .../ParameterType3.kt} | 0 .../ParameterType4.kt} | 0 .../ParameterType5.kt} | 0 .../test/JSBasicCompletionTestGenerated.java | 363 ++++++++++-------- .../test/JvmBasicCompletionTestGenerated.java | 363 ++++++++++-------- 30 files changed, 390 insertions(+), 336 deletions(-) rename idea/idea-completion/testData/basic/common/{InFunctionLiteral.kt => InLambda.kt} (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields1.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields2.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields3.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields4.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields5.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFields6.kt (100%) rename idea/idea-completion/testData/basic/common/{ => backingFields}/BackingFieldsInStringTemplate.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateExtensionMembers1.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateExtensionMembers2.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateExtensionMembers3.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateExtensionMembers4.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateMembers1.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateMembers2.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateMembers3.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateMembers4.kt (100%) rename idea/idea-completion/testData/basic/common/{ => immediateMembers}/ImmediateMembers5.kt (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName0.kt => lambdaSignature/ParameterName0.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName1.kt => lambdaSignature/ParameterName1.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName2.kt => lambdaSignature/ParameterName2.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName3.kt => lambdaSignature/ParameterName3.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName4.kt => lambdaSignature/ParameterName4.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterName5.kt => lambdaSignature/ParameterName5.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterType1.kt => lambdaSignature/ParameterType1.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterType2.kt => lambdaSignature/ParameterType2.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterType3.kt => lambdaSignature/ParameterType3.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterType4.kt => lambdaSignature/ParameterType4.kt} (100%) rename idea/idea-completion/testData/basic/common/{FunctionLiteralParameterType5.kt => lambdaSignature/ParameterType5.kt} (100%) diff --git a/idea/idea-completion/testData/basic/common/InFunctionLiteral.kt b/idea/idea-completion/testData/basic/common/InLambda.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/InFunctionLiteral.kt rename to idea/idea-completion/testData/basic/common/InLambda.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields1.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields1.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields1.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields2.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields2.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields2.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields2.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields3.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields3.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields3.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields3.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields4.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields4.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields4.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields4.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields5.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields5.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields5.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields5.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFields6.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFields6.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFields6.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFields6.kt diff --git a/idea/idea-completion/testData/basic/common/BackingFieldsInStringTemplate.kt b/idea/idea-completion/testData/basic/common/backingFields/BackingFieldsInStringTemplate.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/BackingFieldsInStringTemplate.kt rename to idea/idea-completion/testData/basic/common/backingFields/BackingFieldsInStringTemplate.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateExtensionMembers1.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateExtensionMembers1.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers1.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateExtensionMembers2.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers2.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateExtensionMembers2.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers2.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateExtensionMembers3.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers3.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateExtensionMembers3.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers3.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateExtensionMembers4.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers4.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateExtensionMembers4.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers4.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateMembers1.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateMembers1.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers1.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateMembers2.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers2.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateMembers2.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers2.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateMembers3.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers3.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateMembers3.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers3.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateMembers4.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers4.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateMembers4.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers4.kt diff --git a/idea/idea-completion/testData/basic/common/ImmediateMembers5.kt b/idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers5.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/ImmediateMembers5.kt rename to idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers5.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName0.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName0.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName1.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName1.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName2.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName2.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName3.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName4.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName4.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterName5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterName5.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterType1.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterType1.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterType2.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterType2.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterType3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterType3.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterType4.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterType4.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt diff --git a/idea/idea-completion/testData/basic/common/FunctionLiteralParameterType5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/FunctionLiteralParameterType5.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 1ddb34d33aa..a6d17fc63aa 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -67,48 +67,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("BackingFields1.kt") - public void testBackingFields1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields1.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields2.kt") - public void testBackingFields2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields2.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields3.kt") - public void testBackingFields3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields3.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields4.kt") - public void testBackingFields4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields4.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields5.kt") - public void testBackingFields5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields5.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields6.kt") - public void testBackingFields6() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields6.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFieldsInStringTemplate.kt") - public void testBackingFieldsInStringTemplate() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFieldsInStringTemplate.kt"); - doTest(fileName); - } - @TestMetadata("BasicAny.kt") public void testBasicAny() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BasicAny.kt"); @@ -259,72 +217,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } - @TestMetadata("FunctionLiteralParameterName0.kt") - public void testFunctionLiteralParameterName0() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName0.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName1.kt") - public void testFunctionLiteralParameterName1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName1.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName2.kt") - public void testFunctionLiteralParameterName2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName2.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName3.kt") - public void testFunctionLiteralParameterName3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName3.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName4.kt") - public void testFunctionLiteralParameterName4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName4.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName5.kt") - public void testFunctionLiteralParameterName5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName5.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType1.kt") - public void testFunctionLiteralParameterType1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType1.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType2.kt") - public void testFunctionLiteralParameterType2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType2.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType3.kt") - public void testFunctionLiteralParameterType3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType3.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType4.kt") - public void testFunctionLiteralParameterType4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType4.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType5.kt") - public void testFunctionLiteralParameterType5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType5.kt"); - doTest(fileName); - } - @TestMetadata("FunctionVariableCallArgument.kt") public void testFunctionVariableCallArgument() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionVariableCallArgument.kt"); @@ -373,60 +265,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } - @TestMetadata("ImmediateExtensionMembers1.kt") - public void testImmediateExtensionMembers1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers1.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers2.kt") - public void testImmediateExtensionMembers2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers2.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers3.kt") - public void testImmediateExtensionMembers3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers3.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers4.kt") - public void testImmediateExtensionMembers4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers4.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers1.kt") - public void testImmediateMembers1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers1.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers2.kt") - public void testImmediateMembers2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers2.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers3.kt") - public void testImmediateMembers3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers3.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers4.kt") - public void testImmediateMembers4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers4.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers5.kt") - public void testImmediateMembers5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers5.kt"); - doTest(fileName); - } - @TestMetadata("ImportedEnumMembers.kt") public void testImportedEnumMembers() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImportedEnumMembers.kt"); @@ -499,12 +337,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } - @TestMetadata("InFunctionLiteral.kt") - public void testInFunctionLiteral() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InFunctionLiteral.kt"); - doTest(fileName); - } - @TestMetadata("InGlobalPropertyInitializer.kt") public void testInGlobalPropertyInitializer() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InGlobalPropertyInitializer.kt"); @@ -529,6 +361,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("InLambda.kt") + public void testInLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InLambda.kt"); + doTest(fileName); + } + @TestMetadata("InLocalObjectDeclaration.kt") public void testInLocalObjectDeclaration() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InLocalObjectDeclaration.kt"); @@ -1180,6 +1018,57 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes } } + @TestMetadata("idea/idea-completion/testData/basic/common/backingFields") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BackingFields extends AbstractJSBasicCompletionTest { + public void testAllFilesPresentInBackingFields() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/backingFields"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("BackingFields1.kt") + public void testBackingFields1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields1.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields2.kt") + public void testBackingFields2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields2.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields3.kt") + public void testBackingFields3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields3.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields4.kt") + public void testBackingFields4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields4.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields5.kt") + public void testBackingFields5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields5.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields6.kt") + public void testBackingFields6() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields6.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFieldsInStringTemplate.kt") + public void testBackingFieldsInStringTemplate() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFieldsInStringTemplate.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/extensions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1315,6 +1204,144 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes } } + @TestMetadata("idea/idea-completion/testData/basic/common/immediateMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ImmediateMembers extends AbstractJSBasicCompletionTest { + public void testAllFilesPresentInImmediateMembers() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/immediateMembers"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ImmediateExtensionMembers1.kt") + public void testImmediateExtensionMembers1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers1.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers2.kt") + public void testImmediateExtensionMembers2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers2.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers3.kt") + public void testImmediateExtensionMembers3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers3.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers4.kt") + public void testImmediateExtensionMembers4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers4.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers1.kt") + public void testImmediateMembers1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers1.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers2.kt") + public void testImmediateMembers2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers2.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers3.kt") + public void testImmediateMembers3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers3.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers4.kt") + public void testImmediateMembers4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers4.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers5.kt") + public void testImmediateMembers5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers5.kt"); + doTest(fileName); + } + } + + @TestMetadata("idea/idea-completion/testData/basic/common/lambdaSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LambdaSignature extends AbstractJSBasicCompletionTest { + public void testAllFilesPresentInLambdaSignature() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/lambdaSignature"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ParameterName0.kt") + public void testParameterName0() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName1.kt") + public void testParameterName1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName2.kt") + public void testParameterName2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName3.kt") + public void testParameterName3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName4.kt") + public void testParameterName4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName5.kt") + public void testParameterName5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType1.kt") + public void testParameterType1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType2.kt") + public void testParameterType2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType3.kt") + public void testParameterType3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType4.kt") + public void testParameterType4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType5.kt") + public void testParameterType5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index cf2aebc8ef5..34bec74e287 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -67,48 +67,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("BackingFields1.kt") - public void testBackingFields1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields1.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields2.kt") - public void testBackingFields2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields2.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields3.kt") - public void testBackingFields3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields3.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields4.kt") - public void testBackingFields4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields4.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields5.kt") - public void testBackingFields5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields5.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFields6.kt") - public void testBackingFields6() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFields6.kt"); - doTest(fileName); - } - - @TestMetadata("BackingFieldsInStringTemplate.kt") - public void testBackingFieldsInStringTemplate() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BackingFieldsInStringTemplate.kt"); - doTest(fileName); - } - @TestMetadata("BasicAny.kt") public void testBasicAny() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/BasicAny.kt"); @@ -259,72 +217,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } - @TestMetadata("FunctionLiteralParameterName0.kt") - public void testFunctionLiteralParameterName0() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName0.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName1.kt") - public void testFunctionLiteralParameterName1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName1.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName2.kt") - public void testFunctionLiteralParameterName2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName2.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName3.kt") - public void testFunctionLiteralParameterName3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName3.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName4.kt") - public void testFunctionLiteralParameterName4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName4.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterName5.kt") - public void testFunctionLiteralParameterName5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterName5.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType1.kt") - public void testFunctionLiteralParameterType1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType1.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType2.kt") - public void testFunctionLiteralParameterType2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType2.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType3.kt") - public void testFunctionLiteralParameterType3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType3.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType4.kt") - public void testFunctionLiteralParameterType4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType4.kt"); - doTest(fileName); - } - - @TestMetadata("FunctionLiteralParameterType5.kt") - public void testFunctionLiteralParameterType5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionLiteralParameterType5.kt"); - doTest(fileName); - } - @TestMetadata("FunctionVariableCallArgument.kt") public void testFunctionVariableCallArgument() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/FunctionVariableCallArgument.kt"); @@ -373,60 +265,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } - @TestMetadata("ImmediateExtensionMembers1.kt") - public void testImmediateExtensionMembers1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers1.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers2.kt") - public void testImmediateExtensionMembers2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers2.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers3.kt") - public void testImmediateExtensionMembers3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers3.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateExtensionMembers4.kt") - public void testImmediateExtensionMembers4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateExtensionMembers4.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers1.kt") - public void testImmediateMembers1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers1.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers2.kt") - public void testImmediateMembers2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers2.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers3.kt") - public void testImmediateMembers3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers3.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers4.kt") - public void testImmediateMembers4() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers4.kt"); - doTest(fileName); - } - - @TestMetadata("ImmediateMembers5.kt") - public void testImmediateMembers5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImmediateMembers5.kt"); - doTest(fileName); - } - @TestMetadata("ImportedEnumMembers.kt") public void testImportedEnumMembers() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/ImportedEnumMembers.kt"); @@ -499,12 +337,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } - @TestMetadata("InFunctionLiteral.kt") - public void testInFunctionLiteral() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InFunctionLiteral.kt"); - doTest(fileName); - } - @TestMetadata("InGlobalPropertyInitializer.kt") public void testInGlobalPropertyInitializer() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InGlobalPropertyInitializer.kt"); @@ -529,6 +361,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("InLambda.kt") + public void testInLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InLambda.kt"); + doTest(fileName); + } + @TestMetadata("InLocalObjectDeclaration.kt") public void testInLocalObjectDeclaration() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/InLocalObjectDeclaration.kt"); @@ -1180,6 +1018,57 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT } } + @TestMetadata("idea/idea-completion/testData/basic/common/backingFields") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BackingFields extends AbstractJvmBasicCompletionTest { + public void testAllFilesPresentInBackingFields() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/backingFields"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("BackingFields1.kt") + public void testBackingFields1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields1.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields2.kt") + public void testBackingFields2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields2.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields3.kt") + public void testBackingFields3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields3.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields4.kt") + public void testBackingFields4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields4.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields5.kt") + public void testBackingFields5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields5.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFields6.kt") + public void testBackingFields6() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFields6.kt"); + doTest(fileName); + } + + @TestMetadata("BackingFieldsInStringTemplate.kt") + public void testBackingFieldsInStringTemplate() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/backingFields/BackingFieldsInStringTemplate.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/extensions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -1315,6 +1204,144 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT } } + @TestMetadata("idea/idea-completion/testData/basic/common/immediateMembers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ImmediateMembers extends AbstractJvmBasicCompletionTest { + public void testAllFilesPresentInImmediateMembers() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/immediateMembers"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ImmediateExtensionMembers1.kt") + public void testImmediateExtensionMembers1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers1.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers2.kt") + public void testImmediateExtensionMembers2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers2.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers3.kt") + public void testImmediateExtensionMembers3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers3.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateExtensionMembers4.kt") + public void testImmediateExtensionMembers4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateExtensionMembers4.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers1.kt") + public void testImmediateMembers1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers1.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers2.kt") + public void testImmediateMembers2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers2.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers3.kt") + public void testImmediateMembers3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers3.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers4.kt") + public void testImmediateMembers4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers4.kt"); + doTest(fileName); + } + + @TestMetadata("ImmediateMembers5.kt") + public void testImmediateMembers5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/immediateMembers/ImmediateMembers5.kt"); + doTest(fileName); + } + } + + @TestMetadata("idea/idea-completion/testData/basic/common/lambdaSignature") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class LambdaSignature extends AbstractJvmBasicCompletionTest { + public void testAllFilesPresentInLambdaSignature() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/lambdaSignature"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("ParameterName0.kt") + public void testParameterName0() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName1.kt") + public void testParameterName1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName2.kt") + public void testParameterName2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName3.kt") + public void testParameterName3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName4.kt") + public void testParameterName4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterName5.kt") + public void testParameterName5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType1.kt") + public void testParameterType1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType2.kt") + public void testParameterType2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType3.kt") + public void testParameterType3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType4.kt") + public void testParameterType4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); + doTest(fileName); + } + + @TestMetadata("ParameterType5.kt") + public void testParameterType5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 75d668bc1989ddefe314c50f3c875c6907cf41e8 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 21:07:33 +0300 Subject: [PATCH 108/450] Adapted completion in lambda signatures to modern syntax --- .../completion/KotlinCompletionContributor.kt | 41 +++++++++++++------ .../common/lambdaSignature/ParameterName1.kt | 7 ---- .../common/lambdaSignature/ParameterName2.kt | 2 +- .../common/lambdaSignature/ParameterName3.kt | 5 --- .../common/lambdaSignature/ParameterType1.kt | 2 +- .../common/lambdaSignature/ParameterType2.kt | 8 ---- .../common/lambdaSignature/ParameterType3.kt | 2 +- .../common/lambdaSignature/ParameterType4.kt | 2 +- .../common/lambdaSignature/ParameterType5.kt | 2 +- .../test/JSBasicCompletionTestGenerated.java | 18 -------- .../test/JvmBasicCompletionTestGenerated.java | 18 -------- 11 files changed, 33 insertions(+), 74 deletions(-) delete mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt delete mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt delete mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt index e5c785dbe22..443661a2189 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt @@ -22,10 +22,7 @@ import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.patterns.PlatformPatterns import com.intellij.patterns.PsiJavaPatterns.elementType import com.intellij.patterns.PsiJavaPatterns.psiElement -import com.intellij.psi.PsiComment -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiErrorElement -import com.intellij.psi.TokenType +import com.intellij.psi.* import com.intellij.psi.search.PsiElementProcessor import com.intellij.psi.tree.TokenSet import com.intellij.psi.util.PsiTreeUtil @@ -73,11 +70,10 @@ public class KotlinCompletionContributor : CompletionContributor() { PackageDirectiveCompletion.ACTIVATION_PATTERN.accepts(tokenBefore) -> PackageDirectiveCompletion.DUMMY_IDENTIFIER - isInFunctionLiteralParameterList(tokenBefore) -> CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED - isInClassHeader(tokenBefore) -> CompletionUtilCore.DUMMY_IDENTIFIER // do not add '$' to not interrupt class declaration parsing - else -> specialExtensionReceiverDummyIdentifier(tokenBefore) + else -> specialLambdaSignatureDummyIdentifier(tokenBefore) + ?: specialExtensionReceiverDummyIdentifier(tokenBefore) ?: specialInTypeArgsDummyIdentifier(tokenBefore) ?: specialInParameterListDummyIdentifier(tokenBefore) ?: specialInArgumentListDummyIdentifier(tokenBefore) @@ -137,12 +133,6 @@ public class KotlinCompletionContributor : CompletionContributor() { return expression.getTextRange()!!.getEndOffset() } - private fun isInFunctionLiteralParameterList(tokenBefore: PsiElement?): Boolean { - val parameterList = tokenBefore?.parents?.firstOrNull { it is JetParameterList } ?: return false - val parent = parameterList.getParent() - return parent is JetFunctionLiteral && parent.getValueParameterList() == parameterList - } - private fun isInClassHeader(tokenBefore: PsiElement?): Boolean { val classOrObject = tokenBefore?.parents?.firstIsInstanceOrNull() ?: return false val name = classOrObject.getNameIdentifier() ?: return false @@ -151,6 +141,31 @@ public class KotlinCompletionContributor : CompletionContributor() { return name.endOffset <= offset && offset <= body.startOffset } + private fun specialLambdaSignatureDummyIdentifier(tokenBefore: PsiElement?): String? { + var leaf = tokenBefore + while (leaf is PsiWhiteSpace || leaf is PsiComment) { + leaf = leaf.prevLeaf(true) + } + + val lambda = leaf?.parents?.firstOrNull { it is JetFunctionLiteral } ?: return null + + val lambdaChild = leaf!!.parents.takeWhile { it != lambda }.lastOrNull() ?: return null + if (lambdaChild is JetParameterList) return CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + + if (lambdaChild !is JetBlockExpression) return null + val blockChild = leaf.parents.takeWhile { it != lambdaChild }.lastOrNull() + if (blockChild !is PsiErrorElement) return null + val inIncompleteSignature = blockChild.siblings(forward = false, withItself = false).all { + when (it) { + is PsiWhiteSpace, is PsiComment -> true + is JetBinaryExpressionWithTypeRHS -> it.getOperationReference().getReferencedNameElementType() == JetTokens.COLON + else -> false + } + } + return if (inIncompleteSignature) CompletionUtilCore.DUMMY_IDENTIFIER_TRIMMED + "->" else null + + } + private val declarationKeywords = TokenSet.create(JetTokens.FUN_KEYWORD, JetTokens.VAL_KEYWORD, JetTokens.VAR_KEYWORD) private val declarationTokens = TokenSet.orSet(TokenSet.create(JetTokens.IDENTIFIER, JetTokens.LT, JetTokens.GT, JetTokens.COMMA, JetTokens.DOT, JetTokens.QUEST, JetTokens.COLON, diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt deleted file mode 100644 index c5121c132de..00000000000 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun bar() { - val handler = { () } -} - -// INVOCATION_COUNT: 0 -// EXIST: bar -// EXIST: null diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt index 55db1b4c8ab..c69b8158009 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { (i: Int, ) } + val handler = { i: Int, } } // NUMBER: 0 diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt deleted file mode 100644 index 8bc5663f4c1..00000000000 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun bar() { - val handler = { (i, ) } -} - -// NUMBER: 0 diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt index de166f1fe4a..ec68c3abffe 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { (i: ) } + val handler = { i: } } // EXIST: Int diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt deleted file mode 100644 index fc207cd39db..00000000000 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt +++ /dev/null @@ -1,8 +0,0 @@ -fun bar() { - val handler = { (i: } -} - -// EXIST: Int -// EXIST: String -// ABSENT: bar -// ABSENT: handler \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt index 17af74fc398..060a49f860b 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { (i: Int, s: } + val handler = { i: Int, s: } } // EXIST: Int diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt index 9829505c48a..d36cdebac48 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { (i: List<>) } + val handler = { i: List<> } } // EXIST: Int diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt index d9199af455b..7c6325deb21 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { (i: Map } + val handler = { i: Map } } // EXIST: Int diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index a6d17fc63aa..9ad422833e5 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1281,24 +1281,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } - @TestMetadata("ParameterName1.kt") - public void testParameterName1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); - doTest(fileName); - } - @TestMetadata("ParameterName2.kt") public void testParameterName2() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt"); doTest(fileName); } - @TestMetadata("ParameterName3.kt") - public void testParameterName3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); - doTest(fileName); - } - @TestMetadata("ParameterName4.kt") public void testParameterName4() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); @@ -1317,12 +1305,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } - @TestMetadata("ParameterType2.kt") - public void testParameterType2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); - doTest(fileName); - } - @TestMetadata("ParameterType3.kt") public void testParameterType3() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 34bec74e287..405c2c9f8ba 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1281,24 +1281,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } - @TestMetadata("ParameterName1.kt") - public void testParameterName1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); - doTest(fileName); - } - @TestMetadata("ParameterName2.kt") public void testParameterName2() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName2.kt"); doTest(fileName); } - @TestMetadata("ParameterName3.kt") - public void testParameterName3() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); - doTest(fileName); - } - @TestMetadata("ParameterName4.kt") public void testParameterName4() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); @@ -1317,12 +1305,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } - @TestMetadata("ParameterType2.kt") - public void testParameterType2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); - doTest(fileName); - } - @TestMetadata("ParameterType3.kt") public void testParameterType3() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); From 91c4bf753097cacf5832218e428f65729a12bc6c Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 21:08:31 +0300 Subject: [PATCH 109/450] Renamed test data --- .../{ParameterName0.kt => ParameterName1.kt} | 0 .../common/lambdaSignature/ParameterName3.kt | 5 ++++ .../common/lambdaSignature/ParameterName4.kt | 8 +++-- .../common/lambdaSignature/ParameterName5.kt | 9 ------ .../{ParameterType5.kt => ParameterType2.kt} | 2 +- .../common/lambdaSignature/ParameterType3.kt | 2 +- .../common/lambdaSignature/ParameterType4.kt | 2 +- .../test/JSBasicCompletionTestGenerated.java | 30 +++++++++---------- .../test/JvmBasicCompletionTestGenerated.java | 30 +++++++++---------- 9 files changed, 44 insertions(+), 44 deletions(-) rename idea/idea-completion/testData/basic/common/lambdaSignature/{ParameterName0.kt => ParameterName1.kt} (100%) create mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt delete mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt rename idea/idea-completion/testData/basic/common/lambdaSignature/{ParameterType5.kt => ParameterType2.kt} (63%) diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt similarity index 100% rename from idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt new file mode 100644 index 00000000000..260f160dd77 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt @@ -0,0 +1,5 @@ +fun bar() { + val handler = { i, } +} + +// NUMBER: 0 diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt index 260f160dd77..bb9325e7bd4 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt @@ -1,5 +1,9 @@ fun bar() { - val handler = { i, } + val handler = { + foo() + } } -// NUMBER: 0 +// INVOCATION_COUNT: 0 +// EXIST: bar +// EXIST: null diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt deleted file mode 100644 index bb9325e7bd4..00000000000 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt +++ /dev/null @@ -1,9 +0,0 @@ -fun bar() { - val handler = { - foo() - } -} - -// INVOCATION_COUNT: 0 -// EXIST: bar -// EXIST: null diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt similarity index 63% rename from idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt rename to idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt index 7c6325deb21..060a49f860b 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { i: Map } + val handler = { i: Int, s: } } // EXIST: Int diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt index 060a49f860b..d36cdebac48 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { i: Int, s: } + val handler = { i: List<> } } // EXIST: Int diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt index d36cdebac48..7c6325deb21 100644 --- a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt @@ -1,5 +1,5 @@ fun bar() { - val handler = { i: List<> } + val handler = { i: Map } } // EXIST: Int diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 9ad422833e5..2b1ad07c25b 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1275,9 +1275,9 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/lambdaSignature"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("ParameterName0.kt") - public void testParameterName0() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt"); + @TestMetadata("ParameterName1.kt") + public void testParameterName1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); doTest(fileName); } @@ -1287,24 +1287,30 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("ParameterName3.kt") + public void testParameterName3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); + doTest(fileName); + } + @TestMetadata("ParameterName4.kt") public void testParameterName4() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); doTest(fileName); } - @TestMetadata("ParameterName5.kt") - public void testParameterName5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); - doTest(fileName); - } - @TestMetadata("ParameterType1.kt") public void testParameterType1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); doTest(fileName); } + @TestMetadata("ParameterType2.kt") + public void testParameterType2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); + doTest(fileName); + } + @TestMetadata("ParameterType3.kt") public void testParameterType3() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); @@ -1316,12 +1322,6 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); doTest(fileName); } - - @TestMetadata("ParameterType5.kt") - public void testParameterType5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); - doTest(fileName); - } } @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 405c2c9f8ba..24bad404838 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1275,9 +1275,9 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/lambdaSignature"), Pattern.compile("^(.+)\\.kt$"), true); } - @TestMetadata("ParameterName0.kt") - public void testParameterName0() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName0.kt"); + @TestMetadata("ParameterName1.kt") + public void testParameterName1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName1.kt"); doTest(fileName); } @@ -1287,24 +1287,30 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("ParameterName3.kt") + public void testParameterName3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName3.kt"); + doTest(fileName); + } + @TestMetadata("ParameterName4.kt") public void testParameterName4() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName4.kt"); doTest(fileName); } - @TestMetadata("ParameterName5.kt") - public void testParameterName5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); - doTest(fileName); - } - @TestMetadata("ParameterType1.kt") public void testParameterType1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); doTest(fileName); } + @TestMetadata("ParameterType2.kt") + public void testParameterType2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType2.kt"); + doTest(fileName); + } + @TestMetadata("ParameterType3.kt") public void testParameterType3() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType3.kt"); @@ -1316,12 +1322,6 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); doTest(fileName); } - - @TestMetadata("ParameterType5.kt") - public void testParameterType5() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); - doTest(fileName); - } } @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") From 6b78a53c3d6c2908132bc34563ae7c703d7d66cc Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 16:27:49 +0300 Subject: [PATCH 110/450] More tests --- .../basic/common/lambdaSignature/ParameterName5.kt | 5 +++++ .../basic/common/lambdaSignature/ParameterType5.kt | 8 ++++++++ .../test/JSBasicCompletionTestGenerated.java | 12 ++++++++++++ .../test/JvmBasicCompletionTestGenerated.java | 12 ++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt create mode 100644 idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt new file mode 100644 index 00000000000..a8d58c9dc4f --- /dev/null +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt @@ -0,0 +1,5 @@ +fun bar() { + val handler = { p1: Int, p2: List, } +} + +// NUMBER: 0 diff --git a/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt new file mode 100644 index 00000000000..c334dd3ba3b --- /dev/null +++ b/idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt @@ -0,0 +1,8 @@ +fun bar() { + val handler = { i: Int, list: List, s: } +} + +// EXIST: Int +// EXIST: String +// ABSENT: bar +// ABSENT: handler \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 2b1ad07c25b..c2a1f942200 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1299,6 +1299,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("ParameterName5.kt") + public void testParameterName5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); + doTest(fileName); + } + @TestMetadata("ParameterType1.kt") public void testParameterType1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); @@ -1322,6 +1328,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); doTest(fileName); } + + @TestMetadata("ParameterType5.kt") + public void testParameterType5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 24bad404838..f8475833bc8 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1299,6 +1299,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("ParameterName5.kt") + public void testParameterName5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterName5.kt"); + doTest(fileName); + } + @TestMetadata("ParameterType1.kt") public void testParameterType1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType1.kt"); @@ -1322,6 +1328,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType4.kt"); doTest(fileName); } + + @TestMetadata("ParameterType5.kt") + public void testParameterType5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/lambdaSignature/ParameterType5.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/namedArguments") From 88dd86d6034eae2225f3b3eb1e91a7aa879b3d36 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 21:17:31 +0300 Subject: [PATCH 111/450] Fixes: use isExactFunctionOrExtensionFunctionType() to detect when lambda can be passed --- .../jetbrains/kotlin/idea/completion/ExpectedInfos.kt | 2 +- .../kotlin/idea/completion/LookupElementFactory.kt | 2 +- .../kotlin/idea/completion/LookupElementsCollector.kt | 2 +- .../ParameterTypeIsDerivedFromFunction.kt | 9 +++++++++ .../ParameterTypeIsDerivedFromFunction.kt.after | 9 +++++++++ .../handlers/BasicCompletionHandlerTestGenerated.java | 6 ++++++ .../intentions/MoveLambdaOutsideParenthesesIntention.kt | 2 +- .../kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt | 2 +- 8 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt create mode 100644 idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt.after diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt index 06bcd5885ad..1f486d452d7 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt @@ -188,7 +188,7 @@ class ExpectedInfos( if (parameter.hasDefaultValue()) return false // parameter is optional if (parameter.getVarargElementType() != null) return false // vararg arguments list can be empty // last parameter of functional type can be placed outside parenthesis: - if (parameter == parameters.last() && KotlinBuiltIns.isFunctionOrExtensionFunctionType(parameter.getType())) return false + if (parameter == parameters.last() && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameter.getType())) return false return true } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index bf7422df44a..d2a8fe1ea03 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -303,7 +303,7 @@ public class LookupElementFactory( 1 -> { val parameterType = parameters.single().getType() - if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(parameterType)) { + if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() if (parameterCount <= 1) { // otherwise additional item with lambda template is to be added diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index 1f3f3b24620..1b24471f9cf 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -106,7 +106,7 @@ class LookupElementsCollector( val parameters = descriptor.getValueParameters() if (parameters.size() == 1) { val parameterType = parameters.get(0).getType() - if (KotlinBuiltIns.isFunctionOrExtensionFunctionType(parameterType)) { + if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() if (parameterCount > 1) { var lookupElement = lookupElementFactory.createLookupElement(descriptor, true) diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt new file mode 100644 index 00000000000..0e5f6da65c8 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt @@ -0,0 +1,9 @@ +interface I : () -> Unit + +fun foo(i: I){} + +fun bar() { + +} + +// ELEMENT: foo diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt.after new file mode 100644 index 00000000000..14ea2219a60 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt.after @@ -0,0 +1,9 @@ +interface I : () -> Unit + +fun foo(i: I){} + +fun bar() { + foo() +} + +// ELEMENT: foo diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java index 7ceff4eafc6..e29bb1ea289 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java @@ -220,6 +220,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("ParameterTypeIsDerivedFromFunction.kt") + public void testParameterTypeIsDerivedFromFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/ParameterTypeIsDerivedFromFunction.kt"); + doTest(fileName); + } + @TestMetadata("ReplaceByLambdaTemplateNoClosingParenth.kt") public void testReplaceByLambdaTemplateNoClosingParenth() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt"); diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt index 53a9a56b0cc..06923854d19 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/MoveLambdaOutsideParenthesesIntention.kt @@ -45,7 +45,7 @@ public class MoveLambdaOutsideParenthesesIntention : JetSelfTargetingIntention Date: Mon, 6 Jul 2015 22:04:59 +0300 Subject: [PATCH 112/450] Completion: more intuitive presentation of function items that insert lambda --- .../kotlin/idea/completion/LookupElementFactory.kt | 14 ++++++++++---- .../testData/basic/common/SubstitutedSignature3.kt | 4 ++-- .../testData/handlers/smart/SAMExpected1.kt | 2 +- .../testData/handlers/smart/SAMExpected1.kt.after | 2 +- .../idea-completion/testData/smart/SAMExpected1.kt | 2 +- .../testData/smart/generics/GenericFunction4.kt | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index d2a8fe1ea03..9526c72b015 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -169,11 +169,20 @@ public class LookupElementFactory( } var element = LookupElementBuilder.create(lookupObject, name) + val insertHandler = getDefaultInsertHandler(descriptor) + element = element.withInsertHandler(insertHandler) + when (descriptor) { is FunctionDescriptor -> { val returnType = descriptor.getReturnType() element = element.withTypeText(if (returnType != null) DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(returnType) else "") - element = element.appendTailText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderFunctionParameters(descriptor), false) + + val insertsLambda = (insertHandler as KotlinFunctionInsertHandler).lambdaInfo != null + if (insertsLambda) { + element = element.appendTailText(" {...} ", false) + } + + element = element.appendTailText(DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderFunctionParameters(descriptor), insertsLambda) } is VariableDescriptor -> { @@ -232,9 +241,6 @@ public class LookupElementFactory( element = element.withStrikeoutness(true) } - val insertHandler = getDefaultInsertHandler(descriptor) - element = element.withInsertHandler(insertHandler) - if (insertHandler is KotlinFunctionInsertHandler && insertHandler.lambdaInfo != null) { element.putUserData(KotlinCompletionCharFilter.ACCEPT_OPENING_BRACE, Unit) } diff --git a/idea/idea-completion/testData/basic/common/SubstitutedSignature3.kt b/idea/idea-completion/testData/basic/common/SubstitutedSignature3.kt index 01cfde847bf..f0af4361c6c 100644 --- a/idea/idea-completion/testData/basic/common/SubstitutedSignature3.kt +++ b/idea/idea-completion/testData/basic/common/SubstitutedSignature3.kt @@ -1,5 +1,5 @@ fun foo(list: List) { list. } -// EXIST: { itemText: "firstOrNull", tailText: "(predicate: (String) -> Boolean) for Iterable in kotlin", typeText: "String?" } -// EXIST: { itemText: "toMap", tailText: "(selector: (String) -> K) for Iterable in kotlin", typeText: "Map" } +// EXIST: { itemText: "firstOrNull", tailText: " {...} (predicate: (String) -> Boolean) for Iterable in kotlin", typeText: "String?" } +// EXIST: { itemText: "toMap", tailText: " {...} (selector: (String) -> K) for Iterable in kotlin", typeText: "Map" } diff --git a/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt b/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt index 3bd44948bd8..b717b24dcf3 100644 --- a/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt +++ b/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt @@ -1,4 +1,4 @@ var a : Runnable = // ELEMENT_TEXT: Runnable -// TAIL_TEXT: "(function: () -> Unit) (java.lang)" +// TAIL_TEXT: " {...} (function: () -> Unit) (java.lang)" diff --git a/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt.after b/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt.after index dd80a9ada21..dd389f324f5 100644 --- a/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt.after +++ b/idea/idea-completion/testData/handlers/smart/SAMExpected1.kt.after @@ -1,4 +1,4 @@ var a : Runnable = Runnable { } // ELEMENT_TEXT: Runnable -// TAIL_TEXT: "(function: () -> Unit) (java.lang)" +// TAIL_TEXT: " {...} (function: () -> Unit) (java.lang)" diff --git a/idea/idea-completion/testData/smart/SAMExpected1.kt b/idea/idea-completion/testData/smart/SAMExpected1.kt index 977ce676675..55c9bfde739 100644 --- a/idea/idea-completion/testData/smart/SAMExpected1.kt +++ b/idea/idea-completion/testData/smart/SAMExpected1.kt @@ -1,3 +1,3 @@ var a : Runnable = -// EXIST: {"lookupString":"Runnable", "itemText":"Runnable", "tailText":"(function: () -> Unit) (java.lang)", "typeText":"Runnable"} +// EXIST: {"lookupString":"Runnable", "itemText":"Runnable", "tailText":" {...} (function: () -> Unit) (java.lang)", "typeText":"Runnable"} diff --git a/idea/idea-completion/testData/smart/generics/GenericFunction4.kt b/idea/idea-completion/testData/smart/generics/GenericFunction4.kt index 6b2f65c5274..3dcc801f313 100644 --- a/idea/idea-completion/testData/smart/generics/GenericFunction4.kt +++ b/idea/idea-completion/testData/smart/generics/GenericFunction4.kt @@ -2,5 +2,5 @@ fun foo(list: List): Collection { return list. } -// EXIST: { lookupString: "map", tailText: "(transform: (String) -> Int) for Iterable in kotlin", typeText: "List" } +// EXIST: { lookupString: "map", tailText: " {...} (transform: (String) -> Int) for Iterable in kotlin", typeText: "List" } // ABSENT: filter From 3f74cc6351ed61d7e1ec2d9d065ffda86459d45e Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 7 Jul 2015 13:31:08 +0300 Subject: [PATCH 113/450] More consistent presentation for different completion items producing lambda's --- .../kotlin/idea/completion/LookupElementsCollector.kt | 4 ++-- .../testData/basic/common/HigherOrderFunction1.kt | 2 +- .../testData/basic/common/HigherOrderFunction2.kt | 2 +- .../basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt | 2 +- .../highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after | 2 +- .../basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt | 2 +- .../highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after | 2 +- .../ReplaceByLambdaTemplateNoClosingParenth.kt | 2 +- .../ReplaceByLambdaTemplateNoClosingParenth.kt.after | 2 +- .../basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt | 2 +- .../highOrderFunctions/WithArgsEmptyLambdaAfter.kt.after | 2 +- .../basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt | 2 +- .../highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt.after | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index 1b24471f9cf..0ac00825641 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -117,8 +117,8 @@ class LookupElementsCollector( val tails = presentation.getTailFragments() presentation.clearTail() - presentation.appendTailText(" " + buildLambdaPresentation(parameterType), false) - tails.drop(1)/*drop old function signature*/.forEach { presentation.appendTailText(it.text, it.isGrayed()) } + presentation.appendTailText(" " + buildLambdaPresentation(parameterType) + " ", false) + tails.forEach { presentation.appendTailText(it.text, true) } } override fun handleInsert(context: InsertionContext) { diff --git a/idea/idea-completion/testData/basic/common/HigherOrderFunction1.kt b/idea/idea-completion/testData/basic/common/HigherOrderFunction1.kt index 0f040ffe8ce..b1294efbb1a 100644 --- a/idea/idea-completion/testData/basic/common/HigherOrderFunction1.kt +++ b/idea/idea-completion/testData/basic/common/HigherOrderFunction1.kt @@ -5,4 +5,4 @@ fun test() { } // EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit) ()", typeText:"Unit" } -// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } ()", typeText:"Unit" } +// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } (p: (String, Char) -> Unit) ()", typeText:"Unit" } diff --git a/idea/idea-completion/testData/basic/common/HigherOrderFunction2.kt b/idea/idea-completion/testData/basic/common/HigherOrderFunction2.kt index ee9b2aad939..187b40286b0 100644 --- a/idea/idea-completion/testData/basic/common/HigherOrderFunction2.kt +++ b/idea/idea-completion/testData/basic/common/HigherOrderFunction2.kt @@ -5,4 +5,4 @@ fun test() { } // EXIST: { lookupString:"foo", itemText: "foo", tailText: "(p: (String, Char) -> Unit) for String in ", typeText:"Unit" } -// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } for String in ", typeText:"Unit" } +// EXIST: { lookupString:"foo", itemText: "foo", tailText: " { String, Char -> ... } (p: (String, Char) -> Unit) for String in ", typeText:"Unit" } diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt index 4f853bc548d..61cc344f32d 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after index dcc55fac961..f01aed33a0d 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs1.kt.after @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt index f8ece805cfb..5812622ae3a 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt @@ -6,5 +6,5 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after index bc480d4e9e9..d93c83af6b4 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunctionWithArgs3.kt.after @@ -6,5 +6,5 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt index 1e6481d03d6..bb24097bda3 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt @@ -5,5 +5,5 @@ fun main(args: Array) { } // ELEMENT: "foo" -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" // CHAR: '\t' diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after index d7a7884dcdf..84c3a3a45ab 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/ReplaceByLambdaTemplateNoClosingParenth.kt.after @@ -5,5 +5,5 @@ fun main(args: Array) { } // ELEMENT: "foo" -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" // CHAR: '\t' diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt index 327a06bba0f..fabc6e2ca4f 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt.after index 42a9678079b..afa51f761e8 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsEmptyLambdaAfter.kt.after @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt index 880d6e96240..ccfb1509882 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" diff --git a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt.after b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt.after index ecb94d95e39..0cdd9c1d123 100644 --- a/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt.after +++ b/idea/idea-completion/testData/handlers/basic/highOrderFunctions/WithArgsNonEmptyLambdaAfter.kt.after @@ -5,4 +5,4 @@ fun main(args: Array) { } // ELEMENT: foo -// TAIL_TEXT: " { String, Char -> ... } ()" +// TAIL_TEXT: " { String, Char -> ... } (p: (String, Char) -> Boolean) ()" From 4dc7081dc4b407c4b78f4a4a19ad2fb17b994c82 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 22:16:13 +0300 Subject: [PATCH 114/450] Completion: fixed filtering shadowed declarations for generic functions --- .../idea/util/ShadowedDeclarationsFilter.kt | 9 ++- .../jetbrains/kotlin/util/descriptorUtils.kt | 58 +++++++++++++++++++ .../kotlin/idea/completion/CompletionUtils.kt | 36 ------------ .../completion/DeclarationLookupObjectImpl.kt | 1 + .../kotlin/idea/completion/smart/Utils.kt | 1 + .../shadowing/PreferCloserReceiverGeneric.kt | 14 +++++ .../PreferMoreSpecificExtensionGeneric.kt | 9 +++ ...erMoreSpecificExtensionGenericWithParam.kt | 9 +++ ...MoreSpecificExtensionGeneric.dependency.kt | 7 +++ .../MoreSpecificExtensionGeneric.kt | 6 ++ .../test/JSBasicCompletionTestGenerated.java | 18 ++++++ .../test/JvmBasicCompletionTestGenerated.java | 18 ++++++ ...tiFileJvmBasicCompletionTestGenerated.java | 6 ++ 13 files changed, 154 insertions(+), 38 deletions(-) create mode 100644 idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt create mode 100644 idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt create mode 100644 idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt create mode 100644 idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt create mode 100644 idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.dependency.kt create mode 100644 idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt index fc6551a2fc9..577e5bc0566 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/ShadowedDeclarationsFilter.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.scopes.ChainedScope import org.jetbrains.kotlin.resolve.scopes.ExplicitImportsScope import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import java.util.ArrayList import java.util.HashSet @@ -168,8 +169,12 @@ public class ShadowedDeclarationsFilter( CompositeChecker(listOf()), SymbolUsageValidator.Empty, AdditionalTypeChecker.Composite(listOf()), false) val callResolver = createContainerForMacros(project, moduleDescriptor).callResolver val results = if (isFunction) callResolver.resolveFunctionCall(context) else callResolver.resolveSimpleProperty(context) - val resultingDescriptors = results.getResultingCalls().map { it.getResultingDescriptor() }.toSet() - val filtered = descriptors.filter { it in resultingDescriptors } + val resultingDescriptors = results.getResultingCalls().map { it.getResultingDescriptor() } + val resultingOriginals = resultingDescriptors.mapTo(HashSet()) { it.getOriginal() } + val filtered = descriptors.filter { candidateDescriptor -> + candidateDescriptor.getOriginal() in resultingOriginals /* optimization */ + && resultingDescriptors.any { descriptorsEqualWithSubstitution(it, candidateDescriptor) } + } return if (filtered.isNotEmpty()) filtered else descriptors /* something went wrong, none of our declarations among resolve candidates, let's not filter anything */ } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt new file mode 100644 index 00000000000..61598d00aad --- /dev/null +++ b/idea/ide-common/src/org/jetbrains/kotlin/util/descriptorUtils.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.util + +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.types.TypeConstructor +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.types.typeUtil.equalTypesOrNulls + +public fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?, descriptor2: DeclarationDescriptor?): Boolean { + if (descriptor1 == descriptor2) return true + if (descriptor1 == null || descriptor2 == null) return false + if (descriptor1.getOriginal() != descriptor2.getOriginal()) return false + if (descriptor1 !is CallableDescriptor) return true + descriptor2 as CallableDescriptor + + val typeChecker = JetTypeChecker.withAxioms(object: JetTypeChecker.TypeConstructorEquality { + override fun equals(a: TypeConstructor, b: TypeConstructor): Boolean { + val typeParam1 = a.getDeclarationDescriptor() as? TypeParameterDescriptor + val typeParam2 = b.getDeclarationDescriptor() as? TypeParameterDescriptor + if (typeParam1 != null + && typeParam2 != null + && typeParam1.getContainingDeclaration() == descriptor1 + && typeParam2.getContainingDeclaration() == descriptor2) { + return typeParam1.getIndex() == typeParam2.getIndex() + } + + return a == b + } + }) + + if (!typeChecker.equalTypesOrNulls(descriptor1.getReturnType(), descriptor2.getReturnType())) return false + + val parameters1 = descriptor1.getValueParameters() + val parameters2 = descriptor2.getValueParameters() + if (parameters1.size() != parameters2.size()) return false + for ((param1, param2) in parameters1.zip(parameters2)) { + if (!typeChecker.equalTypes(param1.getType(), param2.getType())) return false + } + return true +} + diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index e4b0d7583fe..ec998138fdc 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -140,42 +140,6 @@ enum class CallableWeight { val CALLABLE_WEIGHT_KEY = Key("CALLABLE_WEIGHT_KEY") -fun descriptorsEqualWithSubstitution(descriptor1: DeclarationDescriptor?, descriptor2: DeclarationDescriptor?): Boolean { - if (descriptor1 == descriptor2) return true - if (descriptor1 == null || descriptor2 == null) return false - if (descriptor1.getOriginal() != descriptor2.getOriginal()) return false - if (descriptor1 !is CallableDescriptor) return true - descriptor2 as CallableDescriptor - - // optimization: - if (descriptor1 == descriptor1.getOriginal() && descriptor2 == descriptor2.getOriginal()) return true - - val typeChecker = JetTypeChecker.withAxioms(object: JetTypeChecker.TypeConstructorEquality { - override fun equals(a: TypeConstructor, b: TypeConstructor): Boolean { - val typeParam1 = a.getDeclarationDescriptor() as? TypeParameterDescriptor - val typeParam2 = b.getDeclarationDescriptor() as? TypeParameterDescriptor - if (typeParam1 != null - && typeParam2 != null - && typeParam1.getContainingDeclaration() == descriptor1 - && typeParam2.getContainingDeclaration() == descriptor2) { - return typeParam1.getIndex() == typeParam2.getIndex() - } - - return a == b - } - }) - - if (!typeChecker.equalTypesOrNulls(descriptor1.getReturnType(), descriptor2.getReturnType())) return false - - val parameters1 = descriptor1.getValueParameters() - val parameters2 = descriptor2.getValueParameters() - if (parameters1.size() != parameters2.size()) return false - for ((param1, param2) in parameters1.zip(parameters2)) { - if (!typeChecker.equalTypes(param1.getType(), param2.getType())) return false - } - return true -} - fun InsertionContext.isAfterDot(): Boolean { var offset = getStartOffset() val chars = getDocument().getCharsSequence() diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt index 6a17db302ff..82fc10112bc 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject +import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import javax.swing.Icon /** diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index 7248aacd28b..cb1c7208726 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import java.util.ArrayList import java.util.HashMap import java.util.HashSet diff --git a/idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt b/idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt new file mode 100644 index 00000000000..ee7ce332369 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt @@ -0,0 +1,14 @@ +interface I { + fun xxx(): T +} + +fun foo(i1: I, i2: I) { + with (i1) { + with (i2) { + xx + } + } +} + +// EXIST: { lookupString: "xxx", itemText: "xxx", tailText: "()", typeText: "String" } +// NOTHING_ELSE diff --git a/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt b/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt new file mode 100644 index 00000000000..6227f2ec54f --- /dev/null +++ b/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt @@ -0,0 +1,9 @@ +fun List.xxx(){} +fun Iterable.xxx(){} + +fun foo() { + listOf(1).xx +} + +// EXIST: { lookupString: "xxx", itemText: "xxx", tailText: "() for List in ", typeText: "Unit" } +// NOTHING_ELSE diff --git a/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt b/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt new file mode 100644 index 00000000000..780455b69ff --- /dev/null +++ b/idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt @@ -0,0 +1,9 @@ +fun List.xxx(t: T){} +fun Iterable.xxx(t: T){} + +fun foo() { + listOf(1).xx +} + +// EXIST: { lookupString: "xxx", itemText: "xxx", tailText: "(t: Int) for List in ", typeText: "Unit" } +// NOTHING_ELSE diff --git a/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.dependency.kt b/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.dependency.kt new file mode 100644 index 00000000000..32d8a983113 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.dependency.kt @@ -0,0 +1,7 @@ +package dependency + +interface Iterable +interface List : Iterable + +fun List.xxx(t: T){} +fun Iterable.xxx(t: T){} diff --git a/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.kt b/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.kt new file mode 100644 index 00000000000..54651e1bb41 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/MoreSpecificExtensionGeneric.kt @@ -0,0 +1,6 @@ +fun foo(list: dependency.List) { + list.xx +} + +// EXIST: { lookupString: "xxx", itemText: "xxx", tailText: "(t: Int) for List in dependency", typeText: "Unit" } +// NOTHING_ELSE diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index c2a1f942200..df3dca167dc 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1650,6 +1650,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("PreferCloserReceiverGeneric.kt") + public void testPreferCloserReceiverGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt"); + doTest(fileName); + } + @TestMetadata("PreferMemberExtension.kt") public void testPreferMemberExtension() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMemberExtension.kt"); @@ -1673,6 +1679,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtension.kt"); doTest(fileName); } + + @TestMetadata("PreferMoreSpecificExtensionGeneric.kt") + public void testPreferMoreSpecificExtensionGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt"); + doTest(fileName); + } + + @TestMetadata("PreferMoreSpecificExtensionGenericWithParam.kt") + public void testPreferMoreSpecificExtensionGenericWithParam() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/typeArgsOrNot") diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index f8475833bc8..4a7e00f9a02 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1650,6 +1650,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("PreferCloserReceiverGeneric.kt") + public void testPreferCloserReceiverGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferCloserReceiverGeneric.kt"); + doTest(fileName); + } + @TestMetadata("PreferMemberExtension.kt") public void testPreferMemberExtension() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMemberExtension.kt"); @@ -1673,6 +1679,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtension.kt"); doTest(fileName); } + + @TestMetadata("PreferMoreSpecificExtensionGeneric.kt") + public void testPreferMoreSpecificExtensionGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGeneric.kt"); + doTest(fileName); + } + + @TestMetadata("PreferMoreSpecificExtensionGenericWithParam.kt") + public void testPreferMoreSpecificExtensionGenericWithParam() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/shadowing/PreferMoreSpecificExtensionGenericWithParam.kt"); + doTest(fileName); + } } @TestMetadata("idea/idea-completion/testData/basic/common/typeArgsOrNot") diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index 5712c7300b2..a8116ef2271 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -137,6 +137,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("MoreSpecificExtensionGeneric") + public void testMoreSpecificExtensionGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionGeneric/"); + doTest(fileName); + } + @TestMetadata("MoreSpecificExtensionInDifferentPackage") public void testMoreSpecificExtensionInDifferentPackage() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/MoreSpecificExtensionInDifferentPackage/"); From 3a1fb7d883faa38921a9e001d6c21b14241c1871 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 3 Jul 2015 19:42:11 +0200 Subject: [PATCH 115/450] QuickFixes: J2K --- .../kotlin/idea/quickfix/{QuickFixes.java => QuickFixes.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/{QuickFixes.java => QuickFixes.kt} (100%) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt similarity index 100% rename from idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.java rename to idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt From 6734dcb82c39e71f7bc39cb673b69a5e52f25d6c Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 3 Jul 2015 19:47:15 +0200 Subject: [PATCH 116/450] QuickFixRegistrar: J2K --- .../quickfix/{QuickFixRegistrar.java => QuickFixRegistrar.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/quickfix/{QuickFixRegistrar.java => QuickFixRegistrar.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.java rename to idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt From 77c0a54a79b9cdabcfacda3ba3684d077fc8d7b6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 3 Jul 2015 20:21:12 +0200 Subject: [PATCH 117/450] convert QuickFixRegistrar to Kotlin; on-demand registration of quickfixes (KT-8307) #KT-8307 Fixed --- .../kotlin/idea/highlighter/JetPsiChecker.kt | 4 +- .../kotlin/idea/quickfix/QuickFixes.kt | 52 +- idea/src/META-INF/extensions/common.xml | 2 + idea/src/META-INF/plugin.xml | 4 + .../kotlin/idea/PluginStartupComponent.java | 2 - .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 464 +++++++++--------- 6 files changed, 273 insertions(+), 255 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt index 4f1b91e0d70..7b43e047252 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt @@ -254,11 +254,11 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension { public fun createQuickfixes(diagnostic: Diagnostic): Collection { val result = arrayListOf() - val intentionActionsFactories = QuickFixes.getActionsFactories(diagnostic.getFactory()) + val intentionActionsFactories = QuickFixes.getInstance().getActionFactories(diagnostic.getFactory()) for (intentionActionsFactory in intentionActionsFactories.filterNotNull()) { result.addAll(intentionActionsFactory.createActions(diagnostic)) } - result.addAll(QuickFixes.getActions(diagnostic.getFactory())) + result.addAll(QuickFixes.getInstance().getActions(diagnostic.getFactory())) return result } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt index 7b582615a44..ec90b9f1762 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/quickfix/QuickFixes.kt @@ -14,27 +14,49 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.quickfix; +package org.jetbrains.kotlin.idea.quickfix -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.intellij.codeInsight.intention.IntentionAction; -import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; - -import java.util.Collection; +import com.google.common.collect.HashMultimap +import com.google.common.collect.Multimap +import com.intellij.codeInsight.intention.IntentionAction +import com.intellij.openapi.components.ServiceManager +import com.intellij.openapi.extensions.ExtensionPointName +import com.intellij.openapi.extensions.Extensions +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory public class QuickFixes { + private val factories: Multimap, JetIntentionActionsFactory> = HashMultimap.create, JetIntentionActionsFactory>() + private val actions: Multimap, IntentionAction> = HashMultimap.create, IntentionAction>() - static final Multimap, JetIntentionActionsFactory> factories = HashMultimap.create(); - static final Multimap, IntentionAction> actions = HashMultimap.create(); - - public static Collection getActionsFactories(DiagnosticFactory diagnosticFactory) { - return factories.get(diagnosticFactory); + init { + Extensions.getExtensions(QuickFixContributor.EP_NAME).forEach { it.registerQuickFixes(this) } } - public static Collection getActions(DiagnosticFactory diagnosticFactory) { - return actions.get(diagnosticFactory); + public fun register(diagnosticFactory: DiagnosticFactory<*>, vararg factory: JetIntentionActionsFactory) { + factories.putAll(diagnosticFactory, factory.toList()) } - private QuickFixes() {} + public fun register(diagnosticFactory: DiagnosticFactory<*>, vararg action: IntentionAction) { + actions.putAll(diagnosticFactory, action.toList()) + } + + public fun getActionFactories(diagnosticFactory: DiagnosticFactory<*>): Collection { + return factories.get(diagnosticFactory) + } + + public fun getActions(diagnosticFactory: DiagnosticFactory<*>): Collection { + return actions.get(diagnosticFactory) + } + + companion object { + public fun getInstance(): QuickFixes = ServiceManager.getService(javaClass()) + } } + +public interface QuickFixContributor { + companion object { + val EP_NAME: ExtensionPointName = ExtensionPointName.create("org.jetbrains.kotlin.quickFixContributor") + } + + fun registerQuickFixes(quickFixes: QuickFixes) +} \ No newline at end of file diff --git a/idea/src/META-INF/extensions/common.xml b/idea/src/META-INF/extensions/common.xml index 13707352502..f33953893b8 100644 --- a/idea/src/META-INF/extensions/common.xml +++ b/idea/src/META-INF/extensions/common.xml @@ -23,5 +23,7 @@ + diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 9c6af2334ef..513efab7734 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -168,6 +168,9 @@ + + @@ -1088,6 +1091,7 @@ + diff --git a/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java b/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java index ee8d6ef5535..b8edca12729 100644 --- a/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java +++ b/idea/src/org/jetbrains/kotlin/idea/PluginStartupComponent.java @@ -20,7 +20,6 @@ import com.intellij.openapi.application.PathMacros; import com.intellij.openapi.components.ApplicationComponent; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.debugger.filter.FilterPackage; -import org.jetbrains.kotlin.idea.quickfix.QuickFixRegistrar; import org.jetbrains.kotlin.utils.PathUtil; public class PluginStartupComponent implements ApplicationComponent { @@ -35,7 +34,6 @@ public class PluginStartupComponent implements ApplicationComponent { @Override public void initComponent() { registerPathVariable(); - QuickFixRegistrar.registerQuickFixes(); FilterPackage.addKotlinStdlibDebugFilterIfNeeded(); } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 8b26c007e77..256dbe1aaae 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -14,327 +14,319 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.quickfix; +package org.jetbrains.kotlin.idea.quickfix -import org.jetbrains.kotlin.idea.core.codeInsight.ImplementMethodsHandler; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.*; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromCallWithConstructorCalleeActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromConstructorCallActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromReferenceExpressionActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromTypeReferenceActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterActionFactory; -import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory; -import org.jetbrains.kotlin.psi.JetClass; -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm; +import com.intellij.codeInsight.intention.IntentionAction +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory +import org.jetbrains.kotlin.diagnostics.Errors.* +import org.jetbrains.kotlin.idea.core.codeInsight.ImplementMethodsHandler +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.* +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromCallWithConstructorCalleeActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromConstructorCallActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromReferenceExpressionActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromTypeReferenceActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateLocalVariableActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterActionFactory +import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory +import org.jetbrains.kotlin.lexer.JetTokens.* +import org.jetbrains.kotlin.psi.JetClass +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm -import static org.jetbrains.kotlin.diagnostics.Errors.*; -import static org.jetbrains.kotlin.lexer.JetTokens.*; +public class QuickFixRegistrar : QuickFixContributor { + public override fun registerQuickFixes(quickFixes: QuickFixes) { + fun DiagnosticFactory<*>.registerFactory(vararg factory: JetIntentionActionsFactory) { + quickFixes.register(this, *factory) + } -public class QuickFixRegistrar { - public static void registerQuickFixes() { - JetSingleIntentionActionFactory - removeAbstractModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD); - JetSingleIntentionActionFactory addAbstractModifierFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD); + fun DiagnosticFactory<*>.registerActions(vararg action: IntentionAction) { + quickFixes.register(this, *action) + } - QuickFixes.factories.put(ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS, removeAbstractModifierFactory); + val removeAbstractModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD) + val addAbstractModifierFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD) - JetSingleIntentionActionFactory removePartsFromPropertyFactory = RemovePartsFromPropertyFix.createFactory(); - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_INITIALIZER, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_INITIALIZER, removePartsFromPropertyFactory); + ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS.registerFactory(removeAbstractModifierFactory) - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_GETTER, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_GETTER, removePartsFromPropertyFactory); + val removePartsFromPropertyFactory = RemovePartsFromPropertyFix.createFactory() + ABSTRACT_PROPERTY_WITH_INITIALIZER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory) + ABSTRACT_PROPERTY_WITH_GETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory) + ABSTRACT_PROPERTY_WITH_SETTER.registerFactory(removeAbstractModifierFactory, removePartsFromPropertyFactory) - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_SETTER, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_PROPERTY_WITH_SETTER, removePartsFromPropertyFactory); + PROPERTY_INITIALIZER_IN_TRAIT.registerFactory(removePartsFromPropertyFactory) - QuickFixes.factories.put(PROPERTY_INITIALIZER_IN_TRAIT, removePartsFromPropertyFactory); + MUST_BE_INITIALIZED_OR_BE_ABSTRACT.registerFactory(addAbstractModifierFactory) + ABSTRACT_MEMBER_NOT_IMPLEMENTED.registerFactory(addAbstractModifierFactory) + MANY_IMPL_MEMBER_NOT_IMPLEMENTED.registerFactory(addAbstractModifierFactory) - QuickFixes.factories.put(MUST_BE_INITIALIZED_OR_BE_ABSTRACT, addAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_MEMBER_NOT_IMPLEMENTED, addAbstractModifierFactory); - QuickFixes.factories.put(MANY_IMPL_MEMBER_NOT_IMPLEMENTED, addAbstractModifierFactory); + val removeFinalModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(FINAL_KEYWORD) + val addAbstractToClassFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD, javaClass()) + ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.registerFactory(removeAbstractModifierFactory, addAbstractToClassFactory) - JetSingleIntentionActionFactory removeFinalModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(FINAL_KEYWORD); + ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.registerFactory(removeAbstractModifierFactory, addAbstractToClassFactory) - JetSingleIntentionActionFactory addAbstractToClassFactory = AddModifierFix.createFactory(ABSTRACT_KEYWORD, JetClass.class); - QuickFixes.factories.put(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, addAbstractToClassFactory); + val removeFunctionBodyFactory = RemoveFunctionBodyFix.createFactory() + ABSTRACT_FUNCTION_WITH_BODY.registerFactory(removeAbstractModifierFactory, removeFunctionBodyFactory) - JetSingleIntentionActionFactory removeFunctionBodyFactory = RemoveFunctionBodyFix.createFactory(); - QuickFixes.factories.put(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, addAbstractToClassFactory); + FINAL_PROPERTY_IN_TRAIT.registerFactory(removeFinalModifierFactory) + FINAL_FUNCTION_WITH_NO_BODY.registerFactory(removeFinalModifierFactory) - QuickFixes.factories.put(ABSTRACT_FUNCTION_WITH_BODY, removeAbstractModifierFactory); - QuickFixes.factories.put(ABSTRACT_FUNCTION_WITH_BODY, removeFunctionBodyFactory); + val addFunctionBodyFactory = AddFunctionBodyFix.createFactory() + NON_ABSTRACT_FUNCTION_WITH_NO_BODY.registerFactory(addAbstractModifierFactory, addFunctionBodyFactory) - QuickFixes.factories.put(FINAL_PROPERTY_IN_TRAIT, removeFinalModifierFactory); - QuickFixes.factories.put(FINAL_FUNCTION_WITH_NO_BODY, removeFinalModifierFactory); + NON_VARARG_SPREAD.registerFactory(RemovePsiElementSimpleFix.createRemoveSpreadFactory()) - JetSingleIntentionActionFactory addFunctionBodyFactory = AddFunctionBodyFix.createFactory(); - QuickFixes.factories.put(NON_ABSTRACT_FUNCTION_WITH_NO_BODY, addAbstractModifierFactory); - QuickFixes.factories.put(NON_ABSTRACT_FUNCTION_WITH_NO_BODY, addFunctionBodyFactory); + MIXING_NAMED_AND_POSITIONED_ARGUMENTS.registerFactory(AddNameToArgumentFix.createFactory()) - QuickFixes.factories.put(NON_VARARG_SPREAD, RemovePsiElementSimpleFix.createRemoveSpreadFactory()); + NON_MEMBER_FUNCTION_NO_BODY.registerFactory(addFunctionBodyFactory) - QuickFixes.factories.put(MIXING_NAMED_AND_POSITIONED_ARGUMENTS, AddNameToArgumentFix.createFactory()); + NOTHING_TO_OVERRIDE.registerFactory( RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OVERRIDE_KEYWORD), + ChangeMemberFunctionSignatureFix.createFactory(), + AddFunctionToSupertypeFix.createFactory()) + VIRTUAL_MEMBER_HIDDEN.registerFactory(AddModifierFix.createFactory(OVERRIDE_KEYWORD)) - QuickFixes.factories.put(NON_MEMBER_FUNCTION_NO_BODY, addFunctionBodyFactory); + USELESS_CAST.registerFactory(RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory("Remove cast")) + DEPRECATED_STATIC_ASSERT.registerFactory(RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory("Remove static type assertion")) - QuickFixes.factories.put(NOTHING_TO_OVERRIDE, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OVERRIDE_KEYWORD)); - QuickFixes.factories.put(NOTHING_TO_OVERRIDE, ChangeMemberFunctionSignatureFix.createFactory()); - QuickFixes.factories.put(NOTHING_TO_OVERRIDE, AddFunctionToSupertypeFix.createFactory()); - QuickFixes.factories.put(VIRTUAL_MEMBER_HIDDEN, AddModifierFix.createFactory(OVERRIDE_KEYWORD)); + val changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory() + WRONG_SETTER_PARAMETER_TYPE.registerFactory(changeAccessorTypeFactory) + WRONG_GETTER_RETURN_TYPE.registerFactory(changeAccessorTypeFactory) - QuickFixes.factories.put(USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory( - "Remove cast")); - QuickFixes.factories.put(DEPRECATED_STATIC_ASSERT, RemoveRightPartOfBinaryExpressionFix.createRemoveTypeFromBinaryExpressionFactory( - "Remove static type assertion")); + USELESS_ELVIS.registerFactory(RemoveRightPartOfBinaryExpressionFix.createRemoveElvisOperatorFactory()) - JetSingleIntentionActionFactory changeAccessorTypeFactory = ChangeAccessorTypeFix.createFactory(); - QuickFixes.factories.put(WRONG_SETTER_PARAMETER_TYPE, changeAccessorTypeFactory); - QuickFixes.factories.put(WRONG_GETTER_RETURN_TYPE, changeAccessorTypeFactory); + val removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true) + REDUNDANT_MODIFIER.registerFactory(removeRedundantModifierFactory) + ABSTRACT_MODIFIER_IN_TRAIT.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, true)) + OPEN_MODIFIER_IN_TRAIT.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD, true)) + TRAIT_CAN_NOT_BE_FINAL.registerFactory(removeFinalModifierFactory) + DEPRECATED_TRAIT_KEYWORD.registerFactory(DeprecatedTraitSyntaxFix, DeprecatedTraitSyntaxFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(USELESS_ELVIS, RemoveRightPartOfBinaryExpressionFix.createRemoveElvisOperatorFactory()); + REDUNDANT_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(true)) + INCOMPATIBLE_MODIFIERS.registerFactory(RemoveModifierFix.createRemoveModifierFactory(false)) + VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY.registerFactory(RemoveModifierFix.createRemoveVarianceFactory()) - JetSingleIntentionActionFactory removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFactory(true); - QuickFixes.factories.put(REDUNDANT_MODIFIER, removeRedundantModifierFactory); - QuickFixes.factories.put(ABSTRACT_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD, - true)); - QuickFixes.factories.put(OPEN_MODIFIER_IN_TRAIT, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD, true)); - QuickFixes.factories.put(TRAIT_CAN_NOT_BE_FINAL, removeFinalModifierFactory); - QuickFixes.factories.put(DEPRECATED_TRAIT_KEYWORD, DeprecatedTraitSyntaxFix.Companion); - QuickFixes.factories.put(DEPRECATED_TRAIT_KEYWORD, DeprecatedTraitSyntaxFix.Companion.createWholeProjectFixFactory()); + val removeOpenModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD) + NON_FINAL_MEMBER_IN_FINAL_CLASS.registerFactory(AddModifierFix.createFactory(OPEN_KEYWORD, javaClass()), + removeOpenModifierFactory) - QuickFixes.factories.put(REDUNDANT_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory(true)); - QuickFixes.factories.put(INCOMPATIBLE_MODIFIERS, RemoveModifierFix.createRemoveModifierFactory(false)); - QuickFixes.factories.put(VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY, RemoveModifierFix.createRemoveVarianceFactory()); + val removeModifierFactory = RemoveModifierFix.createRemoveModifierFactory() + GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY.registerFactory(removeModifierFactory) + REDUNDANT_MODIFIER_IN_GETTER.registerFactory(removeRedundantModifierFactory) + ILLEGAL_MODIFIER.registerFactory(removeModifierFactory) + REPEATED_MODIFIER.registerFactory(removeModifierFactory) - JetSingleIntentionActionFactory removeOpenModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD); - QuickFixes.factories.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, AddModifierFix.createFactory(OPEN_KEYWORD, JetClass.class)); - QuickFixes.factories.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, removeOpenModifierFactory); + val removeInnerModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(INNER_KEYWORD) + INNER_CLASS_IN_TRAIT.registerFactory(removeInnerModifierFactory) + INNER_CLASS_IN_OBJECT.registerFactory(removeInnerModifierFactory) - JetSingleIntentionActionFactory removeModifierFactory = RemoveModifierFix.createRemoveModifierFactory(); - QuickFixes.factories.put(GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY, removeModifierFactory); - QuickFixes.factories.put(REDUNDANT_MODIFIER_IN_GETTER, removeRedundantModifierFactory); - QuickFixes.factories.put(ILLEGAL_MODIFIER, removeModifierFactory); - QuickFixes.factories.put(REPEATED_MODIFIER, removeModifierFactory); + val changeToBackingFieldFactory = ChangeToBackingFieldFix.createFactory() + INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER.registerFactory(changeToBackingFieldFactory) + INITIALIZATION_USING_BACKING_FIELD_OPEN_SETTER.registerFactory(changeToBackingFieldFactory) - JetSingleIntentionActionFactory removeInnerModifierFactory = - RemoveModifierFix.createRemoveModifierFromListOwnerFactory(INNER_KEYWORD); - QuickFixes.factories.put(INNER_CLASS_IN_TRAIT, removeInnerModifierFactory); - QuickFixes.factories.put(INNER_CLASS_IN_OBJECT, removeInnerModifierFactory); + val changeToPropertyNameFactory = ChangeToPropertyNameFix.createFactory() + NO_BACKING_FIELD_ABSTRACT_PROPERTY.registerFactory(changeToPropertyNameFactory) + NO_BACKING_FIELD_CUSTOM_ACCESSORS.registerFactory(changeToPropertyNameFactory) + INACCESSIBLE_BACKING_FIELD.registerFactory(changeToPropertyNameFactory) - JetSingleIntentionActionFactory changeToBackingFieldFactory = ChangeToBackingFieldFix.createFactory(); - QuickFixes.factories.put(INITIALIZATION_USING_BACKING_FIELD_CUSTOM_SETTER, changeToBackingFieldFactory); - QuickFixes.factories.put(INITIALIZATION_USING_BACKING_FIELD_OPEN_SETTER, changeToBackingFieldFactory); + val unresolvedReferenceFactory = AutoImportFix.createFactory() + UNRESOLVED_REFERENCE.registerFactory(unresolvedReferenceFactory) + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(unresolvedReferenceFactory) - JetSingleIntentionActionFactory changeToPropertyNameFactory = ChangeToPropertyNameFix.createFactory(); - QuickFixes.factories.put(NO_BACKING_FIELD_ABSTRACT_PROPERTY, changeToPropertyNameFactory); - QuickFixes.factories.put(NO_BACKING_FIELD_CUSTOM_ACCESSORS, changeToPropertyNameFactory); - QuickFixes.factories.put(INACCESSIBLE_BACKING_FIELD, changeToPropertyNameFactory); + val removeImportFixFactory = RemovePsiElementSimpleFix.createRemoveImportFactory() + CONFLICTING_IMPORT.registerFactory(removeImportFixFactory) - JetSingleIntentionActionFactory unresolvedReferenceFactory = AutoImportFix.Companion.createFactory(); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, unresolvedReferenceFactory); - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, unresolvedReferenceFactory); + SUPERTYPE_NOT_INITIALIZED.registerFactory(SuperClassNotInitialized) + FUNCTION_CALL_EXPECTED.registerFactory(ChangeToFunctionInvocationFix.createFactory()) - JetSingleIntentionActionFactory removeImportFixFactory = RemovePsiElementSimpleFix.createRemoveImportFactory(); - QuickFixes.factories.put(CONFLICTING_IMPORT, removeImportFixFactory); + CANNOT_CHANGE_ACCESS_PRIVILEGE.registerFactory(ChangeVisibilityModifierFix.createFactory()) + CANNOT_WEAKEN_ACCESS_PRIVILEGE.registerFactory(ChangeVisibilityModifierFix.createFactory()) - QuickFixes.factories.put(SUPERTYPE_NOT_INITIALIZED, SuperClassNotInitialized.INSTANCE$); - QuickFixes.factories.put(FUNCTION_CALL_EXPECTED, ChangeToFunctionInvocationFix.createFactory()); + REDUNDANT_NULLABLE.registerFactory(RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.REDUNDANT)) + NULLABLE_SUPERTYPE.registerFactory(RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.SUPERTYPE)) + USELESS_NULLABLE_CHECK.registerFactory(RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.USELESS)) - QuickFixes.factories.put(CANNOT_CHANGE_ACCESS_PRIVILEGE, ChangeVisibilityModifierFix.createFactory()); - QuickFixes.factories.put(CANNOT_WEAKEN_ACCESS_PRIVILEGE, ChangeVisibilityModifierFix.createFactory()); - QuickFixes.factories.put(REDUNDANT_NULLABLE, RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.REDUNDANT)); - QuickFixes.factories.put(NULLABLE_SUPERTYPE, RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.SUPERTYPE)); - QuickFixes.factories.put(USELESS_NULLABLE_CHECK, RemoveNullableFix.createFactory(RemoveNullableFix.NullableKind.USELESS)); + val implementMethodsHandler = ImplementMethodsHandler() + ABSTRACT_MEMBER_NOT_IMPLEMENTED.registerActions(implementMethodsHandler) + MANY_IMPL_MEMBER_NOT_IMPLEMENTED.registerActions(implementMethodsHandler) + VAL_WITH_SETTER.registerFactory(ChangeVariableMutabilityFix.VAL_WITH_SETTER_FACTORY) + VAL_REASSIGNMENT.registerFactory(ChangeVariableMutabilityFix.VAL_REASSIGNMENT_FACTORY) + VAR_OVERRIDDEN_BY_VAL.registerFactory(ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY) - ImplementMethodsHandler implementMethodsHandler = new ImplementMethodsHandler(); - QuickFixes.actions.put(ABSTRACT_MEMBER_NOT_IMPLEMENTED, implementMethodsHandler); - QuickFixes.actions.put(MANY_IMPL_MEMBER_NOT_IMPLEMENTED, implementMethodsHandler); + val removeValVarFromParameterFixFactory = RemoveValVarFromParameterFix.createFactory() + VAL_OR_VAR_ON_FUN_PARAMETER.registerFactory(removeValVarFromParameterFixFactory) + VAL_OR_VAR_ON_LOOP_PARAMETER.registerFactory(removeValVarFromParameterFixFactory) + VAL_OR_VAR_ON_CATCH_PARAMETER.registerFactory(removeValVarFromParameterFixFactory) + VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER.registerFactory(removeValVarFromParameterFixFactory) - QuickFixes.factories.put(VAL_WITH_SETTER, ChangeVariableMutabilityFix.VAL_WITH_SETTER_FACTORY); - QuickFixes.factories.put(VAL_REASSIGNMENT, ChangeVariableMutabilityFix.VAL_REASSIGNMENT_FACTORY); - QuickFixes.factories.put(VAR_OVERRIDDEN_BY_VAL, ChangeVariableMutabilityFix.VAR_OVERRIDDEN_BY_VAL_FACTORY); + VIRTUAL_MEMBER_HIDDEN.registerFactory(AddOverrideToEqualsHashCodeToStringFix.createFactory()) - JetSingleIntentionActionFactory removeValVarFromParameterFixFactory = RemoveValVarFromParameterFix.createFactory(); - QuickFixes.factories.put(VAL_OR_VAR_ON_FUN_PARAMETER, removeValVarFromParameterFixFactory); - QuickFixes.factories.put(VAL_OR_VAR_ON_LOOP_PARAMETER, removeValVarFromParameterFixFactory); - QuickFixes.factories.put(VAL_OR_VAR_ON_CATCH_PARAMETER, removeValVarFromParameterFixFactory); - QuickFixes.factories.put(VAL_OR_VAR_ON_SECONDARY_CONSTRUCTOR_PARAMETER, removeValVarFromParameterFixFactory); + UNUSED_VARIABLE.registerFactory(RemovePsiElementSimpleFix.createRemoveVariableFactory()) - QuickFixes.factories.put(VIRTUAL_MEMBER_HIDDEN, AddOverrideToEqualsHashCodeToStringFix.createFactory()); + UNNECESSARY_SAFE_CALL.registerFactory(ReplaceWithDotCallFix) + UNSAFE_CALL.registerFactory(ReplaceWithSafeCallFix) - QuickFixes.factories.put(UNUSED_VARIABLE, RemovePsiElementSimpleFix.createRemoveVariableFactory()); + UNSAFE_CALL.registerFactory(AddExclExclCallFix) + UNNECESSARY_NOT_NULL_ASSERTION.registerFactory(RemoveExclExclCallFix) + UNSAFE_INFIX_CALL.registerFactory(ReplaceInfixCallFix.createFactory()) - QuickFixes.factories.put(UNNECESSARY_SAFE_CALL, ReplaceWithDotCallFix.Companion); - QuickFixes.factories.put(UNSAFE_CALL, ReplaceWithSafeCallFix.Companion); + val removeProtectedModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(PROTECTED_KEYWORD) + PACKAGE_MEMBER_CANNOT_BE_PROTECTED.registerFactory(removeProtectedModifierFactory) - QuickFixes.factories.put(UNSAFE_CALL, AddExclExclCallFix.Companion); - QuickFixes.factories.put(UNNECESSARY_NOT_NULL_ASSERTION, RemoveExclExclCallFix.Companion); - QuickFixes.factories.put(UNSAFE_INFIX_CALL, ReplaceInfixCallFix.createFactory()); + PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE.registerActions(SpecifyTypeExplicitlyFix()) + AMBIGUOUS_ANONYMOUS_TYPE_INFERRED.registerActions(SpecifyTypeExplicitlyFix()) - JetSingleIntentionActionFactory removeProtectedModifierFactory = RemoveModifierFix.createRemoveModifierFromListOwnerFactory(PROTECTED_KEYWORD); - QuickFixes.factories.put(PACKAGE_MEMBER_CANNOT_BE_PROTECTED, removeProtectedModifierFactory); + ELSE_MISPLACED_IN_WHEN.registerFactory(MoveWhenElseBranchFix.createFactory()) + NO_ELSE_IN_WHEN.registerFactory(AddWhenElseBranchFix.createFactory()) + BREAK_OR_CONTINUE_IN_WHEN.registerFactory(AddLoopLabelFix) - QuickFixes.actions.put(PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE, new SpecifyTypeExplicitlyFix()); - QuickFixes.actions.put(AMBIGUOUS_ANONYMOUS_TYPE_INFERRED, new SpecifyTypeExplicitlyFix()); + NO_TYPE_ARGUMENTS_ON_RHS.registerFactory(AddStarProjectionsFix.createFactoryForIsExpression()) + WRONG_NUMBER_OF_TYPE_ARGUMENTS.registerFactory(AddStarProjectionsFix.createFactoryForJavaClass()) - QuickFixes.factories.put(ELSE_MISPLACED_IN_WHEN, MoveWhenElseBranchFix.createFactory()); - QuickFixes.factories.put(NO_ELSE_IN_WHEN, AddWhenElseBranchFix.createFactory()); - QuickFixes.factories.put(BREAK_OR_CONTINUE_IN_WHEN, AddLoopLabelFix.Companion); + TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER.registerFactory(RemovePsiElementSimpleFix.createRemoveTypeArgumentsFactory()) - QuickFixes.factories.put(NO_TYPE_ARGUMENTS_ON_RHS, AddStarProjectionsFix.createFactoryForIsExpression()); - QuickFixes.factories.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, AddStarProjectionsFix.createFactoryForJavaClass()); + val changeToStarProjectionFactory = ChangeToStarProjectionFix.createFactory() + UNCHECKED_CAST.registerFactory(changeToStarProjectionFactory) + CANNOT_CHECK_FOR_ERASED.registerFactory(changeToStarProjectionFactory) - QuickFixes.factories.put(TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER, RemovePsiElementSimpleFix.createRemoveTypeArgumentsFactory()); + INACCESSIBLE_OUTER_CLASS_EXPRESSION.registerFactory(AddModifierFix.createFactory(INNER_KEYWORD, javaClass())) - JetSingleIntentionActionFactory changeToStarProjectionFactory = ChangeToStarProjectionFix.createFactory(); - QuickFixes.factories.put(UNCHECKED_CAST, changeToStarProjectionFactory); - QuickFixes.factories.put(CANNOT_CHECK_FOR_ERASED, changeToStarProjectionFactory); + val addOpenModifierToClassDeclarationFix = AddOpenModifierToClassDeclarationFix.createFactory() + FINAL_SUPERTYPE.registerFactory(addOpenModifierToClassDeclarationFix) + FINAL_UPPER_BOUND.registerFactory(addOpenModifierToClassDeclarationFix) - QuickFixes.factories.put(INACCESSIBLE_OUTER_CLASS_EXPRESSION, AddModifierFix.createFactory(INNER_KEYWORD, JetClass.class)); + OVERRIDING_FINAL_MEMBER.registerFactory(MakeOverriddenMemberOpenFix.createFactory()) - JetSingleIntentionActionFactory addOpenModifierToClassDeclarationFix = AddOpenModifierToClassDeclarationFix.createFactory(); - QuickFixes.factories.put(FINAL_SUPERTYPE, addOpenModifierToClassDeclarationFix); - QuickFixes.factories.put(FINAL_UPPER_BOUND, addOpenModifierToClassDeclarationFix); + PARAMETER_NAME_CHANGED_ON_OVERRIDE.registerFactory(RenameParameterToMatchOverriddenMethodFix.createFactory()) - QuickFixes.factories.put(OVERRIDING_FINAL_MEMBER, MakeOverriddenMemberOpenFix.createFactory()); + OPEN_MODIFIER_IN_ENUM.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD)) + ABSTRACT_MODIFIER_IN_ENUM.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD)) + ILLEGAL_ENUM_ANNOTATION.registerFactory(RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ENUM_KEYWORD)) - QuickFixes.factories.put(PARAMETER_NAME_CHANGED_ON_OVERRIDE, RenameParameterToMatchOverriddenMethodFix.createFactory()); + NESTED_CLASS_NOT_ALLOWED.registerFactory(AddModifierFix.createFactory(INNER_KEYWORD)) - QuickFixes.factories.put(OPEN_MODIFIER_IN_ENUM, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(OPEN_KEYWORD)); - QuickFixes.factories.put(ABSTRACT_MODIFIER_IN_ENUM, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ABSTRACT_KEYWORD)); - QuickFixes.factories.put(ILLEGAL_ENUM_ANNOTATION, RemoveModifierFix.createRemoveModifierFromListOwnerFactory(ENUM_KEYWORD)); + CONFLICTING_PROJECTION.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(false)) + PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(false)) + PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE.registerFactory(RemoveModifierFix.createRemoveProjectionFactory(false)) - QuickFixes.factories.put(NESTED_CLASS_NOT_ALLOWED, AddModifierFix.createFactory(INNER_KEYWORD)); + NOT_AN_ANNOTATION_CLASS.registerFactory(MakeClassAnAnnotationClassFix.createFactory()) - QuickFixes.factories.put(CONFLICTING_PROJECTION, RemoveModifierFix.createRemoveProjectionFactory(false)); - QuickFixes.factories.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, RemoveModifierFix.createRemoveProjectionFactory(false)); - QuickFixes.factories.put(PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE, RemoveModifierFix.createRemoveProjectionFactory(false)); + val changeVariableTypeFix = ChangeVariableTypeFix.createFactoryForPropertyOrReturnTypeMismatchOnOverride() + RETURN_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix) + PROPERTY_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(changeVariableTypeFix) + COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH.registerFactory(ChangeVariableTypeFix.createFactoryForComponentFunctionReturnTypeMismatch()) - QuickFixes.factories.put(NOT_AN_ANNOTATION_CLASS, MakeClassAnAnnotationClassFix.createFactory()); + val changeFunctionReturnTypeFix = ChangeFunctionReturnTypeFix.createFactoryForChangingReturnTypeToUnit() + RETURN_TYPE_MISMATCH.registerFactory(changeFunctionReturnTypeFix) + NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY.registerFactory(changeFunctionReturnTypeFix) + RETURN_TYPE_MISMATCH_ON_OVERRIDE.registerFactory(ChangeFunctionReturnTypeFix.createFactoryForReturnTypeMismatchOnOverride()) + COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH.registerFactory(ChangeFunctionReturnTypeFix.createFactoryForComponentFunctionReturnTypeMismatch()) + HAS_NEXT_FUNCTION_TYPE_MISMATCH.registerFactory(ChangeFunctionReturnTypeFix.createFactoryForHasNextFunctionTypeMismatch()) + COMPARE_TO_TYPE_MISMATCH.registerFactory(ChangeFunctionReturnTypeFix.createFactoryForCompareToTypeMismatch()) - JetIntentionActionsFactory changeVariableTypeFix = ChangeVariableTypeFix.createFactoryForPropertyOrReturnTypeMismatchOnOverride(); - QuickFixes.factories.put(RETURN_TYPE_MISMATCH_ON_OVERRIDE, changeVariableTypeFix); - QuickFixes.factories.put(PROPERTY_TYPE_MISMATCH_ON_OVERRIDE, changeVariableTypeFix); - QuickFixes.factories.put(COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, ChangeVariableTypeFix.createFactoryForComponentFunctionReturnTypeMismatch()); + TOO_MANY_ARGUMENTS.registerFactory(ChangeFunctionSignatureFix.createFactory()) + NO_VALUE_FOR_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactory()) + UNUSED_PARAMETER.registerFactory(ChangeFunctionSignatureFix.createFactoryForUnusedParameter()) + EXPECTED_PARAMETERS_NUMBER_MISMATCH.registerFactory(ChangeFunctionSignatureFix.createFactoryForParametersNumberMismatch()) + DEPRECATED_LAMBDA_SYNTAX.registerFactory(DeprecatedLambdaSyntaxFix, DeprecatedLambdaSyntaxFix.createWholeProjectFixFactory()) - JetSingleIntentionActionFactory changeFunctionReturnTypeFix = ChangeFunctionReturnTypeFix.createFactoryForChangingReturnTypeToUnit(); - QuickFixes.factories.put(RETURN_TYPE_MISMATCH, changeFunctionReturnTypeFix); - QuickFixes.factories.put(NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, changeFunctionReturnTypeFix); - QuickFixes.factories.put(RETURN_TYPE_MISMATCH_ON_OVERRIDE, ChangeFunctionReturnTypeFix.createFactoryForReturnTypeMismatchOnOverride()); - QuickFixes.factories.put(COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH, ChangeFunctionReturnTypeFix.createFactoryForComponentFunctionReturnTypeMismatch()); - QuickFixes.factories.put(HAS_NEXT_FUNCTION_TYPE_MISMATCH, ChangeFunctionReturnTypeFix.createFactoryForHasNextFunctionTypeMismatch()); - QuickFixes.factories.put(COMPARE_TO_TYPE_MISMATCH, ChangeFunctionReturnTypeFix.createFactoryForCompareToTypeMismatch()); + EXPECTED_PARAMETER_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedParameterTypeMismatch()) + EXPECTED_RETURN_TYPE_MISMATCH.registerFactory(ChangeTypeFix.createFactoryForExpectedReturnTypeMismatch()) - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, ChangeFunctionSignatureFix.createFactory()); - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, ChangeFunctionSignatureFix.createFactory()); - QuickFixes.factories.put(UNUSED_PARAMETER, ChangeFunctionSignatureFix.createFactoryForUnusedParameter()); - QuickFixes.factories.put(EXPECTED_PARAMETERS_NUMBER_MISMATCH, ChangeFunctionSignatureFix.createFactoryForParametersNumberMismatch()); - QuickFixes.factories.put(DEPRECATED_LAMBDA_SYNTAX, DeprecatedLambdaSyntaxFix.Factory); - QuickFixes.factories.put(DEPRECATED_LAMBDA_SYNTAX, DeprecatedLambdaSyntaxFix.Factory.createWholeProjectFixFactory()); + val changeFunctionLiteralReturnTypeFix = ChangeFunctionLiteralReturnTypeFix.createFactoryForExpectedOrAssignmentTypeMismatch() + EXPECTED_TYPE_MISMATCH.registerFactory(changeFunctionLiteralReturnTypeFix) + ASSIGNMENT_TYPE_MISMATCH.registerFactory(changeFunctionLiteralReturnTypeFix) - QuickFixes.factories.put(EXPECTED_PARAMETER_TYPE_MISMATCH, ChangeTypeFix.createFactoryForExpectedParameterTypeMismatch()); - QuickFixes.factories.put(EXPECTED_RETURN_TYPE_MISMATCH, ChangeTypeFix.createFactoryForExpectedReturnTypeMismatch()); + UNRESOLVED_REFERENCE.registerFactory(CreateUnaryOperationActionFactory) + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateUnaryOperationActionFactory) + NO_VALUE_FOR_PARAMETER.registerFactory(CreateUnaryOperationActionFactory) - JetSingleIntentionActionFactory changeFunctionLiteralReturnTypeFix = ChangeFunctionLiteralReturnTypeFix.createFactoryForExpectedOrAssignmentTypeMismatch(); - QuickFixes.factories.put(EXPECTED_TYPE_MISMATCH, changeFunctionLiteralReturnTypeFix); - QuickFixes.factories.put(ASSIGNMENT_TYPE_MISMATCH, changeFunctionLiteralReturnTypeFix); + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateBinaryOperationActionFactory) + UNRESOLVED_REFERENCE.registerFactory(CreateBinaryOperationActionFactory) + NONE_APPLICABLE.registerFactory(CreateBinaryOperationActionFactory) + NO_VALUE_FOR_PARAMETER.registerFactory(CreateBinaryOperationActionFactory) + TOO_MANY_ARGUMENTS.registerFactory(CreateBinaryOperationActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateUnaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateUnaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateUnaryOperationActionFactory.INSTANCE$); + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateCallableFromCallActionFactory) + UNRESOLVED_REFERENCE.registerFactory(CreateCallableFromCallActionFactory) + NO_VALUE_FOR_PARAMETER.registerFactory(CreateCallableFromCallActionFactory) + TOO_MANY_ARGUMENTS.registerFactory(CreateCallableFromCallActionFactory) + EXPRESSION_EXPECTED_PACKAGE_FOUND.registerFactory(CreateCallableFromCallActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateBinaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateBinaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(NONE_APPLICABLE, CreateBinaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateBinaryOperationActionFactory.INSTANCE$); - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateBinaryOperationActionFactory.INSTANCE$); + NO_VALUE_FOR_PARAMETER.registerFactory(CreateConstructorFromDelegationCallActionFactory) + TOO_MANY_ARGUMENTS.registerFactory(CreateConstructorFromDelegationCallActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateCallableFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateCallableFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateCallableFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateCallableFromCallActionFactory.INSTANCE$); - QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateCallableFromCallActionFactory.INSTANCE$); + NO_VALUE_FOR_PARAMETER.registerFactory(CreateConstructorFromDelegatorToSuperCallActionFactory) + TOO_MANY_ARGUMENTS.registerFactory(CreateConstructorFromDelegatorToSuperCallActionFactory) - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateConstructorFromDelegationCallActionFactory.INSTANCE$); - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateConstructorFromDelegationCallActionFactory.INSTANCE$); + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateClassFromConstructorCallActionFactory) + UNRESOLVED_REFERENCE.registerFactory(CreateClassFromConstructorCallActionFactory) + EXPRESSION_EXPECTED_PACKAGE_FOUND.registerFactory(CreateClassFromConstructorCallActionFactory) - QuickFixes.factories.put(NO_VALUE_FOR_PARAMETER, CreateConstructorFromDelegatorToSuperCallActionFactory.INSTANCE$); - QuickFixes.factories.put(TOO_MANY_ARGUMENTS, CreateConstructorFromDelegatorToSuperCallActionFactory.INSTANCE$); + UNRESOLVED_REFERENCE.registerFactory(CreateLocalVariableActionFactory) + EXPRESSION_EXPECTED_PACKAGE_FOUND.registerFactory(CreateLocalVariableActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateClassFromConstructorCallActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromConstructorCallActionFactory.INSTANCE$); - QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateClassFromConstructorCallActionFactory.INSTANCE$); + UNRESOLVED_REFERENCE.registerFactory(CreateParameterActionFactory) + UNRESOLVED_REFERENCE_WRONG_RECEIVER.registerFactory(CreateParameterActionFactory) + EXPRESSION_EXPECTED_PACKAGE_FOUND.registerFactory(CreateParameterActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateLocalVariableActionFactory.INSTANCE$); - QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateLocalVariableActionFactory.INSTANCE$); + NAMED_PARAMETER_NOT_FOUND.registerFactory(CreateParameterByNamedArgumentActionFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateParameterActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE_WRONG_RECEIVER, CreateParameterActionFactory.INSTANCE$); - QuickFixes.factories.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, CreateParameterActionFactory.INSTANCE$); + FUNCTION_EXPECTED.registerFactory(CreateInvokeFunctionActionFactory) - QuickFixes.factories.put(NAMED_PARAMETER_NOT_FOUND, CreateParameterByNamedArgumentActionFactory.INSTANCE$); + val factoryForTypeMismatchError = QuickFixFactoryForTypeMismatchError() + TYPE_MISMATCH.registerFactory(factoryForTypeMismatchError) + NULL_FOR_NONNULL_TYPE.registerFactory(factoryForTypeMismatchError) + CONSTANT_EXPECTED_TYPE_MISMATCH.registerFactory(factoryForTypeMismatchError) - QuickFixes.factories.put(FUNCTION_EXPECTED, CreateInvokeFunctionActionFactory.INSTANCE$); + SMARTCAST_IMPOSSIBLE.registerFactory(CastExpressionFix.createFactoryForSmartCastImpossible()) - QuickFixFactoryForTypeMismatchError factoryForTypeMismatchError = new QuickFixFactoryForTypeMismatchError(); - QuickFixes.factories.put(TYPE_MISMATCH, factoryForTypeMismatchError); - QuickFixes.factories.put(NULL_FOR_NONNULL_TYPE, factoryForTypeMismatchError); - QuickFixes.factories.put(CONSTANT_EXPECTED_TYPE_MISMATCH, factoryForTypeMismatchError); + PLATFORM_CLASS_MAPPED_TO_KOTLIN.registerFactory(MapPlatformClassToKotlinFix.createFactory()) - QuickFixes.factories.put(SMARTCAST_IMPOSSIBLE, CastExpressionFix.createFactoryForSmartCastImpossible()); + MANY_CLASSES_IN_SUPERTYPE_LIST.registerFactory(RemoveSupertypeFix.createFactory()) - QuickFixes.factories.put(PLATFORM_CLASS_MAPPED_TO_KOTLIN, MapPlatformClassToKotlinFix.createFactory()); + NO_GET_METHOD.registerFactory(CreateGetFunctionActionFactory) + NO_SET_METHOD.registerFactory(CreateSetFunctionActionFactory) + HAS_NEXT_MISSING.registerFactory(CreateHasNextFunctionActionFactory) + HAS_NEXT_FUNCTION_NONE_APPLICABLE.registerFactory(CreateHasNextFunctionActionFactory) + NEXT_MISSING.registerFactory(CreateNextFunctionActionFactory) + NEXT_NONE_APPLICABLE.registerFactory(CreateNextFunctionActionFactory) + ITERATOR_MISSING.registerFactory(CreateIteratorFunctionActionFactory) + COMPONENT_FUNCTION_MISSING.registerFactory(CreateComponentFunctionActionFactory) - QuickFixes.factories.put(MANY_CLASSES_IN_SUPERTYPE_LIST, RemoveSupertypeFix.createFactory()); + DELEGATE_SPECIAL_FUNCTION_MISSING.registerFactory(CreatePropertyDelegateAccessorsActionFactory) + DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE.registerFactory(CreatePropertyDelegateAccessorsActionFactory) - QuickFixes.factories.put(NO_GET_METHOD, CreateGetFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(NO_SET_METHOD, CreateSetFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(HAS_NEXT_MISSING, CreateHasNextFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(HAS_NEXT_FUNCTION_NONE_APPLICABLE, CreateHasNextFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(NEXT_MISSING, CreateNextFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(NEXT_NONE_APPLICABLE, CreateNextFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(ITERATOR_MISSING, CreateIteratorFunctionActionFactory.INSTANCE$); - QuickFixes.factories.put(COMPONENT_FUNCTION_MISSING, CreateComponentFunctionActionFactory.INSTANCE$); + UNRESOLVED_REFERENCE.registerFactory(CreateClassFromTypeReferenceActionFactory, + CreateClassFromReferenceExpressionActionFactory, + CreateClassFromCallWithConstructorCalleeActionFactory) - QuickFixes.factories.put(DELEGATE_SPECIAL_FUNCTION_MISSING, CreatePropertyDelegateAccessorsActionFactory.INSTANCE$); - QuickFixes.factories.put(DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE, CreatePropertyDelegateAccessorsActionFactory.INSTANCE$); + PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED.registerFactory(InsertDelegationCallQuickfix.InsertThisDelegationCallFactory) - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromTypeReferenceActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromReferenceExpressionActionFactory.INSTANCE$); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, CreateClassFromCallWithConstructorCalleeActionFactory.INSTANCE$); + EXPLICIT_DELEGATION_CALL_REQUIRED.registerFactory(InsertDelegationCallQuickfix.InsertThisDelegationCallFactory) + EXPLICIT_DELEGATION_CALL_REQUIRED.registerFactory(InsertDelegationCallQuickfix.InsertSuperDelegationCallFactory) - QuickFixes.factories.put(PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED, InsertDelegationCallQuickfix.InsertThisDelegationCallFactory.INSTANCE$); + ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL.registerFactory(MigrateAnnotationMethodCallFix, + MigrateAnnotationMethodCallInWholeFile) - QuickFixes.factories.put(EXPLICIT_DELEGATION_CALL_REQUIRED, InsertDelegationCallQuickfix.InsertThisDelegationCallFactory.INSTANCE$); - QuickFixes.factories.put(EXPLICIT_DELEGATION_CALL_REQUIRED, InsertDelegationCallQuickfix.InsertSuperDelegationCallFactory.INSTANCE$); + ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR.registerFactory(DeprecatedEnumEntrySuperConstructorSyntaxFix, + DeprecatedEnumEntrySuperConstructorSyntaxFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL, MigrateAnnotationMethodCallFix.Companion); - QuickFixes.factories.put(ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL, MigrateAnnotationMethodCallInWholeFile.Companion); + ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER.registerFactory(DeprecatedEnumEntryDelimiterSyntaxFix, + DeprecatedEnumEntryDelimiterSyntaxFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR, DeprecatedEnumEntrySuperConstructorSyntaxFix.Companion); - QuickFixes.factories.put(ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR, DeprecatedEnumEntrySuperConstructorSyntaxFix.Companion.createWholeProjectFixFactory()); + MISSING_CONSTRUCTOR_KEYWORD.registerFactory(MissingConstructorKeywordFix, + MissingConstructorKeywordFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER, DeprecatedEnumEntryDelimiterSyntaxFix.Companion); - QuickFixes.factories.put(ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER, DeprecatedEnumEntryDelimiterSyntaxFix.Companion.createWholeProjectFixFactory()); + FUNCTION_EXPRESSION_WITH_NAME.registerFactory(RemoveNameFromFunctionExpressionFix, + RemoveNameFromFunctionExpressionFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(MISSING_CONSTRUCTOR_KEYWORD, MissingConstructorKeywordFix.Companion); - QuickFixes.factories.put(MISSING_CONSTRUCTOR_KEYWORD, MissingConstructorKeywordFix.Companion.createWholeProjectFixFactory()); + UNRESOLVED_REFERENCE.registerFactory(ReplaceObsoleteLabelSyntaxFix, + ReplaceObsoleteLabelSyntaxFix.createWholeProjectFixFactory()) - QuickFixes.factories.put(FUNCTION_EXPRESSION_WITH_NAME, RemoveNameFromFunctionExpressionFix.Companion); - QuickFixes.factories.put(FUNCTION_EXPRESSION_WITH_NAME, RemoveNameFromFunctionExpressionFix.Companion.createWholeProjectFixFactory()); + DEPRECATED_SYMBOL_WITH_MESSAGE.registerFactory(DeprecatedSymbolUsageFix, + DeprecatedSymbolUsageInWholeProjectFix) - QuickFixes.factories.put(UNRESOLVED_REFERENCE, ReplaceObsoleteLabelSyntaxFix.Companion); - QuickFixes.factories.put(UNRESOLVED_REFERENCE, ReplaceObsoleteLabelSyntaxFix.Companion.createWholeProjectFixFactory()); - - QuickFixes.factories.put(DEPRECATED_SYMBOL_WITH_MESSAGE, DeprecatedSymbolUsageFix.Companion); - QuickFixes.factories.put(DEPRECATED_SYMBOL_WITH_MESSAGE, DeprecatedSymbolUsageInWholeProjectFix.Companion); - - QuickFixes.factories.put(ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, ReplaceJavaAnnotationPositionedArgumentsFix.Companion); + ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix) } } From 7386ea0d0b9af274437d04c277fcc762cd4c9e0c Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 8 Jul 2015 16:26:17 +0300 Subject: [PATCH 118/450] Avoid counting directory parent for file --- .../frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java | 7 ++++++- .../kotlin/idea/caches/resolve/KotlinResolveCache.kt | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java index d84168d11b3..2d95ad9d0e6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiUtil.java @@ -373,8 +373,13 @@ public class JetPsiUtil { @Nullable @Contract("null, _ -> null") - public static PsiElement getTopmostParentOfTypes(@Nullable PsiElement element, @NotNull Class... parentTypes) { + public static PsiElement getTopmostParentOfTypes( + @Nullable PsiElement element, + @NotNull Class... parentTypes) { + if (element instanceof PsiFile) return null; + PsiElement answer = PsiTreeUtil.getParentOfType(element, parentTypes); + if (answer instanceof PsiFile) return answer; do { PsiElement next = PsiTreeUtil.getParentOfType(answer, parentTypes); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt index 4a5179f8c2d..5e5d613a099 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt @@ -21,6 +21,7 @@ import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.IndexNotReadyException import com.intellij.openapi.project.Project import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.PsiModificationTracker @@ -195,6 +196,8 @@ private object KotlinResolveDataProvider { ) fun findAnalyzableParent(element: JetElement): JetElement { + if (element is JetFile) return element + val topmostElement = JetPsiUtil.getTopmostParentOfTypes(element, *topmostElementTypes) as JetElement? // parameters and supertype lists are not analyzable by themselves, but if we don't count them as topmost, we'll stop inside, say, // object expressions inside arguments of super constructors of classes (note that classes themselves are not topmost elements) From 4d6ab824c8e07de57694111932aaf27cff56ef4b Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 5 May 2015 19:01:16 +0300 Subject: [PATCH 119/450] Adding Java descriptors to the test data for nullability warnings --- .../nullabilityWarnings/arithmetic.kt | 5 +---- .../nullabilityWarnings/arithmetic.txt | 12 +++++++++++ .../nullabilityWarnings/array.kt | 5 +---- .../nullabilityWarnings/array.txt | 12 +++++++++++ .../nullabilityWarnings/assignToVar.kt | 5 +---- .../nullabilityWarnings/assignToVar.txt | 16 +++++++++++++-- .../nullabilityWarnings/conditions.kt | 5 +---- .../nullabilityWarnings/conditions.txt | 12 +++++++++++ .../nullabilityWarnings/dataFlowInfo.kt | 5 +---- .../nullabilityWarnings/dataFlowInfo.txt | 13 +++++++++++- .../nullabilityWarnings/defaultParameters.kt | 5 +---- .../nullabilityWarnings/defaultParameters.txt | 12 +++++++++++ .../delegatedProperties.kt | 5 +---- .../delegatedProperties.txt | 20 +++++++++++++++++++ .../nullabilityWarnings/delegation.kt | 5 +---- .../nullabilityWarnings/delegation.txt | 12 +++++++++++ .../nullabilityWarnings/derefenceExtension.kt | 5 +---- .../derefenceExtension.txt | 16 +++++++++++++-- .../nullabilityWarnings/derefenceMember.kt | 5 +---- .../nullabilityWarnings/derefenceMember.txt | 13 ++++++++++++ .../nullabilityWarnings/elvis.kt | 5 +---- .../nullabilityWarnings/elvis.txt | 12 +++++++++++ .../nullabilityWarnings/expectedType.kt | 5 +---- .../nullabilityWarnings/expectedType.txt | 12 +++++++++++ .../platformTypes/nullabilityWarnings/for.kt | 5 +---- .../platformTypes/nullabilityWarnings/for.txt | 12 +++++++++++ .../nullabilityWarnings/functionArguments.kt | 5 +---- .../nullabilityWarnings/functionArguments.txt | 16 +++++++++++++-- .../inferenceInConditionals.kt | 6 +----- .../inferenceInConditionals.txt | 15 +++++++++++--- .../nullabilityWarnings/invoke.kt | 5 +---- .../nullabilityWarnings/invoke.txt | 20 +++++++++++++++++++ .../nullabilityWarnings/kt6829.kt | 5 +---- .../nullabilityWarnings/kt6829.txt | 10 +++++++++- .../nullabilityWarnings/multiDeclaration.kt | 5 +---- .../nullabilityWarnings/multiDeclaration.txt | 20 +++++++++++++++++++ .../notNullAfterSafeCall.kt | 6 +----- .../notNullAfterSafeCall.txt | 10 +++++++++- .../nullabilityWarnings/notNullAssertion.kt | 5 +---- .../nullabilityWarnings/notNullAssertion.txt | 12 +++++++++++ .../notNullAssertionInCall.kt | 5 +---- .../notNullAssertionInCall.txt | 10 ++++++++++ ...notNullTypeMarkedWithNullableAnnotation.kt | 6 +----- ...otNullTypeMarkedWithNullableAnnotation.txt | 10 +++++++++- .../nullabilityWarnings/passToJava.kt | 5 +---- .../nullabilityWarnings/passToJava.txt | 20 ++++++++++++++++++- .../nullabilityWarnings/primitiveArray.kt | 5 +---- .../nullabilityWarnings/primitiveArray.txt | 12 +++++++++++ .../nullabilityWarnings/safeCall.kt | 5 +---- .../nullabilityWarnings/safeCall.txt | 13 ++++++++++++ .../senselessComparisonEquals.kt | 5 +---- .../senselessComparisonEquals.txt | 12 +++++++++++ .../senselessComparisonIdentityEquals.kt | 5 +---- .../senselessComparisonIdentityEquals.txt | 12 +++++++++++ .../nullabilityWarnings/throw.kt | 5 +---- .../nullabilityWarnings/throw.txt | 12 +++++++++++ .../nullabilityWarnings/uselessElvisInCall.kt | 5 +---- .../uselessElvisInCall.txt | 10 ++++++++++ 58 files changed, 403 insertions(+), 133 deletions(-) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt index 43aa5abd3d0..31a29d95c56 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type var platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt index b8def46715c..7144141c3ca 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.Int! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Int! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Int! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt index 2dce002aff8..928f061ef8d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt index b8def46715c..5fd62c6b767 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.Array<(out) kotlin.Int!>! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Array<(out) kotlin.Int!>! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Array<(out) kotlin.Int!>! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt index 600db661622..478a0ae9708 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - var v: J = J() var n: J? = J() diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt index b258b62a31a..4715dbb23bc 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt @@ -1,5 +1,17 @@ package -internal var n: p.J? -internal var v: p.J +internal var n: J? +internal var v: J internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt index 4e875c499b7..c9e785bb6d3 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -14,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt index b8def46715c..65c7261ddc6 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.Boolean! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Boolean! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Boolean! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt index eb1fd9521cd..e716abbe6a8 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { val n = J.staticN foo(n) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt index 7719efbbb09..64f161d3f05 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt @@ -1,4 +1,15 @@ package -internal fun foo(/*0*/ j: p.J): kotlin.Unit +internal fun foo(/*0*/ j: J): kotlin.Unit internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt index b9cbbe9a057..3cbba78872d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -14,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt index 19bf516c533..e413b1e74fd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -19,8 +18,6 @@ public class J { // FILE: k.kt -import p.* - var A by J.staticNN var B by J.staticN var C by J.staticJ \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt index be11c83820c..4face54f705 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt @@ -3,3 +3,23 @@ package internal var A: kotlin.String! internal var B: kotlin.String! internal var C: kotlin.String! + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public trait DP { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun get(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun set(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!, /*2*/ c: kotlin.Any!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var staticJ: J.DP! + org.jetbrains.annotations.Nullable() public final var staticN: J.DP! + org.jetbrains.annotations.NotNull() public final var staticNN: J.DP! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt index 38f22824d4b..bf012440dde 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; import java.util.*; @@ -14,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - class A : List by J.staticNN class B : List by J.staticN class C : List by J.staticJ \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt index 8088400d541..c3c73d2853b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt @@ -53,3 +53,15 @@ internal final class C : kotlin.List { public open override /*1*/ /*delegation*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.List public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.(Mutable)List! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt index 0c61dbac4c3..5c96709c95e 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt index e909556b47c..71f08415efa 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt @@ -2,5 +2,17 @@ package internal fun test(): kotlin.Unit internal fun with(/*0*/ t: T, /*1*/ f: T.() -> kotlin.Unit): kotlin.Unit -internal fun p.J?.bar(): kotlin.Unit -internal fun p.J.foo(): kotlin.Unit +internal fun J?.bar(): kotlin.Unit +internal fun J.foo(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt index 0ccc1a0b2fc..b0f108a737b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -17,8 +16,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt index 7e19ffea500..8c9b73aa0f6 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt @@ -2,3 +2,16 @@ package internal fun test(): kotlin.Unit internal fun with(/*0*/ t: T, /*1*/ f: T.() -> kotlin.Unit): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.kt index 7ec695beb29..6dcd4b4aeaa 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -SENSELESS_COMPARISON -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt index 0cdc5c96fce..5001e655040 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt @@ -1,7 +1,6 @@ // !CHECK_TYPE -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt index bb5589537e6..d15f6d928aa 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; import java.util.*; @@ -14,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt index b8def46715c..011c6034370 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.(Mutable)List! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt index dcca95d883d..228464fceba 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -14,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { foo(J.staticNN) foo(J.staticN) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt index febe9fdde72..818aef0eb85 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt @@ -1,5 +1,17 @@ package -internal fun bar(/*0*/ j: p.J?): kotlin.Unit -internal fun foo(/*0*/ j: p.J): kotlin.Unit +internal fun bar(/*0*/ j: J?): kotlin.Unit +internal fun foo(/*0*/ j: J): kotlin.Unit internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.kt index 2028b23d1f4..a35af95498a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.kt @@ -1,6 +1,4 @@ -// FILE: p/J.java - -package p; +// FILE: J.java import org.jetbrains.annotations.*; import java.util.*; @@ -15,8 +13,6 @@ public class J { // FILE: k.kt -import p.* - fun safeCall(c: J?) { c?.nn()?.length() } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt index 3cd68f13413..3ed6cbe4fb4 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt @@ -1,5 +1,14 @@ package -internal fun elvis(/*0*/ c: p.J): kotlin.Any? -internal fun ifelse(/*0*/ c: p.J): kotlin.Any? -internal fun safeCall(/*0*/ c: p.J?): kotlin.Unit +internal fun elvis(/*0*/ c: J): kotlin.Any? +internal fun ifelse(/*0*/ c: J): kotlin.Any? +internal fun safeCall(/*0*/ c: J?): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List! + org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt index d7fdcac56eb..0b055a57320 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -17,8 +16,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { J.staticNN() J.staticN() diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt index b8def46715c..fec729f8aa7 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt @@ -1,3 +1,23 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public trait Invoke { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var staticJ: J.Invoke! + org.jetbrains.annotations.Nullable() public final var staticN: J.Invoke! + org.jetbrains.annotations.NotNull() public final var staticNN: J.Invoke! + public final /*synthesized*/ fun Invoke(/*0*/ function: () -> kotlin.Unit): J.Invoke +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt index 21129c3c083..9d76a42b010 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt @@ -2,8 +2,7 @@ // KT-6829 False warning on map to @Nullable -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun foo(collection: Collection) { val mapped = collection.map { it.method() } mapped[0].length() diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt index 066df5f85b8..099ffe5132d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt @@ -1,4 +1,12 @@ package -internal fun foo(/*0*/ collection: kotlin.Collection): kotlin.Unit +internal fun foo(/*0*/ collection: kotlin.Collection): kotlin.Unit public fun kotlin.Iterable.map(/*0*/ transform: (T) -> R): kotlin.List + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + org.jetbrains.annotations.Nullable() public open fun method(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt index c7ddde2a2b6..977f804794b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt @@ -1,6 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -19,8 +18,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt index b8def46715c..66977b314a7 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt @@ -1,3 +1,23 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public trait Multi { + public abstract fun component1(): kotlin.String! + public abstract fun component2(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var staticJ: J.Multi! + org.jetbrains.annotations.Nullable() public final var staticN: J.Multi! + org.jetbrains.annotations.NotNull() public final var staticNN: J.Multi! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.kt index 47bd945635a..420dc45a990 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.kt @@ -1,6 +1,4 @@ -// FILE: p/J.java - -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -10,8 +8,6 @@ public class J { // FILE: k.kt -import p.J - fun test(j: J?) { val s = j?.nn() if (s != null) { diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt index 4811fa11f1a..95590d06e57 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt @@ -1,3 +1,11 @@ package -internal fun test(/*0*/ j: p.J?): kotlin.Unit +internal fun test(/*0*/ j: J?): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.kt index 8d882af3213..75a31645695 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -SENSELESS_COMPARISON -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.kt index 42d5c782d80..7c4f02a8cd2 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -12,8 +11,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt index 79f259ce9cb..adf9031c655 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt @@ -10,3 +10,13 @@ internal final class Bar { internal final fun invoke(/*0*/ a: kotlin.Any): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.kt index 2c396a46367..40515b7c858 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.kt @@ -1,6 +1,4 @@ -// FILE: p/J.java - -package p; +// FILE: J.java import org.jetbrains.annotations.*; import java.util.*; @@ -12,8 +10,6 @@ public class J { // FILE: k.kt -import p.* - fun list(j: J): Any { val a = j.n()!! diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt index 8059f2c7f76..aea2df5eedd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt @@ -1,3 +1,11 @@ package -internal fun list(/*0*/ j: p.J): kotlin.Any +internal fun list(/*0*/ j: J): kotlin.Any + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt index 89f3a61f6f2..257badf0b86 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -26,8 +25,6 @@ public class J { // FILE: k.kt -import p.* - fun test(n: J?, nn: J) { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt index 468c30694dc..f1c3b9d5460 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt @@ -1,3 +1,21 @@ package -internal fun test(/*0*/ n: p.J?, /*1*/ nn: p.J): kotlin.Unit +internal fun test(/*0*/ n: J?, /*1*/ nn: J): kotlin.Unit + +public open class J { + public constructor J() + public constructor J(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!) + public final var j: J! + org.jetbrains.annotations.Nullable() public final var n: J! + org.jetbrains.annotations.NotNull() public final var nn: J! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun set(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! + public open fun staticSet(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt index 84a3c69f789..75d088a0078 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt index b8def46715c..ff4baf160aa 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: kotlin.IntArray! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.IntArray! + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.IntArray! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.kt index 9c20b759ae9..0e3cb21c2fe 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -SENSELESS_COMPARISON -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -17,8 +16,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt index b8def46715c..c29fb5ad665 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt @@ -1,3 +1,16 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.kt index 468ff5c4959..3e16583b802 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.kt index 6cab5d050bd..ee64b8d261e 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_EXPRESSION -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -15,8 +14,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt index b8def46715c..34903ffd954 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt @@ -1,3 +1,15 @@ package internal fun test(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: J! + org.jetbrains.annotations.Nullable() public final var staticN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt index 9d74d623335..38ac1551f4f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt @@ -1,5 +1,4 @@ -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -13,8 +12,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { throw J.staticNN } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt index 324eef14d41..27c21d877a9 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt @@ -3,3 +3,15 @@ package internal fun test(): kotlin.Unit internal fun test1(): kotlin.Unit internal fun test2(): kotlin.Unit + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final var staticJ: java.lang.Exception! + org.jetbrains.annotations.Nullable() public final var staticN: java.lang.Exception! + org.jetbrains.annotations.NotNull() public final var staticNN: java.lang.Exception! +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.kt index 230514a1596..ab1f846dcbf 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.kt @@ -1,7 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -// FILE: p/J.java -package p; +// FILE: J.java import org.jetbrains.annotations.*; @@ -12,8 +11,6 @@ public class J { // FILE: k.kt -import p.* - fun test() { // @NotNull platform type val platformNN = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt index 79f259ce9cb..adf9031c655 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt @@ -10,3 +10,13 @@ internal final class Bar { internal final fun invoke(/*0*/ a: kotlin.Any): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + +public open class J { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + org.jetbrains.annotations.NotNull() public final var staticNN: J! +} From 64866183f7f1419623d76d27c7a2fa4d38b5d39c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 26 Feb 2015 18:44:12 +0300 Subject: [PATCH 120/450] Spec for enhancing Java declarations with annotations --- spec-docs/flexible-java-types.md | 258 ++++++++++++++++++++++++++++++- 1 file changed, 257 insertions(+), 1 deletion(-) diff --git a/spec-docs/flexible-java-types.md b/spec-docs/flexible-java-types.md index 232206c920d..d7381dd81dc 100644 --- a/spec-docs/flexible-java-types.md +++ b/spec-docs/flexible-java-types.md @@ -139,4 +139,260 @@ The compiler issues warnings specific to `@Nullable`/`@NotNull` in the following - a `@Nullable` value is assigned to a not-null location (including passing parameters and receivers to functions/properties); - a nullable value is assigned to a `@NotNull` location; - a `@NotNull` value is dereferenced with a safe call (`?.`), used in `!!` or on the left-hand side of an elvis operator `?:`; - - a `@NotNull` value is compared with `null` through `==`, `!=`, `===` or `!==` \ No newline at end of file + - a `@NotNull` value is compared with `null` through `==`, `!=`, `===` or `!==` + +## More precise type information from annotations + +Goals: + - Catch more errors related to nullability in case of Java interop + - Keep all class hierarchies consistent at all times (no hierarchy errors related to incorrect annotations) + - (!) If the code compiled with annotations, it should always compile without annotations (because external annotations may disappear) + + This process never results in errors. On any mismatch, a bare platform signature is used (and a warning issued). + +### Annotations recognized by the compiler + +- `org.jetbrains.annotations.Nullable` - value may be null/accepts nulls +- `org.jetbrains.annotations.NotNull` - value can not be null/passing null leads to an exception +- `org.jetbrains.annotations.ReadOnly` - only non-mutating methods can be used on this collection/iterable/iterator +- `org.jetbrains.annotations.Mutable` - mutating methods can be used on this collection/iterable/iterator +- `kotlin.jvm.KotlinSignature(str)` - `str` is a string representation of a more precise signature + +See [appendix](#appendix) for more details + +### Enhancing signatures with annotated declarations + +NOTE: the intention is that if the enhanced signature is not compatible with the overridden signatures from superclasses, +it is discarded, and a warning is issued. We also would like to discard only the mismatching parts of the signature, and thus keep as +much information as possible. + +Example: + +``` java +class Super { + void foo(@NotNull String p) {...} +} + +class Sub extends Super { + @Override + void foo(@Nullable String p) {...} // Warning: Signature does not match the one in the superclass, discarded +} +``` + +#### @KotlinSignature + +``` java +package kotlin.jvm; + +@Target({ElementType.METHOD, ElementType.TYPE, ElementType.CONSTRUCTOR, ElementType.FIELD}) +public @interface KotlinSignature { + String value(); +} +``` + +Usage: + +``` java +class C { + @KotlinSignature("fun foo(): MutableList") + List foo() { ... } +} + +``` + +Name resolution: `@KotlinSignature` can use short names from types, because full names are already specified in respective positions in +the Java signature. + +- If there's a `@KotlinSignature` annotation, other annotations are ignored +- If erasure of the signature specified by `@KotlinSignature` differs from the actual erased signature, + a warning is reported and the `@KotlinSignature` annotation is ignored +- Otherwise, the signature from `@KotlinSignature` is used. + +#### @Nullable, @NotNull, @ReadOnly, @Mutable + +What can be annotated: + - field: annotation applies to its type + - method: annotation applies to its return type + - parameter: annotation applies to its type + - type (in Java 8): annotation applies to this type + +Consider a type `(L..U?)`. Nullability annotations enhance it in the following way: + - `@Nullable`: `(L?..U?)` + - `@NotNull`: `(L..U)` + +Note that if upper and lower bound of a flexible type are the same, it is replaced by the bounds (e.g. `(T?..T?) => T?`) + +Consider a collection type `(MC..C?)` (upper bound may be nullable or not). Mutability annotations enhance it in the following way: + - `@ReadOnly`: `(C..C?)` + - `@Mutable`: `(MC..MC?)` + +Nullability annotations are applied after mutability annotations. + +Examples: + +| Java | Kotlin| +|------|-------| +| `Foo` | `Foo!` | +| `@Nullable Foo` | `Foo?` | +| `@NotNull Foo` | `Foo` | +| `List` | `(Mutable)List!` | +| `@ReadOnly List` | `List!` | +| `@Mutable List` | `MutableList!` | +| `@NotNull @Mutable List` | `MutableList` | +| `@Nullable @ReadOnly List` | `List?` | + +*NOTE*: array types are never flattened: `@NotNull Object[]` becomes `(Array..Array)`. + +### Propagating type information from superclasses + +A signature is represented as a list of its parts: + - upper bounds of type parameters + - value parameter types + - return type + +Enhancement rules (the result of their application is called a *propagated signature*) for each part: + - collect annotations from all supertypes and the override in the subclass + - for parts other than return type (which may be covariantly overridden) if there are conflicts (`@Nullable` together with `@NotNull` or + `@ReadOnly` together with `@Mutable`), discard the respective annotations and issue appropriate warnings + - for return types (only the 0-index, see below): + - fist, take annotations from supertypes, and among them: if there's `@NotNull`, discard `@Nullable`, if there's `@Mutable` discard `@ReadOnly` + - then if in the subtype there's `@Nullable` and in the supertype there's `@NotNull`, discard the nullability annotations (analogously, + for mutability annotations) + - apply the annotations and check compatibility with all parts from supertypes, if there's any incompatibility, issue a warning and take + a platform type + +> NOTE: Only flexible types are enhanced, because we want to avoid cases like this +``` java + void foo(@Nullable int x) {...} +``` +this code is incorrect, but Java does not reject it, so if we see this as a Kotlin declaration +``` kotlin + fun foo(x: Int?) +``` +we can't even call it properly (this, in theory, can be worked around by storing pure Java signatures alongside Kotlin ones). + +Detecting annotations on parts from supertypes: + - consider all types have the form of `(L..U)`, where an inflexible type `T` is written `(T..T)` + - if `L` is nullable, say that `@Nullable` annotation is present + - if `U` is not-null, say that `@NotNull` is present + - if `L` is a read-only collection/iterable/iterator type, say that `@ReadOnly` is present + - if `U` is a mutable collection/iterable/iterator type, say that `@Mutable` is present + +Examples: + +``` java +interface A { + @NotNull + String foo(@NotNull String p); +} + +interface B { + @Nullable + String foo(@Nullable String p); +} + +interface C extends A, B { + // this is an override in Java, but would not be an override in Kotlin because of a conflict in parameter types: String vs String? + // Thus, the resulting descriptor is + // fun foo(p: String!): String + // return type is covariantly enhanced to not-null, + // a warning issued about the parameter + + @Override + String foo(String p); +} +``` + +Other cases: + +``` +R foo(@NotNull P p) // super A +R foo(P p) // super B +R foo(P p) // subclass C + +// Result: +fun foo(p: P): R! // parameter type propagated from A +``` + +``` +R foo(@NotNull P p) // super A +R foo(P p) // super B +R foo(@Nullable P p) // subclass C + +// Result: +fun foo(p: P!): R! // conflict on parameter between A and C +``` + +``` +R foo(P p) // super A +R foo(P p) // super B +R foo(@NotNull P p) // subclass C + +// Result: +fun foo(p: P): R! // parameter type specified in C, no conflict with superclasses +``` + +``` +@NotNull +R foo(P p) // super A +R foo(P p) // super B +@Nullable +R foo(P p) // subclass C + +// Result: +fun foo(p: P!): R! // conflict on return type: subtype wants a nullable, but not-null already promised +``` + +``` +R foo(@NotNull @ReadOnly List p) // super A +R foo(@Nullable @ReadOnly List p) // subclass B + +// Result: +fun foo(p: List!): R! // conflict on nullability, no conflict on mutability +``` + +``` +fun foo(MutableList p): R // super A, written in Kotlin or has @KotlinSignature +@Nullable +R foo(List p) // subclass B + +// Result: +fun foo(MutableList p): R! // parameter propagated from superclass (@Mutable, @NotNull), conflict on return type +``` + +*NOTE*: nullability warnings should still be reported in the Kotlin code in case of discarding the enhancing information due to conflicts. + +**Propagation into generic arguments**. Since annotations have to be propagated to type arguments as well as the head type constructor, +the following procedure is used. First, every sub-tree of the type is assigned an index which is its zero-based position in the textual +representation of the type (`0` is root). Example: for `A>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C, 3 - D, 4 - E`, +which corresponds to the left-to-right breadth-first walk of the tree representation of the type. For flexible types, both bounds are indexed +in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. Now, in the aforementioned procedure, annotations are collected and +considered *at each index*, and only index 0 of the return type is considered as possibly covariant (this is done for simplicity). + +Example: + - `Mutable(List)!` + - `Mutable(List)!` + - 0: `Mutable(List)!`, `Mutable(List)!` + - 1: `A!`, `A!`, `A?`, `A?` + +NOTE: if the set of descriptors overridden by the resulting enhanced signature differs from the set overridden by the platform signature, +the enhanced signature must be discarded and a warning issued. + +Checklist: + - any platform signature should override any enhanced/propagated signature created for the same member or one of its overridden. + +### Appendix + +We can also support the following annotations out-of-the-box: +* [`android.support.annotation`](https://developer.android.com/reference/android/support/annotation/package-summary.html) + * [`android.support.annotation.Nullable`](https://developer.android.com/reference/android/support/annotation/Nullable.html) + * [`android.support.annotation.NonNull`](https://developer.android.com/reference/android/support/annotation/NonNull.html) +* From [FindBugs](http://findbugs.sourceforge.net/manual/annotations.html) and [`javax.annotation`](https://code.google.com/p/jsr-305/source/browse/trunk/ri/src/main/java/javax/annotation/) + * `*.annotations.CheckForNull` + * `*.NonNull` + * `*.Nullable` +* [`javax.validation.constraints`](http://docs.oracle.com/javaee/6/api/javax/validation/constraints/package-summary.html) + * `NotNull` and `NotNull.List` +* [Project Lombok](http://projectlombok.org/features/NonNull.html) +* [`org.eclipse.jdt.annotation`](https://wiki.eclipse.org/JDT_Core/Null_Analysis) +* [`org.checkerframework.checker.nullness.qual`](http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#nullness-checker) From a6a099b0f54680d9b3371a4977a9000b0d5eda05 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 18 Jun 2015 10:28:36 +0300 Subject: [PATCH 121/450] Fix flexible type rendering Do not append "!" if bounds have same nullability --- .../propagation/parameter/InheritNotVararg.txt | 2 +- .../propagation/parameter/InheritNotVarargInteger.txt | 2 +- .../propagation/parameter/InheritNotVarargNotNull.txt | 2 +- .../propagation/parameter/InheritVararg.txt | 2 +- .../propagation/parameter/InheritVarargInteger.txt | 2 +- .../propagation/parameter/InheritVarargNotNull.txt | 2 +- .../jetbrains/kotlin/renderer/DescriptorRendererImpl.kt | 9 +++++++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVararg.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVararg.txt index d5c09e06b57..2e95f51a5ee 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVararg.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVararg.txt @@ -4,7 +4,7 @@ public interface InheritNotVararg { public interface Sub : test.InheritNotVararg.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p0: (kotlin.Array?..kotlin.Array?)): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p0: kotlin.Array<(out) kotlin.String!>?): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargInteger.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargInteger.txt index dc659f6a6ad..a8db63ba808 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargInteger.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargInteger.txt @@ -4,7 +4,7 @@ public interface InheritNotVarargInteger { public interface Sub : test.InheritNotVarargInteger.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p0: (kotlin.Array?..kotlin.Array?)): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p0: kotlin.Array<(out) kotlin.Int!>?): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargNotNull.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargNotNull.txt index fc338970c32..aafe1541a83 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargNotNull.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNotVarargNotNull.txt @@ -4,7 +4,7 @@ public interface InheritNotVarargNotNull { public interface Sub : test.InheritNotVarargNotNull.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p: (kotlin.Array?..kotlin.Array?)): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p: kotlin.Array<(out) kotlin.String!>?): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVararg.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVararg.txt index c020a7d2089..6939cfb447f 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVararg.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVararg.txt @@ -4,7 +4,7 @@ public interface InheritVararg { public interface Sub : test.InheritVararg.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ vararg p0: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ vararg p0: kotlin.String! /*kotlin.Array<(out) kotlin.String!>*/): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargInteger.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargInteger.txt index 85b925cd3ad..1751f272446 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargInteger.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargInteger.txt @@ -4,7 +4,7 @@ public interface InheritVarargInteger { public interface Sub : test.InheritVarargInteger.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ vararg p0: kotlin.Int! /*kotlin.Array<(out) kotlin.Int!>!*/): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ vararg p0: kotlin.Int! /*kotlin.Array<(out) kotlin.Int!>*/): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargNotNull.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargNotNull.txt index ec47d07815c..ed8a0965ecb 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargNotNull.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritVarargNotNull.txt @@ -4,7 +4,7 @@ public interface InheritVarargNotNull { public interface Sub : test.InheritVarargNotNull.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ vararg p: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ vararg p: kotlin.String! /*kotlin.Array<(out) kotlin.String!>*/): kotlin.Unit } public interface Super { diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 6678fa46a11..0c0d18d43b3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -870,8 +870,13 @@ internal class DescriptorRendererImpl( private fun replacePrefixes(lowerRendered: String, lowerPrefix: String, upperRendered: String, upperPrefix: String, foldedPrefix: String): String? { if (lowerRendered.startsWith(lowerPrefix) && upperRendered.startsWith(upperPrefix)) { val lowerWithoutPrefix = lowerRendered.substring(lowerPrefix.length()) - if (differsOnlyInNullability(lowerWithoutPrefix, upperRendered.substring(upperPrefix.length()))) { - return foldedPrefix + lowerWithoutPrefix + "!" + val upperWithoutPrefix = upperRendered.substring(upperPrefix.length()) + val flexibleCollectionName = foldedPrefix + lowerWithoutPrefix + + if (lowerWithoutPrefix == upperWithoutPrefix) return flexibleCollectionName + + if (differsOnlyInNullability(lowerWithoutPrefix, upperWithoutPrefix)) { + return flexibleCollectionName + "!" } } return null From 2de3a3b59e03d19331db6c0ccf921b69842fb362 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 7 Apr 2015 16:35:04 +0300 Subject: [PATCH 122/450] Minor. Rename addToScope -> addFakeOverride --- .../jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt | 2 +- .../kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt | 2 +- .../kotlin/load/java/components/DescriptorResolverUtils.java | 2 +- .../jetbrains/kotlin/builtins/functions/FunctionClassScope.kt | 2 +- .../descriptors/impl/EnumEntrySyntheticClassDescriptor.java | 2 +- .../src/org/jetbrains/kotlin/resolve/OverridingUtil.java | 4 ++-- .../descriptors/DeserializedClassDescriptor.kt | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt index 03730eff4d2..4b466be340e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt @@ -164,7 +164,7 @@ class CollectionStubMethodGenerator( val result = ArrayList() OverrideResolver.generateOverridesInAClass(klass, listOf(), object : OverridingUtil.DescriptorSink { - override fun addToScope(fakeOverride: CallableMemberDescriptor) { + override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { if (fakeOverride !is FunctionDescriptor) return if (fakeOverride.findOverriddenFromDirectSuperClass(mutableCollectionClass) != null) { result.add(fakeOverride) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt index 9d9c9ffa469..281951e026c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassMemberScope.kt @@ -99,7 +99,7 @@ public open class LazyClassMemberScope( private fun generateFakeOverrides(name: Name, fromSupertypes: Collection, result: MutableCollection, exactDescriptorClass: Class) { OverridingUtil.generateOverridesInFunctionGroup(name, fromSupertypes, ArrayList(result), thisDescriptor, object : OverridingUtil.DescriptorSink { - override fun addToScope(fakeOverride: CallableMemberDescriptor) { + override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { assert(exactDescriptorClass.isInstance(fakeOverride)) { "Wrong descriptor type in an override: " + fakeOverride + " while expecting " + exactDescriptorClass.getSimpleName() } @suppress("UNCHECKED_CAST") result.add(fakeOverride as D) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java index 5339279af47..bc930f714a6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/DescriptorResolverUtils.java @@ -54,7 +54,7 @@ public final class DescriptorResolverUtils { new OverridingUtil.DescriptorSink() { @Override @SuppressWarnings("unchecked") - public void addToScope(@NotNull CallableMemberDescriptor fakeOverride) { + public void addFakeOverride(@NotNull CallableMemberDescriptor fakeOverride) { OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, new Function1() { @Override public Unit invoke(@NotNull CallableMemberDescriptor descriptor) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt index 13b68e0d240..1efe3d2b79e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt @@ -64,7 +64,7 @@ class FunctionClassScope( /* membersFromCurrent = */ if (name == invoke?.getName()) listOf(invoke) else listOf(), functionClass, object : OverridingUtil.DescriptorSink { - override fun addToScope(fakeOverride: CallableMemberDescriptor) { + override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, null) result.add(fakeOverride as FunctionDescriptor) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index 9ea7d184fd2..d8090db79f1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -235,7 +235,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { new OverridingUtil.DescriptorSink() { @Override @SuppressWarnings("unchecked") - public void addToScope(@NotNull CallableMemberDescriptor fakeOverride) { + public void addFakeOverride(@NotNull CallableMemberDescriptor fakeOverride) { OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, null); result.add((D) fakeOverride); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java index 32dd748c5bd..ab6175cb5ad 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/OverridingUtil.java @@ -356,7 +356,7 @@ public class OverridingUtil { for (CallableMemberDescriptor descriptor : effectiveOverridden) { bindOverride(fakeOverride, descriptor); } - sink.addToScope(fakeOverride); + sink.addFakeOverride(fakeOverride); } @NotNull @@ -569,7 +569,7 @@ public class OverridingUtil { } public interface DescriptorSink { - void addToScope(@NotNull CallableMemberDescriptor fakeOverride); + void addFakeOverride(@NotNull CallableMemberDescriptor fakeOverride); void conflict(@NotNull CallableMemberDescriptor fromSuper, @NotNull CallableMemberDescriptor fromCurrent); } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index 1244c3f7e11..f9bb831697b 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -203,7 +203,7 @@ public class DeserializedClassDescriptor( private fun generateFakeOverrides(name: Name, fromSupertypes: Collection, result: MutableCollection) { val fromCurrent = ArrayList(result) OverridingUtil.generateOverridesInFunctionGroup(name, fromSupertypes, fromCurrent, classDescriptor, object : OverridingUtil.DescriptorSink { - override fun addToScope(fakeOverride: CallableMemberDescriptor) { + override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { // TODO: report "cannot infer visibility" OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, null) @suppress("UNCHECKED_CAST") From 579ca9c1f230f6757ff82e48aa21f962d85a8231 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Mon, 13 Apr 2015 13:28:42 +0300 Subject: [PATCH 123/450] Minor. Typo --- .../kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 536569cb0ae..6859304e46f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -348,7 +348,7 @@ public abstract class LazyJavaMemberScope( p.println(javaClass.getSimpleName(), " {") p.pushIndent() - p.println("containigDeclaration: ${getContainingDeclaration()}") + p.println("containingDeclaration: ${getContainingDeclaration()}") p.popIndent() p.println("}") From d140e83386e50abe927da57d5458ee07d306bd76 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 15 Apr 2015 14:11:50 +0300 Subject: [PATCH 124/450] Minor. Methods renamed to reflect tha fact that they handle more types than just collections --- .../SignaturesPropagationData.java | 21 ++++++++++--------- .../java/lazy/types/LazyJavaTypeResolver.kt | 2 +- .../kotlin/platform/JavaToKotlinClassMap.java | 4 ++-- .../jetbrains/kotlin/idea/util/TypeUtils.kt | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java index ab1fe1d5c54..510ae307971 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/kotlinSignature/SignaturesPropagationData.java @@ -158,12 +158,13 @@ public class SignaturesPropagationData { if (JvmPackage.getPLATFORM_TYPES()) return autoType; List typesFromSuperMethods = ContainerUtil.map(superFunctions, - new Function() { - @Override - public TypeAndVariance fun(FunctionDescriptor superFunction) { - return new TypeAndVariance(superFunction.getReturnType(), Variance.OUT_VARIANCE); - } - }); + new Function() { + @Override + public TypeAndVariance fun(FunctionDescriptor superFunction) { + return new TypeAndVariance(superFunction.getReturnType(), + Variance.OUT_VARIANCE); + } + }); return modifyTypeAccordingToSuperMethods(autoType, typesFromSuperMethods, MEMBER_SIGNATURE_COVARIANT); } @@ -629,10 +630,10 @@ public class SignaturesPropagationData { if (classifierFromSuper instanceof ClassDescriptor) { ClassDescriptor classFromSuper = (ClassDescriptor) classifierFromSuper; - if (JavaToKotlinClassMap.INSTANCE.isMutableCollection(classFromSuper)) { + if (JavaToKotlinClassMap.INSTANCE.isMutable(classFromSuper)) { someSupersMutable = true; } - else if (JavaToKotlinClassMap.INSTANCE.isReadOnlyCollection(classFromSuper)) { + else if (JavaToKotlinClassMap.INSTANCE.isReadOnly(classFromSuper)) { if (typeFromSuper.varianceOfPosition == Variance.OUT_VARIANCE) { someSupersCovariantReadOnly = true; } @@ -648,12 +649,12 @@ public class SignaturesPropagationData { return classifier; } else if (someSupersMutable) { - if (JavaToKotlinClassMap.INSTANCE.isReadOnlyCollection(klass)) { + if (JavaToKotlinClassMap.INSTANCE.isReadOnly(klass)) { return JavaToKotlinClassMap.INSTANCE.convertReadOnlyToMutable(klass); } } else if (someSupersNotCovariantReadOnly || someSupersCovariantReadOnly) { - if (JavaToKotlinClassMap.INSTANCE.isMutableCollection(klass)) { + if (JavaToKotlinClassMap.INSTANCE.isMutable(klass)) { return JavaToKotlinClassMap.INSTANCE.convertMutableToReadOnly(klass); } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index 4d46b4913be..3d0e1db82c0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -162,7 +162,7 @@ class LazyJavaTypeResolver( val kotlinDescriptor = javaToKotlin.mapJavaToKotlin(fqName) ?: return null if (howThisTypeIsUsedEffectively == MEMBER_SIGNATURE_COVARIANT || howThisTypeIsUsedEffectively == SUPERTYPE) { - if (javaToKotlin.isReadOnlyCollection(kotlinDescriptor)) { + if (javaToKotlin.isReadOnly(kotlinDescriptor)) { return javaToKotlin.convertReadOnlyToMutable(kotlinDescriptor) } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java index 51100339bc1..72462feb817 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java @@ -182,11 +182,11 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap { return className.isSafe() ? mapPlatformClass(className.toSafe()) : Collections.emptySet(); } - public boolean isMutableCollection(@NotNull ClassDescriptor mutable) { + public boolean isMutable(@NotNull ClassDescriptor mutable) { return mutableToReadOnly.containsKey(mutable); } - public boolean isReadOnlyCollection(@NotNull ClassDescriptor readOnly) { + public boolean isReadOnly(@NotNull ClassDescriptor readOnly) { return readOnlyToMutable.containsKey(readOnly); } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt index f69c29cee03..2b9061816df 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt @@ -43,7 +43,7 @@ public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true) if (jetType.isFlexible()) { val flexible = jetType.flexibility() val lowerClass = flexible.lowerBound.getConstructor().getDeclarationDescriptor() as? ClassDescriptor? - val isCollection = lowerClass != null && JavaToKotlinClassMap.INSTANCE.isMutableCollection(lowerClass) + val isCollection = lowerClass != null && JavaToKotlinClassMap.INSTANCE.isMutable(lowerClass) // (Mutable)Collection! -> MutableCollection? // Foo<(Mutable)Collection!>! -> Foo>? // Foo! -> Foo? From e095162c1970d496acfac3021b389b8f9c682217 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 15 Apr 2015 18:25:56 +0300 Subject: [PATCH 125/450] Minor. Dictionary --- .idea/dictionaries/abreslav.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.idea/dictionaries/abreslav.xml b/.idea/dictionaries/abreslav.xml index a5f9f22a06f..9035118b0b9 100644 --- a/.idea/dictionaries/abreslav.xml +++ b/.idea/dictionaries/abreslav.xml @@ -2,12 +2,14 @@ accessor + covariantly deserialized dominator inferrer iterable nondeterministic nullable + overridable pseudocode substitutor subtyping From 991f0fcf2e1d3167724a4ce53abbf4d17ea24b00 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 15 Apr 2015 18:25:13 +0300 Subject: [PATCH 126/450] Type enhancement and qualifier extraction --- .../load/java/components/typeEnhancement.kt | 78 ++++++++++++ .../load/java/components/typeQualifiers.kt | 113 ++++++++++++++++++ .../kotlin/platform/JavaToKotlinClassMap.java | 12 ++ 3 files changed, 203 insertions(+) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt new file mode 100644 index 00000000000..e85c342c1c7 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt @@ -0,0 +1,78 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.components + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE +import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY +import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL +import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE +import org.jetbrains.kotlin.platform.JavaToKotlinClassMap +import org.jetbrains.kotlin.types.* + + +fun JetType.enhance(qualifiers: JavaTypeQualifiers): JetType { + val mutabilityEnhanced = + if (this.isFlexible()) + this.flexibility().enhanceMutability(qualifiers.mutability) + else this + return mutabilityEnhanced.enhanceNullability(qualifiers.nullability) +} + +private fun Flexibility.enhanceMutability(qualifier: MutabilityQualifier?): JetType { + val mapping = JavaToKotlinClassMap.INSTANCE + + val (newLower, newUpper) = run { + when (qualifier) { + READ_ONLY -> { + val lowerClass = TypeUtils.getClassDescriptor(lowerBound) + if (lowerClass != null && mapping.isMutable(lowerClass)) { + return@run Pair(lowerBound.replaceClass(mapping.convertMutableToReadOnly(lowerClass)), upperBound) + } + } + MUTABLE -> { + val upperClass = TypeUtils.getClassDescriptor(upperBound) + if (upperClass != null && mapping.isReadOnly(upperClass) ) { + return@run Pair(lowerBound, upperBound.replaceClass(mapping.convertReadOnlyToMutable(upperClass))) + } + } + } + return@run Pair(lowerBound, upperBound) + } + + return DelegatingFlexibleType.create(newLower, newUpper, extraCapabilities) +} + +private fun JetType.enhanceNullability(qualifier: NullabilityQualifier?): JetType { + return when (qualifier) { + NULLABLE -> TypeUtils.makeNullable(this) + NOT_NULL -> TypeUtils.makeNotNullable(this) + else -> this + } +} + +private fun JetType.replaceClass(newClass: ClassDescriptor): JetType { + assert(newClass.getTypeConstructor().getParameters().size() == getArguments().size(), + {"Can't replace type constructor ${getConstructor()} by ${newClass}: type parameter count does not match"}) + return JetTypeImpl( + getAnnotations(), + newClass.getTypeConstructor(), + isMarkedNullable(), + getArguments(), + newClass.getMemberScope(getArguments()) + ) +} \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt new file mode 100644 index 00000000000..a95f22544c9 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt @@ -0,0 +1,113 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.components + +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.load.java.JvmAnnotationNames +import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE +import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY +import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL +import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.platform.JavaToKotlinClassMap +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.flexibility +import org.jetbrains.kotlin.types.isFlexible + +enum class NullabilityQualifier { + NULLABLE, + NOT_NULL +} + +val NULLABLE_ANNOTATIONS = listOf( + JvmAnnotationNames.JETBRAINS_NULLABLE_ANNOTATION +) + +val NOT_NULL_ANNOTATIONS = listOf( + JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION +) + +enum class MutabilityQualifier { + READ_ONLY, + MUTABLE +} + +val READ_ONLY_ANNOTATIONS = listOf( + JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION +) + +val MUTABLE_ANNOTATIONS = listOf( + JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION +) + +class JavaTypeQualifiers( + val nullability: NullabilityQualifier?, + val mutability: MutabilityQualifier? +) + +private fun JetType.extractQualifiers(): JavaTypeQualifiers { + val (lower, upper) = + if (this.isFlexible()) + flexibility().let { Pair(it.lowerBound, it.upperBound) } + else Pair(this, this) + + val mapping = JavaToKotlinClassMap.INSTANCE + return JavaTypeQualifiers( + if (lower.isMarkedNullable()) NULLABLE else if (!upper.isMarkedNullable()) NOT_NULL else null, + if (mapping.isReadOnly(lower)) READ_ONLY else if (mapping.isMutable(upper)) MUTABLE else null + ) +} + +private fun Annotations.extractQualifiers(): JavaTypeQualifiers { + fun List.ifPresent(qualifier: T) = if (any { findAnnotation(it) != null}) qualifier else null + fun singleNotNull(x: T?, y: T?) = if (x == null || y == null) x ?: y else null + + return JavaTypeQualifiers( + singleNotNull(NULLABLE_ANNOTATIONS.ifPresent(NULLABLE), NOT_NULL_ANNOTATIONS.ifPresent(NOT_NULL)), + singleNotNull(READ_ONLY_ANNOTATIONS.ifPresent(READ_ONLY), MUTABLE_ANNOTATIONS.ifPresent(MUTABLE)) + ) +} + +fun JetType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { + val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet() + val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet() + val own = getAnnotations().extractQualifiers() + + if (isCovariant) { + fun Set.selectCovariantly(low: T, high: T, own: T?): T? { + val supertypeQualifier = if (low in this) low else if (high in this) high else null + return if (supertypeQualifier == low && own == high) null else own ?: supertypeQualifier + } + return JavaTypeQualifiers( + nullabilityFromSupertypes.selectCovariantly(NOT_NULL, NULLABLE, own.nullability), + mutabilityFromSupertypes.selectCovariantly(MUTABLE, READ_ONLY, own.mutability) + ) + } + else { + fun Set.selectInvariantly(own: T?): T? { + val effectiveSet = own?.let { (this + own).toSet() } ?: this + // if this set contains exactly one element, it is the qualifier everybody agrees upon, + // otherwise (no qualifiers, or multiple qualifiers), there's no single such qualifier + // and all qualifiers are discarded + return effectiveSet.singleOrNull() + } + return JavaTypeQualifiers( + nullabilityFromSupertypes.selectInvariantly(own.nullability), + mutabilityFromSupertypes.selectInvariantly(own.mutability) + ) + } +} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java index 72462feb817..fee5cb32198 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java @@ -29,6 +29,8 @@ import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType; +import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.types.TypeUtils; import java.lang.annotation.Annotation; import java.util.*; @@ -186,10 +188,20 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap { return mutableToReadOnly.containsKey(mutable); } + public boolean isMutable(@NotNull JetType type) { + ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); + return classDescriptor != null && isMutable(classDescriptor); + } + public boolean isReadOnly(@NotNull ClassDescriptor readOnly) { return readOnlyToMutable.containsKey(readOnly); } + public boolean isReadOnly(@NotNull JetType type) { + ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); + return classDescriptor != null && isReadOnly(classDescriptor); + } + @NotNull public ClassDescriptor convertMutableToReadOnly(@NotNull ClassDescriptor mutable) { ClassDescriptor readOnly = mutableToReadOnly.get(mutable); From f376b2ba70d2df18fbbd614158991b661cc1d4d0 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 17 Apr 2015 13:15:06 +0300 Subject: [PATCH 127/450] Stub infrastructure for enhancing platform signatures --- .../TraceBasedExternalSignatureResolver.java | 9 ++++++- .../java/components/signatureEnhancement.kt | 24 +++++++++++++++++++ .../components/ExternalSignatureResolver.java | 13 ++++++++++ .../lazy/descriptors/LazyJavaMemberScope.kt | 6 +++-- 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java index af409f32f2c..617e2abae38 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.load.java.components; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; @@ -36,6 +37,7 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationDat import org.jetbrains.kotlin.types.JetType; import javax.inject.Inject; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -134,4 +136,9 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors) { trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor, signatureErrors); } -} + + @Override + public Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures) { + return ComponentsPackage.enhanceSignatures(platformSignatures); + } +} \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt new file mode 100644 index 00000000000..faac03716e7 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.components + +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor + +fun enhanceSignatures(platformSignatures: Collection): Collection { + // TODO: implement + return platformSignatures +} \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java index 338adf9e7d5..673f1de131a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java @@ -18,12 +18,14 @@ package org.jetbrains.kotlin.load.java.components; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.load.java.structure.JavaField; import org.jetbrains.kotlin.load.java.structure.JavaMember; import org.jetbrains.kotlin.load.java.structure.JavaMethod; import org.jetbrains.kotlin.types.JetType; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -73,6 +75,11 @@ public interface ExternalSignatureResolver { public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors) { throw new UnsupportedOperationException("Should not be called"); } + + @Override + public Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures) { + return platformSignatures; + } }; abstract class MemberSignature { @@ -201,4 +208,10 @@ public interface ExternalSignatureResolver { ); void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors); + + /** + * Replaces some items in the {@code platformSignatures} collection with enhanced signatures. + * Is called after binding overrides, so the implementation is allowed to inspect contents of getOverriddenDescriptors() + */ + Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 6859304e46f..ee88fb2de79 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -86,14 +86,16 @@ public abstract class LazyJavaMemberScope( computeNonDeclaredFunctions(result, name) + val enhancedResult = c.externalSignatureResolver.enhanceSignatures(result) + // Make sure that lazy things are computed before we release the lock - for (f in result) { + for (f in enhancedResult) { for (p in f.getValueParameters()) { p.hasDefaultValue() } } - result.toReadOnlyList() + enhancedResult.toReadOnlyList() } protected data class MethodSignatureData( From 61da419c4a820be7189e70e7e0842a03e545f114 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 17 Apr 2015 15:41:41 +0300 Subject: [PATCH 128/450] Spec: account for problematic cases (some unsolved yet) --- spec-docs/flexible-java-types.md | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/spec-docs/flexible-java-types.md b/spec-docs/flexible-java-types.md index d7381dd81dc..74b190488ce 100644 --- a/spec-docs/flexible-java-types.md +++ b/spec-docs/flexible-java-types.md @@ -381,6 +381,48 @@ the enhanced signature must be discarded and a warning issued. Checklist: - any platform signature should override any enhanced/propagated signature created for the same member or one of its overridden. +### Problematic cases of Java inheritance + +**Case 1**. Fake override for conflicting signatures with the same erasure: + +``` +// Kotlin +trait A { + fun foo(x: String) +} + +trait B { + fun foo(x: String?) +} + +// Java +interface JC extends A, B {} + +// Kotlin + +class D : JC { + // how to override both foo(String) and foo(String?) in this class? +} +``` + +Possible solution: make fake overrides generated for Java class have platform signatures and perform normal enhancement for them + +**Case 2**. Inheriting a property through a Java class + +It may be overridden by a Java function, for example + +**Case 3**. Inheriting an extension function/property through a Java class + +Explicit override(s) may also interfere. + +**Case 4**. Raw types interfering with override-compatibility of Java signatures with Kotlin ones + +**Case 5**. Order of type parameters in Java methods matters only partly + +The first parameter matters, others may come in any order. + +See also: [KT-7496](https://youtrack.jetbrains.com/issue/KT-7496) + ### Appendix We can also support the following annotations out-of-the-box: From 4248654f5f64dba080e26fabb39f972f4e69e605 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 17 Apr 2015 18:22:02 +0300 Subject: [PATCH 129/450] Signature enhancement: most basic version implemented --- .../java/components/signatureEnhancement.kt | 118 +++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt index faac03716e7..84ea8d8fdc8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt @@ -16,9 +16,123 @@ package org.jetbrains.kotlin.load.java.components +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor +import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver +import org.jetbrains.kotlin.types.JetType fun enhanceSignatures(platformSignatures: Collection): Collection { - // TODO: implement - return platformSignatures + return platformSignatures.map { + it.enhance() + } +} + +fun D.enhance(): D { + // TODO type parameters + // TODO use new type parameters while enhancing other types + // TODO Propagation into generic type arguments + + val enhancedReceiverType = + if (getExtensionReceiverParameter() != null) + parts { it.getExtensionReceiverParameter()!!.toPart() }.enhance() + else null + + val enhancedValueParameters = getValueParameters().map { + p -> parts { it.getValueParameters()[p.getIndex()]!!.toPart() }.enhance() + } + + val enhancedReturnType = parts { it.getReturnType()!!.toReturnTypePart() }.enhance() + + if (this is JavaMethodDescriptor) { + val enhancedFunction = JavaMethodDescriptor.createJavaMethod( + getContainingDeclaration()!!, + getAnnotations(), + getName(), + getSource() + ) + enhancedFunction.initialize( + enhancedReceiverType, + getDispatchReceiverParameter(), + getTypeParameters(), + enhancedValueParameters, + enhancedReturnType, + getModality(), + getVisibility() + ) + enhancedFunction.setHasStableParameterNames(hasStableParameterNames()) + enhancedFunction.setHasSynthesizedParameterNames(hasSynthesizedParameterNames()) + + for (overridden in getOverriddenDescriptors()) { + enhancedFunction.addOverriddenDescriptor(overridden) + } + + @suppress("UNCHECKED_CAST") + return enhancedFunction as D + } + + return this +} + +fun > SignatureParts.enhance(): T { + val qualifiers = fromOverride.type.computeQualifiersForOverride(this.fromOverridden.map { it.type }, fromOverride.isCovariant) + return fromOverride.replaceType(fromOverride.type.enhance(qualifiers)) +} + +class SignatureParts>( + val fromOverride: P, + val fromOverridden: Collection

+) + +interface SignaturePart { + val isCovariant: Boolean + get() = false + + val type: JetType + + fun replaceType(newType: JetType): T +} + +fun ReceiverParameterDescriptor.toPart() = object : SignaturePart { + override val type = getType() + + override fun replaceType(newType: JetType) = newType +} + +fun ValueParameterDescriptor.toPart() = object : SignaturePart { + override val type = getType() + + override fun replaceType(newType: JetType) = ValueParameterDescriptorImpl( + getContainingDeclaration(), + null, + getIndex(), + getAnnotations(), + getName(), + newType, + declaresDefaultValue(), + if (getVarargElementType() != null) newType.getArguments()[0].getType() else null, + getSource() + ) +} + +fun JetType.toReturnTypePart() = object : SignaturePart { + override val type = this@toReturnTypePart + + override val isCovariant: Boolean = true + + override fun replaceType(newType: JetType) = newType +} + +fun > D.parts(collector: (D) -> P): SignatureParts { + return SignatureParts( + collector(this), + this.getOverriddenDescriptors().map { + @suppress("UNCHECKED_CAST") + collector(it as D) + } + ) } \ No newline at end of file From 9644eeb047fbeba1e88fd7c281755fd82f20a07d Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 23 Apr 2015 16:24:32 +0300 Subject: [PATCH 130/450] Propagating annotations into type arguments --- .../java/components/signatureEnhancement.kt | 12 +- .../load/java/components/typeEnhancement.kt | 129 ++++++++++++------ .../load/java/components/typeQualifiers.kt | 41 +++++- .../org/jetbrains/kotlin/utils/collections.kt | 2 + 4 files changed, 136 insertions(+), 48 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt index 84ea8d8fdc8..1b01e6993c3 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt @@ -16,14 +16,12 @@ package org.jetbrains.kotlin.load.java.components -import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor -import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver import org.jetbrains.kotlin.types.JetType fun enhanceSignatures(platformSignatures: Collection): Collection { @@ -79,7 +77,7 @@ fun D.enhance(): D { } fun > SignatureParts.enhance(): T { - val qualifiers = fromOverride.type.computeQualifiersForOverride(this.fromOverridden.map { it.type }, fromOverride.isCovariant) + val qualifiers = fromOverride.type.computeIndexedQualifiersForOverride(this.fromOverridden.map { it.type }, fromOverride.isCovariant) return fromOverride.replaceType(fromOverride.type.enhance(qualifiers)) } @@ -98,13 +96,13 @@ interface SignaturePart { } fun ReceiverParameterDescriptor.toPart() = object : SignaturePart { - override val type = getType() + override val type = this@toPart.getType() // workaround for KT-7557 override fun replaceType(newType: JetType) = newType } fun ValueParameterDescriptor.toPart() = object : SignaturePart { - override val type = getType() + override val type = this@toPart.getType() // workaround for KT-7557 override fun replaceType(newType: JetType) = ValueParameterDescriptorImpl( getContainingDeclaration(), @@ -114,7 +112,7 @@ fun ValueParameterDescriptor.toPart() = object : SignaturePart>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C, 3 - D, 4 - E`, +// which corresponds to the left-to-right breadth-first walk of the tree representation of the type. +// For flexible types, both bounds are indexed in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. +fun JetType.enhance(qualifiers: (Int) -> JavaTypeQualifiers) = this.enhancePossiblyFlexible(qualifiers, 0).type -fun JetType.enhance(qualifiers: JavaTypeQualifiers): JetType { - val mutabilityEnhanced = - if (this.isFlexible()) - this.flexibility().enhanceMutability(qualifiers.mutability) - else this - return mutabilityEnhanced.enhanceNullability(qualifiers.nullability) + +private enum class TypeComponentPosition { + FLEXIBLE_LOWER, + FLEXIBLE_UPPER, + INFLEXIBLE } -private fun Flexibility.enhanceMutability(qualifier: MutabilityQualifier?): JetType { +data class Result(val type: JetType, val subtreeSize: Int) + +private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result { + if (this.isError()) return Result(this, 1) + return if (this.isFlexible()) { + with(this.flexibility()) { + val lowerResult = lowerBound.enhanceInflexible(qualifiers, index, TypeComponentPosition.FLEXIBLE_LOWER) + val upperResult = upperBound.enhanceInflexible(qualifiers, index, TypeComponentPosition.FLEXIBLE_UPPER) + assert(lowerResult.subtreeSize == upperResult.subtreeSize) { + "Different tree sizes of bounds: " + + "lower = ($lowerBound, ${lowerResult.subtreeSize}), " + + "upper = ($upperBound, ${upperResult.subtreeSize})" + } + Result( + DelegatingFlexibleType.create(lowerResult.type, upperResult.type, extraCapabilities), lowerResult.subtreeSize + ) + } + } + else this.enhanceInflexible(qualifiers, index, TypeComponentPosition.INFLEXIBLE) +} + +private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int, position: TypeComponentPosition): Result { + val shouldEnhance = position.shouldEnhance() + if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1) + + val originalClass = getConstructor().getDeclarationDescriptor() as? ClassDescriptor + ?: return Result(this, 1) + + val effectiveQualifiers = qualifiers(index) + val enhancedClass = originalClass.enhanceMutability(effectiveQualifiers, position) + + var globalArgIndex = index + 1 + val enhancedArguments = getArguments().mapIndexed { + localArgIndex, arg -> + if (arg.isStarProjection()) { + globalArgIndex++ + TypeUtils.makeStarProjection(enhancedClass.getTypeConstructor().getParameters()[localArgIndex]) + } + else { + val (enhancedType, subtreeSize) = arg.getType().enhancePossiblyFlexible(qualifiers, globalArgIndex) + globalArgIndex += subtreeSize + TypeProjectionImpl( + arg.getProjectionKind(), + enhancedType + ) + } + } + + val enhancedType = JetTypeImpl( + getAnnotations(), + enhancedClass.getTypeConstructor(), + this.getEnhancedNullability(effectiveQualifiers, position), + enhancedArguments, + enhancedClass.getMemberScope(enhancedArguments) + ) + return Result(enhancedType, globalArgIndex - index) +} + +private fun TypeComponentPosition.shouldEnhance() = this != TypeComponentPosition.INFLEXIBLE + +private fun ClassDescriptor.enhanceMutability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): ClassDescriptor { + if (!position.shouldEnhance()) return this + val mapping = JavaToKotlinClassMap.INSTANCE - val (newLower, newUpper) = run { - when (qualifier) { - READ_ONLY -> { - val lowerClass = TypeUtils.getClassDescriptor(lowerBound) - if (lowerClass != null && mapping.isMutable(lowerClass)) { - return@run Pair(lowerBound.replaceClass(mapping.convertMutableToReadOnly(lowerClass)), upperBound) - } - } - MUTABLE -> { - val upperClass = TypeUtils.getClassDescriptor(upperBound) - if (upperClass != null && mapping.isReadOnly(upperClass) ) { - return@run Pair(lowerBound, upperBound.replaceClass(mapping.convertReadOnlyToMutable(upperClass))) - } + when (qualifiers.mutability) { + READ_ONLY -> { + if (position == TypeComponentPosition.FLEXIBLE_LOWER && mapping.isMutable(this)) { + return mapping.convertMutableToReadOnly(this) + } + } + MUTABLE -> { + if (position == TypeComponentPosition.FLEXIBLE_UPPER && mapping.isReadOnly(this) ) { + return mapping.convertReadOnlyToMutable(this) } } - return@run Pair(lowerBound, upperBound) } - return DelegatingFlexibleType.create(newLower, newUpper, extraCapabilities) + return this } -private fun JetType.enhanceNullability(qualifier: NullabilityQualifier?): JetType { - return when (qualifier) { - NULLABLE -> TypeUtils.makeNullable(this) - NOT_NULL -> TypeUtils.makeNotNullable(this) - else -> this +private fun JetType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): Boolean { + if (!position.shouldEnhance()) return this.isMarkedNullable() + + return when (qualifiers.nullability) { + NULLABLE -> true + NOT_NULL -> false + else -> this.isMarkedNullable() } } - -private fun JetType.replaceClass(newClass: ClassDescriptor): JetType { - assert(newClass.getTypeConstructor().getParameters().size() == getArguments().size(), - {"Can't replace type constructor ${getConstructor()} by ${newClass}: type parameter count does not match"}) - return JetTypeImpl( - getAnnotations(), - newClass.getTypeConstructor(), - isMarkedNullable(), - getArguments(), - newClass.getMemberScope(getArguments()) - ) -} \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt index a95f22544c9..ff5bf35211c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.load.java.components +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE @@ -27,6 +28,8 @@ import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible +import org.jetbrains.kotlin.utils.getOrDefault +import java.util.ArrayList enum class NullabilityQualifier { NULLABLE, @@ -57,7 +60,11 @@ val MUTABLE_ANNOTATIONS = listOf( class JavaTypeQualifiers( val nullability: NullabilityQualifier?, val mutability: MutabilityQualifier? -) +) { + companion object { + val NONE = JavaTypeQualifiers(null, null) + } +} private fun JetType.extractQualifiers(): JavaTypeQualifiers { val (lower, upper) = @@ -82,7 +89,37 @@ private fun Annotations.extractQualifiers(): JavaTypeQualifiers { ) } -fun JetType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { +fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): (Int) -> JavaTypeQualifiers { + fun JetType.toIndexed(): List { + val list = ArrayList(1) + + fun add(type: JetType) { + list.add(type) + for (arg in type.getArguments()) { + if (arg.isStarProjection()) { + list.add(arg.getType()) + } + else { + add(arg.getType()) + } + } + } + + add(this) + return list + } + + val indexedFromSupertypes = fromSupertypes.map { it.toIndexed() } + val indexedThisType = this.toIndexed() + + return _r@ fun(index: Int): JavaTypeQualifiers { + val qualifiers = indexedThisType.getOrDefault(index, { return JavaTypeQualifiers.NONE }) + val verticalSlice = indexedFromSupertypes.map { it.getOrDefault(index, { null }) }.filterNotNull() + return qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant) + } +} + +private fun JetType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { val nullabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().nullability }.filterNotNull().toSet() val mutabilityFromSupertypes = fromSupertypes.map { it.extractQualifiers().mutability }.filterNotNull().toSet() val own = getAnnotations().extractQualifiers() diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt index 4e97127de1d..64bd09855ce 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt @@ -105,3 +105,5 @@ public fun Collection.toReadOnlyList(): List = if (isEmpty()) Collections.emptyList() else ArrayList(this) public fun T?.singletonOrEmptyList(): List = if (this != null) Collections.singletonList(this) else Collections.emptyList() + +public inline fun List.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) \ No newline at end of file From a8b5698145e67d2b6eeb37ec976b1298a644297e Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 23 Apr 2015 18:23:08 +0300 Subject: [PATCH 131/450] Proper enhancement for SAM adapters --- .../java/components/signatureEnhancement.kt | 24 +------------ .../sam/SamAdapterFunctionDescriptor.java | 27 +++++++++++++-- .../descriptors/JavaMethodDescriptor.java | 34 +++++++++++++++---- 3 files changed, 54 insertions(+), 31 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt index 1b01e6993c3..6272f43a9b5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt @@ -47,30 +47,8 @@ fun D.enhance(): D { val enhancedReturnType = parts { it.getReturnType()!!.toReturnTypePart() }.enhance() if (this is JavaMethodDescriptor) { - val enhancedFunction = JavaMethodDescriptor.createJavaMethod( - getContainingDeclaration()!!, - getAnnotations(), - getName(), - getSource() - ) - enhancedFunction.initialize( - enhancedReceiverType, - getDispatchReceiverParameter(), - getTypeParameters(), - enhancedValueParameters, - enhancedReturnType, - getModality(), - getVisibility() - ) - enhancedFunction.setHasStableParameterNames(hasStableParameterNames()) - enhancedFunction.setHasSynthesizedParameterNames(hasSynthesizedParameterNames()) - - for (overridden in getOverriddenDescriptors()) { - enhancedFunction.addOverriddenDescriptor(overridden) - } - @suppress("UNCHECKED_CAST") - return enhancedFunction as D + return this.enhance(enhancedReceiverType, enhancedValueParameters, enhancedReturnType) as D } return this diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterFunctionDescriptor.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterFunctionDescriptor.java index db1a506d2e8..20c5158fa42 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterFunctionDescriptor.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterFunctionDescriptor.java @@ -17,6 +17,10 @@ package org.jetbrains.kotlin.load.java.sam; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; +import org.jetbrains.kotlin.descriptors.FunctionDescriptor; +import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor; import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor; @@ -24,8 +28,17 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor; private final JavaMethodDescriptor declaration; public SamAdapterFunctionDescriptor(@NotNull JavaMethodDescriptor declaration) { - super(declaration.getContainingDeclaration(), null, declaration.getAnnotations(), - declaration.getName(), Kind.SYNTHESIZED, declaration.getSource()); + this(declaration.getContainingDeclaration(), null, Kind.SYNTHESIZED, declaration); + } + + private SamAdapterFunctionDescriptor( + @NotNull DeclarationDescriptor containingDeclaration, + @Nullable SimpleFunctionDescriptor original, + @NotNull Kind kind, + @NotNull JavaMethodDescriptor declaration + ) { + super(containingDeclaration, original, declaration.getAnnotations(), + declaration.getName(), kind, declaration.getSource()); this.declaration = declaration; setHasStableParameterNames(declaration.hasStableParameterNames()); setHasSynthesizedParameterNames(declaration.hasSynthesizedParameterNames()); @@ -36,4 +49,14 @@ import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor; public JavaMethodDescriptor getOriginForSam() { return declaration; } + + @NotNull + @Override + protected JavaMethodDescriptor createSubstitutedCopy( + @NotNull DeclarationDescriptor newOwner, + @Nullable FunctionDescriptor original, + @NotNull Kind kind + ) { + return new SamAdapterFunctionDescriptor(newOwner, (SimpleFunctionDescriptor) original, kind, declaration); + } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java index 92bb1269271..99cff0089bc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java @@ -18,14 +18,13 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; -import org.jetbrains.kotlin.descriptors.SourceElement; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; -import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.types.JetType; + +import java.util.List; public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor { private Boolean hasStableParameterNames = null; @@ -74,7 +73,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement @NotNull @Override - protected FunctionDescriptorImpl createSubstitutedCopy( + protected JavaMethodDescriptor createSubstitutedCopy( @NotNull DeclarationDescriptor newOwner, @Nullable FunctionDescriptor original, @NotNull Kind kind @@ -91,4 +90,27 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames()); return result; } + + @NotNull + public JavaMethodDescriptor enhance( + @Nullable JetType enhancedReceiverType, + @NotNull List enhancedValueParameters, + @NotNull JetType enhancedReturnType + ) { + JavaMethodDescriptor enhancedMethod = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); + enhancedMethod.initialize( + enhancedReceiverType, + getDispatchReceiverParameter(), + getTypeParameters(), + enhancedValueParameters, + enhancedReturnType, + getModality(), + getVisibility() + ); + for (FunctionDescriptor overridden : getOverriddenDescriptors()) { + enhancedMethod.addOverriddenDescriptor(overridden); + } + + return enhancedMethod; + } } From 04aee291b93ae4b53e28ac5415dd9174185cd853 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 29 Apr 2015 19:38:17 +0300 Subject: [PATCH 132/450] Proper treatment of return types --- .../load/java/components/typeQualifiers.kt | 18 +++++++++-- .../tests/j+k/types/returnCollection.kt | 13 ++++++++ .../tests/j+k/types/returnCollection.txt | 17 +++++++++++ .../types/shapeMismatchInCovariantPosition.kt | 19 ++++++++++++ .../shapeMismatchInCovariantPosition.txt | 30 +++++++++++++++++++ ...shapeMismatchInCovariantPositionGeneric.kt | 19 ++++++++++++ ...hapeMismatchInCovariantPositionGeneric.txt | 30 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 27 +++++++++++++++++ spec-docs/flexible-java-types.md | 13 ++++++-- 9 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt index ff5bf35211c..b329265c78e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.load.java.components -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE @@ -26,6 +25,7 @@ import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible import org.jetbrains.kotlin.utils.getOrDefault @@ -112,10 +112,22 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection, but in the subclass it may be Derived, which + // is declared to extend Super, and propagating data here is highly non-trivial, so we only look at the head type constructor + // (outermost type), unless the type in the subclass is interchangeable with the all the types in superclasses: + // e.g. we have (Mutable)List! in the subclass and { List, (Mutable)List! } from superclasses + // Note that `this` is flexible here, so it's equal to it's bounds + val onlyHeadTypeConstructor = isCovariant && fromSupertypes.any { !JetTypeChecker.DEFAULT.equalTypes(it, this) } + + return fun(index: Int): JavaTypeQualifiers { + val isHeadTypeConstructor = index == 0 + if (!isHeadTypeConstructor && onlyHeadTypeConstructor) return JavaTypeQualifiers.NONE + val qualifiers = indexedThisType.getOrDefault(index, { return JavaTypeQualifiers.NONE }) val verticalSlice = indexedFromSupertypes.map { it.getOrDefault(index, { null }) }.filterNotNull() - return qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant) + + // Only the head type constructor is safely co-variant + return qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor) } } diff --git a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt new file mode 100644 index 00000000000..84e5a4b8eb8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt @@ -0,0 +1,13 @@ +// FILE: k.kt + +trait K { + fun foo(): List +} + +// FILE: J.java + +import java.util.*; + +interface J extends K { + List foo(); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt new file mode 100644 index 00000000000..d918d8c2f36 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt @@ -0,0 +1,17 @@ +package + +public/*package*/ /*synthesized*/ fun J(/*0*/ function: () -> kotlin.(Mutable)List!): J + +public/*package*/ trait J : K { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(): kotlin.List + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait K { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(): kotlin.List + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt new file mode 100644 index 00000000000..33a4d10347f --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt @@ -0,0 +1,19 @@ +// FILE: k.kt + +trait G +trait SubG : G + +trait K { + fun foo(): G + fun bar(): G? +} + +// FILE: J.java + +import java.util.*; + +interface J extends K { + SubG foo(); + SubG bar(); + SubG baz(); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt new file mode 100644 index 00000000000..514a4497b84 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt @@ -0,0 +1,30 @@ +package + +internal trait G { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ trait J : K { + public abstract override /*1*/ fun bar(): SubG? + public abstract fun baz(): SubG! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(): SubG + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait K { + internal abstract fun bar(): G? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(): G + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait SubG : G { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt new file mode 100644 index 00000000000..e07ec6ec4b3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt @@ -0,0 +1,19 @@ +// FILE: k.kt + +trait G +trait SubG : G + +trait K { + fun foo(): G + fun bar(): G? +} + +// FILE: J.java + +import java.util.*; + +interface J extends K { + SubG> foo(); + SubG> bar(); + SubG> baz(); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt new file mode 100644 index 00000000000..5927cab9c4c --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt @@ -0,0 +1,30 @@ +package + +internal trait G { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ trait J : K { + public abstract override /*1*/ fun bar(): SubG!>? + public abstract fun baz(): SubG!>! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(): SubG!> + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait K { + internal abstract fun bar(): G? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(): G + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait SubG : G { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 7f828debc5d..1ae5226e81f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -8183,6 +8183,33 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/UnboxingNulls.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/diagnostics/tests/j+k/types") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Types extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInTypes() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/types"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("returnCollection.kt") + public void testReturnCollection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt"); + doTest(fileName); + } + + @TestMetadata("shapeMismatchInCovariantPosition.kt") + public void testShapeMismatchInCovariantPosition() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt"); + doTest(fileName); + } + + @TestMetadata("shapeMismatchInCovariantPositionGeneric.kt") + public void testShapeMismatchInCovariantPositionGeneric() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/jdk-annotations") diff --git a/spec-docs/flexible-java-types.md b/spec-docs/flexible-java-types.md index 74b190488ce..12b23399515 100644 --- a/spec-docs/flexible-java-types.md +++ b/spec-docs/flexible-java-types.md @@ -254,7 +254,7 @@ Enhancement rules (the result of their application is called a *propagated signa - collect annotations from all supertypes and the override in the subclass - for parts other than return type (which may be covariantly overridden) if there are conflicts (`@Nullable` together with `@NotNull` or `@ReadOnly` together with `@Mutable`), discard the respective annotations and issue appropriate warnings - - for return types (only the 0-index, see below): + - for return types (full if the type from override is `~~`-equivalent to all from supertypes, and only 0-index (see below) otherwise)): - fist, take annotations from supertypes, and among them: if there's `@NotNull`, discard `@Nullable`, if there's `@Mutable` discard `@ReadOnly` - then if in the subtype there's `@Nullable` and in the supertype there's `@NotNull`, discard the nullability annotations (analogously, for mutability annotations) @@ -366,8 +366,15 @@ fun foo(MutableList p): R! // parameter propagated from superclass (@Mutable, the following procedure is used. First, every sub-tree of the type is assigned an index which is its zero-based position in the textual representation of the type (`0` is root). Example: for `A>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C, 3 - D, 4 - E`, which corresponds to the left-to-right breadth-first walk of the tree representation of the type. For flexible types, both bounds are indexed -in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. Now, in the aforementioned procedure, annotations are collected and -considered *at each index*, and only index 0 of the return type is considered as possibly covariant (this is done for simplicity). +in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. + +Now, in the aforementioned procedure, annotations are collected and considered *at each index* for types other than return types. Return types +are co-variant, thus the overriding type may not match the overridden ones in its shape (e.g. we can have `Foo` from super, +and `Baz>` in the override, where `Baz` extends `Foo`). This makes it impossible sometimes to propagate data into +covariant overrides, and in such cases we resort to only looking at the head constructor (index == 0). The safe cases are detected by checking +that the overriding type is `~~`-equivalent to all the overridden ones, which guarantees that their shapes match. For example, the overriding +type may be `(Mutable)List!` while the overridden ones may be `List` and `List`, the equivalence holds and we can safely +assume the enhanced return type to be `List` (subtype of both overridden ones). Example: - `Mutable(List)!` From 8c7873998384dc0db5a8de0ab0c97b02a8cda352 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 29 Apr 2015 20:54:13 +0300 Subject: [PATCH 133/450] Proper enhancement for type parameters --- .../load/java/components/typeEnhancement.kt | 17 ++++++++----- .../diagnostics/tests/j+k/types/arrayList.kt | 15 ++++++++++++ .../diagnostics/tests/j+k/types/arrayList.txt | 24 +++++++++++++++++++ .../tests/j+k/types/typeParameter.kt | 11 +++++++++ .../tests/j+k/types/typeParameter.txt | 15 ++++++++++++ .../propagation/return/TypeParamOfClass.txt | 2 +- .../return/TypeParamOfClassSubstituted.txt | 2 +- .../propagation/return/TypeParamOfFun.txt | 4 ++-- .../checkers/JetDiagnosticsTestGenerated.java | 12 ++++++++++ 9 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/types/arrayList.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/arrayList.txt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt index e54514c5f8b..bcf098a9610 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.load.java.components import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL @@ -62,18 +64,18 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i val shouldEnhance = position.shouldEnhance() if (!shouldEnhance && getArguments().isEmpty()) return Result(this, 1) - val originalClass = getConstructor().getDeclarationDescriptor() as? ClassDescriptor + val originalClass = getConstructor().getDeclarationDescriptor() ?: return Result(this, 1) val effectiveQualifiers = qualifiers(index) - val enhancedClass = originalClass.enhanceMutability(effectiveQualifiers, position) + val enhancedClassifier = originalClass.enhanceMutability(effectiveQualifiers, position) var globalArgIndex = index + 1 val enhancedArguments = getArguments().mapIndexed { localArgIndex, arg -> if (arg.isStarProjection()) { globalArgIndex++ - TypeUtils.makeStarProjection(enhancedClass.getTypeConstructor().getParameters()[localArgIndex]) + TypeUtils.makeStarProjection(enhancedClassifier.getTypeConstructor().getParameters()[localArgIndex]) } else { val (enhancedType, subtreeSize) = arg.getType().enhancePossiblyFlexible(qualifiers, globalArgIndex) @@ -87,18 +89,21 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i val enhancedType = JetTypeImpl( getAnnotations(), - enhancedClass.getTypeConstructor(), + enhancedClassifier.getTypeConstructor(), this.getEnhancedNullability(effectiveQualifiers, position), enhancedArguments, - enhancedClass.getMemberScope(enhancedArguments) + if (enhancedClassifier is ClassDescriptor) + enhancedClassifier.getMemberScope(enhancedArguments) + else enhancedClassifier.getDefaultType().getMemberScope() ) return Result(enhancedType, globalArgIndex - index) } private fun TypeComponentPosition.shouldEnhance() = this != TypeComponentPosition.INFLEXIBLE -private fun ClassDescriptor.enhanceMutability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): ClassDescriptor { +private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): ClassifierDescriptor { if (!position.shouldEnhance()) return this + if (this !is ClassDescriptor) return this // mutability is not applicable for type parameters val mapping = JavaToKotlinClassMap.INSTANCE diff --git a/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt b/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt new file mode 100644 index 00000000000..107e4068059 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt @@ -0,0 +1,15 @@ +// FILE: k.kt + +trait ML { + public fun foo(): MutableList +} + +class K : J(), ML + +// FILE: J.java + +import java.util.*; + +class J extends ML { + public List foo() { return null; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt b/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt new file mode 100644 index 00000000000..36f1fa464ad --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt @@ -0,0 +1,24 @@ +package + +public/*package*/ open class J : ML { + public/*package*/ constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class K : J, ML { + public constructor K() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun foo(): kotlin.MutableList + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait ML { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt new file mode 100644 index 00000000000..3aac76a2aad --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt @@ -0,0 +1,11 @@ +// FILE: k.kt + +trait K { + fun foo(t: T) +} + +// FILE: J.java + +interface J extends K { + void foo(T t); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt new file mode 100644 index 00000000000..836bc55a09d --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt @@ -0,0 +1,15 @@ +package + +public/*package*/ trait J : K { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(/*0*/ t: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal trait K { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal abstract fun foo(/*0*/ t: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt index 192d611dfa4..73432c13ca7 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClass.txt @@ -9,6 +9,6 @@ public interface TypeParamOfClass { public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): T! + org.jetbrains.annotations.NotNull() public abstract fun foo(): T } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt index 1c759f64976..2a7210129e7 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfClassSubstituted.txt @@ -9,6 +9,6 @@ public interface TypeParamOfClassSubstituted { public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): T! + org.jetbrains.annotations.NotNull() public abstract fun foo(): T } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt index 283136f6ebb..cf25cb6eb92 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TypeParamOfFun.txt @@ -4,11 +4,11 @@ public interface TypeParamOfFun { public interface Sub : test.TypeParamOfFun.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(): E! + public abstract override /*1*/ fun foo(): E } public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): T! + org.jetbrains.annotations.NotNull() public abstract fun foo(): T } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 1ae5226e81f..b5529a443fa 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -8192,6 +8192,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/types"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("arrayList.kt") + public void testArrayList() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/arrayList.kt"); + doTest(fileName); + } + @TestMetadata("returnCollection.kt") public void testReturnCollection() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt"); @@ -8209,6 +8215,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt"); doTest(fileName); } + + @TestMetadata("typeParameter.kt") + public void testTypeParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt"); + doTest(fileName); + } } } From 694af022c87a4afee91b453abb6d88fde4571213 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 5 May 2015 18:51:35 +0300 Subject: [PATCH 134/450] Type Enhancement for Java fields and constructors supported as well --- .../java/components/signatureEnhancement.kt | 6 ++- .../compiledJava/notNull/NotNullField.txt | 2 +- .../adapters/ConstructorWithAnnotations.java | 10 +++++ .../adapters/ConstructorWithAnnotations.txt | 6 +++ .../jvm/compiler/LoadJavaTestGenerated.java | 6 +++ .../JavaCallableMemberDescriptor.java | 12 ++++++ .../JavaConstructorDescriptor.java | 30 ++++++++++++-- .../descriptors/JavaMethodDescriptor.java | 3 ++ .../descriptors/JavaPropertyDescriptor.java | 40 +++++++++++++++++-- .../descriptors/LazyJavaClassMemberScope.kt | 5 ++- .../lazy/descriptors/LazyJavaMemberScope.kt | 5 ++- .../impl/VariableDescriptorImpl.java | 2 +- 12 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt index 6272f43a9b5..037b4a9a262 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt @@ -21,7 +21,9 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl -import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor import org.jetbrains.kotlin.types.JetType fun enhanceSignatures(platformSignatures: Collection): Collection { @@ -46,7 +48,7 @@ fun D.enhance(): D { val enhancedReturnType = parts { it.getReturnType()!!.toReturnTypePart() }.enhance() - if (this is JavaMethodDescriptor) { + if (this is JavaCallableMemberDescriptor) { @suppress("UNCHECKED_CAST") return this.enhance(enhancedReceiverType, enhancedValueParameters, enhancedReturnType) as D } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullField.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullField.txt index 18c748212c0..7c3c4d0f703 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullField.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullField.txt @@ -2,5 +2,5 @@ package test public open class NotNullField { public constructor NotNullField() - org.jetbrains.annotations.NotNull() public final var hi: kotlin.String! + org.jetbrains.annotations.NotNull() public final var hi: kotlin.String } diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java b/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java new file mode 100644 index 00000000000..6c83ef8687b --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java @@ -0,0 +1,10 @@ +package test; + +import org.jetbrains.annotations.NotNull; + +import java.lang.String; + +public class ConstructorWithAnnotations { + public ConstructorWithAnnotations(Runnable r, @NotNull String s) { + } +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.txt new file mode 100644 index 00000000000..913ac28d907 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.txt @@ -0,0 +1,6 @@ +package test + +public open class ConstructorWithAnnotations { + public /*synthesized*/ constructor ConstructorWithAnnotations(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.String) + public constructor ConstructorWithAnnotations(/*0*/ p0: java.lang.Runnable!, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.String) +} diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 89d0b94765f..dece7cfbdba 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -1568,6 +1568,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava(fileName); } + @TestMetadata("ConstructorWithAnnotations.java") + public void testConstructorWithAnnotations() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/ConstructorWithAnnotations.java"); + doTestCompiledJava(fileName); + } + @TestMetadata("DeepSamLoop.java") public void testDeepSamLoop() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/DeepSamLoop.java"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java index 83381073306..5970da42013 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java @@ -16,7 +16,19 @@ package org.jetbrains.kotlin.load.java.descriptors; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor; +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; +import org.jetbrains.kotlin.types.JetType; + +import java.util.List; public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor { + @NotNull + JavaCallableMemberDescriptor enhance( + @Nullable JetType enhancedReceiverType, + @NotNull List enhancedValueParameters, + @NotNull JetType enhancedReturnType + ); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java index 562e767dff2..6afd38862bb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java @@ -18,12 +18,12 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.descriptors.SourceElement; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl; +import org.jetbrains.kotlin.types.JetType; + +import java.util.List; public class JavaConstructorDescriptor extends ConstructorDescriptorImpl implements JavaCallableMemberDescriptor { private Boolean hasStableParameterNames = null; @@ -92,4 +92,26 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme result.setHasSynthesizedParameterNames(hasSynthesizedParameterNames()); return result; } + + @Override + @NotNull + public JavaConstructorDescriptor enhance( + @Nullable JetType enhancedReceiverType, + @NotNull List enhancedValueParameters, + @NotNull JetType enhancedReturnType + ) { + JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); + enhanced.initialize( + enhancedReceiverType, + getDispatchReceiverParameter(), + getTypeParameters(), + enhancedValueParameters, + enhancedReturnType, + getModality(), + getVisibility() + ); + + return enhanced; + } + } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java index 99cff0089bc..22435b63b09 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java @@ -91,6 +91,9 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement return result; } + + + @Override @NotNull public JavaMethodDescriptor enhance( @Nullable JetType enhancedReceiverType, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index 0fff0babcb1..9ad24f14cdc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -17,13 +17,14 @@ package org.jetbrains.kotlin.load.java.descriptors; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.Modality; -import org.jetbrains.kotlin.descriptors.SourceElement; -import org.jetbrains.kotlin.descriptors.Visibility; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.types.JetType; + +import java.util.List; public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements JavaCallableMemberDescriptor { public JavaPropertyDescriptor( @@ -41,4 +42,35 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja public boolean hasSynthesizedParameterNames() { return false; } + + @NotNull + @Override + public JavaCallableMemberDescriptor enhance( + @Nullable JetType enhancedReceiverType, + @NotNull List enhancedValueParameters, + @NotNull JetType enhancedReturnType + ) { + JavaPropertyDescriptor enhanced = new JavaPropertyDescriptor( + getContainingDeclaration(), + getAnnotations(), + getVisibility(), + isVar(), + getName(), + getSource() + ); + assert getGetter() == null : "Field must not have a getter: " + this; + assert getSetter() == null : "Field must not have a setter: " + this; + enhanced.initialize(null, null); + enhanced.setSetterProjectedOut(isSetterProjectedOut()); + if (compileTimeInitializer != null) { + enhanced.setCompileTimeInitializer(compileTimeInitializer); + } + enhanced.setType( + enhancedReturnType, + getTypeParameters(), // TODO + getDispatchReceiverParameter(), + enhancedReceiverType + ); + return enhanced; + } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 0d915a9c960..394c49b59af 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -71,7 +71,10 @@ public class LazyJavaClassMemberScope( result.add(descriptor) result.addIfNotNull(c.samConversionResolver.resolveSamAdapter(descriptor)) } - result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) } + + c.externalSignatureResolver.enhanceSignatures( + result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) } + ).toReadOnlyList() } override fun computeNonDeclaredFunctions(result: MutableCollection, name: Name) { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index ee88fb2de79..6426e9a8fc3 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -236,7 +236,10 @@ public abstract class LazyJavaMemberScope( computeNonDeclaredProperties(name, properties) - properties.toReadOnlyList() + if (DescriptorUtils.isAnnotationClass(containingDeclaration)) + properties.toReadOnlyList() + else + c.externalSignatureResolver.enhanceSignatures(properties).toReadOnlyList() } private fun resolveProperty(field: JavaField): PropertyDescriptor { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java index 74b418f1f80..b5ff6c55c58 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java @@ -32,7 +32,7 @@ import java.util.Set; public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor { private JetType outType; - private NullableLazyValue> compileTimeInitializer; + protected NullableLazyValue> compileTimeInitializer; public VariableDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, From 31f4ff749c34c8ff573a1d6e1688c39ea1b4463c Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 5 May 2015 21:35:37 +0300 Subject: [PATCH 135/450] Type annotations supported in Java elements Reflection-related implementations are pending --- .../PsiBasedExternalAnnotationResolver.java | 23 ++++++++----- .../impl/JavaAnnotationOwnerImpl.java | 8 ++--- .../java/structure/impl/JavaClassImpl.java | 12 ------- .../structure/impl/JavaClassifierImpl.java | 26 ++++++++++++++- .../java/structure/impl/JavaElementUtil.java | 17 ++++------ .../java/structure/impl/JavaMemberImpl.java | 7 ++++ .../java/structure/impl/JavaTypeImpl.java | 25 +++++++++++++- .../impl/JavaValueParameterImpl.java | 33 ++++++++++++++++++- .../java/structure/JavaClassifierType.java | 2 +- .../reflect/ReflectJavaClassifierType.kt | 14 +++++--- 10 files changed, 125 insertions(+), 42 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/PsiBasedExternalAnnotationResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/PsiBasedExternalAnnotationResolver.java index 4bd2daea519..0b8ff30a6a0 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/PsiBasedExternalAnnotationResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/PsiBasedExternalAnnotationResolver.java @@ -24,8 +24,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.load.java.structure.JavaAnnotation; import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner; import org.jetbrains.kotlin.load.java.structure.impl.JavaAnnotationImpl; -import org.jetbrains.kotlin.load.java.structure.impl.JavaAnnotationOwnerImpl; import org.jetbrains.kotlin.load.java.structure.impl.JavaElementCollectionFromPsiArrayUtil; +import org.jetbrains.kotlin.load.java.structure.impl.JavaModifierListOwnerImpl; import org.jetbrains.kotlin.name.FqName; import java.util.Collection; @@ -35,18 +35,25 @@ public class PsiBasedExternalAnnotationResolver implements ExternalAnnotationRes @Nullable @Override public JavaAnnotation findExternalAnnotation(@NotNull JavaAnnotationOwner owner, @NotNull FqName fqName) { - PsiAnnotation psiAnnotation = findExternalAnnotation(((JavaAnnotationOwnerImpl) owner).getPsi(), fqName); - return psiAnnotation == null ? null : new JavaAnnotationImpl(psiAnnotation); + if (owner instanceof JavaModifierListOwnerImpl) { + JavaModifierListOwnerImpl modifierListOwner = (JavaModifierListOwnerImpl) owner; + PsiAnnotation psiAnnotation = findExternalAnnotation(modifierListOwner.getPsi(), fqName); + return psiAnnotation == null ? null : new JavaAnnotationImpl(psiAnnotation); + } + return null; } @NotNull @Override public Collection findExternalAnnotations(@NotNull JavaAnnotationOwner owner) { - PsiModifierListOwner psiOwner = ((JavaAnnotationOwnerImpl) owner).getPsi(); - PsiAnnotation[] annotations = ExternalAnnotationsManager.getInstance(psiOwner.getProject()).findExternalAnnotations(psiOwner); - return annotations == null - ? Collections.emptyList() - : JavaElementCollectionFromPsiArrayUtil.annotations(annotations); + if (owner instanceof JavaModifierListOwnerImpl) { + PsiModifierListOwner psiOwner = ((JavaModifierListOwnerImpl) owner).getPsi(); + PsiAnnotation[] annotations = ExternalAnnotationsManager.getInstance(psiOwner.getProject()).findExternalAnnotations(psiOwner); + return annotations == null + ? Collections.emptyList() + : JavaElementCollectionFromPsiArrayUtil.annotations(annotations); + } + return Collections.emptyList(); } @Nullable diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaAnnotationOwnerImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaAnnotationOwnerImpl.java index dab67466412..c13860e33d6 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaAnnotationOwnerImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaAnnotationOwnerImpl.java @@ -16,11 +16,11 @@ package org.jetbrains.kotlin.load.java.structure.impl; -import com.intellij.psi.PsiModifierListOwner; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.PsiAnnotationOwner; +import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.load.java.structure.JavaAnnotationOwner; public interface JavaAnnotationOwnerImpl extends JavaAnnotationOwner { - @NotNull - PsiModifierListOwner getPsi(); + @Nullable + PsiAnnotationOwner getAnnotationOwnerPsi(); } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java index 57db2aef037..d7f9e5d13dd 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassImpl.java @@ -146,18 +146,6 @@ public class JavaClassImpl extends JavaClassifierImpl implements JavaC return JavaElementUtil.getVisibility(this); } - @NotNull - @Override - public Collection getAnnotations() { - return JavaElementUtil.getAnnotations(this); - } - - @Nullable - @Override - public JavaAnnotation findAnnotation(@NotNull FqName fqName) { - return JavaElementUtil.findAnnotation(this, fqName); - } - @Override @NotNull public JavaClassifierType getDefaultType() { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java index cbca1c0ecaf..f94bd71652e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java @@ -16,16 +16,28 @@ package org.jetbrains.kotlin.load.java.structure.impl; +import com.intellij.psi.PsiAnnotationOwner; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiTypeParameter; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.load.java.structure.JavaAnnotation; import org.jetbrains.kotlin.load.java.structure.JavaClassifier; +import org.jetbrains.kotlin.name.FqName; -public abstract class JavaClassifierImpl extends JavaElementImpl implements JavaClassifier { +import java.util.Collection; + +public abstract class JavaClassifierImpl extends JavaElementImpl implements JavaClassifier, JavaAnnotationOwnerImpl { protected JavaClassifierImpl(@NotNull Psi psiClass) { super(psiClass); } + @NotNull + @Override + public PsiAnnotationOwner getAnnotationOwnerPsi() { + return getPsi().getModifierList(); + } + @NotNull /* package */ static JavaClassifier create(@NotNull PsiClass psiClass) { if (psiClass instanceof PsiTypeParameter) { @@ -35,4 +47,16 @@ public abstract class JavaClassifierImpl extends JavaEleme return new JavaClassImpl(psiClass); } } + + @NotNull + @Override + public Collection getAnnotations() { + return JavaElementUtil.getAnnotations(this); + } + + @Nullable + @Override + public JavaAnnotation findAnnotation(@NotNull FqName fqName) { + return JavaElementUtil.findAnnotation(this, fqName); + } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementUtil.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementUtil.java index 03c6cdc46d6..c0a225744c3 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementUtil.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaElementUtil.java @@ -16,10 +16,7 @@ package org.jetbrains.kotlin.load.java.structure.impl; -import com.intellij.psi.PsiAnnotation; -import com.intellij.psi.PsiModifier; -import com.intellij.psi.PsiModifierList; -import com.intellij.psi.PsiModifierListOwner; +import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.Visibilities; @@ -66,18 +63,18 @@ import static org.jetbrains.kotlin.load.java.structure.impl.JavaElementCollectio @NotNull public static Collection getAnnotations(@NotNull JavaAnnotationOwnerImpl owner) { - PsiModifierList modifierList = owner.getPsi().getModifierList(); - if (modifierList != null) { - return annotations(modifierList.getAnnotations()); + PsiAnnotationOwner annotationOwnerPsi = owner.getAnnotationOwnerPsi(); + if (annotationOwnerPsi != null) { + return annotations(annotationOwnerPsi.getAnnotations()); } return Collections.emptyList(); } @Nullable public static JavaAnnotation findAnnotation(@NotNull JavaAnnotationOwnerImpl owner, @NotNull FqName fqName) { - PsiModifierList modifierList = owner.getPsi().getModifierList(); - if (modifierList != null) { - PsiAnnotation psiAnnotation = modifierList.findAnnotation(fqName.asString()); + PsiAnnotationOwner annotationOwnerPsi = owner.getAnnotationOwnerPsi(); + if (annotationOwnerPsi != null) { + PsiAnnotation psiAnnotation = annotationOwnerPsi.findAnnotation(fqName.asString()); return psiAnnotation == null ? null : new JavaAnnotationImpl(psiAnnotation); } return null; diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMemberImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMemberImpl.java index 03989fb0a0b..f730d42fc57 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMemberImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaMemberImpl.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.load.java.structure.impl; +import com.intellij.psi.PsiAnnotationOwner; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiMember; import org.jetbrains.annotations.NotNull; @@ -35,6 +36,12 @@ public abstract class JavaMemberImpl extends JavaElementI super(psiMember); } + @Nullable + @Override + public PsiAnnotationOwner getAnnotationOwnerPsi() { + return getPsi().getModifierList(); + } + @NotNull @Override public Name getName() { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaTypeImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaTypeImpl.java index 1b55598c529..e2874bafc5a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaTypeImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaTypeImpl.java @@ -19,10 +19,14 @@ package org.jetbrains.kotlin.load.java.structure.impl; import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.load.java.structure.JavaAnnotation; import org.jetbrains.kotlin.load.java.structure.JavaArrayType; import org.jetbrains.kotlin.load.java.structure.JavaType; +import org.jetbrains.kotlin.name.FqName; -public abstract class JavaTypeImpl implements JavaType { +import java.util.Collection; + +public abstract class JavaTypeImpl implements JavaType, JavaAnnotationOwnerImpl { private final Psi psiType; public JavaTypeImpl(@NotNull Psi psiType) { @@ -34,6 +38,12 @@ public abstract class JavaTypeImpl implements JavaType { return psiType; } + @Nullable + @Override + public PsiAnnotationOwner getAnnotationOwnerPsi() { + return getPsi(); + } + @NotNull public static JavaTypeImpl create(@NotNull PsiType psiType) { return psiType.accept(new PsiTypeVisitor>() { @@ -75,6 +85,19 @@ public abstract class JavaTypeImpl implements JavaType { return new JavaArrayTypeImpl(getPsi().createArrayType()); } + @NotNull + @Override + public Collection getAnnotations() { + return JavaElementUtil.getAnnotations(this); + } + + @Nullable + @Override + public JavaAnnotation findAnnotation(@NotNull FqName fqName) { + return JavaElementUtil.findAnnotation(this, fqName); + } + + @Override public int hashCode() { return getPsi().hashCode(); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaValueParameterImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaValueParameterImpl.java index d54774cbed4..d8a03f5ad37 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaValueParameterImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaValueParameterImpl.java @@ -16,10 +16,13 @@ package org.jetbrains.kotlin.load.java.structure.impl; +import com.intellij.psi.PsiAnnotationOwner; import com.intellij.psi.PsiParameter; import com.intellij.psi.impl.compiled.ClsParameterImpl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.descriptors.Visibilities; +import org.jetbrains.kotlin.descriptors.Visibility; import org.jetbrains.kotlin.load.java.structure.JavaAnnotation; import org.jetbrains.kotlin.load.java.structure.JavaType; import org.jetbrains.kotlin.load.java.structure.JavaValueParameter; @@ -28,11 +31,39 @@ import org.jetbrains.kotlin.name.Name; import java.util.Collection; -public class JavaValueParameterImpl extends JavaElementImpl implements JavaValueParameter, JavaAnnotationOwnerImpl { +public class JavaValueParameterImpl extends JavaElementImpl + implements JavaValueParameter, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl { public JavaValueParameterImpl(@NotNull PsiParameter psiParameter) { super(psiParameter); } + @Nullable + @Override + public PsiAnnotationOwner getAnnotationOwnerPsi() { + return getPsi().getModifierList(); + } + + @Override + public boolean isAbstract() { + return false; + } + + @Override + public boolean isStatic() { + return false; + } + + @Override + public boolean isFinal() { + return false; + } + + @NotNull + @Override + public Visibility getVisibility() { + return Visibilities.LOCAL; + } + @NotNull @Override public Collection getAnnotations() { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java index d776e0de3c8..02711b38a9b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaClassifierType.java @@ -23,7 +23,7 @@ import org.jetbrains.annotations.ReadOnly; import java.util.Collection; import java.util.List; -public interface JavaClassifierType extends JavaType { +public interface JavaClassifierType extends JavaType, JavaAnnotationOwner { @Nullable JavaClassifier getClassifier(); diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt index f18d036a06f..f7e863fe164 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt @@ -16,10 +16,8 @@ package org.jetbrains.kotlin.load.java.structure.reflect -import org.jetbrains.kotlin.load.java.structure.JavaClassifier -import org.jetbrains.kotlin.load.java.structure.JavaClassifierType -import org.jetbrains.kotlin.load.java.structure.JavaType -import org.jetbrains.kotlin.load.java.structure.JavaTypeSubstitutor +import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.name.FqName import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.lang.reflect.TypeVariable @@ -48,4 +46,12 @@ public class ReflectJavaClassifierType(public override val type: Type) : Reflect override fun getTypeArguments(): List { return (type as? ParameterizedType)?.getActualTypeArguments()?.map { ReflectJavaType.create(it) } ?: listOf() } + + override fun getAnnotations(): Collection { + return emptyList() // TODO + } + + override fun findAnnotation(fqName: FqName): JavaAnnotation? { + return null // TODO + } } From eaae88133c2213e3f6e54d97bc04e667f7fb0c6e Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 7 May 2015 16:47:51 +0300 Subject: [PATCH 136/450] Minor FilteredAnnotations moved out of Java-specific code --- .../load/java/lazy/LazyJavaAnnotations.kt | 24 ------------------ .../java/lazy/types/LazyJavaTypeResolver.kt | 2 +- .../descriptors/annotations/Annotations.kt | 25 +++++++++++++++++++ 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaAnnotations.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaAnnotations.kt index 3c5ab696ad9..af921d85906 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaAnnotations.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/LazyJavaAnnotations.kt @@ -44,29 +44,5 @@ class LazyJavaAnnotations( override fun isEmpty() = !iterator().hasNext() } -class FilteredAnnotations( - private val delegate: Annotations, - private val fqNameFilter: (FqName) -> Boolean -) : Annotations { - override fun findAnnotation(fqName: FqName) = - if (fqNameFilter(fqName)) delegate.findAnnotation(fqName) - else null - - override fun findExternalAnnotation(fqName: FqName) = - if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName) - else null - - override fun iterator() = delegate.asSequence() - .filter { annotation -> - val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor() - descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName -> - fqName.isSafe() && fqNameFilter(fqName.toSafe()) - } - } - .iterator() - - override fun isEmpty() = !iterator().hasNext() -} - fun LazyJavaResolverContext.resolveAnnotations(annotationsOwner: JavaAnnotationOwner): Annotations = LazyJavaAnnotations(this, annotationsOwner) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index 3d0e1db82c0..cbe1b646dcc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations import org.jetbrains.kotlin.load.java.JvmAnnotationNames.* import org.jetbrains.kotlin.load.java.components.TypeUsage import org.jetbrains.kotlin.load.java.components.TypeUsage.* -import org.jetbrains.kotlin.load.java.lazy.FilteredAnnotations import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt index c008c9559d3..6396fa9d4e7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.descriptors.annotations import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.resolve.DescriptorUtils public trait Annotations : Iterable { @@ -40,3 +41,27 @@ public trait Annotations : Iterable { } } } + +class FilteredAnnotations( + private val delegate: Annotations, + private val fqNameFilter: (FqName) -> Boolean +) : Annotations { + override fun findAnnotation(fqName: FqName) = + if (fqNameFilter(fqName)) delegate.findAnnotation(fqName) + else null + + override fun findExternalAnnotation(fqName: FqName) = + if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName) + else null + + override fun iterator() = delegate.sequence() + .filter { annotation -> + val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor() + descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName -> + fqName.isSafe() && fqNameFilter(fqName.toSafe()) + } + } + .iterator() + + override fun isEmpty() = !iterator().hasNext() +} From c6b91b0f8168026fd9351d1fab67045155a1b755 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 7 May 2015 21:58:22 +0300 Subject: [PATCH 137/450] Java type annotations supported in LazyJavaTypeResolver --- .../java/structure/impl/JavaClassifierImpl.java | 2 +- .../loadJava/sourceJava/TypeAnnotations.java | 16 ++++++++++++++++ .../loadJava/sourceJava/TypeAnnotations.txt | 6 ++++++ .../jvm/compiler/LoadJavaTestGenerated.java | 6 ++++++ .../load/java/lazy/types/LazyJavaTypeResolver.kt | 5 ++++- .../descriptors/annotations/Annotations.kt | 12 ++++++++++++ 6 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/loadJava/sourceJava/TypeAnnotations.java create mode 100644 compiler/testData/loadJava/sourceJava/TypeAnnotations.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java index f94bd71652e..2d43b64ab63 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaClassifierImpl.java @@ -32,7 +32,7 @@ public abstract class JavaClassifierImpl extends JavaEleme super(psiClass); } - @NotNull + @Nullable @Override public PsiAnnotationOwner getAnnotationOwnerPsi() { return getPsi().getModifierList(); diff --git a/compiler/testData/loadJava/sourceJava/TypeAnnotations.java b/compiler/testData/loadJava/sourceJava/TypeAnnotations.java new file mode 100644 index 00000000000..30516b4fbb9 --- /dev/null +++ b/compiler/testData/loadJava/sourceJava/TypeAnnotations.java @@ -0,0 +1,16 @@ +package test; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE_USE) +@interface A { + String value() default ""; +} + +interface G {} +interface G2 {} + +public interface TypeAnnotations { + void f(G<@A String> p); + void f(G2<@A String, @A Integer> p); +} \ No newline at end of file diff --git a/compiler/testData/loadJava/sourceJava/TypeAnnotations.txt b/compiler/testData/loadJava/sourceJava/TypeAnnotations.txt new file mode 100644 index 00000000000..8021ab11fcc --- /dev/null +++ b/compiler/testData/loadJava/sourceJava/TypeAnnotations.txt @@ -0,0 +1,6 @@ +package test + +public interface TypeAnnotations { + public abstract fun f(/*0*/ p: test.G2<@[test.A()] kotlin.String!, @[test.A()] kotlin.Int!>!): kotlin.Unit + public abstract fun f(/*0*/ p: test.G<@[test.A()] kotlin.String!>!): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index dece7cfbdba..76e902d4c03 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -5156,6 +5156,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestSourceJava(fileName); } + @TestMetadata("TypeAnnotations.java") + public void testTypeAnnotations() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/sourceJava/TypeAnnotations.java"); + doTestSourceJava(fileName); + } + @TestMetadata("WrongNumberOfGenericParameters.java") public void testWrongNumberOfGenericParameters() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.java"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt index cbe1b646dcc..c53b66ebf50 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/types/LazyJavaTypeResolver.kt @@ -20,10 +20,12 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations import org.jetbrains.kotlin.load.java.JvmAnnotationNames.* import org.jetbrains.kotlin.load.java.components.TypeUsage import org.jetbrains.kotlin.load.java.components.TypeUsage.* +import org.jetbrains.kotlin.load.java.lazy.LazyJavaAnnotations import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext import org.jetbrains.kotlin.load.java.lazy.TypeParameterResolver import org.jetbrains.kotlin.load.java.lazy.types.JavaTypeFlexibility.FLEXIBLE_LOWER_BOUND @@ -110,6 +112,7 @@ class LazyJavaTypeResolver( private val javaType: JavaClassifierType, private val attr: JavaTypeAttributes ) : AbstractLazyType(c.storageManager) { + private val annotations = CompositeAnnotations(listOf(LazyJavaAnnotations(c, javaType), attr.typeAnnotations)) private val classifier = c.storageManager.createNullableLazyValue { javaType.getClassifier() } @@ -291,7 +294,7 @@ class LazyJavaTypeResolver( override fun isMarkedNullable(): Boolean = nullable() - override fun getAnnotations() = attr.typeAnnotations + override fun getAnnotations() = annotations } public object FlexibleJavaClassifierTypeCapabilities : FlexibleTypeCapabilities { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt index 6396fa9d4e7..d6627b229fb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt @@ -65,3 +65,15 @@ class FilteredAnnotations( override fun isEmpty() = !iterator().hasNext() } + +class CompositeAnnotations( + private val delegates: List +) : Annotations { + override fun isEmpty() = delegates.all { it.isEmpty() } + + override fun findAnnotation(fqName: FqName) = delegates.asSequence().map { it.findAnnotation(fqName) }.filterNotNull().firstOrNull() + + override fun findExternalAnnotation(fqName: FqName) = delegates.asSequence().map { it.findExternalAnnotation(fqName) }.filterNotNull().firstOrNull() + + override fun iterator() = delegates.asSequence().flatMap { it.asSequence() }.iterator() +} \ No newline at end of file From c769748cb0055a501fa5426de115af66998c5823 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 19 Jun 2015 15:47:07 +0300 Subject: [PATCH 138/450] Move type enhacement parts to separate package in runtime It's needed to enhace types when loading descriptors via reflection. Also get rid of `enhanceSignatures` method in ExternalSignatureResolver as enhancement does not use external signature at all --- .../TraceBasedExternalSignatureResolver.java | 7 ------- .../java/components/ExternalSignatureResolver.java | 13 ------------- .../lazy/descriptors/LazyJavaClassMemberScope.kt | 9 ++++----- .../java/lazy/descriptors/LazyJavaMemberScope.kt | 5 +++-- .../java/typeEnhacement}/signatureEnhancement.kt | 6 +++--- .../load/java/typeEnhacement}/typeEnhancement.kt | 12 ++++++------ .../load/java/typeEnhacement}/typeQualifiers.kt | 10 +++++----- 7 files changed, 21 insertions(+), 41 deletions(-) rename {compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components => core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement}/signatureEnhancement.kt (95%) rename {compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components => core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement}/typeEnhancement.kt (92%) rename {compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components => core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement}/typeQualifiers.kt (94%) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java index 617e2abae38..767a0eaae20 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.load.java.components; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; @@ -37,7 +36,6 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationDat import org.jetbrains.kotlin.types.JetType; import javax.inject.Inject; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -136,9 +134,4 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors) { trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor, signatureErrors); } - - @Override - public Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures) { - return ComponentsPackage.enhanceSignatures(platformSignatures); - } } \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java index 673f1de131a..338adf9e7d5 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/components/ExternalSignatureResolver.java @@ -18,14 +18,12 @@ package org.jetbrains.kotlin.load.java.components; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.load.java.structure.JavaField; import org.jetbrains.kotlin.load.java.structure.JavaMember; import org.jetbrains.kotlin.load.java.structure.JavaMethod; import org.jetbrains.kotlin.types.JetType; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -75,11 +73,6 @@ public interface ExternalSignatureResolver { public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors) { throw new UnsupportedOperationException("Should not be called"); } - - @Override - public Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures) { - return platformSignatures; - } }; abstract class MemberSignature { @@ -208,10 +201,4 @@ public interface ExternalSignatureResolver { ); void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors); - - /** - * Replaces some items in the {@code platformSignatures} collection with enhanced signatures. - * Is called after binding overrides, so the implementation is allowed to inspect contents of getOverriddenDescriptors() - */ - Collection enhanceSignatures(@NotNull @ReadOnly Collection platformSignatures); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 394c49b59af..dc7734a8b68 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -35,16 +35,15 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.JavaConstructor import org.jetbrains.kotlin.load.java.structure.JavaMethod +import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorFactory import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.emptyOrSingletonList -import org.jetbrains.kotlin.utils.ifEmpty -import org.jetbrains.kotlin.utils.valuesToMap +import org.jetbrains.kotlin.utils.* import java.util.ArrayList import java.util.Collections import java.util.LinkedHashSet @@ -72,7 +71,7 @@ public class LazyJavaClassMemberScope( result.addIfNotNull(c.samConversionResolver.resolveSamAdapter(descriptor)) } - c.externalSignatureResolver.enhanceSignatures( + enhanceSignatures( result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) } ).toReadOnlyList() } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 6426e9a8fc3..f14ee7d8ae6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType import org.jetbrains.kotlin.load.java.structure.JavaField import org.jetbrains.kotlin.load.java.structure.JavaMethod import org.jetbrains.kotlin.load.java.structure.JavaValueParameter +import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES @@ -86,7 +87,7 @@ public abstract class LazyJavaMemberScope( computeNonDeclaredFunctions(result, name) - val enhancedResult = c.externalSignatureResolver.enhanceSignatures(result) + val enhancedResult = enhanceSignatures(result) // Make sure that lazy things are computed before we release the lock for (f in enhancedResult) { @@ -239,7 +240,7 @@ public abstract class LazyJavaMemberScope( if (DescriptorUtils.isAnnotationClass(containingDeclaration)) properties.toReadOnlyList() else - c.externalSignatureResolver.enhanceSignatures(properties).toReadOnlyList() + enhanceSignatures(properties).toReadOnlyList() } private fun resolveProperty(field: JavaField): PropertyDescriptor { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt similarity index 95% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt rename to core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt index 037b4a9a262..36837dfdc59 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt @@ -14,16 +14,16 @@ * limitations under the License. */ -package org.jetbrains.kotlin.load.java.components +package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.load.java.typeEnhacement.computeIndexedQualifiersForOverride +import org.jetbrains.kotlin.load.java.typeEnhacement.enhance import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor -import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor -import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor import org.jetbrains.kotlin.types.JetType fun enhanceSignatures(platformSignatures: Collection): Collection { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt similarity index 92% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt rename to core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index bcf098a9610..1d232e7b94e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -14,15 +14,15 @@ * limitations under the License. */ -package org.jetbrains.kotlin.load.java.components +package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE -import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY -import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL -import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE +import org.jetbrains.kotlin.load.java.typeEnhacement.JavaTypeQualifiers +import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.MUTABLE +import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.READ_ONLY +import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NULL +import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.types.* diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt similarity index 94% rename from compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt rename to core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index b329265c78e..15dfa4c0776 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -14,14 +14,14 @@ * limitations under the License. */ -package org.jetbrains.kotlin.load.java.components +package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.load.java.JvmAnnotationNames -import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE -import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY -import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL -import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE +import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.MUTABLE +import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.READ_ONLY +import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NULL +import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.types.JetType From 4710168c5ae4168e77899d7dc78d930c9d9fdf28 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 2 Jul 2015 12:55:53 +0300 Subject: [PATCH 139/450] Minor. Specify visibility for some declarations in typeEnhacement --- .../java/typeEnhacement/signatureEnhancement.kt | 13 ++++++------- .../load/java/typeEnhacement/typeEnhancement.kt | 2 +- .../load/java/typeEnhacement/typeQualifiers.kt | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt index 36837dfdc59..0e0c87d1f2b 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt @@ -22,17 +22,16 @@ import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.load.java.typeEnhacement.computeIndexedQualifiersForOverride -import org.jetbrains.kotlin.load.java.typeEnhacement.enhance import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.types.JetType -fun enhanceSignatures(platformSignatures: Collection): Collection { +public fun enhanceSignatures(platformSignatures: Collection): Collection { return platformSignatures.map { it.enhance() } } -fun D.enhance(): D { +private fun D.enhance(): D { // TODO type parameters // TODO use new type parameters while enhancing other types // TODO Propagation into generic type arguments @@ -75,13 +74,13 @@ interface SignaturePart { fun replaceType(newType: JetType): T } -fun ReceiverParameterDescriptor.toPart() = object : SignaturePart { +private fun ReceiverParameterDescriptor.toPart() = object : SignaturePart { override val type = this@toPart.getType() // workaround for KT-7557 override fun replaceType(newType: JetType) = newType } -fun ValueParameterDescriptor.toPart() = object : SignaturePart { +private fun ValueParameterDescriptor.toPart() = object : SignaturePart { override val type = this@toPart.getType() // workaround for KT-7557 override fun replaceType(newType: JetType) = ValueParameterDescriptorImpl( @@ -97,7 +96,7 @@ fun ValueParameterDescriptor.toPart() = object : SignaturePart { +private fun JetType.toReturnTypePart() = object : SignaturePart { override val type = this@toReturnTypePart override val isCovariant: Boolean = true @@ -105,7 +104,7 @@ fun JetType.toReturnTypePart() = object : SignaturePart { override fun replaceType(newType: JetType) = newType } -fun > D.parts(collector: (D) -> P): SignatureParts { +private fun > D.parts(collector: (D) -> P): SignatureParts { return SignatureParts( collector(this), this.getOverriddenDescriptors().map { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index 1d232e7b94e..332b72e9a05 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -39,7 +39,7 @@ private enum class TypeComponentPosition { INFLEXIBLE } -data class Result(val type: JetType, val subtreeSize: Int) +private data class Result(val type: JetType, val subtreeSize: Int) private fun JetType.enhancePossiblyFlexible(qualifiers: (Int) -> JavaTypeQualifiers, index: Int): Result { if (this.isError()) return Result(this, 1) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index 15dfa4c0776..6edac91ae36 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -36,11 +36,11 @@ enum class NullabilityQualifier { NOT_NULL } -val NULLABLE_ANNOTATIONS = listOf( +private val NULLABLE_ANNOTATIONS = listOf( JvmAnnotationNames.JETBRAINS_NULLABLE_ANNOTATION ) -val NOT_NULL_ANNOTATIONS = listOf( +private val NOT_NULL_ANNOTATIONS = listOf( JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION ) @@ -49,11 +49,11 @@ enum class MutabilityQualifier { MUTABLE } -val READ_ONLY_ANNOTATIONS = listOf( +private val READ_ONLY_ANNOTATIONS = listOf( JvmAnnotationNames.JETBRAINS_READONLY_ANNOTATION ) -val MUTABLE_ANNOTATIONS = listOf( +private val MUTABLE_ANNOTATIONS = listOf( JvmAnnotationNames.JETBRAINS_MUTABLE_ANNOTATION ) From f6c4ec153336c2e46383631929793264c0be4654 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 6 Jul 2015 15:34:23 +0300 Subject: [PATCH 140/450] Move creation of enhanced ValueParameterDescriptor to JavaCallableMemberDescriptor It's needed because new parameter owner is not created while enhacing types (It was containing declaration of old value parameter that is wrong) Also simplified SignatureParts' logic: `replaceType` is always an identity function --- .../JavaCallableMemberDescriptor.java | 2 +- .../JavaConstructorDescriptor.java | 4 +- .../descriptors/JavaMethodDescriptor.java | 4 +- .../descriptors/JavaPropertyDescriptor.java | 2 +- .../kotlin/load/java/descriptors/util.kt | 50 +++++++++++++ .../typeEnhacement/signatureEnhancement.kt | 70 +++++-------------- 6 files changed, 73 insertions(+), 59 deletions(-) create mode 100644 core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java index 5970da42013..c64326a2bf3 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaCallableMemberDescriptor.java @@ -28,7 +28,7 @@ public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor { @NotNull JavaCallableMemberDescriptor enhance( @Nullable JetType enhancedReceiverType, - @NotNull List enhancedValueParameters, + @NotNull List enhancedValueParametersTypes, @NotNull JetType enhancedReturnType ); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java index 6afd38862bb..44090e6b210 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java @@ -97,7 +97,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme @NotNull public JavaConstructorDescriptor enhance( @Nullable JetType enhancedReceiverType, - @NotNull List enhancedValueParameters, + @NotNull List enhancedValueParametersTypes, @NotNull JetType enhancedReturnType ) { JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); @@ -105,7 +105,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme enhancedReceiverType, getDispatchReceiverParameter(), getTypeParameters(), - enhancedValueParameters, + DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), enhanced), enhancedReturnType, getModality(), getVisibility() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java index 22435b63b09..e999b400cd5 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java @@ -97,7 +97,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement @NotNull public JavaMethodDescriptor enhance( @Nullable JetType enhancedReceiverType, - @NotNull List enhancedValueParameters, + @NotNull List enhancedValueParametersTypes, @NotNull JetType enhancedReturnType ) { JavaMethodDescriptor enhancedMethod = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); @@ -105,7 +105,7 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement enhancedReceiverType, getDispatchReceiverParameter(), getTypeParameters(), - enhancedValueParameters, + DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), enhancedMethod), enhancedReturnType, getModality(), getVisibility() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index 9ad24f14cdc..1b15a7b1ddf 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -47,7 +47,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja @Override public JavaCallableMemberDescriptor enhance( @Nullable JetType enhancedReceiverType, - @NotNull List enhancedValueParameters, + @NotNull List enhancedValueParametersTypes, @NotNull JetType enhancedReturnType ) { JavaPropertyDescriptor enhanced = new JavaPropertyDescriptor( diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt new file mode 100644 index 00000000000..5d11301f7ef --- /dev/null +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.descriptors + +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.resolve.descriptorUtil.module +import org.jetbrains.kotlin.types.JetType + +fun createEnhancedValueParameters( + enhancedTypes: Collection, + oldValueParameters: Collection, + newOwner: DeclarationDescriptor +): List { + assert(enhancedTypes.size() == oldValueParameters.size()) { + "Different value parameters sizes: Enhanced = ${enhancedTypes.size()}, Old = ${oldValueParameters.size()}" + } + + return enhancedTypes.zip(oldValueParameters).map { + pair -> + val (newType, oldParameter) = pair + ValueParameterDescriptorImpl( + newOwner, + null, + oldParameter.getIndex(), + oldParameter.getAnnotations(), + oldParameter.getName(), + newType, + oldParameter.declaresDefaultValue(), + if (oldParameter.getVarargElementType() != null) newOwner.module.builtIns.getArrayElementType(newType) else null, + oldParameter.getSource() + ) + } +} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt index 0e0c87d1f2b..fdce10f2176 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/signatureEnhancement.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl @@ -38,78 +39,41 @@ private fun D.enhance(): D { val enhancedReceiverType = if (getExtensionReceiverParameter() != null) - parts { it.getExtensionReceiverParameter()!!.toPart() }.enhance() + parts(isCovariant = false) { it.getExtensionReceiverParameter()!!.getType() }.enhance() else null - val enhancedValueParameters = getValueParameters().map { - p -> parts { it.getValueParameters()[p.getIndex()]!!.toPart() }.enhance() + val enhancedValueParametersTypes = getValueParameters().map { + p -> parts(isCovariant = false) { it.getValueParameters()[p.getIndex()].getType() }.enhance() } - val enhancedReturnType = parts { it.getReturnType()!!.toReturnTypePart() }.enhance() + val enhancedReturnType = parts(isCovariant = true) { it.getReturnType()!! }.enhance() if (this is JavaCallableMemberDescriptor) { @suppress("UNCHECKED_CAST") - return this.enhance(enhancedReceiverType, enhancedValueParameters, enhancedReturnType) as D + return this.enhance(enhancedReceiverType, enhancedValueParametersTypes, enhancedReturnType) as D } return this } -fun > SignatureParts.enhance(): T { - val qualifiers = fromOverride.type.computeIndexedQualifiersForOverride(this.fromOverridden.map { it.type }, fromOverride.isCovariant) - return fromOverride.replaceType(fromOverride.type.enhance(qualifiers)) -} - -class SignatureParts>( - val fromOverride: P, - val fromOverridden: Collection

-) - -interface SignaturePart { +private class SignatureParts( + val fromOverride: JetType, + val fromOverridden: Collection, val isCovariant: Boolean - get() = false - - val type: JetType - - fun replaceType(newType: JetType): T +) { + fun enhance(): JetType { + val qualifiers = fromOverride.computeIndexedQualifiersForOverride(this.fromOverridden, isCovariant) + return fromOverride.enhance(qualifiers) + } } -private fun ReceiverParameterDescriptor.toPart() = object : SignaturePart { - override val type = this@toPart.getType() // workaround for KT-7557 - - override fun replaceType(newType: JetType) = newType -} - -private fun ValueParameterDescriptor.toPart() = object : SignaturePart { - override val type = this@toPart.getType() // workaround for KT-7557 - - override fun replaceType(newType: JetType) = ValueParameterDescriptorImpl( - getContainingDeclaration(), - null, - getIndex(), - getAnnotations(), - getName(), - newType, - declaresDefaultValue(), - if (getVarargElementType() != null) KotlinBuiltIns.getInstance().getArrayElementType(newType) else null, - getSource() - ) -} - -private fun JetType.toReturnTypePart() = object : SignaturePart { - override val type = this@toReturnTypePart - - override val isCovariant: Boolean = true - - override fun replaceType(newType: JetType) = newType -} - -private fun > D.parts(collector: (D) -> P): SignatureParts { +private fun D.parts(isCovariant: Boolean, collector: (D) -> JetType): SignatureParts { return SignatureParts( collector(this), this.getOverriddenDescriptors().map { @suppress("UNCHECKED_CAST") collector(it as D) - } + }, + isCovariant ) } \ No newline at end of file From c01c59d562b6051d6d1a6ba2eed1b7fd08fddbc9 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 8 Jul 2015 10:51:36 +0300 Subject: [PATCH 141/450] Use doSubstitute when enhacing types of Java method Before this commit old type parameters were inserted into new descriptor, and that broke a simple contract: desc.child.getContainingDeclaration() == desc. We use `doSubstitute` here because it does exactly what we need: 1. creates full copy of descriptor 2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc. But we had to customize `doSubstitute`: add some parameters like `newReturnType` NOTE: Strange testData change. (Mutable)List! after substitution becomes MutableList..List<*>?. But it's not wrong because List behaves exactly as List<*>, and the same happens when substituing Java class scope: public class A { void foo(List x) {} } Kotlin: A.foo(), type of first value parameter --- (Mutable)List A().foo(), type of first value parameter --- MutableList..List<*>? --- .../MethodWithMappedClasses.txt | 2 +- .../MethodWithTypeParameters.txt | 2 +- .../JavaConstructorDescriptor.java | 1 + .../descriptors/JavaMethodDescriptor.java | 23 ++++++---- .../impl/FunctionDescriptorImpl.java | 42 ++++++++++++++++--- .../impl/PropertyDescriptorImpl.java | 4 +- 6 files changed, 56 insertions(+), 18 deletions(-) diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.txt index af3fde71cba..ff5ea05cdd9 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.txt @@ -2,5 +2,5 @@ package test public open class MethodWithMappedClasses { public constructor MethodWithMappedClasses() - public open fun copy(/*0*/ dest: kotlin.(Mutable)List!, /*1*/ src: kotlin.(Mutable)List!): kotlin.Unit + public open fun copy(/*0*/ dest: (kotlin.MutableList..kotlin.List<*>?), /*1*/ src: kotlin.(Mutable)List!): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.txt index 8a999647cfc..8c2a3a0006c 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.txt @@ -2,5 +2,5 @@ package test public open class MethodWithTypeParameters { public constructor MethodWithTypeParameters() - public open fun foo(/*0*/ a: A!, /*1*/ b: (kotlin.MutableList..kotlin.List?), /*2*/ c: kotlin.(Mutable)List!): kotlin.Unit where B : kotlin.(Mutable)List! + public open fun foo(/*0*/ a: A!, /*1*/ b: (kotlin.MutableList..kotlin.List?), /*2*/ c: (kotlin.MutableList..kotlin.List<*>?)): kotlin.Unit where B : kotlin.(Mutable)List! } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java index 44090e6b210..4343f749847 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaConstructorDescriptor.java @@ -101,6 +101,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme @NotNull JetType enhancedReturnType ) { JavaConstructorDescriptor enhanced = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); + // We do not use doSubstitute here as in JavaMethodDescriptor.enhance because type parameters of constructor belongs to class enhanced.initialize( enhancedReceiverType, getDispatchReceiverParameter(), diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java index e999b400cd5..e9f9b2aa4b8 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaMethodDescriptor.java @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.types.TypeSubstitutor; import java.util.List; @@ -100,16 +101,20 @@ public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implement @NotNull List enhancedValueParametersTypes, @NotNull JetType enhancedReturnType ) { - JavaMethodDescriptor enhancedMethod = createSubstitutedCopy(getContainingDeclaration(), getOriginal(), getKind()); - enhancedMethod.initialize( - enhancedReceiverType, - getDispatchReceiverParameter(), - getTypeParameters(), - DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), enhancedMethod), - enhancedReturnType, - getModality(), - getVisibility() + List enhancedValueParameters = + DescriptorsPackage.createEnhancedValueParameters(enhancedValueParametersTypes, getValueParameters(), this); + + // We use `doSubstitute` here because it does exactly what we need: + // 1. creates full copy of descriptor + // 2. copies method's type parameters (with new containing declaration) and properly substitute to them in value parameters, return type and etc. + JavaMethodDescriptor enhancedMethod = (JavaMethodDescriptor) doSubstitute( + TypeSubstitutor.EMPTY, getContainingDeclaration(), getModality(), getVisibility(), getOriginal(), + /* copyOverrides = */ false, getKind(), + enhancedValueParameters, enhancedReceiverType, enhancedReturnType ); + + assert enhancedMethod != null : "null after substitution while enhancing " + toString(); + for (FunctionDescriptor overridden : getOverriddenDescriptors()) { enhancedMethod.addOverriddenDescriptor(overridden); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java index 3ce0941e14b..dfb6b614f3e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/FunctionDescriptorImpl.java @@ -197,6 +197,31 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo @Nullable FunctionDescriptor original, boolean copyOverrides, @NotNull Kind kind + ) { + return doSubstitute(originalSubstitutor, + newOwner, newModality, newVisibility, original, copyOverrides, kind, + getValueParameters(), getExtensionReceiverParameterType(), getReturnType() + ); + } + + @Nullable + protected JetType getExtensionReceiverParameterType() { + if (extensionReceiverParameter == null) return null; + return extensionReceiverParameter.getType(); + } + + + @Nullable + protected FunctionDescriptor doSubstitute(@NotNull TypeSubstitutor originalSubstitutor, + @NotNull DeclarationDescriptor newOwner, + @NotNull Modality newModality, + @NotNull Visibility newVisibility, + @Nullable FunctionDescriptor original, + boolean copyOverrides, + @NotNull Kind kind, + @NotNull List newValueParameterDescriptors, + @Nullable JetType newExtensionReceiverParameterType, + @NotNull JetType newReturnType ) { FunctionDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, original, kind); @@ -207,8 +232,8 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo ); JetType substitutedReceiverParameterType = null; - if (extensionReceiverParameter != null) { - substitutedReceiverParameterType = substitutor.substitute(getExtensionReceiverParameter().getType(), Variance.IN_VARIANCE); + if (newExtensionReceiverParameterType != null) { + substitutedReceiverParameterType = substitutor.substitute(newExtensionReceiverParameterType, Variance.IN_VARIANCE); if (substitutedReceiverParameterType == null) { return null; } @@ -232,12 +257,14 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo } } - List substitutedValueParameters = getSubstitutedValueParameters(substitutedDescriptor, this, substitutor); + List substitutedValueParameters = getSubstitutedValueParameters( + substitutedDescriptor, newValueParameterDescriptors, substitutor + ); if (substitutedValueParameters == null) { return null; } - JetType substitutedReturnType = substitutor.substitute(getReturnType(), Variance.OUT_VARIANCE); + JetType substitutedReturnType = substitutor.substitute(newReturnType, Variance.OUT_VARIANCE); if (substitutedReturnType == null) { return null; } @@ -272,9 +299,12 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo } @Nullable - public static List getSubstitutedValueParameters(FunctionDescriptor substitutedDescriptor, @NotNull FunctionDescriptor functionDescriptor, @NotNull TypeSubstitutor substitutor) { + public static List getSubstitutedValueParameters( + FunctionDescriptor substitutedDescriptor, + @NotNull List unsubstitutedValueParameters, + @NotNull TypeSubstitutor substitutor + ) { List result = new ArrayList(); - List unsubstitutedValueParameters = functionDescriptor.getValueParameters(); for (ValueParameterDescriptor unsubstitutedValueParameter : unsubstitutedValueParameters) { // TODO : Lazy? JetType substitutedType = substitutor.substitute(unsubstitutedValueParameter.getType(), Variance.IN_VARIANCE); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java index b03a1c84f8b..546b9a39ef7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java @@ -255,7 +255,9 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr setter.hasBody(), setter.isDefault(), kind, original == null ? null : original.getSetter(), SourceElement.NO_SOURCE ); if (newSetter != null) { - List substitutedValueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters(newSetter, setter, substitutor); + List substitutedValueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters( + newSetter, setter.getValueParameters(), substitutor + ); if (substitutedValueParameters == null) { // The setter is projected out, e.g. in this case: // trait Tr { var v: T } From 1469a0aa6fef0e398ba527af334e9f7c6ce74ce3 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 2 Jul 2015 12:53:48 +0300 Subject: [PATCH 142/450] Make computation of indexed JavaTypeQualifiers eager --- .../load/java/typeEnhacement/typeQualifiers.kt | 12 ++++++++---- .../src/org/jetbrains/kotlin/utils/collections.kt | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index 6edac91ae36..fdf1f306047 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -119,16 +119,20 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection val isHeadTypeConstructor = index == 0 - if (!isHeadTypeConstructor && onlyHeadTypeConstructor) return JavaTypeQualifiers.NONE + assert(isHeadTypeConstructor || !onlyHeadTypeConstructor) { "Only head type constructors should be computed" } - val qualifiers = indexedThisType.getOrDefault(index, { return JavaTypeQualifiers.NONE }) + val qualifiers = indexedThisType[index] val verticalSlice = indexedFromSupertypes.map { it.getOrDefault(index, { null }) }.filterNotNull() // Only the head type constructor is safely co-variant - return qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor) + qualifiers.computeQualifiersForOverride(verticalSlice, isCovariant && isHeadTypeConstructor) } + + return { index -> computedResult.getOrDefault(index) { JavaTypeQualifiers.NONE } } } private fun JetType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt index 64bd09855ce..3aaf3f7ac6c 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt @@ -106,4 +106,5 @@ public fun Collection.toReadOnlyList(): List = public fun T?.singletonOrEmptyList(): List = if (this != null) Collections.singletonList(this) else Collections.emptyList() -public inline fun List.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) \ No newline at end of file +public inline fun List.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) +public inline fun Array.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) From 0375e45936acde17d4648531eb247c65aa1cb229 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 18 Jun 2015 10:16:14 +0300 Subject: [PATCH 143/450] Change reporting policy for NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS If lower bound of flexible is nullable treat it like Kotlin nullable type Anyway appropriate errors are reported outside JavaNullabilityWarningsChecker --- .../kotlin/load/kotlin/KotlinJvmCheckerProvider.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index a2088456c69..0853a822abc 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -217,12 +217,18 @@ private fun checkTypeParameterDescriptorsAreNotReified( public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { private fun JetType.mayBeNull(): NullabilityInformationSource? { if (!isError() && !isFlexible() && TypeUtils.isNullableType(this)) return NullabilityInformationSource.KOTLIN + + if (isFlexible() && TypeUtils.isNullableType(flexibility().lowerBound)) return NullabilityInformationSource.KOTLIN + if (getAnnotations().isMarkedNullable()) return NullabilityInformationSource.JAVA return null } private fun JetType.mustNotBeNull(): NullabilityInformationSource? { if (!isError() && !isFlexible() && !TypeUtils.isNullableType(this)) return NullabilityInformationSource.KOTLIN + + if (isFlexible() && !TypeUtils.isNullableType(flexibility().upperBound)) return NullabilityInformationSource.KOTLIN + if (!isMarkedNullable() && getAnnotations().isMarkedNotNull()) return NullabilityInformationSource.JAVA return null } From a551f21e9f449c37cf9d49f0221582b42e140eae Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 17 Jun 2015 17:44:38 +0300 Subject: [PATCH 144/450] Use original descriptor when trying to obtain source Also refine `getOriginal` of `DeclarationDescriptorWithSource` for comfortable use --- .../descriptors/DeclarationDescriptorWithSource.java | 4 ++++ .../kotlin/descriptors/impl/AbstractClassDescriptor.java | 2 +- .../descriptors/impl/DeclarationDescriptorNonRootImpl.java | 7 +++++++ .../descriptors/impl/LazySubstitutingClassDescriptor.java | 2 +- .../kotlin/idea/caches/resolve/JavaResolveExtension.kt | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithSource.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithSource.java index 3fb6c5c672b..8da3c734972 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithSource.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/DeclarationDescriptorWithSource.java @@ -21,4 +21,8 @@ import org.jetbrains.annotations.NotNull; public interface DeclarationDescriptorWithSource extends DeclarationDescriptor { @NotNull SourceElement getSource(); + + @Override + @NotNull + DeclarationDescriptorWithSource getOriginal(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java index 336195d6f3d..21c4b60d743 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java @@ -66,7 +66,7 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { @NotNull @Override - public DeclarationDescriptor getOriginal() { + public DeclarationDescriptorWithSource getOriginal() { return this; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorNonRootImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorNonRootImpl.java index 018cf921e16..6b83fd6d018 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorNonRootImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/DeclarationDescriptorNonRootImpl.java @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptorNonRoot; +import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource; import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; @@ -45,6 +46,12 @@ public abstract class DeclarationDescriptorNonRootImpl this.source = source; } + @NotNull + @Override + public DeclarationDescriptorWithSource getOriginal() { + return (DeclarationDescriptorWithSource) super.getOriginal(); + } + @Override @NotNull public DeclarationDescriptor getContainingDeclaration() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index aeb3b18cbee..224498d01e7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -146,7 +146,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public DeclarationDescriptor getOriginal() { + public DeclarationDescriptorWithSource getOriginal() { return original.getOriginal(); } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt index 95cfd9a5edf..ba0e9518b98 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt @@ -104,7 +104,7 @@ private fun JavaDescriptorResolver.getContainingScope(member: JavaMember): JetSc private fun Collection.findByJavaElement(javaElement: JavaElement): T? { return firstOrNull { member -> - val memberJavaElement = (member.getSource() as? JavaSourceElement)?.javaElement + val memberJavaElement = (member.getOriginal().getSource() as? JavaSourceElement)?.javaElement when { memberJavaElement == javaElement -> true From fd43799c6ee42ff85ef540a3b6006763ae93a041 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 17 Jun 2015 18:27:01 +0300 Subject: [PATCH 145/450] Use original descriptor when working with errors in KotlinSignature Otherwise enhanced version are treated differently --- .../components/TraceBasedExternalSignatureResolver.java | 2 +- .../kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java | 4 ++-- .../load/java/descriptors/JavaPropertyDescriptor.java | 8 +++++--- .../java/lazy/descriptors/LazyJavaClassMemberScope.kt | 2 +- .../load/java/lazy/descriptors/LazyJavaMemberScope.kt | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java index 767a0eaae20..9fa7cfa7d22 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java @@ -132,6 +132,6 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes @Override public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List signatureErrors) { - trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor, signatureErrors); + trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor.getOriginal(), signatureErrors); } } \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java index cdf983a252a..b982e1a93e2 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java @@ -90,7 +90,7 @@ public class ExpectedLoadErrorsUtil { //noinspection ConstantConditions List errors = Arrays.asList(error.split("\\|")); - map.put(descriptor, errors); + map.put(descriptor.getOriginal(), errors); return null; } @@ -113,7 +113,7 @@ public class ExpectedLoadErrorsUtil { Collection descriptors = bindingContext.getKeys(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS); for (DeclarationDescriptor descriptor : descriptors) { List errors = bindingContext.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor); - result.put(descriptor, errors); + result.put(descriptor.getOriginal(), errors); } return result; diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java index 1b15a7b1ddf..5bcfa77bde4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/JavaPropertyDescriptor.java @@ -33,9 +33,10 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja @NotNull Visibility visibility, boolean isVar, @NotNull Name name, - @NotNull SourceElement source + @NotNull SourceElement source, + @Nullable PropertyDescriptor original ) { - super(containingDeclaration, null, annotations, Modality.FINAL, visibility, isVar, name, Kind.DECLARATION, source); + super(containingDeclaration, original, annotations, Modality.FINAL, visibility, isVar, name, Kind.DECLARATION, source); } @Override @@ -56,7 +57,8 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja getVisibility(), isVar(), getName(), - getSource() + getSource(), + getOriginal() ); assert getGetter() == null : "Field must not have a getter: " + this; assert getSetter() == null : "Field must not have a setter: " + this; diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index dc7734a8b68..90951433e91 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -104,7 +104,7 @@ public class LazyJavaClassMemberScope( val propertyDescriptor = JavaPropertyDescriptor( getContainingDeclaration(), annotations, method.getVisibility(), - /* isVar = */ false, method.getName(), c.sourceElementFactory.source(method) + /* isVar = */ false, method.getName(), c.sourceElementFactory.source(method), /* original */ null ) // default getter is necessary because there is no real field in annotation diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index f14ee7d8ae6..30b7914a38a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -276,7 +276,7 @@ public abstract class LazyJavaMemberScope( val propertyName = field.getName() return JavaPropertyDescriptor(containingDeclaration, annotations, visibility, isVar, propertyName, - c.sourceElementFactory.source(field)) + c.sourceElementFactory.source(field), /* original = */ null) } private fun getPropertyType(field: JavaField, annotations: Annotations): JetType { From e13f34a8a006bb14bb6ef2947d2486244b2b8604 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 6 Jul 2015 18:59:39 +0300 Subject: [PATCH 146/450] Minor. Use getOrElse from stdlib --- .../kotlin/load/java/typeEnhacement/typeQualifiers.kt | 5 ++--- .../src/org/jetbrains/kotlin/utils/collections.kt | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt index fdf1f306047..5c46b8e4d9f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeQualifiers.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.flexibility import org.jetbrains.kotlin.types.isFlexible -import org.jetbrains.kotlin.utils.getOrDefault import java.util.ArrayList enum class NullabilityQualifier { @@ -126,13 +125,13 @@ fun JetType.computeIndexedQualifiersForOverride(fromSupertypes: Collection computedResult.getOrDefault(index) { JavaTypeQualifiers.NONE } } + return { index -> computedResult.getOrElse(index) { JavaTypeQualifiers.NONE } } } private fun JetType.computeQualifiersForOverride(fromSupertypes: Collection, isCovariant: Boolean): JavaTypeQualifiers { diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt index 3aaf3f7ac6c..4e97127de1d 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt @@ -105,6 +105,3 @@ public fun Collection.toReadOnlyList(): List = if (isEmpty()) Collections.emptyList() else ArrayList(this) public fun T?.singletonOrEmptyList(): List = if (this != null) Collections.singletonList(this) else Collections.emptyList() - -public inline fun List.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) -public inline fun Array.getOrDefault(index: Int, default: (Int) -> T): T = if (index in 0..size() - 1) this[index] else default(index) From 0173cb1c17e4f5c6141c000e78bb2b18404a4238 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 6 Jul 2015 18:40:40 +0300 Subject: [PATCH 147/450] Diagnostics test data fixed --- .../tests/TraitOverrideObjectMethods.txt | 2 +- .../ValAndFunOverrideCompatibilityClash.txt | 26 +++++++-------- .../delegation/DelegationToJavaIface.txt | 4 +-- .../tests/j+k/GenericsInSupertypes.txt | 32 +++++++++---------- ...umentsNullability-NotNull-SpecialTypes.txt | 4 +-- ...ArgumentsNullability-NotNull-UserTypes.txt | 4 +-- .../tests/j+k/javaStaticImport.txt | 2 +- .../j+k/kt1730_implementCharSequence.txt | 8 ++--- .../tests/nullabilityAndSmartCasts/kt1270.kt | 2 +- .../nullabilityWarnings/kt6829.kt | 2 +- .../platformTypes/supertypeTypeArguments.txt | 14 ++++---- .../tests/regressions/kt1639-JFrame.txt | 2 +- .../diagnostics/tests/regressions/kt588.txt | 2 +- .../diagnostics/tests/scopes/visibility2.txt | 26 +++++++-------- .../diagnostics/tests/subtyping/kt-1457.txt | 26 +++++++-------- .../when/ExhaustivePlatformEnumAnnotated.txt | 2 +- 16 files changed, 79 insertions(+), 79 deletions(-) diff --git a/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.txt b/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.txt index 6cd3c885d45..4e261e98d7d 100644 --- a/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.txt +++ b/compiler/testData/diagnostics/tests/TraitOverrideObjectMethods.txt @@ -2,7 +2,7 @@ package internal interface MyTrait : java.lang.Object { protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ fun finalize(): kotlin.Unit public final override /*1*/ /*fake_override*/ fun getClass(): java.lang.Class<*>! public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt b/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt index 7aa796b4868..b9509423bbb 100644 --- a/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt +++ b/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt @@ -25,12 +25,12 @@ internal final class Foo1 : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.Int!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): kotlin.Int! public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -40,24 +40,24 @@ internal final class Foo1 : java.util.ArrayList { public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Int! invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.Int! - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int!): kotlin.Int! public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/delegation/DelegationToJavaIface.txt b/compiler/testData/diagnostics/tests/delegation/DelegationToJavaIface.txt index 18399c5fefe..6ba09e9a8d9 100644 --- a/compiler/testData/diagnostics/tests/delegation/DelegationToJavaIface.txt +++ b/compiler/testData/diagnostics/tests/delegation/DelegationToJavaIface.txt @@ -11,13 +11,13 @@ internal final class TestIface : java.lang.Runnable { internal final class TestObject : java.lang.Object { public constructor TestObject(/*0*/ o: java.lang.Object) protected open override /*1*/ /*delegation*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean protected open override /*1*/ /*delegation*/ fun finalize(): kotlin.Unit public final override /*1*/ /*fake_override*/ fun getClass(): java.lang.Class<*>! public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public final override /*1*/ /*fake_override*/ fun notify(): kotlin.Unit public final override /*1*/ /*fake_override*/ fun notifyAll(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public final override /*1*/ /*fake_override*/ fun wait(): kotlin.Unit public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0: kotlin.Long): kotlin.Unit public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0: kotlin.Long, /*1*/ p1: kotlin.Int): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt b/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt index 0d49eb4bc2f..f3be5c0cf91 100644 --- a/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt @@ -7,12 +7,12 @@ internal abstract class AL : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: p.P!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: p.P!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): p.P! public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -22,24 +22,24 @@ internal abstract class AL : java.util.ArrayList { public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): p.P! invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): p.P! - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: p.P!): p.P! public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -50,7 +50,7 @@ internal abstract class AL : java.util.ArrayList { internal abstract class K : p.C { public constructor K() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p: p.A!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p: p.A): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -67,7 +67,7 @@ package p { public open class B : p.A { public constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public/*package*/ open override /*1*/ fun foo(/*0*/ p: p.A!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p: p.A): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -75,7 +75,7 @@ package p { public open class C : p.B, p.A { public constructor C() public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*2*/ /*fake_override*/ fun foo(/*0*/ p: p.A!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun foo(/*0*/ p: p.A): kotlin.Unit public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt index ac3d083dfb6..04ca74d4447 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt @@ -11,9 +11,9 @@ public open class A { public open class X { public constructor X() - public/*package*/ open fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: T!): kotlin.Unit + public/*package*/ open fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: T): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - org.jetbrains.annotations.NotNull() public/*package*/ open fun fooN(): T! + org.jetbrains.annotations.NotNull() public/*package*/ open fun fooN(): T public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt index 28891f6e92d..0363db8ebbb 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt @@ -11,9 +11,9 @@ public open class A { public open class X { public constructor X() - public/*package*/ open fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: T!): kotlin.Unit + public/*package*/ open fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: T): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - org.jetbrains.annotations.NotNull() public/*package*/ open fun fooN(): T! + org.jetbrains.annotations.NotNull() public/*package*/ open fun fooN(): T public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/j+k/javaStaticImport.txt b/compiler/testData/diagnostics/tests/j+k/javaStaticImport.txt index 6a1ca31528e..a508a227198 100644 --- a/compiler/testData/diagnostics/tests/j+k/javaStaticImport.txt +++ b/compiler/testData/diagnostics/tests/j+k/javaStaticImport.txt @@ -19,7 +19,7 @@ package backend { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - org.jetbrains.annotations.NotNull() public open fun doSmth(/*0*/ s: kotlin.String!): kotlin.String! + org.jetbrains.annotations.NotNull() public open fun doSmth(/*0*/ s: kotlin.String!): kotlin.String } } } diff --git a/compiler/testData/diagnostics/tests/j+k/kt1730_implementCharSequence.txt b/compiler/testData/diagnostics/tests/j+k/kt1730_implementCharSequence.txt index 437a3bf71db..8b782e8a748 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt1730_implementCharSequence.txt +++ b/compiler/testData/diagnostics/tests/j+k/kt1730_implementCharSequence.txt @@ -6,8 +6,8 @@ public open class C : kotlin.CharSequence { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int java.lang.Override() public open override /*1*/ fun length(): kotlin.Int - java.lang.Override() public open override /*1*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence! - java.lang.Override() public open override /*1*/ fun toString(): kotlin.String! + java.lang.Override() public open override /*1*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence + java.lang.Override() public open override /*1*/ fun toString(): kotlin.String } internal final class T : C { @@ -16,6 +16,6 @@ internal final class T : C { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int java.lang.Override() public open override /*1*/ /*fake_override*/ fun length(): kotlin.Int - java.lang.Override() public open override /*1*/ /*fake_override*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence! - java.lang.Override() public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String! + java.lang.Override() public open override /*1*/ /*fake_override*/ fun subSequence(/*0*/ start: kotlin.Int, /*1*/ end: kotlin.Int): kotlin.CharSequence + java.lang.Override() public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt index 3b0a1227122..7f56511c759 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/kt1270.kt @@ -5,7 +5,7 @@ package kt1270 fun foo() { val sc = java.util.HashMap()[""] - val value = sc.value + val value = sc.value } private class SomeClass() { diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt index 9d76a42b010..04c35b7a7ba 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.kt @@ -16,7 +16,7 @@ public class J { fun foo(collection: Collection) { val mapped = collection.map { it.method() } - mapped[0].length() + mapped[0].length() } public fun Iterable.map(transform: (T) -> R): List { diff --git a/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt b/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt index f8e286d2825..63e5756d6bc 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt @@ -29,12 +29,12 @@ internal final class HashMapEx : java.util.HashMap, ExtM invisible_fake open override /*1*/ /*fake_override*/ fun addEntry(/*0*/ p0: kotlin.Int, /*1*/ p1: K!, /*2*/ p2: V!, /*3*/ p3: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun capacity(): kotlin.Int public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any public open override /*2*/ /*fake_override*/ fun containsKey(/*0*/ key: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun containsNullValue(): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun containsValue(/*0*/ value: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun createEntry(/*0*/ p0: kotlin.Int, /*1*/ p1: K!, /*2*/ p2: V!, /*3*/ p3: kotlin.Int): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun entrySet(): kotlin.Set> + public open override /*2*/ /*fake_override*/ fun entrySet(): kotlin.MutableSet> invisible_fake open override /*1*/ /*fake_override*/ fun entrySet0(): kotlin.(Mutable)Set!>! public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun get(/*0*/ key: kotlin.Any?): V? @@ -44,24 +44,24 @@ internal final class HashMapEx : java.util.HashMap, ExtM public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int invisible_fake open override /*1*/ /*fake_override*/ fun init(): kotlin.Unit public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*2*/ /*fake_override*/ fun keySet(): kotlin.Set + public open override /*2*/ /*fake_override*/ fun keySet(): kotlin.MutableSet invisible_fake open override /*1*/ /*fake_override*/ fun loadFactor(): kotlin.Float invisible_fake open override /*1*/ /*fake_override*/ fun newEntryIterator(): kotlin.(Mutable)Iterator!>! invisible_fake open override /*1*/ /*fake_override*/ fun newKeyIterator(): kotlin.(Mutable)Iterator! invisible_fake open override /*1*/ /*fake_override*/ fun newValueIterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun put(/*0*/ key: K!, /*1*/ value: V!): V! - public open override /*1*/ /*fake_override*/ fun putAll(/*0*/ m: (kotlin.MutableMap..kotlin.Map?)): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun put(/*0*/ key: K!, /*1*/ value: V!): V? + public open override /*1*/ /*fake_override*/ fun putAll(/*0*/ m: kotlin.Map): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putAllForCreate(/*0*/ p0: (kotlin.MutableMap..kotlin.Map?)): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putForCreate(/*0*/ p0: K!, /*1*/ p1: V!): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putForNullKey(/*0*/ p0: V!): V! invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ key: kotlin.Any!): V! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ key: kotlin.Any?): V? invisible_fake final override /*1*/ /*fake_override*/ fun removeEntryForKey(/*0*/ p0: kotlin.Any!): java.util.HashMap.Entry! invisible_fake final override /*1*/ /*fake_override*/ fun removeMapping(/*0*/ p0: kotlin.Any!): java.util.HashMap.Entry! invisible_fake open override /*1*/ /*fake_override*/ fun resize(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*2*/ /*fake_override*/ fun size(): kotlin.Int public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String invisible_fake open override /*1*/ /*fake_override*/ fun transfer(/*0*/ p0: kotlin.Array<(out) java.util.HashMap.Entry<*, *>!>!, /*1*/ p1: kotlin.Boolean): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun values(): kotlin.Collection + public open override /*2*/ /*fake_override*/ fun values(): kotlin.MutableCollection invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/regressions/kt1639-JFrame.txt b/compiler/testData/diagnostics/tests/regressions/kt1639-JFrame.txt index c78ad5184f8..6463448f65c 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt1639-JFrame.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt1639-JFrame.txt @@ -645,7 +645,7 @@ package test { invisible_fake final override /*1*/ /*fake_override*/ fun toBack_NoClientCode(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toFront(): kotlin.Unit invisible_fake final override /*1*/ /*fake_override*/ fun toFront_NoClientCode(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun transferFocus(): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun transferFocus(/*0*/ p0: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun transferFocusBackward(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/regressions/kt588.txt b/compiler/testData/diagnostics/tests/regressions/kt588.txt index a6169143ac2..2cb6a33a6f2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt588.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt588.txt @@ -69,7 +69,7 @@ internal final class Test : java.lang.Thread { invisible_fake open override /*1*/ /*fake_override*/ fun stop0(/*0*/ p0: kotlin.Any!): kotlin.Unit kotlin.deprecated(value = "Deprecated in Java") public final override /*1*/ /*fake_override*/ fun suspend(): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun suspend0(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public companion object Companion { private constructor Companion() diff --git a/compiler/testData/diagnostics/tests/scopes/visibility2.txt b/compiler/testData/diagnostics/tests/scopes/visibility2.txt index db6469ade5f..c7e4aa9e390 100644 --- a/compiler/testData/diagnostics/tests/scopes/visibility2.txt +++ b/compiler/testData/diagnostics/tests/scopes/visibility2.txt @@ -38,12 +38,12 @@ package b { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: java.lang.Integer!): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): java.lang.Integer! public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -53,24 +53,24 @@ package b { public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): java.lang.Integer! invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): java.lang.Integer! - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer!): java.lang.Integer! public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt b/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt index 49c11b0035e..3ec3dd40f8f 100644 --- a/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt +++ b/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt @@ -9,12 +9,12 @@ internal final class MyListOfPairs : java.util.ArrayList> { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: Pair!): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: Pair!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection!>..kotlin.Collection!>?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection!>..kotlin.Collection!>?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection!>): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection!>): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): Pair! public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -24,24 +24,24 @@ internal final class MyListOfPairs : java.util.ArrayList> { public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): Pair! invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator!>! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator!>! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator!>! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator!> + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator!> + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator!> invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): Pair! - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: Pair!): Pair! public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List!>! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList!> public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.txt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.txt index 0f5c9acb5f8..a8a18e3895f 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.txt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.txt @@ -32,7 +32,7 @@ public final enum class J : kotlin.Enum { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - org.jetbrains.annotations.NotNull() public open fun create(): J! + org.jetbrains.annotations.NotNull() public open fun create(): J public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): J public final /*synthesized*/ fun values(): kotlin.Array } From 4e17500e1ce50811ff3fb6556c59bd58e934bb4a Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 29 Apr 2015 17:12:32 +0300 Subject: [PATCH 148/450] Test data for LoadJava tests fixed --- .../class/ExtendsAbstractListT.txt | 14 +++++----- .../class/ImplementsListString.txt | 14 +++++----- .../primitiveOverride/ByteOverridesObject.txt | 2 +- .../IntOverridesComparable.txt | 2 +- .../primitiveOverride/IntOverridesNumber.txt | 2 +- .../primitiveOverride/IntOverridesObject.txt | 2 +- .../NullableIntOverridesObject.txt | 2 +- .../primitiveOverride/OverrideInJava.txt | 2 +- .../ClassDoesNotOverrideMethod.txt | 2 +- .../parameter/InheritNullability.txt | 4 +-- .../propagation/parameter/Kt3302.txt | 4 +-- .../parameter/NotNullToNullable.txt | 4 +-- .../parameter/NullableToNotNull.txt | 2 +- .../parameter/SubclassFromGenericAndNot.txt | 4 +-- .../return/AddNotNullJavaSubtype.txt | 2 +- .../return/AddNotNullSameJavaType.txt | 2 +- .../return/AddNullabilityJavaSubtype.txt | 4 +-- .../return/AddNullabilitySameJavaType.txt | 4 +-- .../return/InheritNullabilityJavaSubtype.txt | 4 +-- .../return/InheritNullabilitySameJavaType.txt | 4 +-- .../return/SubclassOfCollection.txt | 2 +- .../TwoSuperclassesReturnJavaSubtype.txt | 4 +-- .../TwoSuperclassesReturnSameJavaType.txt | 4 +-- .../modality/ModalityOfFakeOverrides.txt | 16 ++++++------ .../compiledJava/mutability/LoadIterable.txt | 8 +++--- .../LoadIterableWithNullability.txt | 8 +++--- .../LoadIterableWithPropagation.txt | 16 ++++++------ .../compiledJava/notNull/NotNullIntArray.txt | 2 +- .../compiledJava/notNull/NotNullMethod.txt | 2 +- .../notNull/NotNullObjectArray.txt | 2 +- .../compiledJava/notNull/NotNullParameter.txt | 2 +- .../InheritedOverriddenAdapter.txt | 2 +- .../OverriddenAmbiguousAdapters.txt | 2 +- .../signaturePropagation/RawSuperType.txt | 2 +- ...peWithRecursiveBoundMultipleParameters.txt | 2 +- .../ClassWithObjectMethod.txt | 2 +- .../ClassDoesNotOverrideMethod.txt | 2 +- .../modality/ModalityOfFakeOverrides.txt | 14 +++++----- .../platformTypes/notnullTypeArgument.txt | 26 +++++++++---------- .../platformTypes/nullableTypeArgument.txt | 26 +++++++++---------- .../SamAdapterForOverriddenFromKotlin.txt | 2 +- .../DeepSubclassingKotlinInJava.txt | 6 ++--- .../InheritExtensionAndNot.txt | 4 +-- .../InheritExtensionFunction.txt | 2 +- .../SubclassFromTraitImplementation.txt | 2 +- .../SubclassingKotlinInJava.txt | 2 +- ...opagationAgainstDeserializedSuperclass.txt | 2 +- 47 files changed, 122 insertions(+), 122 deletions(-) diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.txt b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.txt index 3d18e1b2dff..0a34238bdb0 100644 --- a/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.txt +++ b/compiler/testData/compileJavaAgainstKotlin/class/ExtendsAbstractListT.txt @@ -10,17 +10,17 @@ internal abstract class Mine : java.util.AbstractList { public open /*fake_override*/ fun add(/*0*/ T!): kotlin.Boolean public open /*fake_override*/ fun add(/*0*/ kotlin.Int, /*1*/ T!): kotlin.Unit public open /*fake_override*/ fun addAll(/*0*/ kotlin.Collection): kotlin.Boolean - public open /*fake_override*/ fun addAll(/*0*/ kotlin.Int, /*1*/ (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open /*fake_override*/ fun addAll(/*0*/ kotlin.Int, /*1*/ kotlin.Collection): kotlin.Boolean public open /*fake_override*/ fun clear(): kotlin.Unit public open /*fake_override*/ fun contains(/*0*/ kotlin.Any?): kotlin.Boolean public open /*fake_override*/ fun containsAll(/*0*/ kotlin.Collection): kotlin.Boolean public abstract /*fake_override*/ fun get(/*0*/ kotlin.Int): T! - public open /*fake_override*/ fun indexOf(/*0*/ kotlin.Any!): kotlin.Int + public open /*fake_override*/ fun indexOf(/*0*/ kotlin.Any?): kotlin.Int public open /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open /*fake_override*/ fun lastIndexOf(/*0*/ kotlin.Any!): kotlin.Int - public open /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open /*fake_override*/ fun listIterator(/*0*/ kotlin.Int): kotlin.(Mutable)ListIterator! + public open /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open /*fake_override*/ fun lastIndexOf(/*0*/ kotlin.Any?): kotlin.Int + public open /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open /*fake_override*/ fun listIterator(/*0*/ kotlin.Int): kotlin.MutableListIterator invisible_fake open /*fake_override*/ fun outOfBoundsMsg(/*0*/ kotlin.Int): kotlin.String! invisible_fake open /*fake_override*/ fun rangeCheckForAdd(/*0*/ kotlin.Int): kotlin.Unit public open /*fake_override*/ fun remove(/*0*/ kotlin.Any?): kotlin.Boolean @@ -30,7 +30,7 @@ internal abstract class Mine : java.util.AbstractList { public open /*fake_override*/ fun retainAll(/*0*/ kotlin.Collection): kotlin.Boolean public open /*fake_override*/ fun set(/*0*/ kotlin.Int, /*1*/ T!): T! public abstract /*fake_override*/ fun size(): kotlin.Int - public open /*fake_override*/ fun subList(/*0*/ kotlin.Int, /*1*/ kotlin.Int): kotlin.(Mutable)List! + public open /*fake_override*/ fun subList(/*0*/ kotlin.Int, /*1*/ kotlin.Int): kotlin.MutableList public open /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open /*fake_override*/ fun toArray(/*0*/ kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! } diff --git a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.txt b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.txt index 4c097c488c3..c8e93e1d5fa 100644 --- a/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.txt +++ b/compiler/testData/compileJavaAgainstKotlin/class/ImplementsListString.txt @@ -4,22 +4,22 @@ internal abstract class Mine : java.util.List { public constructor Mine() public abstract /*fake_override*/ fun add(/*0*/ kotlin.Int, /*1*/ kotlin.String!): kotlin.Unit public abstract /*fake_override*/ fun add(/*0*/ kotlin.String!): kotlin.Boolean - public abstract /*fake_override*/ fun addAll(/*0*/ (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public abstract /*fake_override*/ fun addAll(/*0*/ kotlin.Collection): kotlin.Boolean public abstract /*fake_override*/ fun addAll(/*0*/ kotlin.Int, /*1*/ (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean public abstract /*fake_override*/ fun clear(): kotlin.Unit - public abstract /*fake_override*/ fun contains(/*0*/ kotlin.Any!): kotlin.Boolean - public abstract /*fake_override*/ fun containsAll(/*0*/ kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public abstract /*fake_override*/ fun contains(/*0*/ kotlin.Any?): kotlin.Boolean + public abstract /*fake_override*/ fun containsAll(/*0*/ kotlin.Collection<*>): kotlin.Boolean public abstract /*fake_override*/ fun get(/*0*/ kotlin.Int): kotlin.String! public abstract /*fake_override*/ fun indexOf(/*0*/ kotlin.Any!): kotlin.Int public abstract /*fake_override*/ fun isEmpty(): kotlin.Boolean - public abstract /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! + public abstract /*fake_override*/ fun iterator(): kotlin.MutableIterator public abstract /*fake_override*/ fun lastIndexOf(/*0*/ kotlin.Any!): kotlin.Int public abstract /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! public abstract /*fake_override*/ fun listIterator(/*0*/ kotlin.Int): kotlin.(Mutable)ListIterator! - public abstract /*fake_override*/ fun remove(/*0*/ kotlin.Any!): kotlin.Boolean + public abstract /*fake_override*/ fun remove(/*0*/ kotlin.Any?): kotlin.Boolean public abstract /*fake_override*/ fun remove(/*0*/ kotlin.Int): kotlin.String! - public abstract /*fake_override*/ fun removeAll(/*0*/ kotlin.(Mutable)Collection<*>!): kotlin.Boolean - public abstract /*fake_override*/ fun retainAll(/*0*/ kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public abstract /*fake_override*/ fun removeAll(/*0*/ kotlin.Collection<*>): kotlin.Boolean + public abstract /*fake_override*/ fun retainAll(/*0*/ kotlin.Collection<*>): kotlin.Boolean public abstract /*fake_override*/ fun set(/*0*/ kotlin.Int, /*1*/ kotlin.String!): kotlin.String! public abstract /*fake_override*/ fun size(): kotlin.Int public abstract /*fake_override*/ fun subList(/*0*/ kotlin.Int, /*1*/ kotlin.Int): kotlin.(Mutable)List! diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/ByteOverridesObject.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/ByteOverridesObject.txt index 001503d8b8d..2ceb1273a48 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/ByteOverridesObject.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/ByteOverridesObject.txt @@ -22,6 +22,6 @@ public/*package*/ open class ExtendsB : test.B { public/*package*/ open class ExtendsC : test.C { public/*package*/ constructor ExtendsC() - public open fun foo(): kotlin.Byte! + public open fun foo(): kotlin.Byte public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesComparable.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesComparable.txt index 2b3b2080112..6328834735d 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesComparable.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesComparable.txt @@ -22,6 +22,6 @@ public/*package*/ open class ExtendsB : test.B { public/*package*/ open class ExtendsC : test.C { public/*package*/ constructor ExtendsC() - public open fun foo(): kotlin.Int! + public open fun foo(): kotlin.Int public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesNumber.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesNumber.txt index c2628690147..e23a75459d8 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesNumber.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesNumber.txt @@ -22,6 +22,6 @@ public/*package*/ open class ExtendsB : test.B { public/*package*/ open class ExtendsC : test.C { public/*package*/ constructor ExtendsC() - public open fun foo(): kotlin.Int! + public open fun foo(): kotlin.Int public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesObject.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesObject.txt index 961872949bb..d4f815b37c3 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesObject.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/IntOverridesObject.txt @@ -22,6 +22,6 @@ public/*package*/ open class ExtendsB : test.B { public/*package*/ open class ExtendsC : test.C { public/*package*/ constructor ExtendsC() - public open fun foo(): kotlin.Int! + public open fun foo(): kotlin.Int public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/NullableIntOverridesObject.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/NullableIntOverridesObject.txt index 9411026f19b..172f848f148 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/NullableIntOverridesObject.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/NullableIntOverridesObject.txt @@ -22,6 +22,6 @@ public/*package*/ open class ExtendsB : test.B { public/*package*/ open class ExtendsC : test.C { public/*package*/ constructor ExtendsC() - public open fun foo(): kotlin.Int! + public open fun foo(): kotlin.Int? public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/OverrideInJava.txt b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/OverrideInJava.txt index 407ad2cb5e4..b337973dbde 100644 --- a/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/OverrideInJava.txt +++ b/compiler/testData/compileJavaAgainstKotlin/method/primitiveOverride/OverrideInJava.txt @@ -11,6 +11,6 @@ internal abstract class B : test.A { public/*package*/ open class ExtendsB : test.B { public/*package*/ constructor ExtendsB() - public open fun foo(): kotlin.Int! + public open fun foo(): kotlin.Int public/*package*/ open fun test(): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt b/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt index 25e55faf381..f9c862da9fa 100644 --- a/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt +++ b/compiler/testData/loadJava/compiledJava/ClassDoesNotOverrideMethod.txt @@ -6,7 +6,7 @@ public abstract class ClassDoesNotOverrideMethod : java.util.Date { invisible_fake final override /*1*/ /*fake_override*/ var fastTime: kotlin.Long public open override /*1*/ /*fake_override*/ fun after(/*0*/ p0: java.util.Date!): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun before(/*0*/ p0: java.util.Date!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any public open override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: java.util.Date!): kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarDate(): sun.util.calendar.BaseCalendar.Date! kotlin.deprecated(value = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun getDate(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNullability.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNullability.txt index e1fd0fc86de..4acef4ae49c 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNullability.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/InheritNullability.txt @@ -4,11 +4,11 @@ public interface InheritNullability { public interface Sub : test.InheritNullability.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p0: kotlin.String!): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p0: kotlin.String): kotlin.Unit } public interface Super { public abstract fun dummy(): kotlin.Unit - public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!): kotlin.Unit + public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String): kotlin.Unit } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/Kt3302.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/Kt3302.txt index ff7c0e33b6c..c8baccc2a06 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/Kt3302.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/Kt3302.txt @@ -4,12 +4,12 @@ public interface Kt3302 { public interface BSONObject { public abstract fun dummy(): kotlin.Unit - public abstract fun put(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.Any!): kotlin.Any! + public abstract fun put(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String, /*1*/ org.jetbrains.annotations.NotNull() p1: kotlin.Any): kotlin.Any! } public interface BasicBSONObject : test.Kt3302.LinkedHashMap, test.Kt3302.BSONObject { public abstract override /*2*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*2*/ fun put(/*0*/ key: kotlin.String!, /*1*/ value: kotlin.Any!): kotlin.Any! + public abstract override /*2*/ fun put(/*0*/ key: kotlin.String, /*1*/ value: kotlin.Any): kotlin.Any! } public interface LinkedHashMap { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NotNullToNullable.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NotNullToNullable.txt index ea246554807..725c802b7ff 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NotNullToNullable.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NotNullToNullable.txt @@ -4,11 +4,11 @@ public interface NotNullToNullable { public interface Sub : test.NotNullToNullable.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p: kotlin.String!): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p: kotlin.String): kotlin.Unit } public interface Super { public abstract fun dummy(): kotlin.Unit - public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!): kotlin.Unit + public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String): kotlin.Unit } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NullableToNotNull.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NullableToNotNull.txt index 99a6a6ef179..7b3bf60f07a 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NullableToNotNull.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/NullableToNotNull.txt @@ -4,7 +4,7 @@ public interface NullableToNotNull { public interface Sub : test.NullableToNotNull.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/SubclassFromGenericAndNot.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/SubclassFromGenericAndNot.txt index e5a07aef461..ef69af33b02 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/SubclassFromGenericAndNot.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/parameter/SubclassFromGenericAndNot.txt @@ -9,11 +9,11 @@ public interface SubclassFromGenericAndNot { public interface NonGeneric { public abstract fun dummy(): kotlin.Unit - public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!): kotlin.Unit + public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String): kotlin.Unit } public interface Sub : test.SubclassFromGenericAndNot.NonGeneric, test.SubclassFromGenericAndNot.Generic { public abstract override /*2*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*2*/ fun foo(/*0*/ key: kotlin.String!): kotlin.Unit + public abstract override /*2*/ fun foo(/*0*/ key: kotlin.String): kotlin.Unit } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullJavaSubtype.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullJavaSubtype.txt index b432f192568..6b95bff2fe8 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullJavaSubtype.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullJavaSubtype.txt @@ -4,7 +4,7 @@ public interface AddNotNullJavaSubtype { public interface Sub : test.AddNotNullJavaSubtype.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract override /*1*/ fun foo(): kotlin.String! + org.jetbrains.annotations.NotNull() public abstract override /*1*/ fun foo(): kotlin.String } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullSameJavaType.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullSameJavaType.txt index 16c66d601eb..9d15cc371b4 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullSameJavaType.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNotNullSameJavaType.txt @@ -4,7 +4,7 @@ public interface AddNotNullSameJavaType { public interface Sub : test.AddNotNullSameJavaType.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract override /*1*/ fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract override /*1*/ fun foo(): kotlin.CharSequence } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilityJavaSubtype.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilityJavaSubtype.txt index 119585dda3e..7f6f5b9f32c 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilityJavaSubtype.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilityJavaSubtype.txt @@ -4,11 +4,11 @@ public interface AddNullabilityJavaSubtype { public interface Sub : test.AddNullabilityJavaSubtype.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(): kotlin.String! + public abstract override /*1*/ fun foo(): kotlin.String } public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilitySameJavaType.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilitySameJavaType.txt index e314b0c1afc..6dfd67de948 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilitySameJavaType.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/AddNullabilitySameJavaType.txt @@ -4,11 +4,11 @@ public interface AddNullabilitySameJavaType { public interface Sub : test.AddNullabilitySameJavaType.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(): kotlin.CharSequence! + public abstract override /*1*/ fun foo(): kotlin.CharSequence } public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilityJavaSubtype.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilityJavaSubtype.txt index 3f186405d99..0310ee65635 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilityJavaSubtype.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilityJavaSubtype.txt @@ -4,11 +4,11 @@ public interface InheritNullabilityJavaSubtype { public interface Sub : test.InheritNullabilityJavaSubtype.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(): kotlin.String! + public abstract override /*1*/ fun foo(): kotlin.String } public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilitySameJavaType.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilitySameJavaType.txt index e0c68dc5b42..06ea5118974 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilitySameJavaType.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/InheritNullabilitySameJavaType.txt @@ -4,11 +4,11 @@ public interface InheritNullabilitySameJavaType { public interface Sub : test.InheritNullabilitySameJavaType.Super { public abstract override /*1*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*1*/ fun foo(): kotlin.CharSequence! + public abstract override /*1*/ fun foo(): kotlin.CharSequence } public interface Super { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.txt index 116c51fa854..4aaff4269d9 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.txt @@ -7,7 +7,7 @@ public interface SubclassOfCollection : kotlin.MutableCollection { public abstract override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean public abstract override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public abstract override /*1*/ fun iterator(): kotlin.(Mutable)Iterator! + public abstract override /*1*/ fun iterator(): kotlin.MutableIterator public abstract override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection): kotlin.Boolean public abstract override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection): kotlin.Boolean diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnJavaSubtype.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnJavaSubtype.txt index 23c06c4bd70..c306b3311f4 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnJavaSubtype.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnJavaSubtype.txt @@ -4,7 +4,7 @@ public interface TwoSuperclassesReturnJavaSubtype { public interface Sub : test.TwoSuperclassesReturnJavaSubtype.Super1, test.TwoSuperclassesReturnJavaSubtype.Super2 { public abstract override /*2*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*2*/ fun foo(): kotlin.String! + public abstract override /*2*/ fun foo(): kotlin.String } public interface Super1 { @@ -14,6 +14,6 @@ public interface TwoSuperclassesReturnJavaSubtype { public interface Super2 { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnSameJavaType.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnSameJavaType.txt index 635d8a77bd9..792b870788a 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnSameJavaType.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/TwoSuperclassesReturnSameJavaType.txt @@ -4,7 +4,7 @@ public interface TwoSuperclassesReturnSameJavaType { public interface Sub : test.TwoSuperclassesReturnSameJavaType.Super1, test.TwoSuperclassesReturnSameJavaType.Super2 { public abstract override /*2*/ /*fake_override*/ fun dummy(): kotlin.Unit - public abstract override /*2*/ fun foo(): kotlin.CharSequence! + public abstract override /*2*/ fun foo(): kotlin.CharSequence } public interface Super1 { @@ -14,6 +14,6 @@ public interface TwoSuperclassesReturnSameJavaType { public interface Super2 { public abstract fun dummy(): kotlin.Unit - org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence! + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.CharSequence } } diff --git a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt index 0252161588b..310024e6e0b 100644 --- a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt +++ b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.txt @@ -6,17 +6,17 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean - org.jetbrains.annotations.NotNull() public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.String! - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + org.jetbrains.annotations.NotNull() public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.String + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean @@ -26,7 +26,7 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.String! public open override /*1*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! } diff --git a/compiler/testData/loadJava/compiledJava/mutability/LoadIterable.txt b/compiler/testData/loadJava/compiledJava/mutability/LoadIterable.txt index c380b33c65b..36940f5e657 100644 --- a/compiler/testData/loadJava/compiledJava/mutability/LoadIterable.txt +++ b/compiler/testData/loadJava/compiledJava/mutability/LoadIterable.txt @@ -1,8 +1,8 @@ package test public interface LoadIterable { - org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.(Mutable)Iterable! - org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.(Mutable)Iterable! - public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() p0: kotlin.(Mutable)Iterable!): kotlin.Unit - public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() p0: kotlin.(Mutable)Iterable!): kotlin.Unit + org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.MutableIterable! + org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.Iterable! + public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() p0: kotlin.MutableIterable!): kotlin.Unit + public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() p0: kotlin.Iterable!): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.txt b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.txt index 486bea8b4fd..f100a0859c1 100644 --- a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.txt +++ b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.txt @@ -1,8 +1,8 @@ package test public interface LoadIterableWithNullability { - org.jetbrains.annotations.NotNull() org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.(Mutable)Iterable! - org.jetbrains.annotations.NotNull() org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.(Mutable)Iterable! - public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() org.jetbrains.annotations.NotNull() p0: kotlin.(Mutable)Iterable!): kotlin.Unit - public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() org.jetbrains.annotations.NotNull() p0: kotlin.(Mutable)Iterable!): kotlin.Unit + org.jetbrains.annotations.NotNull() org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.MutableIterable + org.jetbrains.annotations.NotNull() org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.Iterable + public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() org.jetbrains.annotations.NotNull() p0: kotlin.MutableIterable): kotlin.Unit + public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() org.jetbrains.annotations.NotNull() p0: kotlin.Iterable): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithPropagation.txt b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithPropagation.txt index 3e9b39c46d8..b60f86b8058 100644 --- a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithPropagation.txt +++ b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithPropagation.txt @@ -3,17 +3,17 @@ package test public interface LoadIterableWithPropagation { public interface LoadIterable { - org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.(Mutable)Iterable! - org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.(Mutable)Iterable! - public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() p0: kotlin.(Mutable)Iterable!): kotlin.Unit - public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() p0: kotlin.(Mutable)Iterable!): kotlin.Unit + org.jetbrains.annotations.Mutable() public abstract fun getIterable(): kotlin.MutableIterable! + org.jetbrains.annotations.ReadOnly() public abstract fun getReadOnlyIterable(): kotlin.Iterable! + public abstract fun setIterable(/*0*/ org.jetbrains.annotations.Mutable() p0: kotlin.MutableIterable!): kotlin.Unit + public abstract fun setReadOnlyIterable(/*0*/ org.jetbrains.annotations.ReadOnly() p0: kotlin.Iterable!): kotlin.Unit } public open class LoadIterableImpl : test.LoadIterableWithPropagation.LoadIterable { public constructor LoadIterableImpl() - public open override /*1*/ fun getIterable(): kotlin.(Mutable)Iterable! - public open override /*1*/ fun getReadOnlyIterable(): kotlin.(Mutable)Iterable! - public open override /*1*/ fun setIterable(/*0*/ p0: kotlin.(Mutable)Iterable!): kotlin.Unit - public open override /*1*/ fun setReadOnlyIterable(/*0*/ p0: kotlin.(Mutable)Iterable!): kotlin.Unit + public open override /*1*/ fun getIterable(): kotlin.MutableIterable! + public open override /*1*/ fun getReadOnlyIterable(): kotlin.Iterable! + public open override /*1*/ fun setIterable(/*0*/ p0: kotlin.MutableIterable!): kotlin.Unit + public open override /*1*/ fun setReadOnlyIterable(/*0*/ p0: kotlin.Iterable!): kotlin.Unit } } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.txt index d755f202faa..c658fa481d0 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.txt @@ -2,5 +2,5 @@ package test public open class NotNullIntArray { public constructor NotNullIntArray() - org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.IntArray! + org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.IntArray } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullMethod.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullMethod.txt index 156a9fe5391..0c30b0c6f59 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullMethod.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullMethod.txt @@ -2,5 +2,5 @@ package test public open class NotNullMethod { public constructor NotNullMethod() - org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.String! + org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.String } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.txt index d96514dc9ec..01ce03723aa 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.txt @@ -2,5 +2,5 @@ package test public open class NotNullObjectArray { public constructor NotNullObjectArray() - org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.Array<(out) kotlin.Any!>! + org.jetbrains.annotations.NotNull() public open fun hi(): kotlin.Array<(out) kotlin.Any!> } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullParameter.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullParameter.txt index 9cb03cf421f..06636c18c82 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullParameter.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullParameter.txt @@ -2,5 +2,5 @@ package test public open class NotNullParameter { public constructor NotNullParameter() - public open fun hi(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String!): kotlin.Unit + public open fun hi(/*0*/ org.jetbrains.annotations.NotNull() p0: kotlin.String): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.txt index 12bc206e50e..802355c6bf4 100644 --- a/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.txt +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/InheritedOverriddenAdapter.txt @@ -4,7 +4,7 @@ public interface InheritedOverriddenAdapter { public open class Sub : test.InheritedOverriddenAdapter.Super { public constructor Sub() - public open override /*1*/ fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.txt index 3c14e209a7f..376b3ef7589 100644 --- a/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.txt +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/inheritance/OverriddenAmbiguousAdapters.txt @@ -3,7 +3,7 @@ package test public interface OverriddenAmbiguousAdapters { public interface Sub : test.OverriddenAmbiguousAdapters.Super { - public abstract override /*2*/ fun foo(/*0*/ p0: (() -> kotlin.Unit!)!): kotlin.Unit + public abstract override /*2*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!): kotlin.Unit public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.io.Closeable!): kotlin.Unit public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!): kotlin.Unit } diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt index d8aecadb676..302b5090c63 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.txt @@ -6,7 +6,7 @@ public open class RawSuperType { public open inner class Derived : test.RawSuperType.Super { public constructor Derived() public open override /*1*/ fun dummy(): kotlin.Unit - public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any?): kotlin.Unit } public interface Super { diff --git a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt index f19f6f76e92..b6d22fba192 100644 --- a/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt +++ b/compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperTypeWithRecursiveBoundMultipleParameters.txt @@ -7,7 +7,7 @@ public open class RawSuperTypeWithRecursiveBoundMultipleParameters { public constructor Derived() public open override /*1*/ fun dummy(): kotlin.Unit public open fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: kotlin.Any!): kotlin.Unit - public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any!, /*1*/ p1: test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ p0: kotlin.Any?, /*1*/ p1: test.RawSuperTypeWithRecursiveBoundMultipleParameters.Super<*, *>!): kotlin.Unit } public interface Super!> { diff --git a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt index 96ba443f37e..d83e51668c1 100644 --- a/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt +++ b/compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.txt @@ -4,5 +4,5 @@ public final class ClassWithObjectMethod { public constructor ClassWithObjectMethod() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ fun toString(): kotlin.String! + public open override /*1*/ fun toString(): kotlin.String } diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/ClassDoesNotOverrideMethod.txt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/ClassDoesNotOverrideMethod.txt index 436e31f8308..6def49899eb 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/ClassDoesNotOverrideMethod.txt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/ClassDoesNotOverrideMethod.txt @@ -6,7 +6,7 @@ public abstract class ClassDoesNotOverrideMethod : java.util.Date { invisible_fake final override /*1*/ /*fake_override*/ var fastTime: kotlin.Long public open override /*1*/ /*fake_override*/ fun after(/*0*/ p0: java.util.Date!): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun before(/*0*/ p0: java.util.Date!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any public open override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: java.util.Date!): kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ fun getCalendarDate(): sun.util.calendar.BaseCalendar.Date! kotlin.deprecated(value = "Deprecated in Java") public open override /*1*/ /*fake_override*/ fun getDate(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.txt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.txt index 909ff1c844a..18cd766a66d 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.txt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/modality/ModalityOfFakeOverrides.txt @@ -6,17 +6,17 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.String - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean @@ -26,7 +26,7 @@ public open class ModalityOfFakeOverrides : java.util.AbstractList): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.String! public open override /*1*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! } diff --git a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt index f141b72352f..02eb0d439c2 100644 --- a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt @@ -7,12 +7,12 @@ internal final class C : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.String!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): kotlin.String! public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -20,24 +20,24 @@ internal final class C : java.util.ArrayList { invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String! - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.String! public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun trimToSize(): kotlin.Unit diff --git a/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.txt b/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.txt index 74a2a4542fa..d2b6a1ba643 100644 --- a/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/platformTypes/nullableTypeArgument.txt @@ -7,12 +7,12 @@ internal final class C : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String?): kotlin.Unit public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.String?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: (kotlin.MutableCollection..kotlin.Collection?)): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! - public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun elementData(/*0*/ p0: kotlin.Int): kotlin.String? public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit @@ -20,24 +20,24 @@ internal final class C : java.util.ArrayList { invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.String? invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any!): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any!): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.(Mutable)ListIterator! - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.(Mutable)ListIterator! + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String? - public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.(Mutable)Collection<*>!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String?): kotlin.String? public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.(Mutable)List! + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun trimToSize(): kotlin.Unit diff --git a/compiler/testData/loadJava/javaAgainstKotlin/samAdapters/SamAdapterForOverriddenFromKotlin.txt b/compiler/testData/loadJava/javaAgainstKotlin/samAdapters/SamAdapterForOverriddenFromKotlin.txt index 8d5333eac12..bd1deb09d8e 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/samAdapters/SamAdapterForOverriddenFromKotlin.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/samAdapters/SamAdapterForOverriddenFromKotlin.txt @@ -3,7 +3,7 @@ package test public open class Sub : test.Super { public constructor Sub() public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Unit - public open override /*1*/ fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ r: java.lang.Runnable): kotlin.Unit } public final class Super { diff --git a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/DeepSubclassingKotlinInJava.txt b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/DeepSubclassingKotlinInJava.txt index 223dfd90158..8f00c29fcc6 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/DeepSubclassingKotlinInJava.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/DeepSubclassingKotlinInJava.txt @@ -7,7 +7,7 @@ public open class A { public open class B : test.A { public constructor B() - public open override /*1*/ fun foo(): kotlin.String! + public open override /*1*/ fun foo(): kotlin.String } public open class C : test.B { @@ -17,7 +17,7 @@ public open class C : test.B { public open class D : test.C { public constructor D() - public open override /*1*/ fun foo(): kotlin.String! + public open override /*1*/ fun foo(): kotlin.String } public open class E : test.D { @@ -27,5 +27,5 @@ public open class E : test.D { public open class F : test.E { public constructor F() - public open override /*1*/ fun foo(): kotlin.String! + public open override /*1*/ fun foo(): kotlin.String } diff --git a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionAndNot.txt b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionAndNot.txt index 517383458fb..b4f71eac63a 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionAndNot.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionAndNot.txt @@ -1,8 +1,8 @@ package test public interface Sub : test.Super1, test.Super2 { - public abstract override /*1*/ fun bar(/*0*/ vararg p: kotlin.String! /*kotlin.Array<(out) kotlin.String!>!*/): kotlin.Unit - public abstract override /*1*/ fun foo(/*0*/ p: kotlin.String!): kotlin.Unit + public abstract override /*1*/ fun bar(/*0*/ vararg p: kotlin.String /*kotlin.Array<(out) kotlin.String>*/): kotlin.Unit + public abstract override /*1*/ fun foo(/*0*/ p: kotlin.String): kotlin.Unit public abstract override /*1*/ /*fake_override*/ fun kotlin.Array.bar(): kotlin.Unit public abstract override /*1*/ /*fake_override*/ fun kotlin.String.foo(): kotlin.Unit } diff --git a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionFunction.txt b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionFunction.txt index b15451c9d0f..aca2de9c103 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionFunction.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/InheritExtensionFunction.txt @@ -2,7 +2,7 @@ package test public open class Sub : test.Super { public constructor Sub() - public open override /*1*/ fun kotlin.String!.bar(/*0*/ p: kotlin.String!): kotlin.String! + public open override /*1*/ fun kotlin.String.bar(/*0*/ p: kotlin.String): kotlin.String public final override /*1*/ /*fake_override*/ fun kotlin.String.foo(): kotlin.Unit } diff --git a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassFromTraitImplementation.txt b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassFromTraitImplementation.txt index b3ea369efd1..af61cb0a0f2 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassFromTraitImplementation.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassFromTraitImplementation.txt @@ -8,7 +8,7 @@ internal open class Impl : test.Trait { public open class Subclass : test.Impl { public constructor Subclass() - java.lang.Override() public open override /*1*/ fun bar(): kotlin.String! + java.lang.Override() public open override /*1*/ fun bar(): kotlin.String internal open override /*1*/ /*fake_override*/ fun foo(): kotlin.String } diff --git a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassingKotlinInJava.txt b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassingKotlinInJava.txt index d9c07762f24..cd5842fdebe 100644 --- a/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassingKotlinInJava.txt +++ b/compiler/testData/loadJava/javaAgainstKotlin/signaturePropagation/SubclassingKotlinInJava.txt @@ -2,7 +2,7 @@ package test public open class JavaSubclass : test.KotlinClass { public constructor JavaSubclass() - public open override /*1*/ fun foo(): kotlin.String! + public open override /*1*/ fun foo(): kotlin.String } public open class KotlinClass { diff --git a/compiler/testData/loadJava/kotlinAgainstCompiledJavaWithKotlin/propagationAgainstDeserializedSuperclass.txt b/compiler/testData/loadJava/kotlinAgainstCompiledJavaWithKotlin/propagationAgainstDeserializedSuperclass.txt index 980f9346556..8c3668c4786 100644 --- a/compiler/testData/loadJava/kotlinAgainstCompiledJavaWithKotlin/propagationAgainstDeserializedSuperclass.txt +++ b/compiler/testData/loadJava/kotlinAgainstCompiledJavaWithKotlin/propagationAgainstDeserializedSuperclass.txt @@ -2,7 +2,7 @@ package test public open class J : test.K { public constructor J() - public open override /*1*/ fun foo(/*0*/ l: kotlin.(Mutable)List!): kotlin.String! + public open override /*1*/ fun foo(/*0*/ l: kotlin.MutableList): kotlin.String } internal interface K { From d4e5479f0f312d193fe4ced7d773f2bd64637e33 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 17 Jun 2015 17:37:05 +0300 Subject: [PATCH 149/450] Update testData for nullability warnings They become errors after type enhancement --- .../nullabilityWarnings/arithmetic.kt | 16 +++++++-------- .../nullabilityWarnings/arithmetic.txt | 4 ++-- .../nullabilityWarnings/array.kt | 4 ++-- .../nullabilityWarnings/array.txt | 4 ++-- .../nullabilityWarnings/assignToVar.kt | 2 +- .../nullabilityWarnings/assignToVar.txt | 4 ++-- .../nullabilityWarnings/conditions.kt | 12 +++++------ .../nullabilityWarnings/conditions.txt | 4 ++-- .../nullabilityWarnings/dataFlowInfo.kt | 12 +++++------ .../nullabilityWarnings/dataFlowInfo.txt | 4 ++-- .../nullabilityWarnings/defaultParameters.kt | 2 +- .../nullabilityWarnings/defaultParameters.txt | 4 ++-- .../delegatedProperties.kt | 2 +- .../delegatedProperties.txt | 6 +++--- .../nullabilityWarnings/delegation.kt | 2 +- .../nullabilityWarnings/delegation.txt | 4 ++-- .../nullabilityWarnings/derefenceExtension.kt | 4 ++-- .../derefenceExtension.txt | 4 ++-- .../nullabilityWarnings/derefenceMember.kt | 4 ++-- .../nullabilityWarnings/derefenceMember.txt | 4 ++-- .../nullabilityWarnings/elvis.txt | 4 ++-- .../nullabilityWarnings/expectedType.kt | 2 +- .../nullabilityWarnings/expectedType.txt | 4 ++-- .../platformTypes/nullabilityWarnings/for.kt | 2 +- .../platformTypes/nullabilityWarnings/for.txt | 4 ++-- .../nullabilityWarnings/functionArguments.kt | 2 +- .../nullabilityWarnings/functionArguments.txt | 4 ++-- .../inferenceInConditionals.txt | 4 ++-- .../nullabilityWarnings/invoke.kt | 2 +- .../nullabilityWarnings/invoke.txt | 4 ++-- .../nullabilityWarnings/kt6829.txt | 2 +- .../nullabilityWarnings/multiDeclaration.kt | 2 +- .../nullabilityWarnings/multiDeclaration.txt | 4 ++-- .../notNullAfterSafeCall.txt | 2 +- .../nullabilityWarnings/notNullAssertion.txt | 4 ++-- .../notNullAssertionInCall.txt | 2 +- ...otNullTypeMarkedWithNullableAnnotation.txt | 2 +- .../nullabilityWarnings/passToJava.kt | 20 +++++++++---------- .../nullabilityWarnings/passToJava.txt | 14 ++++++------- .../nullabilityWarnings/primitiveArray.kt | 4 ++-- .../nullabilityWarnings/primitiveArray.txt | 4 ++-- .../nullabilityWarnings/safeCall.txt | 4 ++-- .../senselessComparisonEquals.txt | 4 ++-- .../senselessComparisonIdentityEquals.txt | 4 ++-- .../nullabilityWarnings/throw.kt | 2 +- .../nullabilityWarnings/throw.txt | 4 ++-- .../uselessElvisInCall.txt | 2 +- 47 files changed, 107 insertions(+), 107 deletions(-) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt index 31a29d95c56..92006839405 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.kt @@ -21,35 +21,35 @@ fun test() { var platformJ = J.staticJ +platformNN - +platformN + +platformN +platformJ ++platformNN - ++platformN + ++platformN ++platformJ platformNN++ - platformN++ + platformN++ platformJ++ 1 + platformNN - 1 + platformN + 1 + platformN 1 + platformJ platformNN + 1 - platformN + 1 + platformN + 1 platformJ + 1 1 plus platformNN - 1 plus platformN + 1 plus platformN 1 plus platformJ platformNN plus 1 - platformN plus 1 + platformN plus 1 platformJ plus 1 platformNN += 1 - platformN += 1 + platformN += 1 platformJ += 1 } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt index 7144141c3ca..70ddc963fab 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/arithmetic.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: kotlin.Int! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Int! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Int! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Int? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Int } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt index 928f061ef8d..acf93ae0567 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.kt @@ -21,11 +21,11 @@ fun test() { val platformJ = J.staticJ platformNN[0] - platformN[0] + platformN[0] platformJ[0] platformNN[0] = 1 - platformN[0] = 1 + platformN[0] = 1 platformJ[0] = 1 } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt index 5fd62c6b767..75a3de97607 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: kotlin.Array<(out) kotlin.Int!>! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Array<(out) kotlin.Int!>! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Array<(out) kotlin.Int!>! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Array<(out) kotlin.Int!>? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Array<(out) kotlin.Int!> } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt index 478a0ae9708..712431e8132 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.kt @@ -17,7 +17,7 @@ var n: J? = J() fun test() { v = J.staticNN - v = J.staticN + v = J.staticN v = J.staticJ n = J.staticNN diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt index 4715dbb23bc..1e4d0befe73 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/assignToVar.txt @@ -12,6 +12,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt index c9e785bb6d3..4f322c6cd65 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.kt @@ -22,26 +22,26 @@ fun test() { val platformJ = J.staticJ if (platformNN) {} - if (platformN) {} + if (platformN) {} if (platformJ) {} while (platformNN) {} - while (platformN) {} + while (platformN) {} while (platformJ) {} do {} while (platformNN) - do {} while (platformN) + do {} while (platformN) do {} while (platformJ) platformNN && false - platformN && false + platformN && false platformJ && false platformNN || false - platformN || false + platformN || false platformJ || false !platformNN - !platformN + !platformN !platformJ } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt index 65c7261ddc6..3febba97fa0 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/conditions.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: kotlin.Boolean! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Boolean! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Boolean! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.Boolean? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.Boolean } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt index e716abbe6a8..bb8ff0a9c87 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.kt @@ -14,17 +14,17 @@ public class J { fun test() { val n = J.staticN - foo(n) - J.staticNN = n + foo(n) + J.staticNN = n if (n != null) { - foo(n) - J.staticNN = n + foo(n) + J.staticNN = n } val x: J? = null - J.staticNN = x + J.staticNN = x if (x != null) { - J.staticNN = x + J.staticNN = x } } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt index 64f161d3f05..62c2956663a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/dataFlowInfo.txt @@ -10,6 +10,6 @@ public open class J { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt index 3cbba78872d..4c6d2fc62aa 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.kt @@ -21,7 +21,7 @@ fun test() { // platform type with no annotation val platformJ = J.staticJ - fun foo(p: J = platformNN, p1: J = platformN, p2: J = platformJ) {} + fun foo(p: J = platformNN, p1: J = platformN, p2: J = platformJ) {} fun foo1(p: J? = platformNN, p1: J? = platformN, p2: J? = platformJ) {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/defaultParameters.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt index e413b1e74fd..129ee20826e 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.kt @@ -19,5 +19,5 @@ public class J { // FILE: k.kt var A by J.staticNN -var B by J.staticN +var B by J.staticN var C by J.staticJ \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt index 4face54f705..c254131e578 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt @@ -1,7 +1,7 @@ package internal var A: kotlin.String! -internal var B: kotlin.String! +internal var B: [ERROR : Type from delegate] internal var C: kotlin.String! public open class J { @@ -20,6 +20,6 @@ public open class J { // Static members public final var staticJ: J.DP! - org.jetbrains.annotations.Nullable() public final var staticN: J.DP! - org.jetbrains.annotations.NotNull() public final var staticNN: J.DP! + org.jetbrains.annotations.Nullable() public final var staticN: J.DP? + org.jetbrains.annotations.NotNull() public final var staticNN: J.DP } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt index bf012440dde..5970a02c277 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.kt @@ -14,5 +14,5 @@ public class J { // FILE: k.kt class A : List by J.staticNN -class B : List by J.staticN +class B : List by J.staticN class C : List by J.staticJ \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt index c3c73d2853b..113e6c04242 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegation.txt @@ -62,6 +62,6 @@ public open class J { // Static members public final var staticJ: kotlin.(Mutable)List! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt index 5c96709c95e..03812dbf1ba 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.kt @@ -23,14 +23,14 @@ fun test() { val platformJ = J.staticJ platformNN.foo() - platformN.foo() + platformN.foo() platformJ.foo() with(platformNN) { foo() } with(platformN) { - foo() + foo() } with(platformJ) { foo() diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt index 71f08415efa..9291b06c1bd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceExtension.txt @@ -13,6 +13,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt index b0f108a737b..a62b4e4c2fb 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.kt @@ -25,14 +25,14 @@ fun test() { val platformJ = J.staticJ platformNN.foo() - platformN.foo() + platformN.foo() platformJ.foo() with(platformNN) { foo() } with(platformN) { - foo() + foo() } with(platformJ) { foo() diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt index 8c9b73aa0f6..5b7f1851a98 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/derefenceMember.txt @@ -12,6 +12,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/elvis.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt index 5001e655040..9879205a921 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.kt @@ -23,7 +23,7 @@ fun test() { val platformJ = J.staticJ checkSubtype(platformNN) - checkSubtype(platformN) + checkSubtype(platformN) checkSubtype(platformJ) checkSubtype(platformNN) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/expectedType.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt index d15f6d928aa..4dad6907875 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.kt @@ -22,7 +22,7 @@ fun test() { val platformJ = J.staticJ for (x in platformNN) {} - for (x in platformN) {} + for (x in platformN) {} for (x in platformJ) {} } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt index 011c6034370..fa7da09107d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/for.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: kotlin.(Mutable)List! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.(Mutable)List? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.(Mutable)List } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt index 228464fceba..824731bebdb 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.kt @@ -15,7 +15,7 @@ public class J { fun test() { foo(J.staticNN) - foo(J.staticN) + foo(J.staticN) foo(J.staticJ) bar(J.staticNN) diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt index 818aef0eb85..594f4dd052f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/functionArguments.txt @@ -12,6 +12,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt index 3ed6cbe4fb4..0e614823af9 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/inferenceInConditionals.txt @@ -8,7 +8,7 @@ public open class J { public constructor J() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List! - org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String! + org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List? + org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt index 0b055a57320..951251b949f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.kt @@ -18,7 +18,7 @@ public class J { fun test() { J.staticNN() - J.staticN() + J.staticN() J.staticJ() } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt index fec729f8aa7..12dc37e9833 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt @@ -17,7 +17,7 @@ public open class J { // Static members public final var staticJ: J.Invoke! - org.jetbrains.annotations.Nullable() public final var staticN: J.Invoke! - org.jetbrains.annotations.NotNull() public final var staticNN: J.Invoke! + org.jetbrains.annotations.Nullable() public final var staticN: J.Invoke? + org.jetbrains.annotations.NotNull() public final var staticNN: J.Invoke public final /*synthesized*/ fun Invoke(/*0*/ function: () -> kotlin.Unit): J.Invoke } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt index 099ffe5132d..4498b5ea58e 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/kt6829.txt @@ -7,6 +7,6 @@ public open class J { public constructor J() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - org.jetbrains.annotations.Nullable() public open fun method(): kotlin.String! + org.jetbrains.annotations.Nullable() public open fun method(): kotlin.String? public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt index 977f804794b..996ce6fc410 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.kt @@ -27,7 +27,7 @@ fun test() { val platformJ = J.staticJ val (a1, b1) = platformNN - val (a2, b2) = platformN + val (a2, b2) = platformN val (a3, b3) = platformJ } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt index 66977b314a7..6d630b5f0e1 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt @@ -18,6 +18,6 @@ public open class J { // Static members public final var staticJ: J.Multi! - org.jetbrains.annotations.Nullable() public final var staticN: J.Multi! - org.jetbrains.annotations.NotNull() public final var staticNN: J.Multi! + org.jetbrains.annotations.Nullable() public final var staticN: J.Multi? + org.jetbrains.annotations.NotNull() public final var staticNN: J.Multi } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt index 95590d06e57..ecb6bc198c1 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAfterSafeCall.txt @@ -6,6 +6,6 @@ public open class J { public constructor J() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String! + org.jetbrains.annotations.NotNull() public open fun nn(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertion.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt index adf9031c655..344c25b69e4 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullAssertionInCall.txt @@ -18,5 +18,5 @@ public open class J { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt index aea2df5eedd..f362d5abae8 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/notNullTypeMarkedWithNullableAnnotation.txt @@ -6,6 +6,6 @@ public open class J { public constructor J() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List! + org.jetbrains.annotations.Nullable() public open fun n(): kotlin.(Mutable)List? public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt index 257badf0b86..95aa5173dce 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.kt @@ -33,8 +33,8 @@ fun test(n: J?, nn: J) { // platform type with no annotation val platformJ = J.staticJ - J.staticNN = n - J.staticNN = platformN + J.staticNN = n + J.staticNN = platformN J.staticNN = nn J.staticNN = platformNN J.staticNN = platformJ @@ -53,12 +53,12 @@ fun test(n: J?, nn: J) { J.staticSet(nn, nn, nn) J.staticSet(platformNN, platformNN, platformNN) - J.staticSet(n, n, n) - J.staticSet(platformN, platformN, platformN) + J.staticSet(n, n, n) + J.staticSet(platformN, platformN, platformN) J.staticSet(platformJ, platformJ, platformJ) - J().nn = n - J().nn = platformN + J().nn = n + J().nn = platformN J().nn = nn J().nn = platformNN J().nn = platformJ @@ -77,13 +77,13 @@ fun test(n: J?, nn: J) { J().set(nn, nn, nn) J().set(platformNN, platformNN, platformNN) - J().set(n, n, n) - J().set(platformN, platformN, platformN) + J().set(n, n, n) + J().set(platformN, platformN, platformN) J().set(platformJ, platformJ, platformJ) J(nn, nn, nn) J(platformNN, platformNN, platformNN) - J(n, n, n) - J(platformN, platformN, platformN) + J(n, n, n) + J(platformN, platformN, platformN) J(platformJ, platformJ, platformJ) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt index f1c3b9d5460..1167bc6af33 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/passToJava.txt @@ -4,18 +4,18 @@ internal fun test(/*0*/ n: J?, /*1*/ nn: J): kotlin.Unit public open class J { public constructor J() - public constructor J(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!) + public constructor J(/*0*/ org.jetbrains.annotations.NotNull() nn: J, /*1*/ org.jetbrains.annotations.Nullable() n: J?, /*2*/ j: J!) public final var j: J! - org.jetbrains.annotations.Nullable() public final var n: J! - org.jetbrains.annotations.NotNull() public final var nn: J! + org.jetbrains.annotations.Nullable() public final var n: J? + org.jetbrains.annotations.NotNull() public final var nn: J public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open fun set(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!): kotlin.Unit + public open fun set(/*0*/ org.jetbrains.annotations.NotNull() nn: J, /*1*/ org.jetbrains.annotations.Nullable() n: J?, /*2*/ j: J!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! - public open fun staticSet(/*0*/ org.jetbrains.annotations.NotNull() nn: J!, /*1*/ org.jetbrains.annotations.Nullable() n: J!, /*2*/ j: J!): kotlin.Unit + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J + public open fun staticSet(/*0*/ org.jetbrains.annotations.NotNull() nn: J, /*1*/ org.jetbrains.annotations.Nullable() n: J?, /*2*/ j: J!): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt index 75d088a0078..63d41a2ccb6 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.kt @@ -21,11 +21,11 @@ fun test() { val platformJ = J.staticJ platformNN[0] - platformN[0] + platformN[0] platformJ[0] platformNN[0] = 1 - platformN[0] = 1 + platformN[0] = 1 platformJ[0] = 1 } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt index ff4baf160aa..549e6a94cdc 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: kotlin.IntArray! - org.jetbrains.annotations.Nullable() public final var staticN: kotlin.IntArray! - org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.IntArray! + org.jetbrains.annotations.Nullable() public final var staticN: kotlin.IntArray? + org.jetbrains.annotations.NotNull() public final var staticNN: kotlin.IntArray } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt index c29fb5ad665..7b24a77511a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/safeCall.txt @@ -11,6 +11,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonEquals.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt index 34903ffd954..337b583c502 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/senselessComparisonIdentityEquals.txt @@ -10,6 +10,6 @@ public open class J { // Static members public final var staticJ: J! - org.jetbrains.annotations.Nullable() public final var staticN: J! - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.Nullable() public final var staticN: J? + org.jetbrains.annotations.NotNull() public final var staticNN: J } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt index 38ac1551f4f..df4f6c14145 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.kt @@ -17,7 +17,7 @@ fun test() { } fun test1() { - throw J.staticN + throw J.staticN } fun test2() { diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt index 27c21d877a9..35fa850f446 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/throw.txt @@ -12,6 +12,6 @@ public open class J { // Static members public final var staticJ: java.lang.Exception! - org.jetbrains.annotations.Nullable() public final var staticN: java.lang.Exception! - org.jetbrains.annotations.NotNull() public final var staticNN: java.lang.Exception! + org.jetbrains.annotations.Nullable() public final var staticN: java.lang.Exception? + org.jetbrains.annotations.NotNull() public final var staticNN: java.lang.Exception } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt index adf9031c655..344c25b69e4 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/uselessElvisInCall.txt @@ -18,5 +18,5 @@ public open class J { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members - org.jetbrains.annotations.NotNull() public final var staticNN: J! + org.jetbrains.annotations.NotNull() public final var staticNN: J } From 1b44f77054458a6fc00e5beea047b406ddea0913 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 17 Jun 2015 17:38:47 +0300 Subject: [PATCH 150/450] Minor. trait -> interface in testData --- .../testData/diagnostics/tests/j+k/types/arrayList.kt | 2 +- .../testData/diagnostics/tests/j+k/types/arrayList.txt | 2 +- .../diagnostics/tests/j+k/types/returnCollection.kt | 2 +- .../diagnostics/tests/j+k/types/returnCollection.txt | 4 ++-- .../tests/j+k/types/shapeMismatchInCovariantPosition.kt | 6 +++--- .../tests/j+k/types/shapeMismatchInCovariantPosition.txt | 8 ++++---- .../j+k/types/shapeMismatchInCovariantPositionGeneric.kt | 6 +++--- .../j+k/types/shapeMismatchInCovariantPositionGeneric.txt | 8 ++++---- .../testData/diagnostics/tests/j+k/types/typeParameter.kt | 2 +- .../diagnostics/tests/j+k/types/typeParameter.txt | 4 ++-- .../nullabilityWarnings/delegatedProperties.txt | 2 +- .../tests/platformTypes/nullabilityWarnings/invoke.txt | 2 +- .../nullabilityWarnings/multiDeclaration.txt | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt b/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt index 107e4068059..6e405cc393e 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/arrayList.kt @@ -1,6 +1,6 @@ // FILE: k.kt -trait ML { +interface ML { public fun foo(): MutableList } diff --git a/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt b/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt index 36f1fa464ad..793d26b1e99 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/arrayList.txt @@ -16,7 +16,7 @@ internal final class K : J, ML { public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait ML { +internal interface ML { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract fun foo(): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt index 84e5a4b8eb8..4ead28c1794 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.kt @@ -1,6 +1,6 @@ // FILE: k.kt -trait K { +interface K { fun foo(): List } diff --git a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt index d918d8c2f36..198fd3c2834 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/returnCollection.txt @@ -2,14 +2,14 @@ package public/*package*/ /*synthesized*/ fun J(/*0*/ function: () -> kotlin.(Mutable)List!): J -public/*package*/ trait J : K { +public/*package*/ interface J : K { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ fun foo(): kotlin.List public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait K { +internal interface K { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean internal abstract fun foo(): kotlin.List public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt index 33a4d10347f..84c8934b225 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.kt @@ -1,9 +1,9 @@ // FILE: k.kt -trait G -trait SubG : G +interface G +interface SubG : G -trait K { +interface K { fun foo(): G fun bar(): G? } diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt index 514a4497b84..36ae41d1de9 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPosition.txt @@ -1,12 +1,12 @@ package -internal trait G { +internal interface G { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public/*package*/ trait J : K { +public/*package*/ interface J : K { public abstract override /*1*/ fun bar(): SubG? public abstract fun baz(): SubG! public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ public/*package*/ trait J : K { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait K { +internal interface K { internal abstract fun bar(): G? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean internal abstract fun foo(): G @@ -23,7 +23,7 @@ internal trait K { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait SubG : G { +internal interface SubG : G { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt index e07ec6ec4b3..2ab572dca5a 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.kt @@ -1,9 +1,9 @@ // FILE: k.kt -trait G -trait SubG : G +interface G +interface SubG : G -trait K { +interface K { fun foo(): G fun bar(): G? } diff --git a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt index 5927cab9c4c..84f01f74142 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/shapeMismatchInCovariantPositionGeneric.txt @@ -1,12 +1,12 @@ package -internal trait G { +internal interface G { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public/*package*/ trait J : K { +public/*package*/ interface J : K { public abstract override /*1*/ fun bar(): SubG!>? public abstract fun baz(): SubG!>! public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ public/*package*/ trait J : K { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait K { +internal interface K { internal abstract fun bar(): G? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean internal abstract fun foo(): G @@ -23,7 +23,7 @@ internal trait K { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait SubG : G { +internal interface SubG : G { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt index 3aac76a2aad..550b69b506d 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt @@ -1,6 +1,6 @@ // FILE: k.kt -trait K { +interface K { fun foo(t: T) } diff --git a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt index 836bc55a09d..d96e7b10deb 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt +++ b/compiler/testData/diagnostics/tests/j+k/types/typeParameter.txt @@ -1,13 +1,13 @@ package -public/*package*/ trait J : K { +public/*package*/ interface J : K { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract override /*1*/ fun foo(/*0*/ t: T): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal trait K { +internal interface K { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean internal abstract fun foo(/*0*/ t: T): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt index c254131e578..8861f67a667 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/delegatedProperties.txt @@ -10,7 +10,7 @@ public open class J { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public trait DP { + public interface DP { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public abstract fun get(/*0*/ a: kotlin.Any!, /*1*/ b: kotlin.Any!): kotlin.String! public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt index 12dc37e9833..2c0af6f063f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/invoke.txt @@ -8,7 +8,7 @@ public open class J { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public trait Invoke { + public interface Invoke { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public abstract fun invoke(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt index 6d630b5f0e1..5c7644e6642 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/multiDeclaration.txt @@ -8,7 +8,7 @@ public open class J { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public trait Multi { + public interface Multi { public abstract fun component1(): kotlin.String! public abstract fun component2(): kotlin.String! public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean From cfadda8061c8650c257ed994d611f33ba61cd714 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 18 Jun 2015 13:33:19 +0300 Subject: [PATCH 151/450] Fix codegen tests after types enhancement --- .../box/builtinStubMethods/extendJavaCollections/abstractMap.kt | 2 +- .../codegen/boxWithStdlib/reflection/enclosing/kt6368.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt index 59f2d50e8ad..1a7f0ae1eb2 100644 --- a/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt +++ b/compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections/abstractMap.kt @@ -2,7 +2,7 @@ import java.util.AbstractMap import java.util.Collections class A : AbstractMap() { - override fun entrySet(): Set> = Collections.emptySet() + override fun entrySet(): MutableSet> = Collections.emptySet() } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/enclosing/kt6368.kt b/compiler/testData/codegen/boxWithStdlib/reflection/enclosing/kt6368.kt index 16d226f3c0d..8547b6a5178 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/enclosing/kt6368.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/enclosing/kt6368.kt @@ -15,7 +15,7 @@ val a by Delegates.lazy { } fun box(): String { - val r = a["result"] + val r = a["result"]!! // Check that reflection won't fail r.javaClass.getEnclosingMethod().toString() From f0833d626ac440997d38a4b12bbd59364664a34a Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 18 Jun 2015 13:39:41 +0300 Subject: [PATCH 152/450] Fix intentions tests after types enhancement Types became more accurate --- .../overrideImplement/propagationKJK/foo/Impl.kt.after | 2 +- .../intentions/specifyTypeExplicitly/loopParameter.kt.after | 2 +- .../changeSignature/addParameterNotAvailableForLibrary.kt | 2 +- .../returnTypeCandidates/javaAnnotatedNotNull.kt.after | 2 +- .../returnTypeCandidates/javaAnnotatedNullable.kt.after | 2 +- .../typeParameterNotResolvableInTargetScope.kt.after | 2 +- .../typeParameterResolvableInTargetScope.kt.after | 2 +- .../typeParameterNotResolvableInTargetScope.kt.after | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/idea/testData/codeInsight/overrideImplement/propagationKJK/foo/Impl.kt.after b/idea/testData/codeInsight/overrideImplement/propagationKJK/foo/Impl.kt.after index dc7fc6eda69..2171acf633c 100644 --- a/idea/testData/codeInsight/overrideImplement/propagationKJK/foo/Impl.kt.after +++ b/idea/testData/codeInsight/overrideImplement/propagationKJK/foo/Impl.kt.after @@ -1,7 +1,7 @@ package foo class Impl : Bar() { - override fun f(): Any? { + override fun f(): Any { return super.f() } } diff --git a/idea/testData/intentions/specifyTypeExplicitly/loopParameter.kt.after b/idea/testData/intentions/specifyTypeExplicitly/loopParameter.kt.after index a0d6772e37e..32f4f937299 100644 --- a/idea/testData/intentions/specifyTypeExplicitly/loopParameter.kt.after +++ b/idea/testData/intentions/specifyTypeExplicitly/loopParameter.kt.after @@ -3,7 +3,7 @@ import java.util.HashMap fun foo(map : HashMap) { - for (entry: MutableMap.MutableEntry? in map.entrySet()) { + for (entry: MutableMap.MutableEntry in map.entrySet()) { } } \ No newline at end of file diff --git a/idea/testData/quickfix/changeSignature/addParameterNotAvailableForLibrary.kt b/idea/testData/quickfix/changeSignature/addParameterNotAvailableForLibrary.kt index 923b47d9e29..b69c7577f90 100644 --- a/idea/testData/quickfix/changeSignature/addParameterNotAvailableForLibrary.kt +++ b/idea/testData/quickfix/changeSignature/addParameterNotAvailableForLibrary.kt @@ -1,5 +1,5 @@ // "class org.jetbrains.kotlin.idea.quickfix.AddFunctionParametersFix" "false" -// ERROR: Too many arguments for public open fun equals(other: kotlin.Any!): kotlin.Boolean defined in java.lang.Object +// ERROR: Too many arguments for public open fun equals(other: kotlin.Any?): kotlin.Boolean defined in java.lang.Object fun f(d: java.lang.Object) { d.equals("a", "b") diff --git a/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNotNull.kt.after b/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNotNull.kt.after index c9fd0689e12..8beb976a4dc 100644 --- a/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNotNull.kt.after +++ b/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNotNull.kt.after @@ -4,4 +4,4 @@ fun test() { val s = s() } -private fun s(): String = J.notNull() \ No newline at end of file +private fun s() = J.notNull() \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNullable.kt.after b/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNullable.kt.after index e7b5d46d31b..12f66019646 100644 --- a/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNullable.kt.after +++ b/idea/testData/refactoring/extractFunction/controlFlow/returnTypeCandidates/javaAnnotatedNullable.kt.after @@ -3,4 +3,4 @@ fun test() { val s = s() } -private fun s(): String? = J.nullable() \ No newline at end of file +private fun s() = J.nullable() \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/typeParameters/typeParameterNotResolvableInTargetScope.kt.after b/idea/testData/refactoring/extractFunction/typeParameters/typeParameterNotResolvableInTargetScope.kt.after index a357e3394ad..d4af32e7b7a 100644 --- a/idea/testData/refactoring/extractFunction/typeParameters/typeParameterNotResolvableInTargetScope.kt.after +++ b/idea/testData/refactoring/extractFunction/typeParameters/typeParameterNotResolvableInTargetScope.kt.after @@ -15,4 +15,4 @@ class Foo { } } -private fun Foo.t(l: String): T = map[l] \ No newline at end of file +private fun Foo.t(l: String) = map[l] \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/typeParameters/typeParameterResolvableInTargetScope.kt.after b/idea/testData/refactoring/extractFunction/typeParameters/typeParameterResolvableInTargetScope.kt.after index 31579c65aca..56b4d7bb3f2 100644 --- a/idea/testData/refactoring/extractFunction/typeParameters/typeParameterResolvableInTargetScope.kt.after +++ b/idea/testData/refactoring/extractFunction/typeParameters/typeParameterResolvableInTargetScope.kt.after @@ -11,5 +11,5 @@ class Foo { return t(l) } - private fun t(l: String): T = map[l] + private fun t(l: String) = map[l] } \ No newline at end of file diff --git a/idea/testData/refactoring/introduceProperty/typeParameterNotResolvableInTargetScope.kt.after b/idea/testData/refactoring/introduceProperty/typeParameterNotResolvableInTargetScope.kt.after index bd6e251b5e4..b9961b8e82a 100644 --- a/idea/testData/refactoring/introduceProperty/typeParameterNotResolvableInTargetScope.kt.after +++ b/idea/testData/refactoring/introduceProperty/typeParameterNotResolvableInTargetScope.kt.after @@ -3,7 +3,7 @@ import java.util.* -private val Foo.t: T +private val Foo.t: T? get() = map[""] // SIBLING: From befe025d216ee64478e92547b57b27d0b9850f6d Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 18 Jun 2015 13:44:13 +0300 Subject: [PATCH 153/450] Fix intentions testData: types rendering changed Some more FQ names appeared. The reason is that earlier such types were Lazy and their `toString` method return short version. But after type enhancement they are represented with JetTypeImpl --- .../extractFunction/basic/callWithPlatformTypeReceiver.kt | 4 ++-- .../basic/callWithPlatformTypeReceiver.kt.after | 4 ++-- .../parameters/candidateTypes/flexibleTypesWithNull.kt | 4 ++-- .../candidateTypes/flexibleTypesWithNull.kt.after | 6 +++--- .../parameters/candidateTypes/flexibleTypesWithoutNull.kt | 4 ++-- .../candidateTypes/flexibleTypesWithoutNull.kt.after | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt b/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt index 514c149d396..d57a7d91694 100644 --- a/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt +++ b/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // SUGGESTED_RETURN_TYPES: kotlin.Boolean?, kotlin.Boolean -// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> defined in test. -// PARAM_TYPES: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> +// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(kotlin.Boolean..kotlin.Boolean?), (kotlin.Boolean..kotlin.Boolean?)> defined in test. +// PARAM_TYPES: kotlin.Map.Entry<(kotlin.Boolean..kotlin.Boolean?), (kotlin.Boolean..kotlin.Boolean?)> fun test() { J.getMap().filter { it.getKey() } } \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt.after b/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt.after index 4146cbab390..695749d0e0f 100644 --- a/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt.after +++ b/idea/testData/refactoring/extractFunction/basic/callWithPlatformTypeReceiver.kt.after @@ -1,7 +1,7 @@ // WITH_RUNTIME // SUGGESTED_RETURN_TYPES: kotlin.Boolean?, kotlin.Boolean -// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> defined in test. -// PARAM_TYPES: kotlin.Map.Entry<(Boolean..Boolean?), (Boolean..Boolean?)> +// PARAM_DESCRIPTOR: value-parameter val it: kotlin.Map.Entry<(kotlin.Boolean..kotlin.Boolean?), (kotlin.Boolean..kotlin.Boolean?)> defined in test. +// PARAM_TYPES: kotlin.Map.Entry<(kotlin.Boolean..kotlin.Boolean?), (kotlin.Boolean..kotlin.Boolean?)> fun test() { J.getMap().filter { b(it) } } diff --git a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt index ae641c2ad01..99546e95cfc 100644 --- a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt +++ b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // SUGGESTED_NAMES: i, getN -// PARAM_TYPES: String?, String, kotlin.CharSequence?, CharSequence -// PARAM_DESCRIPTOR: val property: (String..String?) defined in test +// PARAM_TYPES: kotlin.String?, kotlin.String, kotlin.CharSequence?, CharSequence +// PARAM_DESCRIPTOR: val property: (kotlin.String..kotlin.String?) defined in test fun test() { val property = System.getProperty("some") val n = property?.length() diff --git a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt.after b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt.after index a687e4b9262..50f48bb630b 100644 --- a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt.after +++ b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithNull.kt.after @@ -1,10 +1,10 @@ // WITH_RUNTIME // SUGGESTED_NAMES: i, getN -// PARAM_TYPES: String?, String, kotlin.CharSequence?, CharSequence -// PARAM_DESCRIPTOR: val property: (String..String?) defined in test +// PARAM_TYPES: kotlin.String?, kotlin.String, kotlin.CharSequence?, CharSequence +// PARAM_DESCRIPTOR: val property: (kotlin.String..kotlin.String?) defined in test fun test() { val property = System.getProperty("some") val n = i(property) } -private fun i(property: String?) = property?.length() +private fun i(property: String?) = property?.length() \ No newline at end of file diff --git a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt index 6130d9bf142..e3da5db7cd2 100644 --- a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt +++ b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt @@ -1,7 +1,7 @@ // WITH_RUNTIME // SUGGESTED_NAMES: i, getN -// PARAM_TYPES: String, CharSequence -// PARAM_DESCRIPTOR: val property: (String..String?) defined in test +// PARAM_TYPES: kotlin.String, CharSequence +// PARAM_DESCRIPTOR: val property: (kotlin.String..kotlin.String?) defined in test fun test() { val property = System.getProperty("some") val n = property.length() diff --git a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt.after b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt.after index 559b5d08cf7..21d2fede2f3 100644 --- a/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt.after +++ b/idea/testData/refactoring/extractFunction/parameters/candidateTypes/flexibleTypesWithoutNull.kt.after @@ -1,7 +1,7 @@ // WITH_RUNTIME // SUGGESTED_NAMES: i, getN -// PARAM_TYPES: String, CharSequence -// PARAM_DESCRIPTOR: val property: (String..String?) defined in test +// PARAM_TYPES: kotlin.String, CharSequence +// PARAM_DESCRIPTOR: val property: (kotlin.String..kotlin.String?) defined in test fun test() { val property = System.getProperty("some") val n = i(property) From 00e41fc238c5bd7b5979d2b900cd0e45c2027e6b Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 19 Jun 2015 13:56:37 +0300 Subject: [PATCH 154/450] Fix testData after types enhancement --- .../testData/codegen/notNullAssertions/AssertionChecker.kt | 4 ++-- .../kotlin/codegen/GenerateNotNullAssertionsTest.java | 2 +- .../debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt index d3643218d1d..17523ca17c2 100644 --- a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt +++ b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt @@ -45,10 +45,10 @@ fun checkAssertions(illegalStateExpected: Boolean) { check("plus") { A() + A() } // field - check("NULL") { A().NULL } + // check("NULL") { A().NULL } // static field - check("STATIC_NULL") { A.STATIC_NULL } + // check("STATIC_NULL") { A.STATIC_NULL } // postfix expression // TODO: diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java index d30c89bca3f..d07adce460f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java @@ -137,7 +137,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase { loadFile("notNullAssertions/javaMultipleSubstitutions.kt"); String text = generateToText(); - assertEquals(3, StringUtil.getOccurrenceCount(text, "checkExpressionValueIsNotNull")); + assertEquals(0, StringUtil.getOccurrenceCount(text, "checkExpressionValueIsNotNull")); assertEquals(3, StringUtil.getOccurrenceCount(text, "checkParameterIsNotNull")); } diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out index bdd1cc9bd58..94468ad37ce 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out @@ -4,9 +4,9 @@ Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socke stepIntoSpecificKotlinClasses.kt:8 MyJavaClass.java:12 stepIntoSpecificKotlinClasses.kt:8 -Intrinsics.!EXT! -stepIntoSpecificKotlinClasses.kt:8 stepIntoSpecificKotlinClasses.kt:9 +stepIntoSpecificKotlinClasses.kt:10 +Thread.!EXT! Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 From 5ea0c14d4ab6251dd648fb28ea9b5e0b831f8c17 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 19 Jun 2015 15:51:43 +0300 Subject: [PATCH 155/450] Expand the AbstractJvmRuntimeDescriptorLoaderTest hack Remove type related annotations from java source as they have CLASS retention policy --- .../jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt index 77f2c3c8c95..116a8affaee 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt @@ -67,6 +67,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi // NOTE: this test does a dirty hack of text substitution to make all annotations defined in source code retain at runtime. // Specifically each "annotation class" in Kotlin sources is replaced by "Retention(RUNTIME) annotation class", and the same in Java + // Also type related annotations are removed from Java because they are invisible at runtime protected fun doTest(fileName: String) { val file = File(fileName) val text = FileUtil.loadFile(file, true) @@ -112,7 +113,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi val sources = JetTestUtils.createTestFiles(fileName, text, object : TestFileFactoryNoModules() { override fun create(fileName: String, text: String, directives: Map): File { val targetFile = File(tmpdir, fileName) - targetFile.writeText(addRuntimeRetentionToJavaSource(text)) + targetFile.writeText(adaptJavaSource(text)) return targetFile } }) @@ -172,8 +173,9 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi ) } - private fun addRuntimeRetentionToJavaSource(text: String): String { - return text.replace( + private fun adaptJavaSource(text: String): String { + val typeAnnotations = arrayOf("NotNull", "Nullable", "ReadOnly", "Mutable") + return typeAnnotations.fold(text) { text, annotation -> text.replace("@$annotation", "") }.replace( "@interface", "@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @interface" ) From afcdd27d67ec9c41643e28c4db61ba22e54891f2 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 2 Jul 2015 16:43:34 +0300 Subject: [PATCH 156/450] Add some marginal tests for types enhancement --- .../typeEnhancement/annotatedTypeArguments.kt | 38 +++++++++++ .../annotatedTypeArguments.txt | 48 ++++++++++++++ .../methodWithTypeParameter.kt | 51 +++++++++++++++ .../methodWithTypeParameter.txt | 44 +++++++++++++ .../typeEnhancement/overriddenExtensions.kt | 63 +++++++++++++++++++ .../typeEnhancement/overriddenExtensions.txt | 56 +++++++++++++++++ .../returnTypeDifferentConstructor.kt | 37 +++++++++++ .../returnTypeDifferentConstructor.txt | 56 +++++++++++++++++ .../returnTypeOverrideInKotlin.kt | 31 +++++++++ .../returnTypeOverrideInKotlin.txt | 56 +++++++++++++++++ .../supertypeDifferentParameterNullability.kt | 33 ++++++++++ ...supertypeDifferentParameterNullability.txt | 62 ++++++++++++++++++ .../supertypeDifferentReturnNullability.kt | 35 +++++++++++ .../supertypeDifferentReturnNullability.txt | 57 +++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 51 +++++++++++++++ 15 files changed, 718 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.txt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.txt diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt new file mode 100644 index 00000000000..b2a46d6ba21 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt @@ -0,0 +1,38 @@ +// FILE: AnnotatedTypeArguments.java + +import org.jetbrains.annotations.*; + +interface P {} +interface L {} +interface S {} + +class AnnotatedTypeArguments { + + class A { + L, S>> foo(L, S>> x) {return null;} + } + + class B extends A { + // some complicated type tree + // return type and argument's type differ only by nullability of outermost type + @Nullable + L, @NotNull S>> foo(@NotNull L, @NotNull S>> x) {return null;} + } + + class C extends B { + // signature should be the same as in A + L, S>> foo(L, S>> x) {return null;} + } + + class D1 extends C { + // signature should be the same as in A, but annotated String-type should be platform + L, S>> foo(L, S>> x) {return null;} + } + + class D2 extends C { + // return type refined to not-nullable + // argument type here same as in A except outermost type (it becomes flexible because of conflict) + @NotNull + L, S>> foo(@Nullable L, S>> x) {return null;} + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.txt new file mode 100644 index 00000000000..e5833bf45e6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.txt @@ -0,0 +1,48 @@ +package + +public/*package*/ open class AnnotatedTypeArguments { + public/*package*/ constructor AnnotatedTypeArguments() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ open inner class A { + public/*package*/ constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun foo(/*0*/ x: L!, S<*>!>!>!): L!, S<*>!>!>! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class B : AnnotatedTypeArguments.A { + public/*package*/ constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.Nullable() public/*package*/ open override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: L, S<*>>!>): L, S<*>>!>? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class C : AnnotatedTypeArguments.B { + public/*package*/ constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open override /*1*/ fun foo(/*0*/ x: L, S<*>>!>): L, S<*>>!>? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class D1 : AnnotatedTypeArguments.C { + public/*package*/ constructor D1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open override /*1*/ fun foo(/*0*/ x: L, S<*>>!>): L, S<*>>!>? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class D2 : AnnotatedTypeArguments.C { + public/*package*/ constructor D2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: L, S<*>>!>!): L, S<*>>!> + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt new file mode 100644 index 00000000000..b676019d8fb --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt @@ -0,0 +1,51 @@ +// FILE: Outer.java + +import org.jetbrains.annotations.*; + +interface X {} +interface Y {} + +class Outer { + class A { + V foo(K x) { return null; } + + X bar(Y x) { return null; } + } + + class B extends A { + // OK, non-platform types + @Override + @NotNull T2 foo(@Nullable T1 x) { return null; } + + // Parameter type is fully non-flexible (OK) + // Return type is `X?`. + // The reason is that we do not treat it as equal to return type of A.bar because they are base on different type parameters, + // so type enhancing happens only for outermost type. + // TODO: We should properly compare equality with specific local equality axioms (as when calculating overriden descriptors) + @Override + @Nullable X<@Nullable R> bar(@NotNull Y<@NotNull R> x) { return null; } + } + + class C extends B { + // OK, non-platform types + @Override + J foo(I x) { return null; } + + // Parameter type is fully non-flexible (OK) + // Return type is `X?`, same is in B + @Override + X bar(Y x) { return null; } + } + + class D extends C { + // Return type is not-nullable, covariantly overridden, OK + // Parameter type is flexible, because of conflict with supertype, OK + @Override + @NotNull + W foo(@Nullable U x) { return null; } + + + @Override + @NotNull X<@NotNull F> bar(@Nullable Y<@Nullable F> x) { return null; } + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.txt new file mode 100644 index 00000000000..1621e611eb6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.txt @@ -0,0 +1,44 @@ +package + +public/*package*/ open class Outer { + public/*package*/ constructor Outer() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ open inner class A { + public/*package*/ constructor A() + public/*package*/ open fun bar(/*0*/ x: Y!): X! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun foo(/*0*/ x: K!): V! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class B : Outer.A { + public/*package*/ constructor B() + java.lang.Override() public/*package*/ open override /*1*/ fun bar(/*0*/ org.jetbrains.annotations.NotNull() x: Y): X? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public/*package*/ open override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: T1?): T2 + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class C : Outer.B { + public/*package*/ constructor C() + java.lang.Override() public/*package*/ open override /*1*/ fun bar(/*0*/ x: Y): X? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public/*package*/ open override /*1*/ fun foo(/*0*/ x: I?): J + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class D : Outer.C { + public/*package*/ constructor D() + java.lang.Override() public/*package*/ open override /*1*/ fun bar(/*0*/ org.jetbrains.annotations.Nullable() x: Y!): X + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: U?): W + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt new file mode 100644 index 00000000000..1cff51ea18f --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt @@ -0,0 +1,63 @@ +// FILE: A.kt +open class A { + open fun String.foo(y: String?): Int = 1 + open fun String?.bar(y: String): Int = 1 +} + +class E : B1() { + fun baz() { + val x: String? = "" + + x.foo(x) + x.foo("") + x.bar(x) + x.bar("") + } + + override fun String.foo(y: String?): Int = 1 + override fun String?.bar(y: String): Int = 1 +} + +// FILE: B.java +import org.jetbrains.annotations.*; + +// Just inherit enhanced types +class B extends A { + @Override + int foo(String x, String y); + @Override + int bar(String x, String y); +} + +// FILE: B1.java +import org.jetbrains.annotations.*; + +// Just inherit enhanced types (annotations without conflicts) +class B1 extends A { + @Override + int foo(@NotNull String x, String y); + @Override + int bar(@Nullable String x, String y); +} + +// FILE: C.java +import org.jetbrains.annotations.*; + +// Conflicting annotations. Everything is flexible +class C extends A { + @Override + int foo(@Nullable String x, @NotNull String y); + @Override + int bar(@NotNull String x, @Nullable String y); +} + +// FILE: D.java +import org.jetbrains.annotations.*; + +// Just inherit enhanced types (annotations without conflicts) +class D extends B { + @Override + int foo(@Nullable String x, @Nullable String y); + @Override + int bar(@NotNull String x, @NotNull String y); +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.txt new file mode 100644 index 00000000000..1813968a443 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.txt @@ -0,0 +1,56 @@ +package + +internal open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal open fun kotlin.String?.bar(/*0*/ y: kotlin.String): kotlin.Int + internal open fun kotlin.String.foo(/*0*/ y: kotlin.String?): kotlin.Int +} + +public/*package*/ open class B : A { + public/*package*/ constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String?.bar(/*0*/ y: kotlin.String): kotlin.Int + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String.foo(/*0*/ y: kotlin.String?): kotlin.Int +} + +public/*package*/ open class B1 : A { + public/*package*/ constructor B1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String?.bar(/*0*/ y: kotlin.String): kotlin.Int + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String.foo(/*0*/ y: kotlin.String?): kotlin.Int +} + +public/*package*/ open class C : A { + public/*package*/ constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String!.bar(/*0*/ org.jetbrains.annotations.Nullable() y: kotlin.String!): kotlin.Int + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String!.foo(/*0*/ org.jetbrains.annotations.NotNull() y: kotlin.String!): kotlin.Int +} + +public/*package*/ open class D : B { + public/*package*/ constructor D() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String!.bar(/*0*/ org.jetbrains.annotations.NotNull() y: kotlin.String): kotlin.Int + java.lang.Override() public/*package*/ open override /*1*/ fun kotlin.String!.foo(/*0*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Int +} + +internal final class E : B1 { + public constructor E() + internal final fun baz(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal open override /*1*/ fun kotlin.String?.bar(/*0*/ y: kotlin.String): kotlin.Int + internal open override /*1*/ fun kotlin.String.foo(/*0*/ y: kotlin.String?): kotlin.Int +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt new file mode 100644 index 00000000000..c96a266a34f --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt @@ -0,0 +1,37 @@ +// FILE: Outer.java + +import org.jetbrains.annotations.*; + +interface Base {} +interface Derived extends Base {} + +class Outer { + class A { + @Nullable Base<@NotNull String> foo() { return null; } + } + + class B extends A { + @Override + Base foo() {} + } + + class C extends A { + @Override + @NotNull Base foo() {} + } + + class D extends A { + @Override + Derived foo() {} + } + + class E extends A { + @Override + @NotNull Derived foo() {} + } + + class F extends A { + @Override + @NotNull Derived<@NotNull String> foo() {} + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.txt new file mode 100644 index 00000000000..3de4b6bfdcd --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.txt @@ -0,0 +1,56 @@ +package + +public/*package*/ open class Outer { + public/*package*/ constructor Outer() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ open inner class A { + public/*package*/ constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.Nullable() public/*package*/ open fun foo(): Base? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class B : Outer.A { + public/*package*/ constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public/*package*/ open override /*1*/ fun foo(): Base? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class C : Outer.A { + public/*package*/ constructor C() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Base + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class D : Outer.A { + public/*package*/ constructor D() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public/*package*/ open override /*1*/ fun foo(): Derived? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class E : Outer.A { + public/*package*/ constructor E() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Derived + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public/*package*/ open inner class F : Outer.A { + public/*package*/ constructor F() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Derived + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt new file mode 100644 index 00000000000..a010f31db7c --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt @@ -0,0 +1,31 @@ +// FILE: A.java + +import org.jetbrains.annotations.*; + +public class A { + @Nullable Base<@NotNull String> foo() { return null; } +} + +// FILE: a.kt + +interface Base {} +interface Derived : Base {} + +fun bar1(): Derived = null!! +fun bar2(): Derived = null!! + +class B : A() { + override fun foo(): Base { return bar1(); } +} + +class C1 : A() { + override fun foo(): Derived { return bar1(); } +} + +class C2 : A() { + override fun foo(): Derived? { return bar1(); } +} + +class C3 : A() { + override fun foo(): Derived { return bar2(); } +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.txt new file mode 100644 index 00000000000..e5613b2f150 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.txt @@ -0,0 +1,56 @@ +package + +internal fun bar1(): Derived +internal fun bar2(): Derived + +public open class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.Nullable() public/*package*/ open fun foo(): Base? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class B : A { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ fun foo(): Base + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface Base { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C1 : A { + public constructor C1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ fun foo(): Derived + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C2 : A { + public constructor C2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ fun foo(): Derived? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C3 : A { + public constructor C3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal open override /*1*/ fun foo(): Derived + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface Derived : Base { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt new file mode 100644 index 00000000000..1d50f6f48ce --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt @@ -0,0 +1,33 @@ +// FILE: A.java +import org.jetbrains.annotations.*; + +interface A { + void foo(@Nullable String x); +} + +// FILE: B.java +import org.jetbrains.annotations.*; + +interface B { + void foo(@NotNull String x); +} + +// FILE: C.kt + +class C1 : A, B { + override fun foo(x: String) {} +} + +class C2 : A, B { + override fun foo(x: String?) {} +} + +interface I : A, B + +class C3 : I { + override fun foo(x: String) {} +} + +class C4 : I { + override fun foo(x: String?) {} +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.txt new file mode 100644 index 00000000000..2c6055689b2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.txt @@ -0,0 +1,62 @@ +package + +public/*package*/ /*synthesized*/ fun A(/*0*/ function: (kotlin.String!) -> kotlin.Unit): A +public/*package*/ /*synthesized*/ fun B(/*0*/ function: (kotlin.String!) -> kotlin.Unit): B + +public/*package*/ interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface B { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C1 : A, B { + public constructor C1() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(/*0*/ x: kotlin.String): kotlin.Unit + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C2 : A, B { + public constructor C2() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ x: kotlin.String?): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C3 : I { + public constructor C3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(/*0*/ x: kotlin.String): kotlin.Unit + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C4 : I { + public constructor C4() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String): kotlin.Unit + public open override /*1*/ fun foo(/*0*/ x: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface I : A, B { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String): kotlin.Unit + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.kt new file mode 100644 index 00000000000..fbc8c65470a --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.kt @@ -0,0 +1,35 @@ +// FILE: A.java +import org.jetbrains.annotations.*; + +interface A { + @Nullable + String foo(); +} + +// FILE: B.java +import org.jetbrains.annotations.*; + +interface B { + @NotNull + String foo(); +} + +// FILE: C.kt + +class C1 : A, B { + override fun foo(): String? = "" +} + +class C2 : A, B { + override fun foo(): String = "" +} + +interface I : A, B + +class C3 : I { + override fun foo(): String? = "" +} + +class C4 : I { + override fun foo(): String = "" +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.txt new file mode 100644 index 00000000000..20e5b74578a --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.txt @@ -0,0 +1,57 @@ +package + +public/*package*/ /*synthesized*/ fun A(/*0*/ function: () -> kotlin.String!): A +public/*package*/ /*synthesized*/ fun B(/*0*/ function: () -> kotlin.String!): B + +public/*package*/ interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.Nullable() public abstract fun foo(): kotlin.String? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface B { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.NotNull() public abstract fun foo(): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C1 : A, B { + public constructor C1() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun foo(): kotlin.String? + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C2 : A, B { + public constructor C2() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun foo(): kotlin.String + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C3 : I { + public constructor C3() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(): kotlin.String? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C4 : I { + public constructor C4() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface I : A, B { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + org.jetbrains.annotations.NotNull() public abstract override /*2*/ /*fake_override*/ fun foo(): kotlin.String + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index b5529a443fa..345a5ccaf38 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10115,6 +10115,57 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } } + + @TestMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class TypeEnhancement extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInTypeEnhancement() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotatedTypeArguments.kt") + public void testAnnotatedTypeArguments() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt"); + doTest(fileName); + } + + @TestMetadata("methodWithTypeParameter.kt") + public void testMethodWithTypeParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt"); + doTest(fileName); + } + + @TestMetadata("overriddenExtensions.kt") + public void testOverriddenExtensions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeDifferentConstructor.kt") + public void testReturnTypeDifferentConstructor() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("returnTypeOverrideInKotlin.kt") + public void testReturnTypeOverrideInKotlin() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt"); + doTest(fileName); + } + + @TestMetadata("supertypeDifferentParameterNullability.kt") + public void testSupertypeDifferentParameterNullability() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt"); + doTest(fileName); + } + + @TestMetadata("supertypeDifferentReturnNullability.kt") + public void testSupertypeDifferentReturnNullability() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentReturnNullability.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/recovery") From 4479c215d4c264e6ccd1148fe3fcf78ca2b13c33 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 17 Jun 2015 17:48:18 +0300 Subject: [PATCH 157/450] Change return type for `iterator` method of `asList` impls for *Array These objects implement AbstractList that extending MutableCollection. After type propagation `iterator` of AbstractList become MutableIterator, so it cannot be overriden with immutable Iterator --- libraries/stdlib/src/generated/_SpecialJVM.kt | 16 ++++++++-------- .../src/templates/SpecialJVM.kt | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libraries/stdlib/src/generated/_SpecialJVM.kt b/libraries/stdlib/src/generated/_SpecialJVM.kt index b4502eb4aef..79880f368fe 100644 --- a/libraries/stdlib/src/generated/_SpecialJVM.kt +++ b/libraries/stdlib/src/generated/_SpecialJVM.kt @@ -25,7 +25,7 @@ public fun BooleanArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Boolean) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Boolean = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Boolean) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Boolean) @@ -40,7 +40,7 @@ public fun ByteArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Byte) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Byte = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Byte) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Byte) @@ -55,7 +55,7 @@ public fun CharArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Char) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Char = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Char) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Char) @@ -70,7 +70,7 @@ public fun DoubleArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Double) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Double = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Double) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Double) @@ -85,7 +85,7 @@ public fun FloatArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Float) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Float = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Float) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Float) @@ -100,7 +100,7 @@ public fun IntArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Int) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Int = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Int) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Int) @@ -115,7 +115,7 @@ public fun LongArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Long) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Long = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Long) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Long) @@ -130,7 +130,7 @@ public fun ShortArray.asList(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as Short) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Short = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as Short) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as Short) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index 4af239daa08..3cd1e713263 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -167,7 +167,7 @@ fun specialJVM(): List { override fun size(): Int = this@asList.size() override fun isEmpty(): Boolean = this@asList.isEmpty() override fun contains(o: Any?): Boolean = this@asList.contains(o as T) - override fun iterator(): Iterator = this@asList.iterator() + override fun iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): T = this@asList[index] override fun indexOf(o: Any?): Int = this@asList.indexOf(o as T) override fun lastIndexOf(o: Any?): Int = this@asList.lastIndexOf(o as T) From 0a19fb7df27ec4fed0b85916e22ea792f132c586 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 8 Jul 2015 12:13:24 +0300 Subject: [PATCH 158/450] Make project compilable after types enhancement --- .../AccessorForConstructorDescriptor.kt | 3 ++ .../jetbrains/kotlin/codegen/BranchedValue.kt | 2 +- .../jetbrains/kotlin/codegen/inline/SMAP.kt | 2 +- .../LabelNormalizationMethodTransformer.kt | 2 +- .../optimization/fixStack/FixStackAnalyzer.kt | 6 ++-- .../fixStack/LocalVariablesManager.kt | 12 ++++---- .../jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 2 +- .../load/kotlin/JavaAnnotationCallChecker.kt | 2 +- .../load/kotlin/KotlinJvmCheckerProvider.kt | 6 ++-- .../diagnostics/PositioningStrategies.kt | 2 +- .../kotlin/kdoc/psi/impl/KDocLink.kt | 2 +- .../kotlin/psi/JetDoubleColonExpression.kt | 2 +- .../kotlin/psi/JetObjectDeclaration.kt | 2 +- .../org/jetbrains/kotlin/psi/JetPsiFactory.kt | 4 +-- .../psi/KotlinStringLiteralTextEscaper.kt | 2 +- .../kotlin/psi/psiUtil/jetPsiUtil.kt | 4 +-- .../kotlin/resolve/LazyTopDownAnalyzer.kt | 2 +- .../jetbrains/kotlin/resolve/TypeResolver.kt | 2 +- .../kotlin/resolve/VarianceChecker.kt | 2 +- .../kotlin/resolve/calls/CallCompleter.kt | 2 +- .../checkers/CapturingInClosureChecker.kt | 2 +- .../evaluate/ConstantExpressionEvaluator.kt | 4 +-- .../descriptors/LazyScriptClassMemberScope.kt | 1 + .../validation/DeprecatedSymbolValidator.kt | 2 +- .../LockBasedLazyResolveStorageManager.kt | 2 +- .../expressions/FunctionsTypingVisitor.kt | 2 +- .../KotlinLightMethodForTraitFakeOverride.kt | 2 +- .../serialization/AnnotationSerializer.kt | 18 ++++++------ .../kotlin/checkers/LazyOperationsLog.kt | 4 +-- .../cli/jvm/KotlinCliJavaFileManagerTest.kt | 1 + .../kotlin/codegen/InlineTestUtil.kt | 4 +-- .../AbstractDescriptorRendererTest.kt | 2 +- .../calls/AbstractResolvedCallsTest.kt | 2 +- .../CapturedTypeApproximationTest.kt | 2 +- .../org/jetbrains/kotlin/types/TypeUtils.kt | 2 +- .../deserialization/MemberDeserializer.kt | 2 +- .../kotlin/idea/util/extensionsUtils.kt | 2 +- .../kotlin/resolve/lazy/ElementResolver.kt | 12 ++++---- .../stubBuilder/ClassClsStubBuilder.kt | 2 +- .../stubBuilder/KotlinClsStubBuilder.kt | 2 +- .../stubBuilder/TypeClsStubBuilder.kt | 2 +- .../decompiler/stubBuilder/clsStubBuilding.kt | 4 +-- .../textBuilder/DecompiledTextFactory.kt | 4 +-- .../KotlinSuppressableWarningProblemGroup.kt | 2 +- .../kotlin/idea/kdoc/KDocReference.kt | 4 +-- .../idea/completion/AllClassesCompletion.kt | 2 +- .../kotlin/idea/completion/CompletionUtils.kt | 2 +- .../completion/KDocCompletionContributor.kt | 2 +- .../idea/completion/LookupElementFactory.kt | 4 +-- .../ParameterNameAndTypeCompletion.kt | 2 +- .../handlers/CastReceiverInsertHandler.kt | 4 +-- .../handlers/KotlinClassInsertHandler.kt | 2 +- .../idea/completion/smart/SmartCompletion.kt | 4 +-- .../smart/TypesWithContainsDetector.kt | 2 +- .../kotlin/idea/completion/smart/Utils.kt | 2 +- .../kotlin/idea/core/descriptorUtils.kt | 2 +- .../kotlin/idea/ExtraSteppingFilter.kt | 4 +-- .../actions/ConfigureKotlinInProjectAction.kt | 6 ++-- .../KotlinCopyPasteReferenceProcessor.kt | 2 +- .../KotlinRuntimeTypeCastSurrounder.kt | 2 +- .../idea/coverage/KotlinCoverageExtension.kt | 8 ++--- .../idea/debugger/JetPositionManager.kt | 2 +- .../idea/debugger/KotlinEditorTextProvider.kt | 2 +- .../KotlinFrameExtraVariablesProvider.kt | 4 +-- .../breakpoints/KotlinFieldBreakpoint.kt | 4 +-- .../idea/editor/KotlinSmartEnterHandler.kt | 2 +- .../DelegatingFindMemberUsagesHandler.kt | 2 +- .../handlers/KotlinFindClassUsagesHandler.kt | 2 +- .../idea/framework/KotlinTemplatesFactory.kt | 2 +- .../inspections/UnusedSymbolInspection.kt | 4 +-- ...precatedCallableAddReplaceWithIntention.kt | 2 +- .../intentions/IterateExpressionIntention.kt | 2 +- .../jetbrains/kotlin/idea/intentions/Utils.kt | 2 +- .../branchedTransformationUtils.kt | 2 +- .../kotlin/idea/quickfix/AddLoopLabelFix.kt | 6 ++-- .../kotlin/idea/quickfix/AutoImportFix.kt | 2 +- .../DeprecatedEnumEntryDelimiterSyntaxFix.kt | 2 +- ...catedEnumEntrySuperConstructorSyntaxFix.kt | 2 +- .../quickfix/DeprecatedLambdaSyntaxFix.kt | 1 + .../quickfix/DeprecatedSymbolUsageFixBase.kt | 6 ++-- .../idea/quickfix/DeprecatedTraitSyntaxFix.kt | 4 +-- .../kotlin/idea/quickfix/ExclExlCallFixes.kt | 2 +- .../quickfix/InsertDelegationCallQuickfix.kt | 4 +-- .../MigrateAnnotationMethodCallFix.kt | 2 +- .../quickfix/MissingConstructorKeywordFix.kt | 2 +- .../quickfix/ReplaceObsoleteLabelSyntaxFix.kt | 4 +-- .../quickfix/ReplaceWithAnnotationAnalyzer.kt | 2 +- .../callableBuilder/CallableBuilder.kt | 6 ++-- .../CreateCallableFromUsageFix.kt | 4 +-- .../createClass/CreateClassFromUsageFix.kt | 4 +-- .../CreateLocalVariableActionFactory.kt | 2 +- .../CreateParameterFromUsageFix.kt | 2 +- .../changeSignature/JetChangeInfo.kt | 2 +- .../changeSignature/JetChangeSignature.kt | 2 +- .../changeSignature/JetChangeSignatureData.kt | 2 +- .../AbstractKotlinInplaceIntroducer.kt | 2 +- .../ExtractableCodeDescriptor.kt | 2 +- .../extractableAnalysisUtil.kt | 4 +-- .../extractionEngine/extractorUtil.kt | 4 +-- .../KotlinInplaceParameterIntroducer.kt | 4 +-- .../KotlinIntroduceParameterHandler.kt | 2 +- .../idea/refactoring/jetRefactoringUtil.kt | 29 ++++++++++--------- ...MoveKotlinTopLevelDeclarationsProcessor.kt | 2 +- ...lesOrDirectoriesDialogWithKotlinOptions.kt | 2 +- .../kotlin/idea/refactoring/move/moveUtils.kt | 2 +- .../kotlin/DataFlowValueRenderingTest.kt | 2 +- .../kotlin/addImport/AbstractAddImportTest.kt | 2 +- .../LightClassesClasspathSortingTest.kt | 1 + ...AbstractEditorForEvaluateExpressionTest.kt | 2 +- .../AbstractKotlinEvaluateExpressionTest.kt | 6 ++-- .../CodeFragmentCompletionInLibraryTest.kt | 4 +-- .../NavigateFromLibrarySourcesTest.kt | 2 +- .../stubBuilder/AbstractClsStubBuilderTest.kt | 2 +- .../ClsStubForWrongAbiVersionTest.kt | 2 +- .../DecompiledTextForWrongAbiVersionTest.kt | 2 +- .../idea/filters/JetExceptionFilterTest.kt | 5 ++++ .../kotlin/idea/kdoc/KDocFinderTest.kt | 2 +- .../nameSuggester/JetNameSuggesterTest.kt | 4 +-- .../resolve/AbstractPartialBodyResolveTest.kt | 2 +- j2k/src/org/jetbrains/kotlin/j2k/Converter.kt | 2 +- .../org/jetbrains/kotlin/j2k/ForConverter.kt | 2 +- .../AccessorToPropertyProcessing.kt | 6 ++-- .../FieldToPropertyProcessing.kt | 2 +- .../MethodIntoObjectProcessing.kt | 2 +- .../ToObjectWithOnlyMethodsProcessing.kt | 2 +- .../jps/incremental/IncrementalCacheImpl.kt | 4 +-- .../jps/build/AbstractIncrementalJpsTest.kt | 2 +- .../js/resolve/diagnostics/jsRenderers.kt | 2 +- .../kotlin/js/inline/FunctionReader.kt | 4 +-- .../removeUnusedLocalFunctionDeclarations.kt | 6 ++-- .../callTranslator/CallInfoExtensions.kt | 2 +- .../callTranslator/FunctionCallCases.kt | 4 +-- .../reference/CallArgumentTranslator.kt | 2 ++ .../NoInternalVisibilityInStdLibTest.kt | 2 +- .../resolve/android/AndroidResourceManager.kt | 2 +- .../resolve/android/AndroidUIXmlProcessor.kt | 2 +- .../lang/resolve/android/AndroidXmlHandler.kt | 2 +- .../AndroidPsiTreeChangePreprocessor.kt | 2 +- .../plugin/android/AndroidRenameProcessor.kt | 2 +- 139 files changed, 227 insertions(+), 212 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt index dc66125a88a..f5bca65b046 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AccessorForConstructorDescriptor.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.jvm.AsmTypes +import org.jetbrains.kotlin.types.JetType import java.util.* public class AccessorForConstructorDescriptor( @@ -38,6 +39,8 @@ public class AccessorForConstructorDescriptor( override fun isPrimary(): Boolean = false + override fun getReturnType(): JetType = super.getReturnType()!! + init { initialize( DescriptorUtils.getReceiverParameterType(getExtensionReceiverParameter()), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt index 4c23e5bb50f..8eea7c615dd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/BranchedValue.kt @@ -49,7 +49,7 @@ open class BranchedValue( open fun condJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { if (arg1 is CondJump) arg1.condJump(jumpLabel, v, jumpIfFalse) else arg1.put(operandType, v) arg2?.put(operandType, v) - v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode], v), jumpLabel); + v.visitJumpInsn(patchOpcode(if (jumpIfFalse) opcode else negatedOperations[opcode]!!, v), jumpLabel); } open fun loopJump(jumpLabel: Label, v: InstructionAdapter, jumpIfFalse: Boolean) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt index ff0cc3ddc08..d5bad814797 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt @@ -284,7 +284,7 @@ class RawFileMapping(val name: String, val path: String) { if (rangeMappings.isNotEmpty() && isLastMapped && couldFoldInRange(lastMappedWithNewIndex, source)) { rangeMapping = rangeMappings.last() rangeMapping.range += source - lastMappedWithNewIndex - dest = lineMappings[lastMappedWithNewIndex] + source - lastMappedWithNewIndex + dest = lineMappings[lastMappedWithNewIndex]!! + source - lastMappedWithNewIndex } else { dest = currentIndex + 1 diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt index 0ff23c89494..7528cef9e4d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/LabelNormalizationMethodTransformer.kt @@ -139,7 +139,7 @@ public object LabelNormalizationMethodTransformer : MethodTransformer() { } private fun isRemoved(labelNode: LabelNode): Boolean = removedLabelNodes.contains(labelNode) - private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode] + private fun getNew(oldLabelNode: LabelNode): LabelNode = newLabelNodes[oldLabelNode]!! } private fun InsnList.replaceNodeGetNext(oldNode: AbstractInsnNode, newNode: AbstractInsnNode): AbstractInsnNode? { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt index e1001342b5a..bd69862aa9b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -134,19 +134,19 @@ public class FixStackAnalyzer( val returnValue = pop() clearStack() val savedValues = savedStacks[beforeInlineMarker] - pushAll(savedValues) + pushAll(savedValues!!) push(returnValue) } else { val savedValues = savedStacks[beforeInlineMarker] - pushAll(savedValues) + pushAll(savedValues!!) } } private fun FixStackFrame.executeRestoreStackInTryCatch(insn: AbstractInsnNode) { val saveNode = context.saveStackMarkerForRestoreMarker[insn] val savedValues = savedStacks.getOrElse(saveNode) { - throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode)}") + throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode!!)}") } pushAll(savedValues) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt index 90e74c3d96c..c4831c322e4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt @@ -39,7 +39,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod } fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { - val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker].size() + val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker]!!.size() return allocateNewHandle(numRestoreStackMarkers, saveStackMarker, savedStackValues) } @@ -54,7 +54,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun getSavedStackDescriptorOrNull(restoreStackMarker: AbstractInsnNode): SavedStackDescriptor { val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] - return allocatedHandles[saveStackMarker].savedStackDescriptor + return allocatedHandles[saveStackMarker]!!.savedStackDescriptor } private fun getFirstUnusedLocalVariableIndex(): Int = @@ -64,7 +64,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) { val saveStackMarker = context.saveStackMarkerForRestoreMarker[restoreStackMarker] - markEmitted(saveStackMarker) + markEmitted(saveStackMarker!!) } fun allocateVariablesForBeforeInlineMarker(beforeInlineMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { @@ -73,16 +73,16 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod fun getBeforeInlineDescriptor(afterInlineMarker: AbstractInsnNode): SavedStackDescriptor { val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] - return allocatedHandles[beforeInlineMarker].savedStackDescriptor + return allocatedHandles[beforeInlineMarker]!!.savedStackDescriptor } fun markAfterInlineMarkerEmitted(afterInlineMarker: AbstractInsnNode) { val beforeInlineMarker = context.openingInlineMethodMarker[afterInlineMarker] - markEmitted(beforeInlineMarker) + markEmitted(beforeInlineMarker!!) } private fun markEmitted(saveStackMarker: AbstractInsnNode) { - val allocatedHandle = allocatedHandles[saveStackMarker] + val allocatedHandle = allocatedHandles[saveStackMarker]!! allocatedHandle.markRestoreNodeEmitted() if (allocatedHandle.isFullyEmitted()) { allocatedHandles.remove(saveStackMarker) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index e3562a67f17..52164b8c799 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -94,7 +94,7 @@ public open class K2JVMCompiler : CLICompiler() { return INTERNAL_ERROR } catch (e: CliOptionProcessingException) { - messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage(), CompilerMessageLocation.NO_LOCATION) + messageSeverityCollector.report(CompilerMessageSeverity.ERROR, e.getMessage()!!, CompilerMessageLocation.NO_LOCATION) return INTERNAL_ERROR } catch (t: Throwable) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt index 94eb2fafe8f..63ffc596c59 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/JavaAnnotationCallChecker.kt @@ -61,7 +61,7 @@ public class JavaAnnotationCallChecker : CallChecker { if (it.getArgumentExpression() != null) { context.trace.report( diagnostic.on( - it.getArgumentExpression() + it.getArgumentExpression()!! ) ) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index 0853a822abc..9f0c1a1838b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -172,7 +172,7 @@ public class PublicFieldAnnotationChecker: DeclarationChecker { if (descriptor !is PropertyDescriptor) { report() } - else if (!bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)) { + else if (!bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) { report() } } @@ -301,7 +301,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { val baseExpression = expression.getLeft() val baseExpressionType = baseExpression?.let{ c.trace.getType(it) } ?: return doIfNotNull( - DataFlowValueFactory.createDataFlowValue(baseExpression, baseExpressionType, c), + DataFlowValueFactory.createDataFlowValue(baseExpression!!, baseExpressionType, c), c ) { c.trace.report(Errors.USELESS_ELVIS.on(expression, baseExpressionType)) @@ -364,7 +364,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker { } else { doIfNotNull(dataFlowValue, c) { - c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode().getPsi(), receiverArgument.getType())) + c.trace.report(Errors.UNNECESSARY_SAFE_CALL.on(c.call.getCallOperationNode()!!.getPsi(), receiverArgument.getType())) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt index a57d3d38272..ecb07d02390 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/PositioningStrategies.kt @@ -289,7 +289,7 @@ public object PositioningStrategies { public val VARIANCE_IN_PROJECTION: PositioningStrategy = object : PositioningStrategy() { override fun mark(element: JetTypeProjection): List { - return markNode(element.getProjectionNode()) + return markNode(element.getProjectionNode()!!) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt index f936c51275c..e7d1182d95f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/kdoc/psi/impl/KDocLink.kt @@ -43,6 +43,6 @@ public class KDocLink(node: ASTNode) : JetElementImpl(node) { return if (tag != null && tag.getSubjectLink() == this) tag else null } - override fun getReferences(): Array? = + override fun getReferences(): Array = ReferenceProvidersRegistry.getReferencesFromProviders(this) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt index 3a3b058918d..a540a86b24b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetDoubleColonExpression.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.lexer.JetTokens public abstract class JetDoubleColonExpression(node: ASTNode) : JetExpressionImpl(node) { public fun getTypeReference(): JetTypeReference? = findChildByType(JetNodeTypes.TYPE_REFERENCE) - public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON) + public fun getDoubleColonTokenReference(): PsiElement = findChildByType(JetTokens.COLONCOLON)!! override fun accept(visitor: JetVisitor, data: D): R { return visitor.visitDoubleColonExpression(this, data) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt index a1b0f6dd383..7f005751faa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetObjectDeclaration.kt @@ -75,5 +75,5 @@ public class JetObjectDeclaration : JetClassOrObject { public fun isObjectLiteral(): Boolean = getStub()?.isObjectLiteral() ?: (getParent() is JetObjectLiteralExpression) - public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD) + public fun getObjectKeyword(): PsiElement = findChildByType(JetTokens.OBJECT_KEYWORD)!! } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt index cb1c6790cd8..b2aa4f59d09 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt @@ -251,7 +251,7 @@ public class JetPsiFactory(private val project: Project) { } public fun createFunctionLiteralParameterList(text: String): JetParameterList { - return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList() + return (createExpression("{ $text -> 0}") as JetFunctionLiteralExpression).getFunctionLiteral().getValueParameterList()!! } public fun createEnumEntry(text: String): JetEnumEntry { @@ -284,7 +284,7 @@ public class JetPsiFactory(private val project: Project) { } public fun createPackageDirective(fqName: FqName): JetPackageDirective { - return createFile("package ${fqName.asString()}").getPackageDirective() + return createFile("package ${fqName.asString()}").getPackageDirective()!! } public fun createPackageDirectiveIfNeeded(fqName: FqName): JetPackageDirective? { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt index 83494aa585d..c6bb1f649f6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt @@ -39,7 +39,7 @@ public class KotlinStringLiteralTextEscaper(host: JetStringTemplateExpression): } when (child) { is JetLiteralStringTemplateEntry -> { - val textRange = rangeInsideHost.intersection(childRange).shiftRight(-childRange.getStartOffset()) + val textRange = rangeInsideHost.intersection(childRange)!!.shiftRight(-childRange.getStartOffset()) outChars.append(child.getText(), textRange.getStartOffset(), textRange.getEndOffset()) textRange.getLength().times { sourceOffsetsList.add(sourceOffset++) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt index 70730cc00f3..8dd690897fb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt @@ -144,9 +144,9 @@ public fun JetElement.getCalleeHighlightingRange(): TextRange { ) ?: return getTextRange() val startOffset = annotationEntry.getAtSymbol()?.getTextRange()?.getStartOffset() - ?: annotationEntry.getCalleeExpression().startOffset + ?: annotationEntry.getCalleeExpression()!!.startOffset - return TextRange(startOffset, annotationEntry.getCalleeExpression().endOffset) + return TextRange(startOffset, annotationEntry.getCalleeExpression()!!.endOffset) } // ---------- Block expression ------------------------------------------------------------------------------------------------------------- diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt index 4bdb281a73d..01f0e39475e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt @@ -210,7 +210,7 @@ public class LazyTopDownAnalyzer { } override fun visitAnonymousInitializer(initializer: JetClassInitializer) { - val classOrObject = PsiTreeUtil.getParentOfType(initializer, javaClass()) + val classOrObject = PsiTreeUtil.getParentOfType(initializer, javaClass())!! c.getAnonymousInitializers().put(initializer, lazyDeclarationResolver!!.resolveToDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 573d33af5b6..55c3ea047b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -226,7 +226,7 @@ public class TypeResolver( val receiverTypeRef = type.getReceiverTypeReference() val receiverType = if (receiverTypeRef == null) null else resolveType(c.noBareTypes(), receiverTypeRef) - val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()) } + val parameterTypes = type.getParameters().map { resolveType(c.noBareTypes(), it.getTypeReference()!!) } val returnTypeRef = type.getReturnTypeReference() val returnType = if (returnTypeRef != null) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt index 9e0d73ef638..2ac5e9e8a06 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt @@ -176,7 +176,7 @@ class VarianceChecker(private val trace: BindingTrace) { for (argumentBinding in getArgumentBindings()) { if (argumentBinding == null || argumentBinding.typeParameterDescriptor == null) continue - val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor, argumentBinding.typeProjection)!! + val projectionKind = getEffectiveProjectionKind(argumentBinding.typeParameterDescriptor!!, argumentBinding.typeProjection)!! val newPosition = when (projectionKind) { OUT -> position IN -> position.opposite() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index faaa381b422..03ac7c51fa4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -77,7 +77,7 @@ public class CallCompleter( resolvedCall.variableCall.getCall().getCalleeExpression() else resolvedCall.getCall().getCalleeExpression() - context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element) + context.symbolUsageValidator.validateCall(resolvedCall.getResultingDescriptor(), context.trace, element!!) } if (results.isSingleResult() && results.getResultingCall().getStatus().isSuccess()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt index 6611164be24..0abee398898 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/CapturingInClosureChecker.kt @@ -74,7 +74,7 @@ class CapturingInClosureChecker : CallChecker { if (InlineUtil.isInlinedArgument(scopeDeclaration as JetFunction, context, false)) { val scopeContainerParent = scopeContainer.getContainingDeclaration() assert(scopeContainerParent != null) { "parent is null for " + scopeContainer } - return !isCapturedVariable(variableParent, scopeContainerParent) || isCapturedInInline(context, scopeContainerParent, variableParent) + return !isCapturedVariable(variableParent, scopeContainerParent!!) || isCapturedInInline(context, scopeContainerParent, variableParent) } return false } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index a5e4178acd9..0110b9b7b4d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -226,7 +226,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (argumentForParameter == null) return null if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) { - val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass()) + val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())!! trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression)) return ErrorValue.create("Division by zero") } @@ -406,7 +406,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } override fun visitClassLiteralExpression(expression: JetClassLiteralExpression, expectedType: JetType?): CompileTimeConstant<*>? { - val jetType = trace.getType(expression) + val jetType = trace.getType(expression)!! if (jetType.isError()) return null return KClassValue(jetType) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt index 00eb512b7f3..bbe826048b0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassMemberScope.kt @@ -97,6 +97,7 @@ public class LazyScriptClassMemberScope protected constructor( val returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType() assert(returnType != null) { "Return type not initialized for " + scriptDescriptor } + returnType!! propertyDescriptor.setType( returnType, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt index 11cc047dfe3..b9f7a41ec3a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/validation/DeprecatedSymbolValidator.kt @@ -47,7 +47,7 @@ public class DeprecatedSymbolValidator : SymbolUsageValidator { override fun validateTypeUsage(targetDescriptor: ClassifierDescriptor, trace: BindingTrace, element: PsiElement) { // Do not check types in annotation entries to prevent cycles in resolve, rely on call message val annotationEntry = JetStubbedPsiUtil.getPsiOrStubParent(element, javaClass(), true) - if (annotationEntry != null && annotationEntry.getCalleeExpression().getConstructorReferenceExpression() == element) + if (annotationEntry != null && annotationEntry.getCalleeExpression()!!.getConstructorReferenceExpression() == element) return // Do not check types in calls to super constructor in extends list, rely on call message diff --git a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt index fb5612e3bf0..4255d781a34 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/storage/LockBasedLazyResolveStorageManager.kt @@ -74,7 +74,7 @@ public class LockBasedLazyResolveStorageManager(private val storageManager: Stor storageManager.compute { trace.record(slice, key) } } - override fun get(slice: ReadOnlySlice, key: K): V = storageManager.compute { trace.get(slice, key) } + override fun get(slice: ReadOnlySlice, key: K): V? = storageManager.compute { trace.get(slice, key) } override fun getKeys(slice: WritableSlice): Collection = storageManager.compute { trace.getKeys(slice) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt index fbc931ea56b..dfa6f649dd9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/FunctionsTypingVisitor.kt @@ -214,7 +214,7 @@ public class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Express // This is needed for ControlStructureTypingVisitor#visitReturnExpression() to properly type-check returned expressions context.trace.record(EXPECTED_RETURN_TYPE, functionLiteral, expectedType) val typeOfBodyExpression = // Type-check the body - components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression(), COERCION_TO_UNIT, newContext).type + components.expressionTypingServices.getBlockReturnedType(functionLiteral.getBodyExpression()!!, COERCION_TO_UNIT, newContext).type return declaredReturnType ?: computeReturnTypeBasedOnReturnExpressions(functionLiteral, context, typeOfBodyExpression) } diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt index b48223d3724..3328415221b 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/KotlinLightMethodForTraitFakeOverride.kt @@ -33,6 +33,6 @@ public class KotlinLightMethodForTraitFakeOverride( override fun getOrigin(): JetDeclaration = origin override fun copy(): PsiElement { - return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()) + return KotlinLightMethodForTraitFakeOverride(getManager(), delegate, origin.copy() as JetDeclaration, getContainingClass()!!) } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 0f10bd149d4..0a23ec43013 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -64,22 +64,22 @@ public object AnnotationSerializer { override fun visitBooleanValue(value: BooleanValue, data: Unit) { setType(Type.BOOLEAN) - setIntValue(if (value.getValue()) 1 else 0) + setIntValue(if (value.getValue()!!) 1 else 0) } override fun visitByteValue(value: ByteValue, data: Unit) { setType(Type.BYTE) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitCharValue(value: CharValue, data: Unit) { setType(Type.CHAR) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitDoubleValue(value: DoubleValue, data: Unit) { setType(Type.DOUBLE) - setDoubleValue(value.getValue()) + setDoubleValue(value.getValue()!!) } override fun visitEnumValue(value: EnumValue, data: Unit) { @@ -95,12 +95,12 @@ public object AnnotationSerializer { override fun visitFloatValue(value: FloatValue, data: Unit) { setType(Type.FLOAT) - setFloatValue(value.getValue()) + setFloatValue(value.getValue()!!) } override fun visitIntValue(value: IntValue, data: Unit) { setType(Type.INT) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitKClassValue(value: KClassValue?, data: Unit?) { @@ -110,7 +110,7 @@ public object AnnotationSerializer { override fun visitLongValue(value: LongValue, data: Unit) { setType(Type.LONG) - setIntValue(value.getValue()) + setIntValue(value.getValue()!!) } override fun visitNullValue(value: NullValue, data: Unit) { @@ -135,12 +135,12 @@ public object AnnotationSerializer { override fun visitShortValue(value: ShortValue, data: Unit) { setType(Type.SHORT) - setIntValue(value.getValue().toLong()) + setIntValue(value.getValue()!!.toLong()) } override fun visitStringValue(value: StringValue, data: Unit) { setType(Type.STRING) - setStringValue(nameTable.getStringIndex(value.getValue())) + setStringValue(nameTable.getStringIndex(value.getValue()!!)) } }, Unit) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt index 015af25125c..15a5706bb2b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt +++ b/compiler/tests/org/jetbrains/kotlin/checkers/LazyOperationsLog.kt @@ -152,7 +152,7 @@ class LazyOperationsLog( } o.javaClass.getSimpleName() == "LazyJavaClassTypeConstructor" -> { val javaClass = o.field("this\$0").field("jClass") - javaClass.getPsi().getName().appendQuoted() + javaClass.getPsi().getName()!!.appendQuoted() } o.javaClass.getSimpleName() == "DeserializedType" -> { val typeDeserializer = o.field("typeDeserializer") @@ -161,7 +161,7 @@ class LazyOperationsLog( val text = when (typeProto.getConstructor().getKind()) { ProtoBuf.Type.Constructor.Kind.CLASS -> context.nameResolver.getFqName(typeProto.getConstructor().getId()).asString() ProtoBuf.Type.Constructor.Kind.TYPE_PARAMETER -> { - val classifier = (o as JetType).getConstructor().getDeclarationDescriptor() + val classifier = (o as JetType).getConstructor().getDeclarationDescriptor()!! "" + classifier.getName() + " in " + DescriptorUtils.getFqName(classifier.getContainingDeclaration()) } else -> "???" diff --git a/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt index d7ccb8cc45a..32e7e827ba3 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/jvm/KotlinCliJavaFileManagerTest.kt @@ -143,6 +143,7 @@ public class KotlinCliJavaFileManagerTest : PsiTestCase() { val pkg = root.createChildDirectory(this, "foo") val dir = myPsiManager.findDirectory(pkg) TestCase.assertNotNull(dir) + dir!! dir.add(PsiFileFactory.getInstance(getProject()).createFileFromText(className + ".java", JavaFileType.INSTANCE, text)) val coreJavaFileManagerExt = KotlinCliJavaFileManagerImpl(myPsiManager) coreJavaFileManagerExt.initIndex(JvmDependenciesIndex(listOf(JavaRoot(root, JavaRoot.RootType.SOURCE)))) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt b/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt index a23c9e83f8d..7935d59e598 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/InlineTestUtil.kt @@ -194,9 +194,9 @@ public object InlineTestUtil { override fun getFileContents(): ByteArray = throw UnsupportedOperationException() override fun hashCode(): Int = throw UnsupportedOperationException() override fun equals(other: Any?): Boolean = throw UnsupportedOperationException() - override fun toString(): String? = throw UnsupportedOperationException() + override fun toString(): String = throw UnsupportedOperationException() } - }.getClassHeader() + }!!.getClassHeader() } private class InlineInfo(val inlineMethods: Set, val classHeaders: Map) diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt index 065e6623946..dd79a6dbe94 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt @@ -79,7 +79,7 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment is JetPrimaryConstructor -> { val jetClassOrObject: JetClassOrObject = declaringElement.getContainingClassOrObject() val classDescriptor = getDescriptor(jetClassOrObject, resolveSession) as ClassDescriptor - addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor(), parameter) + addCorrespondingParameterDescriptor(classDescriptor.getUnsubstitutedPrimaryConstructor()!!, parameter) } else -> super.visitParameter(parameter) } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt index 86ed538e515..81b739de555 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/calls/AbstractResolvedCallsTest.kt @@ -66,7 +66,7 @@ public abstract class AbstractResolvedCallsTest : JetLiteFixture() { open protected fun buildCachedCall( bindingContext: BindingContext, jetFile: JetFile, text: String ): Pair?> { - val element = jetFile.findElementAt(text.indexOf("")) + val element = jetFile.findElementAt(text.indexOf(""))!! val expression = element.getStrictParentOfType() val cachedCall = expression?.getParentResolvedCall(bindingContext, strict = false) diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt index d7fac45ef9f..78f8c707c04 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/typeApproximation/CapturedTypeApproximationTest.kt @@ -106,7 +106,7 @@ public class CapturedTypeApproximationTest() : JetLiteFixture() { val testSubstitutions = createTestSubstitutions(typeParameters) for (testSubstitution in testSubstitutions) { val typeSubstitutor = createTestSubstitutor(testSubstitution) - val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type))!!.getType() + val typeWithCapturedType = typeSubstitutor.substituteWithoutApproximation(TypeProjectionImpl(INVARIANT, type!!))!!.getType() val (lower, upper) = approximateCapturedTypes(typeWithCapturedType) val substitution = approximateCapturedTypesIfNecessary(TypeProjectionImpl(INVARIANT, typeWithCapturedType)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 558ed9d3912..071e9567383 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -63,7 +63,7 @@ fun DeclarationDescriptor.getCapturedTypeParameters(): Collection { // todo type arguments (instead of type parameters) of the type of outer class must be considered; KT-6325 - val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor().getCapturedTypeParameters() + val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor()!!.getCapturedTypeParameters() return typeParameters.map { it.getTypeConstructor() }.toReadOnlyList() } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 7a92b70da47..cc2e0cf7223 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -170,7 +170,7 @@ public class MemberDeserializer(private val c: DeserializationContext) { } private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List { - val containerOfCallable = c.containingDeclaration.getContainingDeclaration().asProtoContainer() + val containerOfCallable = c.containingDeclaration.getContainingDeclaration()!!.asProtoContainer() return callable.getValueParameterList().mapIndexed { i, proto -> ValueParameterDescriptorImpl( diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index d514f844681..40680d232cd 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -102,7 +102,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable( return if (substitutors.any()) listOf(this) else listOf() } else { - return substitutors.map { substitute(it) }.toList() + return substitutors.map { substitute(it)!! }.toList() } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 2d93627af24..ad87d432aef 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -492,19 +492,19 @@ public abstract class ElementResolver protected constructor( ) : BodiesResolveContext { override fun getFiles(): Collection = setOf() - override fun getDeclaredClasses(): Map = mapOf() + override fun getDeclaredClasses(): MutableMap = hashMapOf() - override fun getAnonymousInitializers(): Map = mapOf() + override fun getAnonymousInitializers(): MutableMap = hashMapOf() - override fun getSecondaryConstructors(): Map = mapOf() + override fun getSecondaryConstructors(): MutableMap = hashMapOf() - override fun getProperties(): Map = mapOf() + override fun getProperties(): MutableMap = hashMapOf() - override fun getFunctions(): Map = mapOf() + override fun getFunctions(): MutableMap = hashMapOf() override fun getDeclaringScope(declaration: JetDeclaration): JetScope? = declaringScopes(declaration) - override fun getScripts(): Map = mapOf() + override fun getScripts(): MutableMap = hashMapOf() override fun getOuterDataFlowInfo(): DataFlowInfo = DataFlowInfo.EMPTY diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt index a4b20654904..f6db9e92272 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt @@ -108,7 +108,7 @@ private class ClassClsStubBuilder( val superTypeRefs = supertypeIds.filterNot { //TODO: filtering function types should go away KotlinBuiltIns.isNumberedFunctionClassFqName(it.asSingleFqName().toUnsafe()) - }.map { it.getShortClassName().ref() }.toTypedArray() + }.map { it.getShortClassName().ref()!! }.toTypedArray() return when (classKind) { ProtoBuf.Class.Kind.OBJECT, ProtoBuf.Class.Kind.CLASS_OBJECT -> { KotlinObjectStubImpl( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt index 963559d741a..a4118eb2b62 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/KotlinClsStubBuilder.kt @@ -49,7 +49,7 @@ public open class KotlinClsStubBuilder : ClsStubBuilder() { } fun doBuildFileStub(file: VirtualFile): PsiFileStub? { - val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file) + val kotlinBinaryClass = KotlinBinaryClassCache.getKotlinBinaryClass(file)!! val header = kotlinBinaryClass.getClassHeader() val classId = kotlinBinaryClass.getClassId() val packageFqName = classId.getPackageFqName() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt index 66ae2034b30..61cc3156c56 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt @@ -216,7 +216,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { val typeConstraintListStub = KotlinPlaceHolderStubImpl(parent, JetStubElementTypes.TYPE_CONSTRAINT_LIST) for ((name, type) in protosForTypeConstraintList) { val typeConstraintStub = KotlinPlaceHolderStubImpl(typeConstraintListStub, JetStubElementTypes.TYPE_CONSTRAINT) - KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref()) + KotlinNameReferenceExpressionStubImpl(typeConstraintStub, name.ref()!!) createTypeReferenceStub(typeConstraintStub, type) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index f35d64d8230..39716526e45 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -203,6 +203,6 @@ val ProtoBuf.Callable.annotatedCallableKind: AnnotatedCallableKind } } -fun Name.ref() = StringRef.fromString(this.asString()) +fun Name.ref() = StringRef.fromString(this.asString())!! -fun FqName.ref() = StringRef.fromString(this.asString()) +fun FqName.ref() = StringRef.fromString(this.asString())!! diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt index 191cd9b47c6..bd241a27d5d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextFactory.kt @@ -147,7 +147,7 @@ public fun buildDecompiledText( if (descriptor is CallableDescriptor) { //NOTE: assuming that only return types can be flexible - if (descriptor.getReturnType().isFlexible()) { + if (descriptor.getReturnType()!!.isFlexible()) { builder.append(" ").append(FLEXIBLE_TYPE_COMMENT) } } @@ -191,7 +191,7 @@ public fun buildDecompiledText( companionNeeded = false newlineExceptFirst() builder.append(subindent) - appendDescriptor(companionObject, subindent) + appendDescriptor(companionObject!!, subindent) } if (member is CallableMemberDescriptor && member.getKind() != CallableMemberDescriptor.Kind.DECLARATION diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt index 15961a47845..041030aff2c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/KotlinSuppressableWarningProblemGroup.kt @@ -90,7 +90,7 @@ private object DeclarationKindDetector : JetVisitor( override fun visitProperty(d: JetProperty, _: Unit?) = detect(d, d.getValOrVarKeyword().getText()!!) override fun visitMultiDeclaration(d: JetMultiDeclaration, _: Unit?) = detect(d, d.getValOrVarKeyword()?.getText() ?: "val", - name = d.getEntries().map { it.getName() }.join(", ", "(", ")")) + name = d.getEntries().map { it.getName()!! }.join(", ", "(", ")")) override fun visitTypeParameter(d: JetTypeParameter, _: Unit?) = detect(d, "type parameter", newLineNeeded = false) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt index 69a14e754c9..d57575e72b9 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt @@ -58,7 +58,7 @@ public class KDocReference(element: KDocName): JetMultiReference(eleme override fun handleElementRename(newElementName: String?): PsiElement? { val textRange = getElement().getNameTextRange() - val newText = textRange.replace(getElement().getText(), newElementName) + val newText = textRange.replace(getElement().getText(), newElementName!!) val newLink = KDocElementFactory(getElement().getProject()).createNameFromText(newText) return getElement().replace(newLink) } @@ -181,5 +181,5 @@ private fun getOuterScope(descriptor: DeclarationDescriptorWithSource, resolutio return resolutionFacade.getFileTopLevelScope(containingFile) } } - return getResolutionScope(resolutionFacade, parent) + return getResolutionScope(resolutionFacade, parent!!) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt index 8bc74b494db..63016f0329f 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/AllClassesCompletion.kt @@ -72,7 +72,7 @@ class AllClassesCompletion(private val parameters: CompletionParameters, } private fun PsiClass.isSyntheticKotlinClass(): Boolean { - if (!getName().contains('$')) return false // optimization to not analyze annotations of all classes + if (!getName()!!.contains('$')) return false // optimization to not analyze annotations of all classes return getModifierList()?.findAnnotation(javaClass().getName()) != null } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index ec998138fdc..2b0cec2a384 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -289,7 +289,7 @@ fun LookupElementFactory.createBackingFieldLookupElement( if (accessors.all { it.getBodyExpression() == null }) return null // makes no sense to access backing field - it's the same as accessing property directly val bindingContext = resolutionFacade.analyze(declaration) - if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]) return null + if (!bindingContext[BindingContext.BACKING_FIELD_REQUIRED, property]!!) return null val lookupElement = createLookupElement(property, true) return object : LookupElementDecorator(lookupElement) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt index a033e8b712b..98984a5cde9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KDocCompletionContributor.kt @@ -64,7 +64,7 @@ class KDocNameCompletionSession(parameters: CompletionParameters, val position = parameters.getPosition().getParentOfType(false) ?: return val declaration = position.getContainingDoc().getOwner() ?: return val kdocLink = position.getStrictParentOfType()!! - val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] + val declarationDescriptor = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration]!! if (kdocLink.getTagIfSubject()?.knownTag == KDocKnownTag.PARAM) { addParamCompletions(position, declarationDescriptor) } else { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 9526c72b015..62e7260e9dd 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -104,7 +104,7 @@ public class LookupElementFactory( val lookupObject = object : DeclarationLookupObjectImpl(null, psiClass, resolutionFacade) { override fun getIcon(flags: Int) = psiClass.getIcon(flags) } - var element = LookupElementBuilder.create(lookupObject, psiClass.getName()) + var element = LookupElementBuilder.create(lookupObject, psiClass.getName()!!) .withInsertHandler(KotlinClassInsertHandler) val typeParams = psiClass.getTypeParameters() @@ -123,7 +123,7 @@ public class LookupElementFactory( itemText = containerName.substringAfterLast('.') + "." + itemText containerName = containerName.substringBeforeLast('.', FqName.ROOT.toString()) } - element = element.withPresentableText(itemText) + element = element.withPresentableText(itemText!!) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt index 9efd2dcdf8f..4fb750dbe0c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt @@ -134,7 +134,7 @@ class ParameterNameAndTypeCompletion( } private fun addSuggestionsForJavaClass(psiClass: PsiClass, userPrefix: String, prefixMatcher: PrefixMatcher) { - addSuggestions(psiClass.getName(), userPrefix, prefixMatcher, JavaClassType(psiClass)) + addSuggestions(psiClass.getName()!!, userPrefix, prefixMatcher, JavaClassType(psiClass)) } private fun addSuggestions(className: String, userPrefix: String, prefixMatcher: PrefixMatcher, type: Type) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt index c4cc8f98f86..7fdcf59652d 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/CastReceiverInsertHandler.kt @@ -39,7 +39,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() { val project = context.getProject() val thisObj = if (descriptor.getExtensionReceiverParameter() != null) descriptor.getExtensionReceiverParameter() else descriptor.getDispatchReceiverParameter() - val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj.getType().getConstructor().getDeclarationDescriptor()) + val fqName = IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(thisObj!!.getType().getConstructor().getDeclarationDescriptor()!!) val parentCast = JetPsiFactory(project).createExpression("(expr as $fqName)") as JetParenthesizedExpression val cast = parentCast.getExpression() as JetBinaryExpressionWithTypeRHS @@ -51,7 +51,7 @@ object CastReceiverInsertHandler : KotlinCallableInsertHandler() { val expr = receiver.replace(parentCast) as JetParenthesizedExpression - ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight()) + ShortenReferences.DEFAULT.process((expr.getExpression() as JetBinaryExpressionWithTypeRHS).getRight()!!) } } } \ No newline at end of file diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt index 7d71886227f..8a942149637 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinClassInsertHandler.kt @@ -50,7 +50,7 @@ object KotlinClassInsertHandler : BaseDeclarationInsertHandler() { // first try to resolve short name for faster handling val token = file.findElementAt(startOffset) - val nameRef = token.getParent() as? JetNameReferenceExpression + val nameRef = token!!.getParent() as? JetNameReferenceExpression if (nameRef != null) { val bindingContext = nameRef.getResolutionFacade().analyze(nameRef, BodyResolveMode.PARTIAL) val target = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, nameRef] diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index 50bf4e5f953..d923fb28642 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -391,7 +391,7 @@ class SmartCompletion( null } - val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType) + val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!! val iterableDetector = IterableTypesDetector(project, moduleDescriptor, scope) return buildResultByTypeFilter(expressionWithType, receiver, Tail.RPARENTH) { iterableDetector.isIterable(it, loopVarType) } @@ -403,7 +403,7 @@ class SmartCompletion( if (operationToken != JetTokens.IN_KEYWORD && operationToken != JetTokens.NOT_IN || expressionWithType != binaryExpression.getRight()) return null val leftOperandType = binaryExpression.getLeft()?.let { bindingContext.getType(it) } ?: return null - val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType) + val scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, expressionWithType)!! val detector = TypesWithContainsDetector(scope, leftOperandType, project, moduleDescriptor) return buildResultByTypeFilter(expressionWithType, receiver, null) { detector.hasContains(it) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt index 985c2a7ba34..671f6a9386c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt @@ -56,7 +56,7 @@ class TypesWithContainsDetector( } private fun isGoodContainsFunction(function: FunctionDescriptor, freeTypeParams: Collection): Boolean { - if (!TypeUtils.equalTypes(function.getReturnType(), booleanType)) return false + if (!TypeUtils.equalTypes(function.getReturnType()!!, booleanType)) return false val parameter = function.getValueParameters().singleOrNull() ?: return false val parameterType = HeuristicSignatures.correctedParameterType(function, parameter, moduleDescriptor, project) ?: parameter.getType() val fuzzyParameterType = FuzzyType(parameterType, function.getTypeParameters() + freeTypeParams) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index cb1c7208726..4fd39209eaf 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -270,7 +270,7 @@ fun LookupElementFactory.createLookupElement( element = element.keepOldArgumentListOnTab() } - if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]) { + if (descriptor is ValueParameterDescriptor && bindingContext[BindingContext.AUTO_CREATED_IT, descriptor]!!) { element = element.assignSmartCompletionPriority(SmartCompletionItemPriority.IT) } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt index 9a39a6ba284..ffee1ebd989 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/descriptorUtils.kt @@ -38,7 +38,7 @@ fun DeclarationDescriptorWithVisibility.isVisible( val receiver = element.getReceiverExpression() val type = receiver?.let { bindingContext.getType(it) } - val explicitReceiver = type?.let { ExpressionReceiver(receiver, it) } + val explicitReceiver = type?.let { ExpressionReceiver(receiver!!, it) } if (explicitReceiver != null) { val normalizeReceiver = ExpressionTypingUtils.normalizeReceiverValueForVisibility(explicitReceiver, bindingContext) diff --git a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt index ad52b721093..7ceb7d9087d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt +++ b/idea/src/org/jetbrains/kotlin/idea/ExtraSteppingFilter.kt @@ -37,8 +37,8 @@ public class ExtraSteppingFilter : engine.ExtraSteppingFilter { } val debugProcess = context.getDebugProcess() - val positionManager = JetPositionManager(debugProcess) - val location = context.getFrameProxy().location() + val positionManager = JetPositionManager(debugProcess!!) + val location = context.getFrameProxy()!!.location() return runReadAction { shouldFilter(positionManager, location) } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt index 9808c6faa10..be7f8237291 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/ConfigureKotlinInProjectAction.kt @@ -34,7 +34,7 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() { if (project == null) return if (ConfigureKotlinInProjectUtils.isProjectConfigured(project)) { - Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()) + Messages.showInfoMessage("All modules with kotlin files are configured", e.getPresentation().getText()!!) return } @@ -42,9 +42,9 @@ public abstract class ConfigureKotlinInProjectAction : AnAction() { when { configurators.size() == 1 -> configurators.first().configure(project) - configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()) + configurators.isEmpty() -> Messages.showErrorDialog("There aren't configurators available", e.getPresentation().getText()!!) else -> { - Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()) + Messages.showErrorDialog("More than one configurator is available", e.getPresentation().getText()!!) ConfigureKotlinInProjectUtils.showConfigureKotlinNotificationIfNeeded(project) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index 3780b3a5574..8b6e6c37441 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -303,7 +303,7 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor { - val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName() } + val result = file.getChildren().filter { it is JetClassOrObject }.map { (it as JetClassOrObject).getName()!! } val packagePartFqName = PackagePartClassUtils.getPackagePartFqName(file) return result.union(arrayListOf(packagePartFqName.shortName().asString())) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt index 410af8f4aae..f79fe006813 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/JetPositionManager.kt @@ -107,7 +107,7 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult if (lineNumber >= 0) { val lambdaOrFunIfInside = getLambdaOrFunIfInside(location, psiFile as JetFile, lineNumber) if (lambdaOrFunIfInside != null) { - return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression()) + return SourcePosition.createFromElement(lambdaOrFunIfInside.getBodyExpression()!!) } return SourcePosition.createFromLine(psiFile, lineNumber) } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt index 2e27c137231..39ed62caaab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt @@ -104,7 +104,7 @@ class KotlinEditorTextProvider : EditorTextProvider { fun PsiElement.isCall() = this is JetCallExpression || this is JetOperationExpression || this is JetArrayAccessExpression if (newExpression.isCall() || - newExpression is JetQualifiedExpression && newExpression.getSelectorExpression().isCall()) { + newExpression is JetQualifiedExpression && newExpression.getSelectorExpression()!!.isCall()) { return null } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index a57469c6ca5..fe79d14622a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -69,7 +69,7 @@ private fun findAdditionalExpressions(position: SourcePosition): Set() + val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType() if (elt != null) { reformat(elt) } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt index 54dea8f5d87..0bc7c3a4e51 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/DelegatingFindMemberUsagesHandler.kt @@ -58,7 +58,7 @@ class DelegatingFindMemberUsagesHandler( return kotlinHandler.getPrimaryElements() } - override fun getSecondaryElements(): Array? { + override fun getSecondaryElements(): Array { return kotlinHandler.getSecondaryElements() } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt index 96044154f13..8905dd83ef4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt @@ -119,7 +119,7 @@ public class KotlinFindClassUsagesHandler( var stringsToSearch: Collection object: JavaFindUsagesHandler(psiClass, JavaFindUsagesHandlerFactory.getInstance(element.getProject())) { init { - stringsToSearch = getStringsToSearch(psiClass) + stringsToSearch = getStringsToSearch(psiClass)!! } } return stringsToSearch diff --git a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt index e417457cf5d..79f7724abf4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/framework/KotlinTemplatesFactory.kt @@ -30,7 +30,7 @@ public class KotlinTemplatesFactory : ProjectTemplatesFactory() { override fun getGroups() = arrayOf(KOTLIN_GROUP_NAME) override fun getGroupIcon(group: String) = JetIcons.SMALL_LOGO - override fun createTemplates(group: String, context: WizardContext?) = + override fun createTemplates(group: String?, context: WizardContext?) = arrayOf( BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JVM, "Kotlin - JVM", "Kotlin module for JVM target")), BuilderBasedTemplate(KotlinModuleBuilder(TargetPlatform.JS, "Kotlin - JavaScript", "Kotlin module for JavaScript target")) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 8f6283189ab..57a72dd8c97 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -188,7 +188,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { private fun isConventionalName(namedDeclaration: JetNamedDeclaration): Boolean { val name = namedDeclaration.getNameAsName() - return name.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE + return name!!.getOperationSymbolsToSearch().isNotEmpty() || name == OperatorConventions.INVOKE } private fun hasNonTrivialUsages(declaration: JetNamedDeclaration): Boolean { @@ -200,7 +200,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { for (name in listOf(declaration.getName()) + declaration.getAccessorNames() + declaration.getClassNameForCompanionObject().singletonOrEmptyList()) { assert(name != null) { "Name is null for " + declaration.getElementTextWithContext() } - when (psiSearchHelper.isCheapEnoughToSearch(name, useScope, null, null)) { + when (psiSearchHelper.isCheapEnoughToSearch(name!!, useScope, null, null)) { ZERO_OCCURRENCES -> {} // go on, check other names FEW_OCCURRENCES -> zeroOccurrences = false TOO_MANY_OCCURRENCES -> return true // searching usages is too expensive; behave like it is used diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt index 08334bcac61..3f3b11d2e3c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt @@ -94,7 +94,7 @@ public class DeprecatedCallableAddReplaceWithIntention : JetSelfTargetingRangeIn }.toString() var argument = psiFactory.createArgument(psiFactory.createExpression(argumentText)) - argument = annotationEntry.getValueArgumentList().addArgument(argument) + argument = annotationEntry.getValueArgumentList()!!.addArgument(argument) argument = ShortenReferences.DEFAULT.process(argument) as JetValueArgument PsiDocumentManager.getInstance(argument.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument()) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt index ec785497546..8c430d1e63a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IterateExpressionIntention.kt @@ -50,7 +50,7 @@ public class IterateExpressionIntention : JetSelfTargetingIntention.isAvailable(project, editor, file)) && (anySuggestionFound ?: !suggestions.isEmpty()) - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { CommandProcessor.getInstance().runUndoTransparentAction { createAction(project, editor!!).execute() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt index 0e8d8fc63b1..db0d842e11a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntryDelimiterSyntaxFix.kt @@ -38,7 +38,7 @@ class DeprecatedEnumEntryDelimiterSyntaxFix(element: JetEnumEntry): JetIntention override fun getText(): String = "Insert lacking comma(s) / semicolon(s)" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = insertLackingCommaSemicolon(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = insertLackingCommaSemicolon(element) override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean = super.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedOrNoDelimiter(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt index 6ac30ab803c..b7d52f8d906 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedEnumEntrySuperConstructorSyntaxFix.kt @@ -41,7 +41,7 @@ class DeprecatedEnumEntrySuperConstructorSyntaxFix(element: JetEnumEntry): JetIn override fun getText(): String = "Change to short enum entry super constructor" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = changeConstructorToShort(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = changeConstructorToShort(element) override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean = super.isAvailable(project, editor, file) && DeclarationsChecker.enumEntryUsesDeprecatedSuperConstructor(element) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt index 8f9592649f3..75da5826ca5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedLambdaSyntaxFix.kt @@ -110,6 +110,7 @@ private class LambdaToFunctionExpression( assert(functionLiteralType != null && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(functionLiteralType)) { "Broken function type for expression: ${functionLiteralExpression.getText()}, at: ${DiagnosticUtils.atLocation(functionLiteralExpression)}" } + functionLiteralType!! receiverType = KotlinBuiltIns.getReceiverType(functionLiteralType)?.let { IdeDescriptorRenderers.SOURCE_CODE.renderType(it) } returnType = KotlinBuiltIns.getReturnTypeFromFunctionType(functionLiteralType).let { if (KotlinBuiltIns.isUnit(it)) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index fd9edd37e45..23f76759d79 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -112,7 +112,7 @@ public abstract class DeprecatedSymbolUsageFixBase( if (pattern.isEmpty()) return null val importValues = replaceWithValue.argumentValue("imports"/*TODO: kotlin.ReplaceWith::imports.name*/) as? List<*> ?: return null if (importValues.any { it !is StringValue }) return null - val imports = importValues.map { (it as StringValue).getValue() } + val imports = importValues.map { (it as StringValue).getValue()!! } // should not be available for descriptors with optional parameters if we cannot fetch default values for them (currently for library with no sources) if (descriptor is CallableDescriptor && @@ -681,7 +681,7 @@ public abstract class DeprecatedSymbolUsageFixBase( var explicitType: JetType? = null if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { val valueTypeWithoutExpectedType = value.analyzeInContext( - resolutionScope, + resolutionScope!!, dataFlowInfo = bindingContext.getDataFlowInfo(expressionToBeReplaced) ).getType(value) if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { @@ -690,7 +690,7 @@ public abstract class DeprecatedSymbolUsageFixBase( } val name = suggestName { name -> - resolutionScope.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) + resolutionScope!!.getLocalVariable(Name.identifier(name)) == null && !isNameUsed(name) } var declaration = psiFactory.createDeclarationByPattern("val $0 = $1", name, value) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt index 8ae58d0594c..96371716e0e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedTraitSyntaxFix.kt @@ -31,7 +31,7 @@ public class DeprecatedTraitSyntaxFix(element: PsiElement): JetIntentionAction

( predicate = { it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD) != null }, - taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD).getPsi())}, + taskProcessor = { replaceWithInterfaceKeyword(it.getNode().findChildByType(JetTokens.TRAIT_KEYWORD)!!.getPsi())}, name = "Replace 'trait' with 'interface' in whole project" ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt index b94d10f4ab7..ad5ff7f157d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExlCallFixes.kt @@ -50,7 +50,7 @@ public class RemoveExclExclCallFix(val psiElement: PsiElement) : ExclExclCallFix if (!FileModificationService.getInstance().prepareFileForWrite(file)) return val postfixExpression = getExclExclPostfixExpression() ?: return - val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression().getText()) + val expression = JetPsiFactory(project).createExpression(postfixExpression.getBaseExpression()!!.getText()) postfixExpression.replace(expression) } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt index 8525091469d..e0b8b995007 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/InsertDelegationCallQuickfix.kt @@ -41,7 +41,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon private val keywordToUse = if (isThis) "this" else "super" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val newDelegationCall = element.replaceImplicitDelegationCallWithExplicit(isThis) val resolvedCall = newDelegationCall.getResolvedCall(newDelegationCall.analyze()) @@ -55,7 +55,7 @@ public class InsertDelegationCallQuickfix(val isThis: Boolean, element: JetSecon editor?.moveCaret(leftParOffset + 1) } - override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean { + override fun isAvailable(project: Project, editor: Editor?, file: PsiFile): Boolean { return super.isAvailable(project, editor, file) && element.hasImplicitDelegationCall() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt index 40838b7a53f..c0e4f5dfe0d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MigrateAnnotationMethodCallFix.kt @@ -35,7 +35,7 @@ public class MigrateAnnotationMethodCallFix( override fun getText() = "Replace method call with property access" override fun getFamilyName() = getText() - override fun invoke(project: Project, editor: Editor?, file: JetFile?) = replaceWithSimpleCall(element) + override fun invoke(project: Project, editor: Editor?, file: JetFile) = replaceWithSimpleCall(element) companion object : JetSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic) = diagnostic.createIntentionForFirstParentOfType(::MigrateAnnotationMethodCallFix) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt index a9803eb9693..adcf66ebf8e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MissingConstructorKeywordFix.kt @@ -30,7 +30,7 @@ public class MissingConstructorKeywordFix(element: JetPrimaryConstructor) : JetI override fun getFamilyName(): String = getText() override fun getText(): String = "Add 'constructor' keyword" - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { element.addConstructorKeyword() } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt index 47598fb4195..488285da8ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceObsoleteLabelSyntaxFix.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext -public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIntentionAction(element), CleanupFix { +public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry) : JetIntentionAction(element), CleanupFix { override fun getFamilyName(): String = "Update obsolete label syntax" override fun getText(): String = "Replace with label ${element.getCalleeExpression()?.getText() ?: ""}@" @@ -65,7 +65,7 @@ public class ReplaceObsoleteLabelSyntaxFix(element: JetAnnotationEntry?) : JetIn val baseExpression = (getParent() as? JetAnnotatedExpression)?.getBaseExpression() ?: return false - val nameExpression = getCalleeExpression().getConstructorReferenceExpression() ?: return false + val nameExpression = getCalleeExpression()?.getConstructorReferenceExpression() ?: return false val labelName = nameExpression.getReferencedName() return baseExpression.anyDescendantOfType { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt index 3594cc4a370..9b3abd6a43b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt @@ -182,7 +182,7 @@ object ReplaceWithAnnotationAnalyzer { RedeclarationHandler.DO_NOTHING) is LocalVariableDescriptor -> { val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as JetDeclaration - declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration] + declaration.analyze()[BindingContext.RESOLUTION_SCOPE, declaration]!! } //TODO? diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 97b71773d8a..70b12ca477a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -297,7 +297,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { .subtract(substitutionMap.keySet()) fakeFunction = createFakeFunctionDescriptor(scope, typeArgumentsForFakeFunction.size()) collectSubstitutionsForCallableTypeParameters(fakeFunction, typeArgumentsForFakeFunction, substitutionMap) - mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it], scope) } + mandatoryTypeParametersAsCandidates = receiverTypeCandidate.singletonOrEmptyList() + typeArgumentsForFakeFunction.map { TypeCandidate(substitutionMap[it]!!, scope) } } else { fakeFunction = null @@ -949,7 +949,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { } is JetProperty -> { if (!declaration.hasInitializer() && containingElement is JetBlockExpression) { - val defaultValueType = typeCandidates[callableInfo.returnTypeInfo].firstOrNull()?.theType + val defaultValueType = typeCandidates[callableInfo.returnTypeInfo]!!.firstOrNull()?.theType ?: KotlinBuiltIns.getInstance().getAnyType() val defaultValue = CodeInsightUtils.defaultInitializer(defaultValueType) ?: "null" val initializer = declaration.setInitializer(JetPsiFactory(declaration).createExpression(defaultValue))!! @@ -975,7 +975,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { val caretModel = containingFileEditor.getCaretModel() caretModel.moveToOffset(jetFileToEdit.getNode().getStartOffset()) - val declaration = declarationPointer.getElement() + val declaration = declarationPointer.getElement()!! val builder = TemplateBuilderImpl(jetFileToEdit) if (declaration is JetProperty) { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt index 6005a4456e2..2dcbe735809 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createCallable/CreateCallableFromUsageFix.kt @@ -120,11 +120,11 @@ public abstract class CreateCallableFromUsageFixBase( } } - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val callableInfo = callableInfos.first() val callableBuilder = - CallableBuilderConfiguration(callableInfos, element as JetElement, file!!, editor!!, isExtension).createBuilder() + CallableBuilderConfiguration(callableInfos, element as JetElement, file, editor!!, isExtension).createBuilder() fun runBuilder(placement: CallablePlacement) { callableBuilder.placement = placement diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt index fb77409dad9..2949a68f189 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromUsageFix.kt @@ -80,7 +80,7 @@ public class CreateClassFromUsageFix( return true } - override fun invoke(project: Project, editor: Editor, file: JetFile) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { fun createFileByPackage(psiPackage: PsiPackage): JetFile? { val directories = psiPackage.getDirectories().filter { it.canRefactor() } assert (directories.isNotEmpty()) { "Package '${psiPackage.getQualifiedName()}' must be refactorable" } @@ -103,7 +103,7 @@ public class CreateClassFromUsageFix( val filePath = "${targetDirectory.getVirtualFile().getPath()}/$fileName" CodeInsightUtils.showErrorHint( targetDirectory.getProject(), - editor, + editor!!, "File $filePath already exists but does not correspond to Kotlin file", "Create file", null diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt index 6f2e08a1d8a..b714b19697c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateLocalVariableActionFactory.kt @@ -50,7 +50,7 @@ object CreateLocalVariableActionFactory: JetSingleIntentionActionFactory() { return object: CreateFromUsageFixBase(refExpr) { override fun getText(): String = JetBundle.message("create.local.variable.from.usage", propertyName) - override fun invoke(project: Project, editor: Editor, file: JetFile) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val assignment = refExpr.getAssignmentByLHS() val varExpected = assignment != null var originalElement = assignment ?: refExpr diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt index ceecb9c301d..9111b5bf729 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createVariable/CreateParameterFromUsageFix.kt @@ -37,7 +37,7 @@ public class CreateParameterFromUsageFix( return JetBundle.message("create.parameter.from.usage", parameterInfo.getName()) } - override fun invoke(project: Project, editor: Editor?, file: JetFile?) { + override fun invoke(project: Project, editor: Editor?, file: JetFile) { val config = object : JetChangeSignatureConfiguration { override fun configure(originalDescriptor: JetMethodDescriptor, bindingContext: BindingContext): JetMethodDescriptor { return originalDescriptor.modify { it.addParameter(parameterInfo) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 9cc6f918034..4aa9fd89aa3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -212,7 +212,7 @@ public class JetChangeInfo( public fun renderReturnType(inheritedCallable: JetCallableDefinitionUsage): String { val typeSubstitutor = inheritedCallable.getOrCreateTypeSubstitutor() ?: return newReturnTypeText val currentBaseFunction = inheritedCallable.getBaseFunction().getCurrentCallableDescriptor() ?: return newReturnTypeText - return currentBaseFunction.getReturnType().renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false) + return currentBaseFunction.getReturnType()!!.renderTypeWithSubstitution(typeSubstitutor, newReturnTypeText, false) } public fun primaryMethodUpdated() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index d92efb82d2e..ea42b360901 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -171,7 +171,7 @@ public class JetChangeSignature(project: Project, val params = (preview.getParameterList().getParameters() zip ktChangeInfo.getNewParameters()).map { val (param, paramInfo) = it // Keep original default value for proper update of Kotlin usages - KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName(), param.getType(), paramInfo.defaultValueForCall) + KotlinAwareJavaParameterInfoImpl(paramInfo.getOldIndex(), param.getName()!!, param.getType(), paramInfo.defaultValueForCall) }.toTypedArray() return preview to JavaChangeInfoImpl(visibility, diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt index 8f4eada231b..0f0b43c0309 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureData.kt @@ -99,7 +99,7 @@ public class JetChangeSignatureData( descriptorsForSignatureChange.map { val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.getProject(), it) assert(declaration != null) { "No declaration found for " + baseDescriptor } - JetCallableDefinitionUsage(declaration, it, null, null) + JetCallableDefinitionUsage(declaration!!, it, null, null) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt index 7f79fa4e481..6027764c88b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractKotlinInplaceIntroducer.kt @@ -85,7 +85,7 @@ public abstract class AbstractKotlinInplaceIntroducer( override fun updateTitle(declaration: D?) = updateTitle(declaration, null) - override fun saveSettings(declaration: D?) { + override fun saveSettings(declaration: D) { } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt index eba4e33f276..ae9185b1ce1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt @@ -309,7 +309,7 @@ val ControlFlow.possibleReturnTypes: List returnType.isAnnotatedNotNull(), returnType.isAnnotatedNullable() -> listOf(approximateFlexibleTypes(returnType)) else -> - returnType.getCapability(javaClass()).let { listOf(it.upperBound, it.lowerBound) } + returnType.getCapability(javaClass()).let { listOf(it!!.upperBound, it.lowerBound) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt index 59612298acf..49106b2830d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt @@ -520,7 +520,7 @@ private class MutableParameter( private val defaultType: JetType by Delegates.lazy { writable = false - TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes) + TypeUtils.intersect(JetTypeChecker.DEFAULT, defaultTypes)!! } private val parameterTypeCandidates: List by Delegates.lazy { @@ -530,7 +530,7 @@ private class MutableParameter( val typeList = if (defaultType.isNullabilityFlexible()) { val bounds = defaultType.getCapability(javaClass()) - if (typePredicate(bounds.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound) + if (typePredicate(bounds!!.upperBound)) arrayListOf(bounds.upperBound, bounds.lowerBound) else arrayListOf(bounds.lowerBound) } else arrayListOf(defaultType) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt index 8c05f0a9ad4..245e8137df1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt @@ -275,7 +275,7 @@ private fun makeCall( val inlinableCall = controlFlow.outputValues.size() <= 1 val unboxingExpressions = if (inlinableCall) { - controlFlow.outputValueBoxer.getUnboxingExpressions(callText) + controlFlow.outputValueBoxer.getUnboxingExpressions(callText!!) } else { val varNameValidator = NewDeclarationNameValidator(block, anchorInBlock, NewDeclarationNameValidator.Target.VARIABLES) @@ -293,7 +293,7 @@ private fun makeCall( } if (controlFlow.outputValues.isEmpty()) { - anchor.replace(psiFactory.createExpression(callText)) + anchor.replace(psiFactory.createExpression(callText!!)) return } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index dda2333174d..001c0b030bc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -135,7 +135,7 @@ public class KotlinInplaceParameterIntroducer( val parameterText = if (parameter == addedParameter){ val parameterName = currentName ?: parameter.getName() val parameterType = currentType ?: parameter.getTypeReference()!!.getText() - descriptor = descriptor.copy(newParameterName = parameterName, newParameterTypeText = parameterType) + descriptor = descriptor.copy(newParameterName = parameterName!!, newParameterTypeText = parameterType) val modifier = if (valVar != JetValVar.None) "${valVar.name} " else "" val defaultValue = if (withDefaultValue) " = ${newArgumentValue.getText()}" else "" @@ -250,7 +250,7 @@ public class KotlinInplaceParameterIntroducer( return descriptor.copy( originalRange = originalRange, occurrencesToReplace = if (replaceAll) getOccurrences().map { it.toRange() } else originalRange.singletonList(), - newArgumentValue = getExpr() + newArgumentValue = getExpr()!! ) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 190a7cc24b3..718ae8afbf4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -210,7 +210,7 @@ public open class KotlinIntroduceParameterHandler( open fun invoke(project: Project, editor: Editor, expression: JetExpression, targetParent: JetNamedDeclaration) { val context = expression.analyze() - val expressionType = context.getType(expression) + val expressionType = context.getType(expression)!! if (expressionType.isUnit() || expressionType.isNothing()) { val message = JetRefactoringBundle.message( "cannot.introduce.parameter.of.0.type", diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 6340a695db6..36041e20f18 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -406,7 +406,7 @@ private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, wi } } for (annotation in from.getAnnotations()) { - to.addAnnotation(annotation.getQualifiedName()) + to.addAnnotation(annotation.getQualifiedName()!!) } } @@ -426,7 +426,7 @@ private fun copyTypeParameters( ChangeSignatureUtil.synchronizeList( targetTypeParamList, newTypeParams, - { it.getTypeParameters().toList() }, + { it!!.getTypeParameters().toList() }, BooleanArray(newTypeParams.size()) ) } @@ -456,8 +456,8 @@ public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMeth val targetParamList = method.getParameterList() val newParams = template.getParameterList().getParameters().map { - val param = factory.createParameter(it.getName(), it.getType()) - copyModifierListItems(it.getModifierList(), param.getModifierList()) + val param = factory.createParameter(it.getName()!!, it.getType()) + copyModifierListItems(it.getModifierList()!!, param.getModifierList()!!) param } ChangeSignatureUtil.synchronizeList( @@ -468,7 +468,7 @@ public fun createJavaMethod(template: PsiMethod, targetClass: PsiClass): PsiMeth ) if (template.getModifierList().hasModifierProperty(PsiModifier.ABSTRACT) || targetClass.isInterface()) { - method.getBody().delete() + method.getBody()!!.delete() } else if (!template.isConstructor()) { CreateFromUsageUtils.setupMethodBody(method) @@ -482,9 +482,9 @@ fun createJavaField(property: JetProperty, targetClass: PsiClass): PsiField { ?: throw AssertionError("Can't generate light method: ${property.getElementTextWithContext()}") val factory = PsiElementFactory.SERVICE.getInstance(template.getProject()) - val field = targetClass.add(factory.createField(property.getName(), template.getReturnType())) as PsiField + val field = targetClass.add(factory.createField(property.getName()!!, template.getReturnType()!!)) as PsiField - with(field.getModifierList()) { + with(field.getModifierList()!!) { val templateModifiers = template.getModifierList() setModifierProperty(VisibilityUtil.getVisibilityModifier(templateModifiers), true) if (!property.isVar() || targetClass.isInterface()) { @@ -500,11 +500,12 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { val kind = (klass.resolveToDescriptor() as ClassDescriptor).getKind() val factory = PsiElementFactory.SERVICE.getInstance(klass.getProject()) + val className = klass.getName()!! val javaClassToAdd = when (kind) { - ClassKind.CLASS -> factory.createClass(klass.getName()) - ClassKind.INTERFACE -> factory.createInterface(klass.getName()) - ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(klass.getName()) - ClassKind.ENUM_CLASS -> factory.createEnum(klass.getName()) + ClassKind.CLASS -> factory.createClass(className) + ClassKind.INTERFACE -> factory.createInterface(className) + ClassKind.ANNOTATION_CLASS -> factory.createAnnotationType(className) + ClassKind.ENUM_CLASS -> factory.createEnum(className) else -> throw AssertionError("Unexpected class kind: ${klass.getElementTextWithContext()}") } val javaClass = targetClass.add(javaClassToAdd) as PsiClass @@ -512,9 +513,9 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { val template = LightClassUtil.getPsiClass(klass) ?: throw AssertionError("Can't generate light class: ${klass.getElementTextWithContext()}") - copyModifierListItems(template.getModifierList(), javaClass.getModifierList()) + copyModifierListItems(template.getModifierList()!!, javaClass.getModifierList()!!) if (template.isInterface()) { - javaClass.getModifierList().setModifierProperty(PsiModifier.ABSTRACT, false) + javaClass.getModifierList()!!.setModifierProperty(PsiModifier.ABSTRACT, false) } copyTypeParameters(template, javaClass) { klass, typeParameterList -> @@ -542,7 +543,7 @@ fun createJavaClass(klass: JetClass, targetClass: PsiClass): PsiMember { if (method.isConstructor() && !(hasParams || needSuperCall)) continue with(createJavaMethod(method, javaClass)) { if (isConstructor() && needSuperCall) { - getBody().add(factory.createStatementFromText("super();", this)) + getBody()!!.add(factory.createStatementFromText("super();", this)) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt index 4192974b79b..38527955601 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/MoveKotlinTopLevelDeclarationsProcessor.kt @@ -103,7 +103,7 @@ public class MoveKotlinTopLevelDeclarationsProcessor( private val kotlinToLightElements = elementsToMove.keysToMap { it.toLightElements() } private val conflicts = MultiMap() - override fun createUsageViewDescriptor(usages: Array?): UsageViewDescriptor { + override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor { return MoveMultipleElementsViewDescriptor( elementsToMove.toTypedArray(), MoveClassesOrPackagesUtil.getPackageName(options.moveTarget.packageWrapper) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt index 2f57dcb2e67..5a15178861c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveTopLevelDeclarations/ui/MoveFilesOrDirectoriesDialogWithKotlinOptions.kt @@ -53,7 +53,7 @@ public class MoveFilesOrDirectoriesDialogWithKotlinOptions( gbc.fill = GridBagConstraints.NONE gbc.anchor = GridBagConstraints.WEST gbc.insets = Insets(UIUtil.LARGE_VGAP, 0, 0, UIUtil.DEFAULT_HGAP) - panel.add(JLabel(), gbc) + panel!!.add(JLabel(), gbc) cbUpdatePackageDirective = NonFocusableCheckBox() gbc.gridx = 1 diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index 509713d0e48..029ac09a417 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -311,7 +311,7 @@ public fun moveFilesOrDirectories( } elementsToMove.forEach { - MoveFilesOrDirectoriesUtil.checkMove(it, selectedDir) + MoveFilesOrDirectoriesUtil.checkMove(it, selectedDir!!) if (it is JetFile && it.isInJavaSourceRoot()) { it.updatePackageDirective = updatePackageDirective } diff --git a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt index c890df62468..3143de9ebe7 100644 --- a/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/DataFlowValueRenderingTest.kt @@ -44,7 +44,7 @@ public abstract class AbstractDataFlowValueRenderingTest: JetLightCodeInsightFix fixture.configureByFile(fileName) val jetFile = fixture.getFile() as JetFile - val element = jetFile.findElementAt(fixture.getCaretOffset()) + val element = jetFile.findElementAt(fixture.getCaretOffset())!! val expression = element.getStrictParentOfType()!! val info = expression.analyze().getDataFlowInfo(expression) diff --git a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt index 42e0f72de96..1c9ac78d62f 100644 --- a/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt +++ b/idea/tests/org/jetbrains/kotlin/addImport/AbstractAddImportTest.kt @@ -50,7 +50,7 @@ public abstract class AbstractAddImportTest : AbstractImportsTest() { else -> { val success = ImportInsertHelper.getInstance(getProject()).importDescriptor(file, descriptors.single()) != ImportInsertHelper.ImportDescriptorResult.FAIL if (!success) { - val document = PsiDocumentManager.getInstance(getProject()).getDocument(file) + val document = PsiDocumentManager.getInstance(getProject()).getDocument(file)!! document.replaceString(0, document.getTextLength(), "Failed to add import") PsiDocumentManager.getInstance(getProject()).commitAllDocuments() } diff --git a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt index 63aeddfd2d5..80044d17d57 100644 --- a/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt +++ b/idea/tests/org/jetbrains/kotlin/asJava/LightClassesClasspathSortingTest.kt @@ -57,6 +57,7 @@ class LightClassesClasspathSortingTest : KotlinCodeInsightTestCase() { val psiClass = JavaPsiFacade.getInstance(getProject()).findClass(fqName, ResolveScopeManager.getElementResolveScope(getFile())) assertNotNull(psiClass, "Can't find class for $fqName") + psiClass!! assert(psiClass is KotlinLightClassForExplicitDeclaration || psiClass is KotlinLightClassForPackage, "Should be an explicit light class, but was $fqName ${psiClass.javaClass}") assert(psiClass !is KotlinLightClassForDecompiledDeclaration, diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt index 60b1ca1e2b8..16d6b9c2c24 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractEditorForEvaluateExpressionTest.kt @@ -99,7 +99,7 @@ private fun JavaCodeInsightTestFixture.configureByCodeFragment(filePath: String) file.putCopyableUserData(JetCodeFragment.RUNTIME_TYPE_EVALUATOR, { val codeFragment = JetPsiFactory(getProject()).createBlockCodeFragment("val xxx: $typeStr" , PsiTreeUtil.getParentOfType(elementAt, javaClass())) val context = codeFragment.analyzeFully() - val typeReference: JetTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().getFirstChild(), javaClass()) + val typeReference: JetTypeReference = PsiTreeUtil.getChildOfType(codeFragment.getContentElement().getFirstChild(), javaClass())!! context[BindingContext.TYPE, typeReference] }) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index 2a3dc421c34..74e736fc930 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -277,7 +277,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB private fun createContextElement(context: SuspendContextImpl): PsiElement { val contextElement = ContextUtil.getContextElement(debuggerContext) - Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement.getText()}", + Assert.assertTrue("KotlinCodeFragmentFactory should be accepted for context element otherwise default evaluator will be called. ContextElement = ${contextElement?.getText() ?: "null"}", KotlinCodeFragmentFactory().isContextAccepted(contextElement)) if (contextElement != null) { @@ -290,9 +290,9 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB assert(labelParts.size() == 2) { "Wrong format for DEBUG_LABEL directive: // DEBUG_LABEL: {localVariableName} = {labelText}"} val localVariableName = labelParts[0].trim() val labelName = labelParts[1].trim() - val localVariable = context.getFrameProxy().visibleVariableByName(localVariableName) + val localVariable = context.getFrameProxy()!!.visibleVariableByName(localVariableName) assert(localVariable != null) { "Couldn't find localVariable for label: name = $localVariableName" } - val localVariableValue = context.getFrameProxy().getValue(localVariable) as? ObjectReference + val localVariableValue = context.getFrameProxy()!!.getValue(localVariable) as? ObjectReference assert(localVariableValue != null) { "Local variable $localVariableName should be an ObjectReference" } markupMap.put(localVariableValue, ValueMarkup(labelName, null, labelName)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt index 5c981201fe7..55b099baf48 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionInLibraryTest.kt @@ -42,7 +42,7 @@ public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTes override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry?) { super.configureModule(module, model, contentEntry) - val library = model.getModuleLibraryTable().getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME) + val library = model.getModuleLibraryTable().getLibraryByName(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME)!! val modifiableModel = library.getModifiableModel() modifiableModel.addRoot(findLibrarySourceDir(), OrderRootType.SOURCES) @@ -75,7 +75,7 @@ public class CodeFragmentCompletionInLibraryTest : AbstractJvmBasicCompletionTes } private fun setupFixtureByCodeFragment(fragmentText: String) { - val sourceFile = findLibrarySourceDir().findChild("customLibrary.kt") + val sourceFile = findLibrarySourceDir().findChild("customLibrary.kt")!! val jetFile = PsiManager.getInstance(getProject()).findFile(sourceFile) as JetFile val fooFunctionFromLibrary = jetFile.getDeclarations().first() as JetFunction val codeFragment = JetPsiFactory(fooFunctionFromLibrary).createExpressionCodeFragment( diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt index 936df14f82b..b4b1d85e043 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/NavigateFromLibrarySourcesTest.kt @@ -55,7 +55,7 @@ public class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() { val lightClass = LightClassUtil.getPsiClass(navigationElement as JetClassOrObject) assertTrue(lightClass is KotlinLightClassForDecompiledDeclaration, "Light classes for decompiled declaration should be provided for library source") - assertEquals("Foo", lightClass.getName()) + assertEquals("Foo", lightClass!!.getName()) } private fun checkNavigationFromLibrarySource(referenceText: String, targetFqName: String) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt index 41d89651a87..89273d5637d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/AbstractClsStubBuilderTest.kt @@ -55,7 +55,7 @@ public abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCa private fun getClassFileToDecompile(sourcePath: String): VirtualFile { val outDir = JetTestUtils.tmpDir("libForStubTest-" + sourcePath) MockLibraryUtil.compileKotlin(sourcePath, outDir) - val root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outDir) + val root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outDir)!! return root.findClassFileByName(lastSegment(sourcePath)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt index da40fdbf4f1..f10dc385560 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubForWrongAbiVersionTest.kt @@ -29,7 +29,7 @@ class ClsStubBuilderForWrongAbiVersionTest : AbstractClsStubBuilderTest() { fun testClass() = testStubsForFileWithWrongAbiVersion("ClassWithWrongAbiVersion") private fun testStubsForFileWithWrongAbiVersion(className: String) { - val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!) + val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!! val result = root.findClassFileByName(className) testClsStubsForFile(result, null) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt index 7c4bf7fd93f..a13d69e56aa 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextForWrongAbiVersionTest.kt @@ -47,7 +47,7 @@ public class DecompiledTextForWrongAbiVersionTest : AbstractInternalCompiledClas fun testPackageFacadeWithWrongAbiVersion() = doTest("WrongPackage") fun doTest(name: String) { - val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!) + val root = NavigateToDecompiledLibraryTest.findTestLibraryRoot(myModule!!)!! checkFileWithWrongAbiVersion(root.findClassFileByName(name)) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt index 69f5885a0bd..da9edf459f0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/filters/JetExceptionFilterTest.kt @@ -87,21 +87,26 @@ public class JetExceptionFilterTest : MultiFileTestCase() { VfsUtilCore.findRelativeFile(relativePath, rootDir); } TestCase.assertNotNull(expectedFile) + expectedFile!! val line = createStackTraceElementLine(linePrefix, relativePath, className(expectedFile), lineNumber) val result = filter.applyFilter(line, 0) TestCase.assertNotNull(result) + result!! val info = result.getFirstHyperlinkInfo() TestCase.assertNotNull(info) info as FileHyperlinkInfo val descriptor = info.getDescriptor() TestCase.assertNotNull(descriptor) + descriptor!! TestCase.assertEquals(expectedFile, descriptor.getFile()) val document = FileDocumentManager.getInstance().getDocument(expectedFile) TestCase.assertNotNull(document) + document!! + val expectedOffset = document.getLineStartOffset(lineNumber - 1) TestCase.assertEquals(expectedOffset, descriptor.getOffset()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt index 33daa939643..df96bdc109d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/kdoc/KDocFinderTest.kt @@ -33,7 +33,7 @@ public class KDocFinderTest() : LightPlatformCodeInsightFixtureTestCase() { myFixture.configureByFile(getTestName(false) + ".kt") val declaration = (myFixture.getFile() as JetFile).getDeclarations()[0] val descriptor = declaration.resolveToDescriptor() as ClassDescriptor - val constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor() + val constructorDescriptor = descriptor.getUnsubstitutedPrimaryConstructor()!! val doc = KDocFinder.findKDoc(constructorDescriptor) Assert.assertEquals("Doc for constructor of class C.", doc!!.getContent()) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt index af58246171e..b393f3bf470 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/nameSuggester/JetNameSuggesterTest.kt @@ -68,8 +68,8 @@ public class JetNameSuggesterTest : LightCodeInsightFixtureTestCase() { val expectedResultText = JetTestUtils.getLastCommentInFile(file) try { JetRefactoringUtil.selectExpression(myFixture.getEditor(), file, object : JetRefactoringUtil.SelectExpressionCallback { - override fun run(expression: JetExpression) { - val names = KotlinNameSuggester.suggestNamesByExpressionAndType(expression, expression.analyze(BodyResolveMode.PARTIAL), { true }, "value").sort() + override fun run(expression: JetExpression?) { + val names = KotlinNameSuggester.suggestNamesByExpressionAndType(expression!!, expression.analyze(BodyResolveMode.PARTIAL), { true }, "value").sort() val result = StringUtil.join(names, "\n").trim() assertEquals(expectedResultText, result) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt index 58fb76b35b7..722ca5c1351 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractPartialBodyResolveTest.kt @@ -77,7 +77,7 @@ public abstract class AbstractPartialBodyResolveTest : JetLightCodeInsightFixtur } else { val offset = editor.getCaretModel().getOffset() - val element = file.findElementAt(offset) + val element = file.findElementAt(offset)!! element.getNonStrictParentOfType() ?: error("No JetSimpleNameExpression at caret") } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt index 5b3a131f422..e476666d487 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/Converter.kt @@ -328,7 +328,7 @@ class Converter private constructor( isVal && modifiers.isPrivate) val propertyType = typeToDeclare ?: typeConverter.convertVariableType(field) - addUsageProcessing(FieldToPropertyProcessing(field, correction?.name ?: field.getName(), propertyType.isNullable)) + addUsageProcessing(FieldToPropertyProcessing(field, correction?.name ?: field.getName()!!, propertyType.isNullable)) return Property(name, annotations, diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt index b6e03bb816c..8dfd6d108b2 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt @@ -317,6 +317,6 @@ class ForConverter( val declarationStatement = this as? PsiDeclarationStatement ?: return listOf() return declarationStatement.getDeclaredElements() .filterIsInstance() - .map { it.getName() } + .map { it.getName()!! } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt index dde1798069d..334151d7356 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt @@ -64,7 +64,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi if (accessorKind == AccessorKind.GETTER) { if (arguments.size() != 0) return null // incorrect call propertyNameExpr = callExpr.replace(propertyNameExpr) as JetSimpleNameExpression - return listOf(propertyNameExpr.getReference()) + return listOf(propertyNameExpr.getReference()!!) } else { val value = arguments.singleOrNull()?.getArgumentExpression() ?: return null @@ -76,12 +76,12 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi callExpr.replace(propertyNameExpr) assignment.getLeft()!!.replace(qualifiedExpression) assignment = qualifiedExpression.replace(assignment) as JetBinaryExpression - return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()) + return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()!!) } else { assignment.getLeft()!!.replace(propertyNameExpr) assignment = callExpr.replace(assignment) as JetBinaryExpression - return listOf(assignment.getLeft()!!.getReference()) + return listOf(assignment.getLeft()!!.getReference()!!) } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt index 4f968b900c8..58f916b192f 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt @@ -124,7 +124,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v binary = setCall.getArgumentList().getExpressions().single() as PsiBinaryExpression getCall = binary.getLOperand() as PsiMethodCallExpression - return listOf(getCall.getMethodExpression().getReference(), setCall.getMethodExpression().getReference()) + return listOf(getCall.getMethodExpression().getReference()!!, setCall.getMethodExpression().getReference()!!) } private fun generateGetterCall(qualifier: PsiExpression?): PsiMethodCallExpression { diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt index d124bc48c23..21494e7a9bd 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt @@ -36,7 +36,7 @@ public class MethodIntoObjectProcessing(private val method: PsiMethod, private v else { var qualifiedExpr = factory.createExpressionFromText(objectName + "." + refExpr.getText(), null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()) + return listOf(qualifiedExpr.getReference()!!) } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt index 768f5e6c916..3b5c151e758 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt @@ -30,7 +30,7 @@ class ToObjectWithOnlyMethodsProcessing(private val psiClass: PsiClass) : UsageP val factory = PsiElementFactory.SERVICE.getInstance(psiClass.getProject()) var qualifiedExpr = factory.createExpressionFromText(refExpr.getText() + "." + JvmAbi.INSTANCE_FIELD, null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()) + return listOf(qualifiedExpr.getReference()!!) } } diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt index 7e04e7c4052..2fb84a3378a 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/IncrementalCacheImpl.kt @@ -150,14 +150,14 @@ public class IncrementalCacheImpl(targetDataRoot: File) : StorageOwner, Incremen val decision = when { header.isCompatiblePackageFacadeKind() -> getRecompilationDecision( - protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData)), + protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData!!)), constantsChanged = false, inlinesChanged = false ) header.isCompatibleClassKind() -> when (header.classKind!!) { JvmAnnotationNames.KotlinClass.Kind.CLASS -> getRecompilationDecision( - protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData)), + protoChanged = protoMap.put(className, BitEncoding.decodeBytes(header.annotationData!!)), constantsChanged = constantsMap.process(className, fileBytes), inlinesChanged = inlineFunctionsMap.process(className, fileBytes) ) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt index 6ae59235b9c..5da8374ea31 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractIncrementalJpsTest.kt @@ -292,7 +292,7 @@ public abstract class AbstractIncrementalJpsTest : JpsBuildTestCase() { val mapping = project.dataManager.getSourceToOutputMap(target) mapping.getSources().forEach { - val outputs = mapping.getOutputs(it).sort() + val outputs = mapping.getOutputs(it)!!.sort() if (outputs.isNotEmpty()) { result.println("source $it -> " + outputs) } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt index 2a43145c6a8..546833050de 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/jsRenderers.kt @@ -31,7 +31,7 @@ object RenderFirstLineOfElementText : Renderer { abstract class JsCallDataRenderer : Renderer { protected abstract fun format(data: JsCallDataWithCode): String - override fun render(data: JsCallData?): String = + override fun render(data: JsCallData): String = when (data) { is JsCallDataWithCode -> format(data) is JsCallData -> data.message diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index 4ae6038fbb8..d0e413a66fd 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -123,8 +123,8 @@ public class FunctionReader(private val context: TranslationContext) { val moduleNameLiteral = context.program().getStringLiteral(moduleName) val moduleReference = context.namer().getModuleReference(moduleNameLiteral) - val replacements = hashMapOf(moduleRootVariable[moduleName] to moduleReference, - moduleKotlinVariable[moduleName] to Namer.KOTLIN_OBJECT_REF) + val replacements = hashMapOf(moduleRootVariable[moduleName]!! to moduleReference, + moduleKotlinVariable[moduleName]!! to Namer.KOTLIN_OBJECT_REF) replaceExternalNames(function, replacements) return function } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt index 1fa6bf708b4..ffffb4618e8 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeUnusedLocalFunctionDeclarations.kt @@ -51,7 +51,7 @@ private class UnusedInstanceCollector : JsVisitorWithContextImpl() { val name = x.getName()!! val statementContext = getLastStatementLevelContext() val currentStatement = statementContext.getCurrentNode() - tracker.addCandidateForRemoval(name, currentStatement) + tracker.addCandidateForRemoval(name, currentStatement!!) val references = collectReferencesInside(x) references.filterNotNull() @@ -60,8 +60,8 @@ private class UnusedInstanceCollector : JsVisitorWithContextImpl() { return false } - override fun visit(x: JsNameRef?, ctx: JsContext<*>?): Boolean { - val name = x?.getName() + override fun visit(x: JsNameRef, ctx: JsContext<*>): Boolean { + val name = x.getName() if (name != null) { tracker.markReachable(name) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt index decdb1a8980..7560e306f60 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt @@ -56,7 +56,7 @@ fun VariableAccessInfo.getAccessFunctionName(): String { val descriptor = variableDescriptor if (descriptor is PropertyDescriptor && descriptor.isExtension) { val propertyAccessorDescriptor = if (isGetAccess()) descriptor.getGetter() else descriptor.getSetter() - return context.getNameForDescriptor(propertyAccessorDescriptor).getIdent() + return context.getNameForDescriptor(propertyAccessorDescriptor!!).getIdent() } else { return Namer.getNameForAccessor(variableName.getIdent()!!, isGetAccess(), false) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt index 63efd4a7e9a..78fc93659fc 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt @@ -179,7 +179,7 @@ object InvokeIntrinsic : FunctionCallCase { } override fun FunctionCallInfo.dispatchReceiver(): JsExpression { - return JsInvocation(dispatchReceiver, argumentsInfo.translateArguments) + return JsInvocation(dispatchReceiver!!, argumentsInfo.translateArguments) } /** @@ -242,7 +242,7 @@ object DynamicInvokeAndBracketAccessCallCase : FunctionCallCase { val callType = resolvedCall.getCall().getCallType() return when (callType) { Call.CallType.INVOKE -> - JsInvocation(dispatchReceiver, arguments) + JsInvocation(dispatchReceiver!!, arguments) Call.CallType.ARRAY_GET_METHOD -> JsArrayAccess(dispatchReceiver, arguments[0]) Call.CallType.ARRAY_SET_METHOD -> diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt index 35932a4f309..dc22d6a8c7a 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt @@ -204,6 +204,7 @@ public class CallArgumentTranslator private constructor( val argumentExpression = valueArguments.get(0).getArgumentExpression() assert(argumentExpression != null) + argumentExpression!! val jsExpression = Translation.translateAsExpression(argumentExpression, context) result.add(jsExpression) @@ -250,6 +251,7 @@ public class CallArgumentTranslator private constructor( for (argument in arguments) { val argumentExpression = argument.getArgumentExpression() assert(argumentExpression != null) + argumentExpression!! val argContext = context.innerBlock() val argExpression = Translation.translateAsExpression(argumentExpression, argContext) list.add(argExpression) diff --git a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt index 97070f63ebe..729fb91036f 100644 --- a/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt +++ b/libraries/stdlib/validator/src/test/kotlin/NoInternalVisibilityInStdLibTest.kt @@ -111,7 +111,7 @@ class NoInternalVisibilityInStdLibTest { } After fun tearDown() { - Disposer.dispose(disposable) + Disposer.dispose(disposable!!) disposable = null } diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt index d0259e509f3..666b0c43e21 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidResourceManager.kt @@ -62,7 +62,7 @@ public abstract class AndroidResourceManager(val project: Project) { .map { psiManager.findFile(it) } .filterNotNull() .groupBy { it.getName().substringBeforeLast('.') } - .mapValues { it.getValue().sortBy { it.getParent().getName().length() } } + .mapValues { it.getValue().sortBy { it.getParent()!!.getName().length() } } } companion object { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt index 88dc05ef219..139163e9770 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidUIXmlProcessor.kt @@ -193,7 +193,7 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) { for (res in resources) { if (resourceMap.contains(res.id)) { - val existing = resourceMap[res.id] + val existing = resourceMap[res.id]!! if (!res.sameClass(existing)) { resourcesToExclude.add(res.id) diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt index fce7c656a79..c057ff00f57 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/lang/resolve/android/AndroidXmlHandler.kt @@ -35,7 +35,7 @@ class AndroidXmlHandler(private val elementCallback: (String, String) -> Unit) : val attributesMap = attributes.toMap() val idAttribute = attributesMap[AndroidConst.ID_ATTRIBUTE_NO_NAMESPACE] val widgetType = attributesMap[AndroidConst.CLASS_ATTRIBUTE_NO_NAMESPACE] ?: localName - val name = idAttribute?.let { idToName(idAttribute) } + val name = idAttribute?.let { idToName(idAttribute!!) } if (name != null) elementCallback(name, widgetType) } diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt index a9ba2ba774b..59d1f21c1d6 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidPsiTreeChangePreprocessor.kt @@ -64,7 +64,7 @@ public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, Simpl val info = androidModuleInfo ?: return listOf() val fileManager = VirtualFileManager.getInstance() - return info.resDirectories.map { fileManager.findFileByUrl("file://" + it) } + return info.resDirectories.map { fileManager.findFileByUrl("file://" + it)!! } } private fun PsiFile.isLayoutXmlFile(): Boolean { diff --git a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt index a60c00b3b36..0df89ffb2bc 100644 --- a/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt +++ b/plugins/android-idea-plugin/src/org/jetbrains/kotlin/plugin/android/AndroidRenameProcessor.kt @@ -147,7 +147,7 @@ public class AndroidRenameProcessor : RenamePsiElementProcessor() { newName: String, allRenames: MutableMap ) { - val oldName = field.getName() + val oldName = field.getName()!! val processor = ServiceManager.getService(field.getProject(), javaClass()) renameSyntheticProperties(allRenames, newName, oldName, processor) } From da416f1cafda8877f280ecba49592715f1f6acdd Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 1 Jul 2015 14:48:51 +0300 Subject: [PATCH 159/450] Change traversal order for finding corresponding supertype from DFS to BFS In most cases order doesn't matter as in supertype tree built from real code types with same type constructors should be completely equal. The only case when order does matter is when we artificially add more specific supertype closer to the root. For example specific annotation adding non-platform supertype MutableMap to ConcurrentHashMap ConcurrentHashMap extends ConcurrentMap that extends java.util.Map (mapped to kotlin.MutableMap) So we want in that case to use refined (more specific) version when checking subtypes: ConcurrentHashMap should not be a subtype Map (and respectively Map) It should be pure non-platform Map that can be found only with BFS --- .../findClosestCorrespondingSupertype.kt | 10 ++++ .../findClosestCorrespondingSupertype.txt | 21 +++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++ .../types/checker/TypeCheckingProcedure.java | 12 +--- .../jetbrains/kotlin/types/checker/utils.kt | 59 +++++++++++++++++++ 5 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.kt create mode 100644 compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.txt create mode 100644 core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt diff --git a/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.kt b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.kt new file mode 100644 index 00000000000..a0123248f44 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +interface X +interface A: X +interface B : A, X + +fun foo(x: B) { + // Checks that when checking subtypes we search closes corresponding constructor (e.g. with BFS) + val y: X = x +} diff --git a/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.txt b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.txt new file mode 100644 index 00000000000..f0dfc7c8267 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.txt @@ -0,0 +1,21 @@ +package + +internal fun foo(/*0*/ x: B): kotlin.Unit + +internal interface A : X { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface B : A, X { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface X { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 345a5ccaf38..20b1715069e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -13371,6 +13371,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/subtyping"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("findClosestCorrespondingSupertype.kt") + public void testFindClosestCorrespondingSupertype() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/subtyping/findClosestCorrespondingSupertype.kt"); + doTest(fileName); + } + @TestMetadata("kt2069.kt") public void testKt2069() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/subtyping/kt2069.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java index f017d890f14..0844dc4548d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/TypeCheckingProcedure.java @@ -40,17 +40,7 @@ public class TypeCheckingProcedure { // as the second parameter, applying the substitution of type arguments to it @Nullable public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype, @NotNull TypeCheckingProcedureCallbacks typeCheckingProcedureCallbacks) { - TypeConstructor constructor = subtype.getConstructor(); - if (typeCheckingProcedureCallbacks.assertEqualTypeConstructors(constructor, supertype.getConstructor())) { - return subtype; - } - for (JetType immediateSupertype : constructor.getSupertypes()) { - JetType correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype, typeCheckingProcedureCallbacks); - if (correspondingSupertype != null) { - return TypeSubstitutor.create(subtype).safeSubstitute(correspondingSupertype, Variance.INVARIANT); - } - } - return null; + return CheckerPackage.findCorrespondingSupertype(subtype, supertype, typeCheckingProcedureCallbacks); } public static JetType getOutType(TypeParameterDescriptor parameter, TypeProjection argument) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt new file mode 100644 index 00000000000..bcd0681b245 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/utils.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.types.checker + +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks +import java.util.* + +private class SubtypePathNode(val type: JetType, val previous: SubtypePathNode?) + +public fun findCorrespondingSupertype( + subtype: JetType, supertype: JetType, + typeCheckingProcedureCallbacks: TypeCheckingProcedureCallbacks +): JetType? { + val queue = ArrayDeque() + queue.add(SubtypePathNode(subtype, null)) + + val supertypeConstructor = supertype.getConstructor() + + while (!queue.isEmpty()) { + val lastPathNode = queue.poll() + val currentSubtype = lastPathNode.type + val constructor = currentSubtype.getConstructor() + + if (typeCheckingProcedureCallbacks.assertEqualTypeConstructors(constructor, supertypeConstructor)) { + var substituted = currentSubtype + var currentPathNode = lastPathNode.previous + + while (currentPathNode != null) { + substituted = TypeSubstitutor.create(currentPathNode.type).safeSubstitute(substituted, Variance.INVARIANT) + currentPathNode = currentPathNode.previous + } + + return substituted + } + + for (immediateSupertype in constructor.getSupertypes()) { + queue.add(SubtypePathNode(immediateSupertype, lastPathNode)) + } + } + + return null +} From 81205134656c2b4f7ec300931c209284bf157ab9 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 3 Jul 2015 14:31:24 +0300 Subject: [PATCH 160/450] Add some collections to mockJDK It's neccessary to test they loaded as pure implementation of kotlin collections --- compiler/testData/mockJDK/jre/lib/rt.jar | Bin 999478 -> 1020854 bytes compiler/testData/mockJDK/src.zip | Bin 1420291 -> 1441724 bytes .../generators/mockJDK/GenerateMockJdk.java | 3 +++ 3 files changed, 3 insertions(+) diff --git a/compiler/testData/mockJDK/jre/lib/rt.jar b/compiler/testData/mockJDK/jre/lib/rt.jar index a97c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/compiler/testData/mockJDK/src.zip b/compiler/testData/mockJDK/src.zip index f5c454a3a6b29de56b21315ee2b47ae1915f8216..4ccea0710d6ba093158460064625a15b525ed24f 100644 GIT binary patch delta 129174 zcmZ5`Ra9NuvMsEIdvJGmcXxMp3GPm?g}d9r3GVJra0?P#gFC??_}lmF)7rc5wfR#u zdmq)S&G|F>7!|sz-Seq~qN)Id!i0eP=b;PVmu^Ji!iV~w0DL`;feHQ~fP@7LSz#fC zI^nlF;Y0dB{$H^D9}qL{f93QQkiM}0$ulUiFxz|TA;;kVleR~8LYe^nWupCs!D|2P zhP0vi7qZ`nv_<R@|(#1aqmuFQog zR@(!jUDR9f)(jb?74G-=tAuNQM!F?QRe_U-R){H^r@h61gpPH9-j-zmR~3L|IG=ivT+p zX#=19U7&pHBq|M6ctu#=$iLkzhmue4BVE778*3;$qMinTIJbXH}9{N zWWkNH51_5_Ql~50O;4g#)f87=s-EiE7T1jr{a_~Wi?YJ~I>8Kw;3VS7^le6@uddWM zta?t8W9NEom@1GHzEdL>#24#H1Z5U-p2QTas*nS-aEV6}Z?GTcV7eIRe^w#(yQ^dP z6L4jY)9u6Q&;HFp6tdK`0^iEI>5GHggPg#zR6{2vA19fBzbIy$_ASk??0TX?%a$5` z=cB%U^Pj5xSB%mYry+E%jCp@L0#)-MCmKB`%nISQp8JE$+gVvGK{5@$TMe6ST5NNL z`TV%6Cpplf5Iu}tMV$A5DCilfIA{q0bZ>M&>e%l<%1P&~UpZU~bMqPtxI4IT?^1zA z^-TN5_&e*3=a3kqxxIvmU6~Vi!s!OOFfL9qGU&Z65Yz*a)5X-c8!{(EMmukR$^}ki zl{Z(C)ny{s`n;|dL3*>9m}uh5Z48Ai-zerTC6A-_SwaQ|w2BOM(pmv-S z8?m$%U8P}Vp$UKQc-yoeMtTGAw_+MD7Dv4#`N4@Z6D4fUuWU9ELZzrbf^)sLw^r4D z-G2{4Z9)=am2s9E&HtzZo!6@UC&}=mTP)%t=CtAKU&2^R>rR4+dppWD>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y%nr~Xk`zdck$-Lbs_oYqgL?q8!NkBf%)yb zq+q83xZ6FFP9;^DR#4DIJ=puCi}-QXZoGqAF)A2F!5QCT1+&Ik+kr1Sio5@#yHR4_ zPAiD$Hp~^mpCXFMJ3OpGy9&uud&qMb@;qk>X Date: Wed, 1 Jul 2015 15:31:18 +0300 Subject: [PATCH 161/450] Add PurelyImplements annotation It's parameter is FQ-name of class (currently only from builtins) that added as supertype to annotated Java class. Parameters of annotated class used as non-flexible arguments of added supertype, that helps to propagate more precise types when using in Kotlin. Some standard JDK collections loaded as they annotated with PurelyImplements. See tests for clarification. Before: ArrayList.add(x: Int!) // possible to add null After: ArrayList.add(x: Int) // impossible to add null #KT-7628 Fixed #KT-7835 Fixed --- .../purelyImplementedCollection/arrayList.kt | 22 ++++++ .../purelyImplementedCollection/arrayList.txt | 4 + .../arrayListNullable.kt | 22 ++++++ .../arrayListNullable.txt | 4 + .../customClassMutableCollection.kt | 31 ++++++++ .../customClassMutableCollection.txt | 24 ++++++ .../customClassMutableList.kt | 39 ++++++++++ .../customClassMutableList.txt | 38 +++++++++ .../purelyImplementedCollection/maps.kt | 78 +++++++++++++++++++ .../purelyImplementedCollection/maps.txt | 7 ++ .../mapsWithNullableKey.kt | 54 +++++++++++++ .../mapsWithNullableKey.txt | 6 ++ .../mapsWithNullableValues.kt | 53 +++++++++++++ .../mapsWithNullableValues.txt | 6 ++ .../purelyImplementedCollection/sets.kt | 46 +++++++++++ .../purelyImplementedCollection/sets.txt | 6 ++ .../wrongTypeParametersCount.kt | 39 ++++++++++ .../wrongTypeParametersCount.txt | 38 +++++++++ ...JetDiagnosticsTestWithStdLibGenerated.java | 63 +++++++++++++++ .../java/FakePureImplementationsProvider.kt | 47 +++++++++++ .../kotlin/load/java/JvmAnnotationNames.java | 2 + .../descriptors/LazyJavaClassDescriptor.kt | 52 ++++++++++++- .../kotlin/builtins/KotlinBuiltIns.java | 10 ++- .../src/kotlin/jvm/PurelyImplements.kt | 37 +++++++++ 24 files changed, 724 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt create mode 100644 core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt create mode 100644 core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt new file mode 100644 index 00000000000..b28f1a8c27e --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* + +fun bar(): String? = null + +fun foo() { + var x = ArrayList() + x.add(null) + x.add(bar()) + x.add("") + + x[0] = null + x[0] = bar() + x[0] = "" + + val b1: MutableList = x + val b2: MutableList = x + val b3: List = x + + val b4: Collection = x + val b6: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.txt new file mode 100644 index 00000000000..dd1f7a31060 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.txt @@ -0,0 +1,4 @@ +package + +internal fun bar(): kotlin.String? +internal fun foo(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt new file mode 100644 index 00000000000..fad8fa935c2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* + +fun bar(): String? = null + +fun foo() { + var x = ArrayList() + x.add(null) + x.add(bar()) + x.add("") + + x[0] = null + x[0] = bar() + x[0] = "" + + val b1: MutableList = x + val b2: MutableList = x + val b3: List = x + + val b4: Collection = x + val b6: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.txt new file mode 100644 index 00000000000..dd1f7a31060 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.txt @@ -0,0 +1,4 @@ +package + +internal fun bar(): kotlin.String? +internal fun foo(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt new file mode 100644 index 00000000000..b67883babd4 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +import java.util.* + +// FILE: A.java +@kotlin.jvm.PurelyImplements("kotlin.MutableCollection") +class A extends AbstractCollection { + @Override + public Iterator iterator() { + return null; + } + + @Override + public int size() { + return 0; + } +} + +// FILE: b.kt + +fun bar(): String? = null + +fun foo() { + var x = A() + x.add(null) + x.add(bar()) + x.add("") + + val b1: Collection = x + val b2: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt new file mode 100644 index 00000000000..c8966bb576a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.txt @@ -0,0 +1,24 @@ +package + +internal fun bar(): kotlin.String? +internal fun foo(): kotlin.Unit + +kotlin.jvm.PurelyImplements(value = "kotlin.MutableCollection") public/*package*/ open class A : java.util.AbstractCollection, kotlin.MutableCollection { + public/*package*/ constructor A() + public open override /*2*/ /*fake_override*/ fun add(/*0*/ e: T): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun clear(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean + java.lang.Override() public open override /*2*/ fun iterator(): kotlin.MutableIterator + public open override /*2*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + java.lang.Override() public open override /*2*/ fun size(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! + public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt new file mode 100644 index 00000000000..31e3c57ad0f --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt @@ -0,0 +1,39 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +import java.util.* + +// FILE: A.java +@kotlin.jvm.PurelyImplements("kotlin.MutableList") +class A extends AbstractList { + @Override + public T get(int index) { + return null; + } + + @Override + public int size() { + return 0; + } +} + +// FILE: b.kt + +fun bar(): String? = null + +fun foo() { + var x = A() + x.add(null) + x.add(bar()) + x.add("") + + x[0] = null + x[0] = bar() + x[0] = "" + + val b1: MutableList = x + val b2: MutableList = x + val b3: List = x + + val b4: Collection = x + val b6: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt new file mode 100644 index 00000000000..41c160f2daf --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt @@ -0,0 +1,38 @@ +package + +internal fun bar(): kotlin.String? +internal fun foo(): kotlin.Unit + +kotlin.jvm.PurelyImplements(value = "kotlin.MutableList") public/*package*/ open class A : java.util.AbstractList, kotlin.MutableList { + public/*package*/ constructor A() + protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int + public open override /*2*/ /*fake_override*/ fun add(/*0*/ e: T): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: T): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun clear(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public open override /*2*/ fun get(/*0*/ index: kotlin.Int): T + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*2*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*2*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*2*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! + invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): T + public open override /*2*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: T): T + java.lang.Override() public open override /*2*/ fun size(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! + public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt new file mode 100644 index 00000000000..8cb8a523cf8 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt @@ -0,0 +1,78 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* +import java.util.concurrent.* + +fun bar(): String? = null +val nullableInt: Int? = null + +fun hashMapTest() { + var x: HashMap = HashMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} + +fun treeMapTest() { + var x: TreeMap = TreeMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} + +fun concurrentHashMapTest() { + var x: ConcurrentHashMap = ConcurrentHashMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.txt new file mode 100644 index 00000000000..3b7d946afb4 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.txt @@ -0,0 +1,7 @@ +package + +internal val nullableInt: kotlin.Int? = null +internal fun bar(): kotlin.String? +internal fun concurrentHashMapTest(): kotlin.Unit +internal fun hashMapTest(): kotlin.Unit +internal fun treeMapTest(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt new file mode 100644 index 00000000000..cbf06958749 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt @@ -0,0 +1,54 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* + +fun bar(): String? = null +val nullableInt: Int? = null + +fun hashMapTest() { + var x: HashMap = HashMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x[null] + val b8: Int = x.get("") + + val b9: Int? = x.get("") +} + +fun treeMapTest() { + var x: TreeMap = TreeMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.txt new file mode 100644 index 00000000000..51b387b7d42 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.txt @@ -0,0 +1,6 @@ +package + +internal val nullableInt: kotlin.Int? = null +internal fun bar(): kotlin.String? +internal fun hashMapTest(): kotlin.Unit +internal fun treeMapTest(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt new file mode 100644 index 00000000000..2727dcaee70 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt @@ -0,0 +1,53 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* + +fun bar(): String? = null +val nullableInt: Int? = null + +fun hashMapTest() { + var x: HashMap = HashMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} + +fun treeMapTest() { + var x: TreeMap = TreeMap() + x.put(null, null) + x.put("", null) + x.put(bar(), 1) + x.put("", 1) + + x[null] = 1 + x[bar()] = 1 + x[""] = nullableInt + x[""] = 1 + + val b1: MutableMap = x + val b2: MutableMap = x + val b3: Map = x + val b4: Map = x + val b5: Map = x + + val b6: Int = x[""] + val b7: Int = x.get("") + + val b8: Int? = x.get("") +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.txt new file mode 100644 index 00000000000..51b387b7d42 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.txt @@ -0,0 +1,6 @@ +package + +internal val nullableInt: kotlin.Int? = null +internal fun bar(): kotlin.String? +internal fun hashMapTest(): kotlin.Unit +internal fun treeMapTest(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt new file mode 100644 index 00000000000..7e37f0d0b55 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt @@ -0,0 +1,46 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +import java.util.* + +fun bar(): String? = null + +fun fooHashSet() { + var x = HashSet() + x.add(null) + x.add(bar()) + x.add("") + + val b1: MutableSet = x + val b2: MutableSet = x + val b3: Set = x + + val b4: Collection = x + val b6: MutableCollection = x +} + +fun fooTreeSet() { + var x = TreeSet() + x.add(null) + x.add(bar()) + x.add("") + + val b1: MutableSet = x + val b2: MutableSet = x + val b3: Set = x + + val b4: Collection = x + val b6: MutableCollection = x +} + +fun fooLinkedHashSet() { + var x = LinkedHashSet() + x.add(null) + x.add(bar()) + x.add("") + + val b1: MutableSet = x + val b2: MutableSet = x + val b3: Set = x + + val b4: Collection = x + val b6: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.txt new file mode 100644 index 00000000000..60371b78964 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.txt @@ -0,0 +1,6 @@ +package + +internal fun bar(): kotlin.String? +internal fun fooHashSet(): kotlin.Unit +internal fun fooLinkedHashSet(): kotlin.Unit +internal fun fooTreeSet(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.kt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.kt new file mode 100644 index 00000000000..63d95658bdb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.kt @@ -0,0 +1,39 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +import java.util.* + +// FILE: A.java +@kotlin.jvm.PurelyImplements("kotlin.MutableList") +class A extends AbstractList { + @Override + public T get(int index) { + return null; + } + + @Override + public int size() { + return 0; + } +} + +// FILE: b.kt + +fun bar(): String? = null + +fun foo() { + var x = A() + x.add(null) + x.add(bar()) + x.add("") + + x[0] = null + x[0] = bar() + x[0] = "" + + val b1: MutableList = x + val b2: MutableList = x + val b3: List = x + + val b4: Collection = x + val b6: MutableCollection = x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt new file mode 100644 index 00000000000..436b84b19f5 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.txt @@ -0,0 +1,38 @@ +package + +internal fun bar(): kotlin.String? +internal fun foo(): kotlin.Unit + +kotlin.jvm.PurelyImplements(value = "kotlin.MutableList") public/*package*/ open class A : java.util.AbstractList { + public/*package*/ constructor A() + protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: T!): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: T!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public open override /*1*/ fun get(/*0*/ index: kotlin.Int): T! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! + invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): T! + public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: T!): T! + java.lang.Override() public open override /*1*/ fun size(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! + public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index ed32fc97ab0..dd046cf6fa6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -611,6 +611,69 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic } } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class PurelyImplementedCollection extends AbstractJetDiagnosticsTestWithStdLib { + public void testAllFilesPresentInPurelyImplementedCollection() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("arrayList.kt") + public void testArrayList() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayList.kt"); + doTest(fileName); + } + + @TestMetadata("arrayListNullable.kt") + public void testArrayListNullable() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/arrayListNullable.kt"); + doTest(fileName); + } + + @TestMetadata("customClassMutableCollection.kt") + public void testCustomClassMutableCollection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.kt"); + doTest(fileName); + } + + @TestMetadata("customClassMutableList.kt") + public void testCustomClassMutableList() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.kt"); + doTest(fileName); + } + + @TestMetadata("maps.kt") + public void testMaps() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/maps.kt"); + doTest(fileName); + } + + @TestMetadata("mapsWithNullableKey.kt") + public void testMapsWithNullableKey() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableKey.kt"); + doTest(fileName); + } + + @TestMetadata("mapsWithNullableValues.kt") + public void testMapsWithNullableValues() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.kt"); + doTest(fileName); + } + + @TestMetadata("sets.kt") + public void testSets() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt"); + doTest(fileName); + } + + @TestMetadata("wrongTypeParametersCount.kt") + public void testWrongTypeParametersCount() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/wrongTypeParametersCount.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/regression") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt new file mode 100644 index 00000000000..b416ae514f7 --- /dev/null +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/FakePureImplementationsProvider.kt @@ -0,0 +1,47 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java + +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.resolve.DescriptorUtils + +public object FakePureImplementationsProvider { + public fun getPurelyImplementedInterface(classFqName: FqName): FqName? = when(classFqName) { + in MUTABLE_LISTS_IMPLEMENTATIONS -> MUTABLE_LIST_FQ_NAME + in MUTABLE_MAPS_IMPLEMENTATIONS -> MUTABLE_MAP_FQ_NAME + in MUTABLE_SETS_IMPLEMENTATIONS -> MUTABLE_SET_FQ_NAME + else -> null + } + + private val kotlinBuiltins = KotlinBuiltIns.getInstance() + + private val MUTABLE_LIST_FQ_NAME = DescriptorUtils.getFqNameSafe(kotlinBuiltins.getMutableList()) + private val MUTABLE_SET_FQ_NAME = DescriptorUtils.getFqNameSafe(kotlinBuiltins.getMutableSet()) + private val MUTABLE_MAP_FQ_NAME = DescriptorUtils.getFqNameSafe(kotlinBuiltins.getMutableMap()) + + private val MUTABLE_LISTS_IMPLEMENTATIONS = setOfFqNames("java.util.ArrayList", "java.util.LinkedList") + private val MUTABLE_MAPS_IMPLEMENTATIONS = setOfFqNames( + "java.util.HashMap", "java.util.TreeMap", "java.util.LinkedHashMap", + "java.util.concurrent.ConcurrentHashMap", "java.util.concurrent.ConcurrentSkipListMap" + ) + private val MUTABLE_SETS_IMPLEMENTATIONS = setOfFqNames( + "java.util.HashSet", "java.util.TreeSet", "java.util.LinkedHashSet" + ) +} + +private fun setOfFqNames(vararg names: String) = names.map { FqName(it) }.toSet() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index 7ff48a45ae4..a6c887c1762 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -44,6 +44,8 @@ public final class JvmAnnotationNames { public static final FqName JETBRAINS_MUTABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Mutable"); public static final FqName JETBRAINS_READONLY_ANNOTATION = new FqName("org.jetbrains.annotations.ReadOnly"); + public static final FqName PURELY_IMPLEMENTS_ANNOTATION = new FqName("kotlin.jvm.PurelyImplements"); + public static class KotlinClass { public static final JvmClassName CLASS_NAME = JvmClassName.byInternalName("kotlin/jvm/internal/KotlinClass"); public static final ClassId KIND_CLASS_ID = diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 3005f1a847b..b80311bb371 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -20,6 +20,8 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase +import org.jetbrains.kotlin.load.java.FakePureImplementationsProvider +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.components.TypeUsage import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.load.java.lazy.LazyJavaResolverContext @@ -30,11 +32,12 @@ import org.jetbrains.kotlin.load.java.structure.JavaClass import org.jetbrains.kotlin.load.java.structure.JavaClassifierType import org.jetbrains.kotlin.load.java.structure.JavaType import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.isValidJavaFqName +import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.resolve.scopes.InnerClassesScopeWrapper import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.types.AbstractClassTypeConstructor -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeConstructor +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.ArrayList @@ -121,17 +124,26 @@ class LazyJavaClassDescriptor( val result = ArrayList(javaTypes.size()) val incomplete = ArrayList(0) + val purelyImplementedSupertype: JetType? = getPurelyImplementedSupertype() + for (javaType in javaTypes) { val jetType = c.typeResolver.transformJavaType(javaType, TypeUsage.SUPERTYPE.toAttributes()) if (jetType.isError()) { incomplete.add(javaType) continue } + + if (jetType.getConstructor() == purelyImplementedSupertype?.getConstructor()) { + continue + } + if (!KotlinBuiltIns.isAnyOrNullableAny(jetType)) { result.add(jetType) } } + result.addIfNotNull(purelyImplementedSupertype) + if (incomplete.isNotEmpty()) { c.errorReporter.reportIncompleteHierarchy(getDeclarationDescriptor(), incomplete.map { javaType -> (javaType as JavaClassifierType).getPresentableText() @@ -141,6 +153,40 @@ class LazyJavaClassDescriptor( if (result.isNotEmpty()) result.toReadOnlyList() else listOf(c.module.builtIns.getAnyType()) } + private fun getPurelyImplementedSupertype(): JetType? { + val purelyImplementedFqName = getPurelyImplementsFqNameFromAnnotation() + ?: FakePureImplementationsProvider.getPurelyImplementedInterface(fqName) + ?: return null + + if (purelyImplementedFqName.parent() != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) return null + + val classDescriptor = KotlinBuiltIns.getInstance().getBuiltInClassByNameNullable(purelyImplementedFqName.shortName()) + ?: return null + + if (classDescriptor.getTypeConstructor().getParameters().size() != getParameters().size()) return null + + val parametersAsTypeProjections = getParameters().map { + parameter -> TypeProjectionImpl(Variance.INVARIANT, parameter.getDefaultType()) + } + + return JetTypeImpl( + Annotations.EMPTY, classDescriptor.getTypeConstructor(), + /* nullable =*/ false, parametersAsTypeProjections, + classDescriptor.getMemberScope(parametersAsTypeProjections) + ) + } + + private fun getPurelyImplementsFqNameFromAnnotation(): FqName? { + val annotation = this@LazyJavaClassDescriptor. + getAnnotations(). + findAnnotation(JvmAnnotationNames.PURELY_IMPLEMENTS_ANNOTATION) ?: return null + + val fqNameString = (annotation.getAllValueArguments().values().singleOrNull() as? StringValue)?.getValue() ?: return null + if (!isValidJavaFqName(fqNameString)) return null + + return FqName(fqNameString) + } + override fun getSupertypes(): Collection = supertypes() override fun getAnnotations() = Annotations.EMPTY diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index f7c80e56a14..5c8a0a59259 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -225,8 +225,16 @@ public class KotlinBuiltIns { @NotNull public ClassDescriptor getBuiltInClassByName(@NotNull Name simpleName) { + ClassDescriptor classDescriptor = getBuiltInClassByNameNullable(simpleName); + assert classDescriptor != null : "Must be a class descriptor " + simpleName + ", but was null"; + return classDescriptor; + } + + @Nullable + public ClassDescriptor getBuiltInClassByNameNullable(@NotNull Name simpleName) { ClassifierDescriptor classifier = getBuiltInsPackageFragment().getMemberScope().getClassifier(simpleName); - assert classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier; + assert classifier == null || + classifier instanceof ClassDescriptor : "Must be a class descriptor " + simpleName + ", but was " + classifier; return (ClassDescriptor) classifier; } diff --git a/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt b/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt new file mode 100644 index 00000000000..3f0d061d69f --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/PurelyImplements.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm + +/** + * Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. + * "Pure" means here that each type parameter of class becomes non-platform type argument of that interface. + * + * Example: + * + * class MyList extends AbstractList { ... } + * + * Methods defined in MyList use T as platform, i.e. it's possible to perform unsafe operation in Kotlin: + * MyList().add(null) // compiles + * + * @PurelyImplements("kotlin.MutableList") + * class MyPureList extends AbstractList { ... } + * + * Methods defined in MyPureList overriding methods in MutableList use T as non-platform types: + * MyList().add(null) // Error + * MyList().add(null) // Ok + */ +public annotation class PurelyImplements(public val value: String) From 151231ef1ab9c88f972a8c65540a5b16aedda3f6 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 3 Jul 2015 16:22:24 +0300 Subject: [PATCH 162/450] Adjust testData Standard JDK collections purely implement kotlin.Mutable* with non-platform arguments --- .../testData/diagnostics/tests/Builders.kt | 2 +- .../ValAndFunOverrideCompatibilityClash.txt | 22 +++++++++---------- .../tests/j+k/GenericsInSupertypes.txt | 22 +++++++++---------- .../platformTypes/supertypeTypeArguments.txt | 10 ++++----- .../diagnostics/tests/scopes/visibility2.txt | 22 +++++++++---------- .../diagnostics/tests/subtyping/kt-1457.txt | 22 +++++++++---------- .../platformTypes/notnullTypeArgument.txt | 22 +++++++++---------- .../smart/generics/GenericFunction3.kt | 2 +- j2k/testData/fileOrElement/list/Lists.kt | 2 ++ 9 files changed, 64 insertions(+), 62 deletions(-) diff --git a/compiler/testData/diagnostics/tests/Builders.kt b/compiler/testData/diagnostics/tests/Builders.kt index 2f334cd72d5..0d539318003 100644 --- a/compiler/testData/diagnostics/tests/Builders.kt +++ b/compiler/testData/diagnostics/tests/Builders.kt @@ -135,7 +135,7 @@ class A() : BodyTag("a") { get() = attributes["href"] set(value) { if (value != null) { - attributes.put("href", value) + attributes.put("href", value) // attributes["href"] = value //doesn't work: KT-1355 } } diff --git a/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt b/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt index b9509423bbb..eb76293c0e7 100644 --- a/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt +++ b/compiler/testData/diagnostics/tests/ValAndFunOverrideCompatibilityClash.txt @@ -23,10 +23,10 @@ internal final class Foo1 : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var elementData: kotlin.Array<(out) kotlin.Any!>! protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int - public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.Int!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.Int): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any @@ -37,27 +37,27 @@ internal final class Foo1 : java.util.ArrayList { invisible_fake open override /*1*/ /*fake_override*/ fun ensureCapacityInternal(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Int invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.Int public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int!): kotlin.Int! + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.Int): kotlin.Int public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt b/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt index f3be5c0cf91..28af01cb5e6 100644 --- a/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.txt @@ -5,10 +5,10 @@ internal abstract class AL : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var elementData: kotlin.Array<(out) kotlin.Any!>! protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int - public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: p.P!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: p.P!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: p.P): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: p.P): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any @@ -19,27 +19,27 @@ internal abstract class AL : java.util.ArrayList { invisible_fake open override /*1*/ /*fake_override*/ fun ensureCapacityInternal(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): p.P! + public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): p.P invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): p.P! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): p.P public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: p.P!): p.P! + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: p.P): p.P public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt b/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt index 63e5756d6bc..fe79b88083d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/supertypeTypeArguments.txt @@ -34,7 +34,7 @@ internal final class HashMapEx : java.util.HashMap, ExtM invisible_fake open override /*1*/ /*fake_override*/ fun containsNullValue(): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun containsValue(/*0*/ value: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun createEntry(/*0*/ p0: kotlin.Int, /*1*/ p1: K!, /*2*/ p2: V!, /*3*/ p3: kotlin.Int): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun entrySet(): kotlin.MutableSet> + public open override /*2*/ /*fake_override*/ fun entrySet(): kotlin.MutableSet> invisible_fake open override /*1*/ /*fake_override*/ fun entrySet0(): kotlin.(Mutable)Set!>! public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun get(/*0*/ key: kotlin.Any?): V? @@ -44,13 +44,13 @@ internal final class HashMapEx : java.util.HashMap, ExtM public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int invisible_fake open override /*1*/ /*fake_override*/ fun init(): kotlin.Unit public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*2*/ /*fake_override*/ fun keySet(): kotlin.MutableSet + public open override /*2*/ /*fake_override*/ fun keySet(): kotlin.MutableSet invisible_fake open override /*1*/ /*fake_override*/ fun loadFactor(): kotlin.Float invisible_fake open override /*1*/ /*fake_override*/ fun newEntryIterator(): kotlin.(Mutable)Iterator!>! invisible_fake open override /*1*/ /*fake_override*/ fun newKeyIterator(): kotlin.(Mutable)Iterator! invisible_fake open override /*1*/ /*fake_override*/ fun newValueIterator(): kotlin.(Mutable)Iterator! - public open override /*1*/ /*fake_override*/ fun put(/*0*/ key: K!, /*1*/ value: V!): V? - public open override /*1*/ /*fake_override*/ fun putAll(/*0*/ m: kotlin.Map): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun put(/*0*/ key: K, /*1*/ value: V): V? + public open override /*1*/ /*fake_override*/ fun putAll(/*0*/ m: kotlin.Map): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putAllForCreate(/*0*/ p0: (kotlin.MutableMap..kotlin.Map?)): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putForCreate(/*0*/ p0: K!, /*1*/ p1: V!): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun putForNullKey(/*0*/ p0: V!): V! @@ -62,6 +62,6 @@ internal final class HashMapEx : java.util.HashMap, ExtM public open override /*2*/ /*fake_override*/ fun size(): kotlin.Int public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String invisible_fake open override /*1*/ /*fake_override*/ fun transfer(/*0*/ p0: kotlin.Array<(out) java.util.HashMap.Entry<*, *>!>!, /*1*/ p1: kotlin.Boolean): kotlin.Unit - public open override /*2*/ /*fake_override*/ fun values(): kotlin.MutableCollection + public open override /*2*/ /*fake_override*/ fun values(): kotlin.MutableCollection invisible_fake open override /*1*/ /*fake_override*/ fun writeObject(/*0*/ p0: java.io.ObjectOutputStream!): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/scopes/visibility2.txt b/compiler/testData/diagnostics/tests/scopes/visibility2.txt index c7e4aa9e390..05bfe99c825 100644 --- a/compiler/testData/diagnostics/tests/scopes/visibility2.txt +++ b/compiler/testData/diagnostics/tests/scopes/visibility2.txt @@ -36,10 +36,10 @@ package b { invisible_fake final override /*1*/ /*fake_override*/ var elementData: kotlin.Array<(out) kotlin.Any!>! protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int - public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: java.lang.Integer!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: java.lang.Integer): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any @@ -50,27 +50,27 @@ package b { invisible_fake open override /*1*/ /*fake_override*/ fun ensureCapacityInternal(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): java.lang.Integer! + public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): java.lang.Integer invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): java.lang.Integer! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): java.lang.Integer public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer!): java.lang.Integer! + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: java.lang.Integer): java.lang.Integer public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt b/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt index 3ec3dd40f8f..6a2b7303465 100644 --- a/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt +++ b/compiler/testData/diagnostics/tests/subtyping/kt-1457.txt @@ -7,10 +7,10 @@ internal final class MyListOfPairs : java.util.ArrayList> { invisible_fake final override /*1*/ /*fake_override*/ var elementData: kotlin.Array<(out) kotlin.Any!>! protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int - public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: Pair!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: Pair!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection!>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection!>): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: Pair): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: Pair): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection>): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection>): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any @@ -21,27 +21,27 @@ internal final class MyListOfPairs : java.util.ArrayList> { invisible_fake open override /*1*/ /*fake_override*/ fun ensureCapacityInternal(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): Pair! + public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): Pair invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator!> + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator> public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator!> - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator!> + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator> + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator> invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): Pair! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): Pair public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: Pair!): Pair! + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: Pair): Pair public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList!> + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList> public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt index 02eb0d439c2..7b862069cee 100644 --- a/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/platformTypes/notnullTypeArgument.txt @@ -5,10 +5,10 @@ internal final class C : java.util.ArrayList { invisible_fake final override /*1*/ /*fake_override*/ var elementData: kotlin.Array<(out) kotlin.Any!>! protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int invisible_fake final override /*1*/ /*fake_override*/ var size: kotlin.Int - public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.String!): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: kotlin.String): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection): kotlin.Boolean invisible_fake open override /*1*/ /*fake_override*/ fun batchRemove(/*0*/ p0: kotlin.(Mutable)Collection<*>!, /*1*/ p1: kotlin.Boolean): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any @@ -18,26 +18,26 @@ internal final class C : java.util.ArrayList { public open override /*1*/ /*fake_override*/ fun ensureCapacity(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun ensureCapacityInternal(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun fastRemove(/*0*/ p0: kotlin.Int): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.String! + public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.String invisible_fake open override /*1*/ /*fake_override*/ fun grow(/*0*/ p0: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator + public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int - public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator - public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator + public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String! invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheck(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit invisible_fake open override /*1*/ /*fake_override*/ fun readObject(/*0*/ p0: java.io.ObjectInputStream!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String! + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): kotlin.String public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<*>): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: kotlin.String): kotlin.String public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>! public open override /*1*/ /*fake_override*/ fun toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>! public open override /*1*/ /*fake_override*/ fun trimToSize(): kotlin.Unit diff --git a/idea/idea-completion/testData/smart/generics/GenericFunction3.kt b/idea/idea-completion/testData/smart/generics/GenericFunction3.kt index 02509c6ccfc..2c4f26e6a6a 100644 --- a/idea/idea-completion/testData/smart/generics/GenericFunction3.kt +++ b/idea/idea-completion/testData/smart/generics/GenericFunction3.kt @@ -6,4 +6,4 @@ fun f(){ // EXIST: { lookupString: "listOf", tailText: "() (kotlin)", typeText: "List" } // EXIST: { lookupString: "listOf", tailText: "(vararg values: String) (kotlin)", typeText: "List" } -// EXIST: { lookupString: "arrayListOf", tailText: "(vararg values: String!) (kotlin)", typeText: "ArrayList" } +// EXIST: { lookupString: "arrayListOf", tailText: "(vararg values: String) (kotlin)", typeText: "ArrayList" } diff --git a/j2k/testData/fileOrElement/list/Lists.kt b/j2k/testData/fileOrElement/list/Lists.kt index 43f2676a7d7..c8f66c6c118 100644 --- a/j2k/testData/fileOrElement/list/Lists.kt +++ b/j2k/testData/fileOrElement/list/Lists.kt @@ -1,4 +1,6 @@ // ERROR: Unresolved reference: LinkedList +// ERROR: None of the following functions can be called with the arguments supplied: public open fun add(e: kotlin.Any): kotlin.Boolean defined in java.util.ArrayList public open fun add(index: kotlin.Int, element: kotlin.Any): kotlin.Unit defined in java.util.ArrayList +// ERROR: None of the following functions can be called with the arguments supplied: public open fun add(e: kotlin.Any): kotlin.Boolean defined in java.util.ArrayList public open fun add(index: kotlin.Int, element: kotlin.Any): kotlin.Unit defined in java.util.ArrayList import java.util.* public class Lists { From d350303951d4af4d707768b7f11d1353623c43ae Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 3 Jul 2015 16:23:04 +0300 Subject: [PATCH 163/450] Change HashMap in test to custom class It's implementing kotlin.Map with flexible arguments that is necessary in this test. --- .../methodCall/multipleExactBoundsNullable.kt | 18 ++++++++++++--- .../multipleExactBoundsNullable.txt | 22 +++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt index 72cd6adfb41..c9de5cf0c8a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt @@ -1,4 +1,16 @@ -import java.util.HashMap +// FILE: MyMap.java + +import java.util.AbstractMap; +import java.util.Set; + +class MyMap extends AbstractMap { + @Override + public Set> entrySet() { + return null; + } +} + +// FILE: main.kt interface ResolverForProject { val exposeM: M1 get() = null!! @@ -14,7 +26,7 @@ interface WithFoo { } fun foo(delegateResolver: ResolverForProject): ResolverForProject { - val descriptorByModule = HashMap() + val descriptorByModule = MyMap() val result = ResolverForProjectImpl(descriptorByModule, delegateResolver) result.exposeM.foo() // M is not M2? result.exposeM?.foo() // no warning, M is not M2, hense M is M2! @@ -22,5 +34,5 @@ fun foo(delegateResolver: ResolverForProject): ResolverForPro return ResolverForProjectImpl(descriptorByModule, delegateResolver) // another bound check } -// HashMap :< Map => M = M2! +// MyMap :< Map => M = M2! // RFP :< RFP => M = M2? \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt index dbc14f5d9b7..6a283d0e3f9 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt @@ -2,6 +2,28 @@ package internal fun foo(/*0*/ delegateResolver: ResolverForProject): ResolverForProject +public/*package*/ open class MyMap : java.util.AbstractMap { + public/*package*/ constructor MyMap() + invisible_fake final override /*1*/ /*fake_override*/ var keySet: kotlin.(Mutable)Set! + invisible_fake final override /*1*/ /*fake_override*/ var values: kotlin.(Mutable)Collection! + public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit + protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun clone(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun containsKey(/*0*/ key: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun containsValue(/*0*/ value: kotlin.Any?): kotlin.Boolean + java.lang.Override() public open override /*1*/ fun entrySet(): kotlin.MutableSet> + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun get(/*0*/ key: kotlin.Any?): V? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun keySet(): kotlin.MutableSet + public open override /*1*/ /*fake_override*/ fun put(/*0*/ key: K!, /*1*/ value: V!): V? + public open override /*1*/ /*fake_override*/ fun putAll(/*0*/ m: kotlin.Map): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun remove(/*0*/ key: kotlin.Any?): V? + public open override /*1*/ /*fake_override*/ fun size(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public open override /*1*/ /*fake_override*/ fun values(): kotlin.MutableCollection +} + internal interface ResolverForProject { internal open val exposeM: M1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean From a218c1359f3701a75fc9dcf957c9b35ae7722723 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 3 Jul 2015 16:24:47 +0300 Subject: [PATCH 164/450] Adjust testData: JDK collections behave like non-platform in backend Some of that changes looks like regression and should be fixed soon --- .../codegen/box/platformTypes/primitives/identityEquals.kt | 2 +- .../boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt | 5 ++--- .../kotlin/codegen/GenerateNotNullAssertionsTest.java | 1 - .../tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt | 4 ++-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt index ae9aefb1c64..a4ee0641f67 100644 --- a/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt +++ b/compiler/testData/codegen/box/platformTypes/primitives/identityEquals.kt @@ -3,7 +3,7 @@ fun box(): String { l.add(1000) val x = l[0] === 1000 - if (x) return "Fail: $x" + if (!x) return "Fail: $x" val x1 = l[0] === 1 if (x1) return "Fail 1: $x" val x2 = l[0] === l[0] diff --git a/compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt b/compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt index a459b553fe7..e2d11d5240c 100644 --- a/compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt +++ b/compiler/testData/codegen/boxWithStdlib/fullJdk/platformTypeAssertionStackTrace.kt @@ -1,8 +1,7 @@ -import java.util.Arrays -import java.util.ArrayList +import java.util.* fun box(): String { - val a = ArrayList() + val a = ArrayList() as AbstractList a.add(null) try { val b: String = a[0] diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java index d07adce460f..9f698b8c185 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java @@ -126,7 +126,6 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase { loadFile("notNullAssertions/arrayListGet.kt"); String text = generateToText(); - assertTrue(text.contains("checkExpressionValueIsNotNull")); assertTrue(text.contains("checkParameterIsNotNull")); } diff --git a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt index 3db2a8b12e6..9511fc38b80 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/exceptions.kt @@ -37,7 +37,7 @@ fun genericClassCast() { val c = ArrayList() c.add(1) // EXPRESSION: c.get(0) - // RESULT: instance of java.lang.Integer(id=ID): Ljava/lang/Integer; + // RESULT: 1: I //Breakpoint! val b = 1 } @@ -46,7 +46,7 @@ fun genericClassCast() { val c = ArrayList() c.add("a") // EXPRESSION: c.get(0) - // RESULT: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer: Ljava/lang/ClassCastException; + // RESULT: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number: Ljava/lang/ClassCastException; //Breakpoint! val b = 1 } From 5c60a1bdb8997d246e20c070d77afaf080edccd5 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 2 Jul 2015 19:28:39 +0300 Subject: [PATCH 165/450] Make project compilable after PurelyImplements annotation introduction --- .../codegen/optimization/fixStack/FixStackAnalyzer.kt | 4 ++-- compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt | 2 +- .../kotlin/resolve/calls/tasks/synthesizedInvokes.kt | 2 +- .../kotlin/renderer/AbstractDescriptorRendererTest.kt | 6 +++--- .../AbstractFunctionDescriptorInExpressionRendererTest.kt | 2 +- .../jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt | 2 +- .../idea/completion/ParameterNameAndTypeCompletion.kt | 2 +- .../src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt | 4 ++-- .../jetbrains/kotlin/android/KotlinOutputParserHelper.kt | 2 +- .../idea/debugger/evaluate/KotlinEvaluationBuilder.kt | 2 +- .../idea/intentions/ConvertFunctionToPropertyIntention.kt | 2 +- .../org/jetbrains/kotlin/idea/quickfix/AddLoopLabelFix.kt | 4 ++-- .../kotlin/idea/quickfix/SuperClassNotInitialized.kt | 2 +- .../createFromUsage/callableBuilder/CallableBuilder.kt | 2 +- .../evaluate/AbstractKotlinEvaluateExpressionTest.kt | 1 + j2k/src/org/jetbrains/kotlin/j2k/ReferenceSearcher.kt | 4 ++-- .../src/org/jetbrains/kotlin/js/inline/FunctionReader.kt | 2 +- 17 files changed, 23 insertions(+), 22 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt index bd69862aa9b..6f8daf431eb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -145,8 +145,8 @@ public class FixStackAnalyzer( private fun FixStackFrame.executeRestoreStackInTryCatch(insn: AbstractInsnNode) { val saveNode = context.saveStackMarkerForRestoreMarker[insn] - val savedValues = savedStacks.getOrElse(saveNode) { - throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode!!)}") + val savedValues = savedStacks.getOrElse(saveNode!!) { + throw AssertionError("${indexOf(insn)}: Restore stack is unavailable for ${indexOf(saveNode)}") } pushAll(savedValues) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt index 803db5ea1d8..3328e6c389b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClass.kt @@ -89,7 +89,7 @@ public open class JetClass : JetClassOrObject { val parts = ArrayList() var current: JetClassOrObject? = this while (current != null) { - parts.add(current.getName()) + parts.add(current.getName()!!) current = PsiTreeUtil.getParentOfType(current, javaClass()) } val file = getContainingFile() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt index 9a33c481df4..8ede6660859 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/synthesizedInvokes.kt @@ -52,7 +52,7 @@ fun createSynthesizedInvokes(functions: Collection): Collect fakeOverride } - result.add(synthesized.substitute(TypeSubstitutor.create(invoke.getDispatchReceiverParameter()!!.getType()))) + result.add(synthesized.substitute(TypeSubstitutor.create(invoke.getDispatchReceiverParameter()!!.getType()))!!) } return result diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt index dd79a6dbe94..3f2b65899bf 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractDescriptorRendererTest.kt @@ -89,10 +89,10 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment val parent = accessor.getParent() as JetProperty val propertyDescriptor = getDescriptor(parent, resolveSession) as PropertyDescriptor if (accessor.isGetter()) { - descriptors.add(propertyDescriptor.getGetter()) + descriptors.add(propertyDescriptor.getGetter()!!) } else { - descriptors.add(propertyDescriptor.getSetter()) + descriptors.add(propertyDescriptor.getSetter()!!) } accessor.acceptChildren(this) } @@ -108,7 +108,7 @@ public abstract class AbstractDescriptorRendererTest : KotlinTestWithEnvironment // if class has primary constructor then we visit it later, otherwise add it artificially if (element !is JetClassOrObject || !element.hasExplicitPrimaryConstructor()) { if (descriptor.getUnsubstitutedPrimaryConstructor() != null) { - descriptors.add(descriptor.getUnsubstitutedPrimaryConstructor()) + descriptors.add(descriptor.getUnsubstitutedPrimaryConstructor()!!) } } } diff --git a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractFunctionDescriptorInExpressionRendererTest.kt b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractFunctionDescriptorInExpressionRendererTest.kt index d8a4fd61974..fc971976b78 100644 --- a/compiler/tests/org/jetbrains/kotlin/renderer/AbstractFunctionDescriptorInExpressionRendererTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/renderer/AbstractFunctionDescriptorInExpressionRendererTest.kt @@ -46,7 +46,7 @@ abstract public class AbstractFunctionDescriptorInExpressionRendererTest : Kotli } override fun visitFunctionLiteralExpression(expression: JetFunctionLiteralExpression) { expression.acceptChildren(this) - descriptors.add(bindingContext.get(BindingContext.FUNCTION, expression.getFunctionLiteral())) + descriptors.add(bindingContext.get(BindingContext.FUNCTION, expression.getFunctionLiteral())!!) } }) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index fe5f9b4836c..f72257b8ae8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -34,7 +34,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su if (substitutor.isEmpty()) return descriptor if (substitutedDescriptors == null) { - substitutedDescriptors = HashMap() + substitutedDescriptors = HashMap() } val substituted = substitutedDescriptors!!.getOrPut(descriptor, { descriptor.substitute(substitutor) }) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt index 4fb750dbe0c..142215099cf 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ParameterNameAndTypeCompletion.kt @@ -117,7 +117,7 @@ class ParameterNameAndTypeCompletion( if (parameterType.isVisible(visibilityFilter)) { val lookupElement = MyLookupElement.create("", name, ArbitraryType(parameterType), lookupElementFactory) val count = lookupElementToCount[lookupElement] ?: 0 - lookupElementToCount[lookupElement] = count + 1 + lookupElementToCount[lookupElement!!] = count + 1 } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index 4fd39209eaf..8fad66a4bd5 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -211,7 +211,7 @@ private fun lookupElementsForNullable(factory: () -> LookupElement?): Collection } lookupElement = lookupElement!!.suppressAutoInsertion() lookupElement = lookupElement!!.assignSmartCompletionPriority(SmartCompletionItemPriority.NULLABLE) - result.add(lookupElement) + result.add(lookupElement!!) } lookupElement = factory() @@ -227,7 +227,7 @@ private fun lookupElementsForNullable(factory: () -> LookupElement?): Collection } lookupElement = lookupElement!!.suppressAutoInsertion() lookupElement = lookupElement!!.assignSmartCompletionPriority(SmartCompletionItemPriority.NULLABLE) - result.add(lookupElement) + result.add(lookupElement!!) } return result diff --git a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt index d0f6aed7714..df22920317b 100644 --- a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt +++ b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/KotlinOutputParserHelper.kt @@ -212,7 +212,7 @@ object KotlinOutputParserHelper { else Class.forName("$packagePrefix.GradleMessage\$Kind") - val messageKindConstants = messageKindClass.getEnumConstants() + val messageKindConstants = messageKindClass.getEnumConstants() as Array for (kind in messageKindConstants) { when(kind.toString()) { "ERROR" -> severityObjectMap.put("e", kind) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt index 4da92b78e4c..2e6c1e4e08e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -299,7 +299,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment, override fun visitProperty(property: JetProperty) { val value = property.getUserData(KotlinCodeFragmentFactory.LABEL_VARIABLE_VALUE_KEY) if (value != null) { - valuesForLabels.put(property.getName(), value.asValue()) + valuesForLabels.put(property.getName()!!, value.asValue()) } } }) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt index 888360dce79..cb0082e01ce 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt @@ -85,7 +85,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention"))) - elementsToShorten.add(callElement.getTypeArgumentList()) + elementsToShorten.add(callElement.getTypeArgumentList()!!) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index 74e736fc930..aa91a712f33 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -294,6 +294,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB assert(localVariable != null) { "Couldn't find localVariable for label: name = $localVariableName" } val localVariableValue = context.getFrameProxy()!!.getValue(localVariable) as? ObjectReference assert(localVariableValue != null) { "Local variable $localVariableName should be an ObjectReference" } + localVariableValue!! markupMap.put(localVariableValue, ValueMarkup(labelName, null, labelName)) } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ReferenceSearcher.kt b/j2k/src/org/jetbrains/kotlin/j2k/ReferenceSearcher.kt index 95588e85ab2..91082618d1d 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ReferenceSearcher.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ReferenceSearcher.kt @@ -68,10 +68,10 @@ public object IdeaReferenceSearcher: ReferenceSearcher { override fun findUsagesForExternalCodeProcessing(element: PsiElement, searchJava: Boolean, searchKotlin: Boolean): Collection { val fileTypes = ArrayList() if (searchJava) { - fileTypes.add(JavaLanguage.INSTANCE.getAssociatedFileType()) + fileTypes.add(JavaLanguage.INSTANCE.getAssociatedFileType()!!) } if (searchKotlin) { - fileTypes.add(JetLanguage.INSTANCE.getAssociatedFileType()) + fileTypes.add(JetLanguage.INSTANCE.getAssociatedFileType()!!) } val searchScope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.projectScope(element.getProject()), *fileTypes.toTypedArray()) return ReferencesSearch.search(element, searchScope).findAll() diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index d0e413a66fd..5d7bdb0e6ba 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -92,7 +92,7 @@ public class FunctionReader(private val context: TranslationContext) { public fun contains(descriptor: CallableDescriptor): Boolean { val moduleName = getExternalModuleName(descriptor) val currentModuleName = context.getConfig().getModuleId() - return currentModuleName != moduleName && moduleName in moduleJsDefinition + return currentModuleName != moduleName && moduleName != null && moduleName in moduleJsDefinition } public fun get(descriptor: CallableDescriptor): JsFunction = functionCache.get(descriptor) From 0169963a2705834566e2abfc83bc408ccf9fa111 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 1 Jul 2015 17:16:33 +0300 Subject: [PATCH 166/450] Change Signature: Process internal usages of function parameters when performing Java refactoring --- .../JetChangeSignatureUsageProcessor.java | 56 +++++++++++++++++-- .../JavaMethodOverridesChangeParamAfter.1.kt | 25 +++++++++ .../JavaMethodOverridesChangeParamAfter.java | 25 +++++++++ ...JavaMethodOverridesChangeParamBefore.1.kt} | 6 +- ...JavaMethodOverridesChangeParamBefore.java} | 4 +- ...JavaMethodOverridesReplaceParamAfter.1.kt} | 6 +- ...JavaMethodOverridesReplaceParamAfter.java} | 2 +- ...JavaMethodOverridesReplaceParamBefore.1.kt | 25 +++++++++ ...JavaMethodOverridesReplaceParamBefore.java | 25 +++++++++ .../JetChangeSignatureTest.java | 23 +++++++- 10 files changed, 183 insertions(+), 14 deletions(-) create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.java rename idea/testData/refactoring/changeSignature/{JavaMethodOverridesBefore.1.kt => JavaMethodOverridesChangeParamBefore.1.kt} (75%) rename idea/testData/refactoring/changeSignature/{JavaMethodOverridesBefore.java => JavaMethodOverridesChangeParamBefore.java} (83%) rename idea/testData/refactoring/changeSignature/{JavaMethodOverridesAfter.1.kt => JavaMethodOverridesReplaceParamAfter.1.kt} (75%) rename idea/testData/refactoring/changeSignature/{JavaMethodOverridesAfter.java => JavaMethodOverridesReplaceParamAfter.java} (91%) create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.java diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index 216aac90765..bace90962dd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -26,10 +26,7 @@ import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.OverridingMethodsSearch; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.changeSignature.ChangeInfo; -import com.intellij.refactoring.changeSignature.ChangeSignatureUsageProcessor; -import com.intellij.refactoring.changeSignature.JavaChangeInfo; -import com.intellij.refactoring.changeSignature.OverriderUsageInfo; +import com.intellij.refactoring.changeSignature.*; import com.intellij.refactoring.rename.ResolveSnapshotProvider; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.MoveRenameUsageInfo; @@ -373,6 +370,57 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro FunctionDescriptor functionDescriptor = (FunctionDescriptor) ResolvePackage.resolveToDescriptor(function); result.add(new DeferredJavaMethodOverrideOrSAMUsage(function, functionDescriptor, null)); + + findDeferredUsagesOfParameters(changeInfo, result, function, functionDescriptor); + } + } + + private static void findDeferredUsagesOfParameters( + ChangeInfo changeInfo, + Set result, + JetNamedFunction function, + FunctionDescriptor functionDescriptor + ) { + final JetCallableDefinitionUsage functionInfoForParameters = + new JetCallableDefinitionUsage(function, functionDescriptor, null, null); + List oldParameters = PsiUtilPackage.getValueParameters(function); + ParameterInfo[] parameters = changeInfo.getNewParameters(); + for (int i = 0; i < parameters.length; i++) { + final int paramIndex = i; + ParameterInfo parameterInfo = parameters[paramIndex]; + if (parameterInfo.getOldIndex() >= 0 && parameterInfo.getOldIndex() < oldParameters.size()) { + JetParameter oldParam = oldParameters.get(parameterInfo.getOldIndex()); + String oldParamName = oldParam.getName(); + + if (oldParamName != null && !oldParamName.equals(parameterInfo.getName())) { + for (PsiReference reference : ReferencesSearch.search(oldParam, oldParam.getUseScope())) { + final PsiElement element = reference.getElement(); + + if ((element instanceof JetSimpleNameExpression || element instanceof KDocName) && + !(element.getParent() instanceof JetValueArgumentName)) // Usages in named arguments of the calls usage will be changed when the function call is changed + { + result.add( + new JavaMethodDeferredKotlinUsage((JetElement) element) { + @NotNull + @Override + public JavaMethodKotlinUsageWithDelegate resolve(@NotNull JetChangeInfo javaMethodChangeInfo) { + return new JavaMethodKotlinUsageWithDelegate((JetElement) element, + javaMethodChangeInfo) { + @NotNull + @Override + protected JetUsageInfo getDelegateUsage() { + return new JetParameterUsage((JetElement) element, + getJavaMethodChangeInfo().getNewParameters()[paramIndex], + functionInfoForParameters); + } + }; + } + } + ); + } + } + } + } } } diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.1.kt new file mode 100644 index 00000000000..260f9a89d4d --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.1.kt @@ -0,0 +1,25 @@ +open class X: A() { + fun foo(x: Int): String? { + return super.foo(x) + 1 + } +} + +open class Y: B() { + fun foo(x: Int): String? { + return x.length() * 2 + } +} + +open class Z: X() { + fun foo(x: Int): String? { + return x.length() + } +} + +fun test() { + A().foo("") + B().foo("") + X().foo("") + Y().foo("") + Z().foo("") +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.java new file mode 100644 index 00000000000..0e8c7879e76 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamAfter.java @@ -0,0 +1,25 @@ +import java.lang.Override; +import java.lang.String; + +class A { + String foo(int x) { + return x.length() * 2; + } +} + +class B extends A { + @Override + String foo(int x) { + return super.foo(x + "_"); + } +} + +class Test { + void test() { + new A().foo(""); + new B().foo(""); + new X().foo(""); + new Y().foo(""); + new Z().foo(""); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.1.kt similarity index 75% rename from idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.1.kt rename to idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.1.kt index ef92a4ec76d..5d5c2bde50c 100644 --- a/idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.1.kt +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.1.kt @@ -1,18 +1,18 @@ open class X: A() { fun foo(s: String): Int { - return super.foo(s) + return super.foo(s) + 1 } } open class Y: B() { fun foo(s: String): Int { - return 0 + return s.length() * 2 } } open class Z: X() { fun foo(s: String): Int { - return 0 + return s.length() } } diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.java similarity index 83% rename from idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.java rename to idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.java index 49e00cf60e8..2de8c245f90 100644 --- a/idea/testData/refactoring/changeSignature/JavaMethodOverridesBefore.java +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesChangeParamBefore.java @@ -3,14 +3,14 @@ import java.lang.String; class A { int foo(String s) { - return 0; + return s.length() * 2; } } class B extends A { @Override int foo(String s) { - return super.foo(s); + return super.foo(s + "_"); } } diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.1.kt similarity index 75% rename from idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.1.kt rename to idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.1.kt index 47368b2fbaa..17a9939cfcc 100644 --- a/idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.1.kt +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.1.kt @@ -1,18 +1,18 @@ open class X: A() { fun foo(x: Int): String? { - return super.foo(1) + return super.foo(1) + 1 } } open class Y: B() { fun foo(x: Int): String? { - return 0 + return s.length() * 2 } } open class Z: X() { fun foo(x: Int): String? { - return 0 + return s.length() } } diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.java similarity index 91% rename from idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.java rename to idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.java index 786a267d29c..41a8939a5fa 100644 --- a/idea/testData/refactoring/changeSignature/JavaMethodOverridesAfter.java +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamAfter.java @@ -3,7 +3,7 @@ import java.lang.String; class A { String foo(int x) { - return 0; + return s.length() * 2; } } diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.1.kt new file mode 100644 index 00000000000..5d5c2bde50c --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.1.kt @@ -0,0 +1,25 @@ +open class X: A() { + fun foo(s: String): Int { + return super.foo(s) + 1 + } +} + +open class Y: B() { + fun foo(s: String): Int { + return s.length() * 2 + } +} + +open class Z: X() { + fun foo(s: String): Int { + return s.length() + } +} + +fun test() { + A().foo("") + B().foo("") + X().foo("") + Y().foo("") + Z().foo("") +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.java new file mode 100644 index 00000000000..2de8c245f90 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesReplaceParamBefore.java @@ -0,0 +1,25 @@ +import java.lang.Override; +import java.lang.String; + +class A { + int foo(String s) { + return s.length() * 2; + } +} + +class B extends A { + @Override + int foo(String s) { + return super.foo(s + "_"); + } +} + +class Test { + void test() { + new A().foo(""); + new B().foo(""); + new X().foo(""); + new Y().foo(""); + new Z().foo(""); + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index 9ca0a99a743..f33924de872 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -975,7 +975,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { doTest(changeInfo); } - public void testJavaMethodOverrides() throws Exception { + public void testJavaMethodOverridesReplaceParam() throws Exception { doJavaTest( new JavaRefactoringProvider() { @Nullable @@ -995,6 +995,27 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { ); } + public void testJavaMethodOverridesChangeParam() throws Exception { + doJavaTest( + new JavaRefactoringProvider() { + @Nullable + @Override + PsiType getNewReturnType(@NotNull PsiMethod method) { + return PsiType.getJavaLangString(getPsiManager(), GlobalSearchScope.allScope(getProject())); + } + + @NotNull + @Override + ParameterInfoImpl[] getNewParameters(@NotNull PsiMethod method) { + ParameterInfoImpl[] newParameters = super.getNewParameters(method); + newParameters[0].setName("x"); + newParameters[0].setType(PsiType.INT); + return newParameters; + } + } + ); + } + public void testChangeProperty() throws Exception { JetChangeInfo changeInfo = getChangeInfo(); changeInfo.setNewName("s"); From 9dd6dea85f82d1283d2974f492f3afc3f436666e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 15:25:14 +0300 Subject: [PATCH 167/450] Change Signature: Move UI-related classes to separate package --- .../idea/refactoring/changeSignature/JetChangeSignature.kt | 5 +---- .../{ => ui}/JetCallableParameterTableModel.java | 5 ++++- .../{ => ui}/JetChangePropertySignatureDialog.kt | 0 .../changeSignature/{ => ui}/JetChangeSignatureDialog.java | 3 ++- .../{ => ui}/JetFunctionParameterTableModel.java | 4 +++- .../{ => ui}/JetPrimaryConstructorParameterTableModel.java | 5 ++++- .../{ => ui}/JetSecondaryConstructorParameterTableModel.java | 4 +++- 7 files changed, 17 insertions(+), 9 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetCallableParameterTableModel.java (91%) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetChangePropertySignatureDialog.kt (100%) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetChangeSignatureDialog.java (99%) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetFunctionParameterTableModel.java (94%) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetPrimaryConstructorParameterTableModel.java (91%) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{ => ui}/JetSecondaryConstructorParameterTableModel.java (85%) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index ea42b360901..adc2be4f15a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import com.intellij.lang.java.JavaLanguage import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.diagnostic.Logger -import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.openapi.project.Project import com.intellij.openapi.ui.Messages import com.intellij.psi.PsiElement @@ -32,19 +31,17 @@ import com.intellij.refactoring.util.CanonicalTypes import com.intellij.testFramework.LightVirtualFile import com.intellij.util.VisibilityUtil import org.jetbrains.annotations.TestOnly -import org.jetbrains.kotlin.asJava.KotlinLightMethod import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.idea.JetFileType -import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde -import org.jetbrains.kotlin.idea.core.refactoring.createJavaClass import org.jetbrains.kotlin.idea.core.refactoring.createJavaMethod import org.jetbrains.kotlin.idea.core.refactoring.toPsiFile import org.jetbrains.kotlin.idea.refactoring.CallableRefactoring +import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.JetChangeSignatureDialog import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetCallableParameterTableModel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetCallableParameterTableModel.java similarity index 91% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetCallableParameterTableModel.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetCallableParameterTableModel.java index ac8c0d280a4..96c46afb54b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetCallableParameterTableModel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetCallableParameterTableModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiCodeFragment; @@ -23,6 +23,9 @@ import com.intellij.refactoring.changeSignature.ParameterTableModelBase; import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase; import com.intellij.util.ui.ColumnInfo; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetValVar; import org.jetbrains.kotlin.psi.JetExpression; import org.jetbrains.kotlin.psi.JetPsiFactory; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangePropertySignatureDialog.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangePropertySignatureDialog.kt rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangePropertySignatureDialog.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.java similarity index 99% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.java index 60b414f99eb..ce8b961d443 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureDialog.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.EditorColorsManager; @@ -54,6 +54,7 @@ import org.jetbrains.kotlin.descriptors.Visibilities; import org.jetbrains.kotlin.descriptors.Visibility; import org.jetbrains.kotlin.idea.JetFileType; import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.*; import org.jetbrains.kotlin.psi.JetExpression; import org.jetbrains.kotlin.psi.JetExpressionCodeFragment; import org.jetbrains.kotlin.psi.JetTypeCodeFragment; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetFunctionParameterTableModel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetFunctionParameterTableModel.java similarity index 94% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetFunctionParameterTableModel.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetFunctionParameterTableModel.java index b3dff394552..8627ff65306 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetFunctionParameterTableModel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetFunctionParameterTableModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; @@ -24,6 +24,8 @@ import com.intellij.ui.BooleanTableCellRenderer; import com.intellij.util.ui.ColumnInfo; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.JetFileType; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellRenderer; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetPrimaryConstructorParameterTableModel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetPrimaryConstructorParameterTableModel.java similarity index 91% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetPrimaryConstructorParameterTableModel.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetPrimaryConstructorParameterTableModel.java index 186b3a2fc84..82553775fe5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetPrimaryConstructorParameterTableModel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetPrimaryConstructorParameterTableModel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; import com.intellij.openapi.ui.ComboBoxTableRenderer; import com.intellij.psi.PsiElement; @@ -23,6 +23,9 @@ import com.intellij.util.ui.ColumnInfo; import org.jdesktop.swingx.autocomplete.ComboBoxCellEditor; import org.jetbrains.kotlin.idea.JetFileType; import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetValVar; import javax.swing.*; import javax.swing.table.TableCellEditor; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetSecondaryConstructorParameterTableModel.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetSecondaryConstructorParameterTableModel.java similarity index 85% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetSecondaryConstructorParameterTableModel.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetSecondaryConstructorParameterTableModel.java index 0e7722650aa..45198b54b37 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetSecondaryConstructorParameterTableModel.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetSecondaryConstructorParameterTableModel.java @@ -14,11 +14,13 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; import com.intellij.psi.PsiElement; import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase; import org.jetbrains.kotlin.idea.JetFileType; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; public class JetSecondaryConstructorParameterTableModel extends JetCallableParameterTableModel { public JetSecondaryConstructorParameterTableModel(JetMethodDescriptor methodDescriptor, PsiElement context) { From 51eb989d577b0019b240d6cec9ca5b1467e25ce0 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 15:53:39 +0300 Subject: [PATCH 168/450] J2K: JetChangeSignatureProcessor --- .../JetChangeSignatureProcessor.java | 138 ------------------ .../JetChangeSignatureProcessor.kt | 107 ++++++++++++++ 2 files changed, 107 insertions(+), 138 deletions(-) delete mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java deleted file mode 100644 index 5a9045dbf25..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.refactoring.changeSignature; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Ref; -import com.intellij.psi.PsiElement; -import com.intellij.refactoring.RefactoringBundle; -import com.intellij.refactoring.changeSignature.ChangeSignatureProcessorBase; -import com.intellij.refactoring.changeSignature.ChangeSignatureUsageProcessor; -import com.intellij.refactoring.changeSignature.JavaChangeInfo; -import com.intellij.refactoring.changeSignature.JavaChangeSignatureUsageProcessor; -import com.intellij.refactoring.rename.RenameUtil; -import com.intellij.refactoring.ui.ConflictsDialog; -import com.intellij.usageView.UsageInfo; -import com.intellij.usageView.UsageViewDescriptor; -import com.intellij.util.containers.HashSet; -import com.intellij.util.containers.MultiMap; -import kotlin.KotlinPackage; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetUsageInfo; -import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos; - -import java.util.*; - -public class JetChangeSignatureProcessor extends ChangeSignatureProcessorBase { - private final String commandName; - - public JetChangeSignatureProcessor(Project project, JetChangeInfo changeInfo, String commandName) { - super(project, changeInfo); - this.commandName = commandName; - } - - @NotNull - @Override - protected UsageViewDescriptor createUsageViewDescriptor(UsageInfo[] usages) { - String subject = ChangeSignaturePackage.getKind(getChangeInfo()).getIsConstructor() ? "constructor" : "function"; - return new JetUsagesViewDescriptor(myChangeInfo.getMethod(), RefactoringBundle.message("0.to.change.signature", subject)); - } - - @Override - public JetChangeInfo getChangeInfo() { - return (JetChangeInfo) super.getChangeInfo(); - } - - @NotNull - @Override - protected UsageInfo[] findUsages() { - List allUsages = new ArrayList(); - - List javaChangeInfos = getChangeInfo().getOrCreateJavaChangeInfos(); - if (javaChangeInfos != null) { - JavaChangeSignatureUsageProcessor javaProcessor = new JavaChangeSignatureUsageProcessor(); - for (JavaChangeInfo javaChangeInfo : javaChangeInfos) { - UsageInfo[] javaUsages = javaProcessor.findUsages(javaChangeInfo); - allUsages.add(new KotlinWrapperForJavaUsageInfos(javaChangeInfo, javaUsages, getChangeInfo().getMethod())); - } - } - KotlinPackage.filterIsInstanceTo(super.findUsages(), allUsages, JetUsageInfo.class); - - return allUsages.toArray(new UsageInfo[allUsages.size()]); - } - - @Override - protected boolean preprocessUsages(Ref refUsages) { - for (ChangeSignatureUsageProcessor processor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) { - if (!processor.setupDefaultValues(myChangeInfo, refUsages, myProject)) return false; - } - MultiMap conflictDescriptions = new MultiMap(); - for (ChangeSignatureUsageProcessor usageProcessor : ChangeSignatureUsageProcessor.EP_NAME.getExtensions()) { - MultiMap conflicts = usageProcessor.findConflicts(myChangeInfo, refUsages); - for (PsiElement key : conflicts.keySet()) { - Collection collection = conflictDescriptions.get(key); - if (collection.size() == 0) collection = new HashSet(); - collection.addAll(conflicts.get(key)); - conflictDescriptions.put(key, collection); - } - } - - UsageInfo[] usagesIn = refUsages.get(); - RenameUtil.addConflictDescriptions(usagesIn, conflictDescriptions); - Set usagesSet = new HashSet(Arrays.asList(usagesIn)); - RenameUtil.removeConflictUsages(usagesSet); - if (!conflictDescriptions.isEmpty()) { - if (ApplicationManager.getApplication().isUnitTestMode()) { - throw new ConflictsInTestsException(conflictDescriptions.values()); - } - if (myPrepareSuccessfulSwingThreadCallback != null) { - ConflictsDialog dialog = prepareConflictsDialog(conflictDescriptions, usagesIn); - dialog.show(); - if (!dialog.isOK()) { - if (dialog.isShowConflicts()) prepareSuccessful(); - return false; - } - } - } - - UsageInfo[] array = usagesSet.toArray(new UsageInfo[usagesSet.size()]); - Arrays.sort(array, new Comparator() { - @Override - public int compare(@NotNull UsageInfo u1, @NotNull UsageInfo u2) { - PsiElement element1 = u1.getElement(); - PsiElement element2 = u2.getElement(); - int rank1 = element1 != null ? element1.getTextOffset() : -1; - int rank2 = element2 != null ? element2.getTextOffset() : -1; - return rank2 - rank1; // Reverse order - } - }); - refUsages.set(array); - prepareSuccessful(); - return true; - } - - @Override - protected boolean isPreviewUsages(UsageInfo[] usages) { - return isPreviewUsages(); - } - - @Override - protected String getCommandName() { - return commandName; - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt new file mode 100644 index 00000000000..9018f70e4b6 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt @@ -0,0 +1,107 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature + +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.project.Project +import com.intellij.openapi.util.Ref +import com.intellij.psi.PsiElement +import com.intellij.refactoring.BaseRefactoringProcessor +import com.intellij.refactoring.RefactoringBundle +import com.intellij.refactoring.changeSignature.ChangeSignatureProcessorBase +import com.intellij.refactoring.changeSignature.ChangeSignatureUsageProcessor +import com.intellij.refactoring.changeSignature.JavaChangeSignatureUsageProcessor +import com.intellij.refactoring.rename.RenameUtil +import com.intellij.usageView.UsageInfo +import com.intellij.usageView.UsageViewDescriptor +import com.intellij.util.containers.MultiMap +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetUsageInfo +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos +import java.util.* + +public class JetChangeSignatureProcessor(project: Project, + changeInfo: JetChangeInfo, + private val commandName: String) : ChangeSignatureProcessorBase(project, changeInfo) { + override fun createUsageViewDescriptor(usages: Array): UsageViewDescriptor { + val subject = if (getChangeInfo().kind.isConstructor) "constructor" else "function" + return JetUsagesViewDescriptor(myChangeInfo.getMethod(), RefactoringBundle.message("0.to.change.signature", subject)) + } + + override fun getChangeInfo() = super.getChangeInfo() as JetChangeInfo + + override fun findUsages(): Array { + val allUsages = ArrayList() + getChangeInfo().getOrCreateJavaChangeInfos()?.let { javaChangeInfos -> + val javaProcessor = JavaChangeSignatureUsageProcessor() + javaChangeInfos.mapTo(allUsages) { + KotlinWrapperForJavaUsageInfos(it, javaProcessor.findUsages(it), getChangeInfo().getMethod()) + } + } + super.findUsages().filterIsInstanceTo(allUsages, javaClass>()) + + return allUsages.toTypedArray() + } + + override fun preprocessUsages(refUsages: Ref>): Boolean { + val usageProcessors = ChangeSignatureUsageProcessor.EP_NAME.getExtensions() + + if (!usageProcessors.all { it.setupDefaultValues(myChangeInfo, refUsages, myProject) }) return false + + val conflictDescriptions = object: MultiMap() { + override fun createCollection() = LinkedHashSet() + } + usageProcessors.forEach { conflictDescriptions.putAllValues(it.findConflicts(myChangeInfo, refUsages)) } + + val usages = refUsages.get() + val usagesSet = usages.toHashSet() + + RenameUtil.addConflictDescriptions(usages, conflictDescriptions) + RenameUtil.removeConflictUsages(usagesSet) + if (!conflictDescriptions.isEmpty()) { + if (ApplicationManager.getApplication().isUnitTestMode()) { + throw BaseRefactoringProcessor.ConflictsInTestsException(conflictDescriptions.values()) + } + + myPrepareSuccessfulSwingThreadCallback?.let { + val dialog = prepareConflictsDialog(conflictDescriptions, usages) + dialog.show() + if (!dialog.isOK()) { + if (dialog.isShowConflicts()) prepareSuccessful() + return false + } + } + } + + val usageArray = usagesSet.toTypedArray() + Arrays.sort(usageArray) { u1, u2 -> + val element1 = u1.getElement() + val element2 = u2.getElement() + val rank1 = if (element1 != null) element1.getTextOffset() else -1 + val rank2 = if (element2 != null) element2.getTextOffset() else -1 + rank2 - rank1 // Reverse order + } + refUsages.set(usageArray) + + prepareSuccessful() + + return true + } + + override fun isPreviewUsages(usages: Array?) = isPreviewUsages() + + override fun getCommandName() = commandName +} From 0afea7acac33cbfe27f01d4c97034053575a2ceb Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 16:15:55 +0300 Subject: [PATCH 169/450] J2K: JetUsageInfo --- .../usages/JetCallableDefinitionUsage.java | 2 +- .../{JetUsageInfo.java => JetUsageInfo.kt} | 33 +++++++------------ 2 files changed, 12 insertions(+), 23 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/{JetUsageInfo.java => JetUsageInfo.kt} (52%) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index ae5d4c1cb52..52d2d34ae21 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -165,7 +165,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn } @Override - public boolean processUsage(JetChangeInfo changeInfo, PsiElement element) { + public boolean processUsage(@NotNull JetChangeInfo changeInfo, @NotNull PsiElement element) { if (!(element instanceof JetNamedDeclaration)) return true; JetPsiFactory psiFactory = JetPsiFactory(element.getProject()); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt similarity index 52% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt index 118926c7b7a..b07bc8bca03 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt @@ -14,30 +14,19 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.usageView.UsageInfo; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo; +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference +import com.intellij.usageView.UsageInfo +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo -public abstract class JetUsageInfo extends UsageInfo { - public JetUsageInfo(@NotNull T element) { - super(element); - } +public abstract class JetUsageInfo : UsageInfo { + public constructor(element: T) : super(element) + public constructor(reference: PsiReference) : super(reference) - public JetUsageInfo(@NotNull PsiReference reference) { - super(reference); - } + @suppress("UNCHECKED_CAST") + override fun getElement() = super.getElement() as T? - @Nullable - @Override - public T getElement() { - //noinspection unchecked - return (T) super.getElement(); - } - - public abstract boolean processUsage(JetChangeInfo changeInfo, T element); + public abstract fun processUsage(changeInfo: JetChangeInfo, element: T): Boolean } From 74570333c0d281be15dd74eef13264fc9a037522 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 16:25:22 +0300 Subject: [PATCH 170/450] J2K: JetChangeSignatureHandler (rename to .kt) --- ...etChangeSignatureHandler.java => JetChangeSignatureHandler.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/{JetChangeSignatureHandler.java => JetChangeSignatureHandler.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt From 0bf7bb39876a2a4e7e26fa98114c83d857034b0c Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 2 Jul 2015 17:13:33 +0300 Subject: [PATCH 171/450] J2K: JetChangeSignatureHandler --- .../changeSignature/JetChangeSignature.kt | 14 +- .../JetChangeSignatureHandler.kt | 351 +++++++----------- .../JetChangeSignatureTest.java | 5 +- 3 files changed, 144 insertions(+), 226 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt index adc2be4f15a..cc87043490a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignature.kt @@ -47,16 +47,12 @@ import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.OverrideResolver -public trait JetChangeSignatureConfiguration { - fun configure(originalDescriptor: JetMethodDescriptor, bindingContext: BindingContext): JetMethodDescriptor +public interface JetChangeSignatureConfiguration { + fun configure(originalDescriptor: JetMethodDescriptor, bindingContext: BindingContext): JetMethodDescriptor = originalDescriptor + fun performSilently(affectedFunctions: Collection): Boolean = false + fun forcePerformForSelectedFunctionOnly(): Boolean = false - fun performSilently(affectedFunctions: Collection): Boolean { - return false - } - - fun forcePerformForSelectedFunctionOnly(): Boolean { - return false - } + object Empty: JetChangeSignatureConfiguration } fun JetMethodDescriptor.modify(action: (JetMutableMethodDescriptor) -> Unit): JetMethodDescriptor { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt index 3b287850290..84ad0cce76c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt @@ -14,250 +14,171 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature; +package org.jetbrains.kotlin.idea.refactoring.changeSignature -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.ScrollType; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.HelpID; -import com.intellij.refactoring.RefactoringBundle; -import com.intellij.refactoring.changeSignature.ChangeSignatureHandler; -import com.intellij.refactoring.changeSignature.ChangeSignatureUtil; -import com.intellij.refactoring.util.CommonRefactoringUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; -import org.jetbrains.kotlin.asJava.AsJavaPackage; -import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; -import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils; -import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde; -import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; -import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor; -import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.calls.tasks.TasksPackage; -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; +import com.intellij.openapi.actionSystem.CommonDataKeys +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.editor.ScrollType +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiFile +import com.intellij.psi.PsiMethod +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.refactoring.HelpID +import com.intellij.refactoring.RefactoringBundle +import com.intellij.refactoring.changeSignature.ChangeSignatureHandler +import com.intellij.refactoring.changeSignature.ChangeSignatureUtil +import com.intellij.refactoring.util.CommonRefactoringUtil +import org.jetbrains.kotlin.asJava.unwrapped +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils +import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde +import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle +import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.tasks.isDynamic +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import java.util.Collection; +public class JetChangeSignatureHandler : ChangeSignatureHandler { -import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED; -import static org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignaturePackage.runChangeSignature; + override fun findTargetMember(file: PsiFile, editor: Editor) = + file.findElementAt(editor.getCaretModel().getOffset())?.let { findTargetMember(it) } -public class JetChangeSignatureHandler implements ChangeSignatureHandler { - @Nullable - public static PsiElement findTargetForRefactoring(@NotNull PsiElement element) { - PsiElement elementParent = element.getParent(); - if ((elementParent instanceof JetNamedFunction || elementParent instanceof JetClass || elementParent instanceof JetProperty) - && ((JetNamedDeclaration) elementParent).getNameIdentifier() == element) return elementParent; + override fun findTargetMember(element: PsiElement) = + findTargetForRefactoring(element) - if (elementParent instanceof JetParameter) { - JetParameter parameter = (JetParameter) elementParent; - JetPrimaryConstructor primaryConstructor = PsiTreeUtil.getParentOfType(parameter, JetPrimaryConstructor.class); - if (parameter.hasValOrVar() - && (parameter.getNameIdentifier() == element || parameter.getValOrVarKeyword() == element) - && primaryConstructor != null - && primaryConstructor.getValueParameterList() == parameter.getParent()) return parameter; - } + override fun invoke(project: Project, editor: Editor, file: PsiFile, dataContext: DataContext) { + editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE) - if (elementParent instanceof JetSecondaryConstructor && - ((JetSecondaryConstructor) elementParent).getConstructorKeyword() == element) return elementParent; + val element = findTargetMember(file, editor) ?: CommonDataKeys.PSI_ELEMENT.getData(dataContext) ?: return + val elementAtCaret = file.findElementAt(editor.getCaretModel().getOffset()) ?: return + if (element !is JetElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.getText()}") - if (PsiTreeUtil.getParentOfType(element, JetParameterList.class) != null) { - return PsiTreeUtil.getParentOfType(element, JetFunction.class, JetProperty.class, JetClass.class); - } - - JetTypeParameterList typeParameterList = PsiTreeUtil.getParentOfType(element, JetTypeParameterList.class); - if (typeParameterList != null) { - return PsiTreeUtil.getParentOfType(typeParameterList, JetFunction.class, JetProperty.class, JetClass.class); - } - - JetExpression calleeExpr; - JetCallElement call = PsiTreeUtil.getParentOfType(element, - JetCallExpression.class, - JetDelegatorToSuperCall.class, - JetConstructorDelegationCall.class); - if (call != null) { - calleeExpr = call.getCalleeExpression(); - } - else { - calleeExpr = PsiTreeUtil.getParentOfType(element, JetSimpleNameExpression.class); - } - - if (calleeExpr instanceof JetConstructorCalleeExpression) { - calleeExpr = ((JetConstructorCalleeExpression) calleeExpr).getConstructorReferenceExpression(); - } - if (calleeExpr instanceof JetSimpleNameExpression || calleeExpr instanceof JetConstructorDelegationReferenceExpression) { - JetElement jetElement = PsiTreeUtil.getParentOfType(element, JetElement.class); - if (jetElement == null) return null; - - BindingContext bindingContext = ResolvePackage.analyze(jetElement, BodyResolveMode.FULL); - DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) calleeExpr); - - if (descriptor instanceof ClassDescriptor || descriptor instanceof CallableDescriptor) return calleeExpr; - } - - return null; + invokeChangeSignature(element, elementAtCaret, project, editor) } - public static void invokeChangeSignature( - @NotNull JetElement element, - @NotNull PsiElement context, - @NotNull Project project, - @Nullable Editor editor - ) { - BindingContext bindingContext = ResolvePackage.analyze(element, BodyResolveMode.FULL); + override fun invoke(project: Project, elements: Array, dataContext: DataContext?) { + val element = elements.singleOrNull()?.unwrapped ?: return + if (element !is JetElement) throw AssertionError("This handler must be invoked for Kotlin elements only: ${element.getText()}") - CallableDescriptor callableDescriptor = findDescriptor(element, project, editor, bindingContext); - if (callableDescriptor == null) { - return; - } - - if (callableDescriptor instanceof JavaCallableMemberDescriptor) { - PsiElement declaration = DescriptorToSourceUtilsIde.INSTANCE$.getAnyDeclaration(project, callableDescriptor); - assert declaration instanceof PsiMethod : "PsiMethod expected: " + callableDescriptor; - ChangeSignatureUtil.invokeChangeSignatureOn((PsiMethod) declaration, project); - return; - } - - if (TasksPackage.isDynamic(callableDescriptor)) { - if (editor != null) { - CodeInsightUtils.showErrorHint( - project, - editor, - "Change signature is not applicable to dynamically invoked functions", - "Change Signature", - null - ); - } - return; - } - - runChangeSignature(project, callableDescriptor, emptyConfiguration(), bindingContext, context, null); + val editor = dataContext?.let { CommonDataKeys.EDITOR.getData(it) } + invokeChangeSignature(element, element, project, editor) } - @TestOnly - public static JetChangeSignatureConfiguration getConfiguration() { - return emptyConfiguration(); - } + override fun getTargetNotFoundMessage() = + JetRefactoringBundle.message("error.wrong.caret.position.function.or.constructor.name") - private static JetChangeSignatureConfiguration emptyConfiguration() { - return new JetChangeSignatureConfiguration() { - @NotNull - @Override - public JetMethodDescriptor configure(@NotNull JetMethodDescriptor originalDescriptor, @NotNull BindingContext bindingContext) { - //do nothing - return originalDescriptor; + companion object { + public fun findTargetForRefactoring(element: PsiElement): PsiElement? { + val elementParent = element.getParent() + + if ((elementParent is JetNamedFunction || elementParent is JetClass || elementParent is JetProperty) + && (elementParent as JetNamedDeclaration).getNameIdentifier() === element) return elementParent + + if (elementParent is JetParameter) { + val primaryConstructor = PsiTreeUtil.getParentOfType(elementParent, javaClass()) + if (elementParent.hasValOrVar() + && (elementParent.getNameIdentifier() === element || elementParent.getValOrVarKeyword() === element) + && primaryConstructor != null + && primaryConstructor.getValueParameterList() === elementParent.getParent()) return elementParent } - @Override - public boolean performSilently(@NotNull Collection elements) { - return false; + if (elementParent is JetSecondaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent + + element.getStrictParentOfType()?.let { parameterList -> + return PsiTreeUtil.getParentOfType(parameterList, javaClass(), javaClass(), javaClass()) } - @Override - public boolean forcePerformForSelectedFunctionOnly() { - return false; + element.getStrictParentOfType()?.let { typeParameterList -> + return PsiTreeUtil.getParentOfType(typeParameterList, javaClass(), javaClass(), javaClass()) } - }; - } - @Nullable - @Override - public PsiElement findTargetMember(PsiFile file, Editor editor) { - return findTargetMember(file.findElementAt(editor.getCaretModel().getOffset())); - } + val call: JetCallElement? = PsiTreeUtil.getParentOfType(element, + javaClass(), + javaClass(), + javaClass()) + val calleeExpr = call?.let { + val callee = it.getCalleeExpression() + (callee as? JetConstructorCalleeExpression)?.getConstructorReferenceExpression() ?: callee + } ?: element.getStrictParentOfType() - @Nullable - @Override - public PsiElement findTargetMember(PsiElement element) { - return findTargetForRefactoring(element); - } + if (calleeExpr is JetSimpleNameExpression || calleeExpr is JetConstructorDelegationReferenceExpression) { + val jetElement = element.getStrictParentOfType() ?: return null - @Override - public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, DataContext dataContext) { - editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); - PsiElement element = findTargetMember(file, editor); - if (element == null) { - element = CommonDataKeys.PSI_ELEMENT.getData(dataContext); + val bindingContext = jetElement.analyze(BodyResolveMode.FULL) + val descriptor = bindingContext[BindingContext.REFERENCE_TARGET, calleeExpr as JetReferenceExpression] + + if (descriptor is ClassDescriptor || descriptor is CallableDescriptor) return calleeExpr + } + + return null } - PsiElement elementAtCaret = file.findElementAt(editor.getCaretModel().getOffset()); - if (element != null && elementAtCaret != null) { - assert element instanceof JetElement : "This handler must be invoked for elements of JetLanguage : " + element.getText(); + public fun invokeChangeSignature(element: JetElement, context: PsiElement, project: Project, editor: Editor?) { + val bindingContext = element.analyze(BodyResolveMode.FULL) - invokeChangeSignature((JetElement) element, elementAtCaret, project, editor); + val callableDescriptor = findDescriptor(element, project, editor, bindingContext) ?: return + + if (callableDescriptor is JavaCallableMemberDescriptor) { + val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, callableDescriptor) + assert(declaration is PsiMethod) { "PsiMethod expected: $callableDescriptor" } + ChangeSignatureUtil.invokeChangeSignatureOn(declaration as PsiMethod, project) + return + } + + if (callableDescriptor.isDynamic()) { + if (editor != null) { + CodeInsightUtils.showErrorHint(project, editor, "Change signature is not applicable to dynamically invoked functions", "Change Signature", null) + } + return + } + + runChangeSignature(project, callableDescriptor, JetChangeSignatureConfiguration.Empty, bindingContext, context, null) } - } - @Override - public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, @Nullable DataContext dataContext) { - if (elements.length != 1) return; - Editor editor = dataContext != null ? CommonDataKeys.EDITOR.getData(dataContext) : null; - - PsiElement element = AsJavaPackage.getUnwrapped(elements[0]); - assert element instanceof JetElement : "This handler must be invoked for elements of JetLanguage : " + element.getText(); - - invokeChangeSignature((JetElement) element, element, project, editor); - } - - @Nullable - @Override - public String getTargetNotFoundMessage() { - return JetRefactoringBundle.message("error.wrong.caret.position.function.or.constructor.name"); - } - - @Nullable - public static CallableDescriptor findDescriptor( - @NotNull PsiElement element, - @NotNull Project project, - @Nullable Editor editor, - BindingContext bindingContext - ) { - if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return null; - - DeclarationDescriptor descriptor; - if (element instanceof JetReferenceExpression) { - descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetReferenceExpression) element); - } else { - descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, element); + private fun getDescriptor(bindingContext: BindingContext, element: PsiElement): DeclarationDescriptor? { + val descriptor = when (element) { + is JetReferenceExpression -> bindingContext[BindingContext.REFERENCE_TARGET, element] + else -> bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, element] + } + return if (descriptor is ClassDescriptor) descriptor.getUnsubstitutedPrimaryConstructor() else descriptor } - if (descriptor instanceof ClassDescriptor) { - descriptor = ((ClassDescriptor) descriptor).getUnsubstitutedPrimaryConstructor(); - } - if (descriptor instanceof FunctionDescriptor) { - for (ValueParameterDescriptor parameter : ((FunctionDescriptor) descriptor).getValueParameters()) { - if (parameter.getVarargElementType() != null) { - String message = JetRefactoringBundle.message("error.cant.refactor.vararg.functions"); - CommonRefactoringUtil.showErrorHint(project, editor, message, - REFACTORING_NAME, - HelpID.CHANGE_SIGNATURE); - return null; + + public fun findDescriptor(element: PsiElement, project: Project, editor: Editor?, bindingContext: BindingContext): CallableDescriptor? { + if (!CommonRefactoringUtil.checkReadOnlyStatus(project, element)) return null + + var descriptor = getDescriptor(bindingContext, element) + + return when (descriptor) { + is FunctionDescriptor -> { + if (descriptor.getValueParameters().any { it.getVarargElementType() != null }) { + val message = JetRefactoringBundle.message("error.cant.refactor.vararg.functions") + CommonRefactoringUtil.showErrorHint(project, editor, message, ChangeSignatureHandler.REFACTORING_NAME, HelpID.CHANGE_SIGNATURE) + return null + } + + if (descriptor.getKind() === SYNTHESIZED) { + val message = JetRefactoringBundle.message("cannot.refactor.synthesized.function", descriptor.getName()) + CommonRefactoringUtil.showErrorHint(project, editor, message, ChangeSignatureHandler.REFACTORING_NAME, HelpID.CHANGE_SIGNATURE) + return null + } + + descriptor + } + + is PropertyDescriptor, is ValueParameterDescriptor -> descriptor as CallableDescriptor + + else -> { + val message = RefactoringBundle.getCannotRefactorMessage(JetRefactoringBundle.message("error.wrong.caret.position.function.or.constructor.name")) + CommonRefactoringUtil.showErrorHint(project, editor, message, ChangeSignatureHandler.REFACTORING_NAME, HelpID.CHANGE_SIGNATURE) + null } } - if (((FunctionDescriptor) descriptor).getKind() == SYNTHESIZED) { - String message = JetRefactoringBundle.message("cannot.refactor.synthesized.function", descriptor.getName()); - CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_SIGNATURE); - return null; - } - - - return (FunctionDescriptor) descriptor; - } - else if (descriptor instanceof PropertyDescriptor || descriptor instanceof ValueParameterDescriptor) { - return (CallableDescriptor) descriptor; - } - else { - String message = RefactoringBundle.getCannotRefactorMessage(JetRefactoringBundle.message( - "error.wrong.caret.position.function.or.constructor.name")); - CommonRefactoringUtil.showErrorHint(project, editor, message, REFACTORING_NAME, HelpID.CHANGE_SIGNATURE); - return null; } } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index f33924de872..3176fdee441 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -1128,11 +1128,12 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { PsiElement context = file.findElementAt(editor.getCaretModel().getOffset()); assertNotNull(context); - CallableDescriptor callableDescriptor = JetChangeSignatureHandler.findDescriptor(element, project, editor, bindingContext); + CallableDescriptor callableDescriptor = JetChangeSignatureHandler.Companion.findDescriptor(element, project, editor, bindingContext); assertNotNull(callableDescriptor); return ChangeSignaturePackage.createChangeInfo( - project, callableDescriptor, JetChangeSignatureHandler.getConfiguration(), bindingContext, context); + project, callableDescriptor, JetChangeSignatureConfiguration.Empty.INSTANCE$, bindingContext, context + ); } private class JavaRefactoringProvider { From 8b2be724342bf29daf9541a8f019fbde2dbb481b Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 3 Jul 2015 17:27:47 +0300 Subject: [PATCH 172/450] J2K: JetChangeSignatureDialog (rename to .kt) --- ...{JetChangeSignatureDialog.java => JetChangeSignatureDialog.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/{JetChangeSignatureDialog.java => JetChangeSignatureDialog.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.java rename to idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt From 058829aa559e24bb6f9cb31ae603edff1949e1be Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Mon, 6 Jul 2015 16:08:39 +0300 Subject: [PATCH 173/450] J2K: JetChangeSignatureDialog --- .../ui/JetChangeSignatureDialog.kt | 773 ++++++++---------- 1 file changed, 336 insertions(+), 437 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt index ce8b961d443..f2d89067473 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt @@ -14,525 +14,424 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui; +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorFontType; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.options.ConfigurationException; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.VerticalFlowLayout; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiCodeFragment; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.refactoring.BaseRefactoringProcessor; -import com.intellij.refactoring.changeSignature.CallerChooserBase; -import com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase; -import com.intellij.refactoring.changeSignature.MethodDescriptor; -import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase; -import com.intellij.refactoring.ui.ComboBoxVisibilityPanel; -import com.intellij.refactoring.ui.VisibilityPanelBase; -import com.intellij.ui.DottedBorder; -import com.intellij.ui.EditorTextField; -import com.intellij.ui.components.JBLabel; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.Consumer; -import com.intellij.util.Function; -import com.intellij.util.IJSwingUtilities; -import com.intellij.util.ui.ColumnInfo; -import com.intellij.util.ui.UIUtil; -import com.intellij.util.ui.table.JBTableRow; -import com.intellij.util.ui.table.JBTableRowEditor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.Visibilities; -import org.jetbrains.kotlin.descriptors.Visibility; -import org.jetbrains.kotlin.idea.JetFileType; -import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; -import org.jetbrains.kotlin.idea.refactoring.changeSignature.*; -import org.jetbrains.kotlin.psi.JetExpression; -import org.jetbrains.kotlin.psi.JetExpressionCodeFragment; -import org.jetbrains.kotlin.psi.JetTypeCodeFragment; -import org.jetbrains.kotlin.types.JetType; -import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor.Kind; +import com.intellij.openapi.editor.colors.EditorColorsManager +import com.intellij.openapi.editor.colors.EditorFontType +import com.intellij.openapi.editor.event.DocumentAdapter +import com.intellij.openapi.editor.event.DocumentEvent +import com.intellij.openapi.fileTypes.LanguageFileType +import com.intellij.openapi.options.ConfigurationException +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.VerticalFlowLayout +import com.intellij.openapi.util.text.StringUtil +import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiCodeFragment +import com.intellij.psi.PsiDocumentManager +import com.intellij.psi.PsiElement +import com.intellij.refactoring.BaseRefactoringProcessor +import com.intellij.refactoring.changeSignature.CallerChooserBase +import com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase +import com.intellij.refactoring.changeSignature.MethodDescriptor +import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase +import com.intellij.refactoring.ui.ComboBoxVisibilityPanel +import com.intellij.refactoring.ui.VisibilityPanelBase +import com.intellij.ui.DottedBorder +import com.intellij.ui.EditorTextField +import com.intellij.ui.components.JBLabel +import com.intellij.ui.treeStructure.Tree +import com.intellij.util.Consumer +import com.intellij.util.Function +import com.intellij.util.IJSwingUtilities +import com.intellij.util.ui.UIUtil +import com.intellij.util.ui.table.JBTableRow +import com.intellij.util.ui.table.JBTableRowEditor +import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle +import org.jetbrains.kotlin.idea.refactoring.changeSignature.* +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor.Kind +import org.jetbrains.kotlin.psi.JetExpressionCodeFragment +import org.jetbrains.kotlin.psi.JetPsiFactory +import org.jetbrains.kotlin.psi.JetTypeCodeFragment +import org.jetbrains.kotlin.types.JetType +import java.awt.BorderLayout +import java.awt.Font +import java.awt.Toolkit +import java.awt.event.ItemEvent +import java.awt.event.ItemListener +import java.util.ArrayList +import javax.swing.* -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory; - -public class JetChangeSignatureDialog extends ChangeSignatureDialogBase< +public class JetChangeSignatureDialog( + project: Project, + methodDescriptor: JetMethodDescriptor, + context: PsiElement, + private val commandName: String? +) : ChangeSignatureDialogBase< JetParameterInfo, PsiElement, Visibility, JetMethodDescriptor, ParameterTableModelItemBase, - JetCallableParameterTableModel - > -{ - private final String commandName; + JetCallableParameterTableModel>(project, methodDescriptor, false, context) { + override fun getFileType() = JetFileType.INSTANCE - public JetChangeSignatureDialog(Project project, @NotNull JetMethodDescriptor methodDescriptor, PsiElement context, String commandName) { - super(project, methodDescriptor, false, context); - this.commandName = commandName; - } + override fun createParametersInfoModel(descriptor: JetMethodDescriptor) = createParametersInfoModel(descriptor, myDefaultValueContext) - @Override - protected LanguageFileType getFileType() { - return JetFileType.INSTANCE; - } + override fun createReturnTypeCodeFragment() = createReturnTypeCodeFragment(myProject, myMethod) - @Override - protected JetCallableParameterTableModel createParametersInfoModel(JetMethodDescriptor descriptor) { - return createParametersInfoModel(descriptor, myDefaultValueContext); - } + public fun getReturnType(): JetType? = getType(myReturnTypeCodeFragment as JetTypeCodeFragment?) + + private val parametersTableModel: JetCallableParameterTableModel get() = super.myParametersTableModel + + override fun getRowPresentation(item: ParameterTableModelItemBase, selected: Boolean, focused: Boolean): JComponent? { + val panel = JPanel(BorderLayout()) - @NotNull - private static JetCallableParameterTableModel createParametersInfoModel(JetMethodDescriptor descriptor, PsiElement defaultValueContext) { - switch (descriptor.getKind()) { - case FUNCTION: - return new JetFunctionParameterTableModel(descriptor, defaultValueContext); - case PRIMARY_CONSTRUCTOR: - return new JetPrimaryConstructorParameterTableModel(descriptor, defaultValueContext); - case SECONDARY_CONSTRUCTOR: - return new JetSecondaryConstructorParameterTableModel(descriptor, defaultValueContext); - } - throw new AssertionError("Invalid kind: " + descriptor.getKind()); - } - - @Override - protected PsiCodeFragment createReturnTypeCodeFragment() { - return createReturnTypeCodeFragment(myProject, myMethod); - } - - @NotNull - private static PsiCodeFragment createReturnTypeCodeFragment(@NotNull Project project, @NotNull JetMethodDescriptor method) { - return JetPsiFactory(project).createTypeCodeFragment( - ChangeSignaturePackage.renderOriginalReturnType(method), method.getBaseDeclaration() - ); - } - - @Nullable - public JetType getReturnType() { - return getType((JetTypeCodeFragment) myReturnTypeCodeFragment); - } - - private static JetType getType(JetTypeCodeFragment typeCodeFragment) { - return typeCodeFragment != null ? typeCodeFragment.getType() : null; - } - - @Override - protected JComponent getRowPresentation(ParameterTableModelItemBase item, boolean selected, boolean focused) { - JPanel panel = new JPanel(new BorderLayout()); - String valOrVar = ""; - - if (myMethod.getKind() == Kind.PRIMARY_CONSTRUCTOR) { - switch (item.parameter.getValOrVar()) { - case None: - valOrVar = " "; - break; - case Val: - valOrVar = "val "; - break; - case Var: - valOrVar = "var "; - break; + val valOrVar: String + if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) { + valOrVar = when (item.parameter.valOrVar) { + JetValVar.None -> " " + JetValVar.Val -> "val " + JetValVar.Var -> "var " } } + else { + valOrVar = "" + } - String parameterName = getPresentationName(item); - String typeText = item.typeCodeFragment.getText(); - String defaultValue = item.defaultValueCodeFragment.getText(); - String separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length() + 1); - String text = valOrVar + parameterName + ":" + separator + typeText; + val parameterName = getPresentationName(item) + val typeText = item.typeCodeFragment.getText() + val defaultValue = item.defaultValueCodeFragment.getText() + val separator = StringUtil.repeatSymbol(' ', getParamNamesMaxLength() - parameterName.length() + 1) + var text = "$valOrVar$parameterName:$separator$typeText" - if (StringUtil.isNotEmpty(defaultValue)) - text += " // default value = " + defaultValue; + if (StringUtil.isNotEmpty(defaultValue)) { + text += " // default value = $defaultValue" + } - EditorTextField field = new EditorTextField(" " + text, getProject(), getFileType()) { - @Override - protected boolean shouldHaveBorder() { - return false; - } - }; + val field = object : EditorTextField(" $text", getProject(), getFileType()) { + override fun shouldHaveBorder() = false + } - Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); - font = new Font(font.getFontName(), font.getStyle(), 12); - field.setFont(font); + val plainFont = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN) + field.setFont(Font(plainFont.getFontName(), plainFont.getStyle(), 12)) if (selected && focused) { - panel.setBackground(UIUtil.getTableSelectionBackground()); - field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground()); - } else { - panel.setBackground(UIUtil.getTableBackground()); + panel.setBackground(UIUtil.getTableSelectionBackground()) + field.setAsRendererWithSelection(UIUtil.getTableSelectionBackground(), UIUtil.getTableSelectionForeground()) + } + else { + panel.setBackground(UIUtil.getTableBackground()) if (selected && !focused) { - panel.setBorder(new DottedBorder(UIUtil.getTableForeground())); + panel.setBorder(DottedBorder(UIUtil.getTableForeground())) } } - panel.add(field, BorderLayout.WEST); - return panel; + panel.add(field, BorderLayout.WEST) + + return panel } - private String getPresentationName(ParameterTableModelItemBase item) { - JetParameterInfo parameter = item.parameter; - if (parameter == null) return null; - if (parameter == myParametersTableModel.getReceiver()) return ""; - return parameter.getName(); + private fun getPresentationName(item: ParameterTableModelItemBase): String { + val parameter = item.parameter + return if (parameter == parametersTableModel.getReceiver()) "" else parameter.getName() } - private int getColumnTextMaxLength(Function, String> nameFunction) { - int len = 0; - for (ParameterTableModelItemBase item : myParametersTableModel.getItems()) { - String text = nameFunction.fun(item); - len = Math.max(len, text == null ? 0 : text.length()); - } - return len; + private fun getColumnTextMaxLength(nameFunction: Function1, String?>) = + parametersTableModel.getItems().map { nameFunction(it)?.length() ?: 0 }.max() ?: 0 + + private fun getParamNamesMaxLength() = getColumnTextMaxLength { getPresentationName(it) } + + private fun getTypesMaxLength() = getColumnTextMaxLength { it.typeCodeFragment?.getText() } + + private fun getDefaultValuesMaxLength() = getColumnTextMaxLength { it.defaultValueCodeFragment?.getText() } + + override fun isListTableViewSupported() = true + + override fun isEmptyRow(row: ParameterTableModelItemBase): Boolean { + if (!row.parameter.getName().isNullOrEmpty()) return false + if (!row.parameter.getTypeText().isNullOrEmpty()) return false + return true } - private int getParamNamesMaxLength() { - return getColumnTextMaxLength(new Function, String>() { - @Override - public String fun(ParameterTableModelItemBase item) { - return getPresentationName(item); - } - }); - } + override fun createCallerChooser(title: String, treeToReuse: Tree, callback: Consumer>) = + throw UnsupportedOperationException() - private int getTypesMaxLength() { - return getColumnTextMaxLength(new Function, String>() { - @Override - public String fun(ParameterTableModelItemBase item) { - return item.typeCodeFragment == null ? null : item.typeCodeFragment.getText(); - } - }); - } + override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? { + return object : JBTableRowEditor() { + private val components = ArrayList() + private val nameEditor = EditorTextField(item.parameter.getName(), getProject(), getFileType()) - private int getDefaultValuesMaxLength() { - return getColumnTextMaxLength(new Function, String>() { - @Override - public String fun(ParameterTableModelItemBase item) { - return item.defaultValueCodeFragment == null ? null : item.defaultValueCodeFragment.getText(); - } - }); - } - - @Override - protected boolean isListTableViewSupported() { - return true; - } - - @Override - protected boolean isEmptyRow(ParameterTableModelItemBase row) { - if (!StringUtil.isEmpty(row.parameter.getName())) return false; - if (!StringUtil.isEmpty(row.parameter.getTypeText())) return false; - return true; - } - - @Nullable - @Override - protected CallerChooserBase createCallerChooser(String title, Tree treeToReuse, Consumer> callback) { - throw new UnsupportedOperationException(); - } - - @Override - protected JBTableRowEditor getTableEditor(final JTable t, final ParameterTableModelItemBase item) { - return new JBTableRowEditor() { - private final List components = new ArrayList(); - private final EditorTextField nameEditor = new EditorTextField(item.parameter.getName(), getProject(), getFileType());; - - private void updateNameEditor() { - nameEditor.setEnabled(item.parameter != myParametersTableModel.getReceiver()); + private fun updateNameEditor() { + nameEditor.setEnabled(item.parameter != parametersTableModel.getReceiver()) } - private boolean isDefaultColumnEnabled() { - return item.parameter.getIsNewParameter() && item.parameter != myMethod.getReceiver(); - } + private fun isDefaultColumnEnabled() = + item.parameter.isNewParameter && item.parameter != myMethod.receiver - @Override - public void prepareEditor(JTable table, final int row) { - setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - int column = 0; + override fun prepareEditor(table: JTable, row: Int) { + setLayout(BoxLayout(this, BoxLayout.X_AXIS)) + var column = 0 - for (ColumnInfo columnInfo : myParametersTableModel.getColumnInfos()) { - JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false)); - EditorTextField editor = null; - JComponent component; - final int columnFinal = column; + for (columnInfo in parametersTableModel.getColumnInfos()) { + val panel = JPanel(VerticalFlowLayout(VerticalFlowLayout.TOP, 4, 2, true, false)) + val editor: EditorTextField? + val component: JComponent + val columnFinal = column if (JetCallableParameterTableModel.isTypeColumn(columnInfo)) { - Document document = PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment); - component = editor = new EditorTextField(document, getProject(), getFileType()); + val document = PsiDocumentManager.getInstance(getProject()).getDocument(item.typeCodeFragment) + editor = EditorTextField(document, getProject(), getFileType()) + component = editor } else if (JetCallableParameterTableModel.isNameColumn(columnInfo)) { - component = editor = nameEditor; - updateNameEditor(); + editor = nameEditor + component = editor + updateNameEditor() } else if (JetCallableParameterTableModel.isDefaultValueColumn(columnInfo) && isDefaultColumnEnabled()) { - Document document = PsiDocumentManager.getInstance(getProject()).getDocument(item.defaultValueCodeFragment); - component = editor = new EditorTextField(document, getProject(), getFileType()); + val document = PsiDocumentManager.getInstance(getProject()).getDocument(item.defaultValueCodeFragment) + editor = EditorTextField(document, getProject(), getFileType()) + component = editor } else if (JetPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) { - JComboBox comboBox = new JComboBox(JetValVar.values()); - comboBox.setSelectedItem(item.parameter.getValOrVar()); - comboBox.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - myParametersTableModel.setValueAtWithoutUpdate(e.getItem(), row, columnFinal); - updateSignature(); + val comboBox = JComboBox(JetValVar.values()) + comboBox.setSelectedItem(item.parameter.valOrVar) + comboBox.addItemListener(object : ItemListener { + override fun itemStateChanged(e: ItemEvent) { + parametersTableModel.setValueAtWithoutUpdate(e.getItem(), row, columnFinal) + updateSignature() } - }); - component = comboBox; + }) + component = comboBox + editor = null } else if (JetFunctionParameterTableModel.isReceiverColumn(columnInfo)) { - JCheckBox checkBox = new JCheckBox(); - checkBox.setSelected(myParametersTableModel.getReceiver() == item.parameter); - checkBox.addItemListener( - new ItemListener() { - @Override - public void itemStateChanged(@NotNull ItemEvent e) { - ((JetFunctionParameterTableModel)myParametersTableModel).setReceiver( - e.getStateChange() == ItemEvent.SELECTED ? item.parameter : null - ); - updateSignature(); - updateNameEditor(); - } - } - ); - component = checkBox; + val checkBox = JCheckBox() + checkBox.setSelected(parametersTableModel.getReceiver() == item.parameter) + checkBox.addItemListener { + val newReceiver = if (it.getStateChange() == ItemEvent.SELECTED) item.parameter else null + (parametersTableModel as JetFunctionParameterTableModel).setReceiver(newReceiver) + updateSignature() + updateNameEditor() + } + component = checkBox + editor = null } else - continue; + continue - JBLabel label = new JBLabel(columnInfo.getName(), UIUtil.ComponentStyle.SMALL); - panel.add(label); + val label = JBLabel(columnInfo.getName(), UIUtil.ComponentStyle.SMALL) + panel.add(label) if (editor != null) { - editor.addDocumentListener(new DocumentAdapter() { - @Override - public void documentChanged(DocumentEvent e) { - fireDocumentChanged(e, columnFinal); - } - }); - editor.setPreferredWidth(t.getWidth() / myParametersTableModel.getColumnCount()); + editor.addDocumentListener( + object : DocumentAdapter() { + override fun documentChanged(e: DocumentEvent?) { + fireDocumentChanged(e, columnFinal) + } + } + ) + editor.setPreferredWidth(table.getWidth() / parametersTableModel.getColumnCount()) } - components.add(component); - panel.add(component); - add(panel); - IJSwingUtilities.adjustComponentsOnMac(label, component); - column++; + components.add(component) + panel.add(component) + add(panel) + IJSwingUtilities.adjustComponentsOnMac(label, component) + column++ } } - @Override - public JBTableRow getValue() { - return new JBTableRow() { - @Override - public Object getValueAt(int column) { - ColumnInfo columnInfo = myParametersTableModel.getColumnInfos()[column]; + override fun getValue(): JBTableRow { + return object : JBTableRow { + override fun getValueAt(column: Int): Any? { + val columnInfo = parametersTableModel.getColumnInfos()[column] if (JetPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) - return ((JComboBox) components.get(column)).getSelectedItem(); + return (components.get(column) as JComboBox).getSelectedItem() else if (JetCallableParameterTableModel.isTypeColumn(columnInfo)) - return item.typeCodeFragment; + return item.typeCodeFragment else if (JetCallableParameterTableModel.isNameColumn(columnInfo)) - return ((EditorTextField) components.get(column)).getText(); + return (components.get(column) as EditorTextField).getText() else if (JetCallableParameterTableModel.isDefaultValueColumn(columnInfo)) - return item.defaultValueCodeFragment; + return item.defaultValueCodeFragment else - return null; + return null } - }; + } } - private int getColumnWidth(int letters) { - Font font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN); - font = new Font(font.getFontName(), font.getStyle(), 12); - return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W"); + private fun getColumnWidth(letters: Int): Int { + var font = EditorColorsManager.getInstance().getGlobalScheme().getFont(EditorFontType.PLAIN) + font = Font(font.getFontName(), font.getStyle(), 12) + return letters * Toolkit.getDefaultToolkit().getFontMetrics(font).stringWidth("W") } - private int getEditorIndex(int x) { - int[] columnLetters = isDefaultColumnEnabled() ? - new int[] { 4, getParamNamesMaxLength(), getTypesMaxLength(), getDefaultValuesMaxLength() } : - new int[] { 4, getParamNamesMaxLength(), getTypesMaxLength() }; - int columnIndex = 0; + private fun getEditorIndex(x: Int): Int { + @suppress("NAME_SHADOWING") var x = x - for (int i = myMethod.getKind() == Kind.PRIMARY_CONSTRUCTOR ? 0 : 1; i < columnLetters.length; i ++) { - int width = getColumnWidth(columnLetters[i]); + val columnLetters = if (isDefaultColumnEnabled()) + intArrayOf(4, getParamNamesMaxLength(), getTypesMaxLength(), getDefaultValuesMaxLength()) + else + intArrayOf(4, getParamNamesMaxLength(), getTypesMaxLength()) + + var columnIndex = 0 + for (i in (if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 0 else 1)..columnLetters.size() - 1) { + val width = getColumnWidth(columnLetters[i]) if (x <= width) - return columnIndex; + return columnIndex - columnIndex ++; - x -= width; + columnIndex++ + x -= width } - return columnIndex - 1; + return columnIndex - 1 } - @Override - public JComponent getPreferredFocusedComponent() { - MouseEvent me = getMouseEvent(); - int index = me != null - ? getEditorIndex((int) me.getPoint().getX()) - : myMethod.getKind() == Kind.PRIMARY_CONSTRUCTOR ? 1 : 0; - JComponent component = components.get(index); - return component instanceof EditorTextField ? ((EditorTextField) component).getFocusTarget() : component; + override fun getPreferredFocusedComponent(): JComponent { + val me = getMouseEvent() + val index = if (me != null) + getEditorIndex(me.getPoint().getX().toInt()) + else if (myMethod.kind === Kind.PRIMARY_CONSTRUCTOR) 1 else 0 + val component = components.get(index) + return if (component is EditorTextField) component.getFocusTarget() else component } - @Override - public JComponent[] getFocusableComponents() { - JComponent[] focusable = new JComponent[components.size()]; + override fun getFocusableComponents(): Array { + return Array(components.size()) { + val component = components.get(it) + (component as? EditorTextField)?.getFocusTarget() ?: component + } + } + } + } - for (int i = 0; i < components.size(); i++) { - focusable[i] = components.get(i); + override fun calculateSignature(): String { + val changeInfo = evaluateChangeInfo(parametersTableModel, + myReturnTypeCodeFragment, + getMethodDescriptor(), + getVisibility(), + getMethodName(), + myDefaultValueContext) + return changeInfo.getNewSignature(getMethodDescriptor().originalPrimaryCallable) + } - if (focusable[i] instanceof EditorTextField) - focusable[i] = ((EditorTextField) focusable[i]).getFocusTarget(); + override fun createVisibilityControl() = ComboBoxVisibilityPanel( + arrayOf(Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC) + ) + + override fun updateSignatureAlarmFired() { + super.updateSignatureAlarmFired() + validateButtons() + } + + override fun validateAndCommitData() = null + + override fun canRun() { + if (myNamePanel.isVisible() + && myMethod.canChangeName() + && !JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(getMethodName())) { + throw ConfigurationException(JetRefactoringBundle.message("function.name.is.invalid")) + } + + if (myMethod.canChangeReturnType() === MethodDescriptor.ReadWriteOption.ReadWrite && getReturnType() == null) { + throw ConfigurationException(JetRefactoringBundle.message("return.type.is.invalid")) + } + + val parameterInfos = parametersTableModel.getItems() + + for (item in parameterInfos) { + val parameterName = item.parameter.getName() + + if (item.parameter != parametersTableModel.getReceiver() + && !JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(parameterName)) { + throw ConfigurationException(JetRefactoringBundle.message("parameter.name.is.invalid", parameterName)) + } + + if (getType(item.typeCodeFragment as JetTypeCodeFragment) == null) { + throw ConfigurationException(JetRefactoringBundle.message("parameter.type.is.invalid", item.typeCodeFragment.getText())) + } + } + } + + override fun createRefactoringProcessor(): BaseRefactoringProcessor { + val changeInfo = evaluateChangeInfo(parametersTableModel, + myReturnTypeCodeFragment, + getMethodDescriptor(), + getVisibility(), + getMethodName(), + myDefaultValueContext) + return JetChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle()) + } + + public fun getMethodDescriptor(): JetMethodDescriptor = myMethod + + override fun getSelectedIdx(): Int { + return myMethod.getParameters().withIndex().firstOrNull { it.value.isNewParameter }?.index + ?: super.getSelectedIdx() + } + + companion object { + private fun createParametersInfoModel(descriptor: JetMethodDescriptor, defaultValueContext: PsiElement): JetCallableParameterTableModel { + return when (descriptor.kind) { + JetMethodDescriptor.Kind.FUNCTION -> JetFunctionParameterTableModel(descriptor, defaultValueContext) + JetMethodDescriptor.Kind.PRIMARY_CONSTRUCTOR -> JetPrimaryConstructorParameterTableModel(descriptor, defaultValueContext) + JetMethodDescriptor.Kind.SECONDARY_CONSTRUCTOR -> JetSecondaryConstructorParameterTableModel(descriptor, defaultValueContext) + } + } + + private fun createReturnTypeCodeFragment(project: Project, method: JetMethodDescriptor) = + JetPsiFactory(project).createTypeCodeFragment(method.renderOriginalReturnType(), method.baseDeclaration) + + private fun getType(typeCodeFragment: JetTypeCodeFragment?) = typeCodeFragment?.getType() + + public fun createRefactoringProcessorForSilentChangeSignature(project: Project, + commandName: String, + method: JetMethodDescriptor, + defaultValueContext: PsiElement): BaseRefactoringProcessor { + val parameterTableModel = createParametersInfoModel(method, defaultValueContext) + parameterTableModel.setParameterInfos(method.getParameters()) + val changeInfo = evaluateChangeInfo(parameterTableModel, + createReturnTypeCodeFragment(project, method), + method, + method.getVisibility(), + method.getName(), + defaultValueContext) + return JetChangeSignatureProcessor(project, changeInfo, commandName) + } + + private fun evaluateChangeInfo(parametersModel: JetCallableParameterTableModel, + returnTypeCodeFragment: PsiCodeFragment?, + methodDescriptor: JetMethodDescriptor, + visibility: Visibility, + methodName: String, + defaultValueContext: PsiElement): JetChangeInfo { + val parameters = parametersModel.getItems().map { parameter -> + val parameterInfo = parameter.parameter + + parameterInfo.currentTypeText = parameter.typeCodeFragment.getText().trim() + val codeFragment = parameter.defaultValueCodeFragment as JetExpressionCodeFragment + val oldDefaultValue = parameterInfo.defaultValueForCall + if (codeFragment.getText() != (if (oldDefaultValue != null) oldDefaultValue.getText() else "")) { + parameterInfo.defaultValueForCall = codeFragment.getContentElement() } - return focusable; + parameterInfo } - }; - } - @Override - protected String calculateSignature() { - JetChangeInfo changeInfo = evaluateChangeInfo( - myParametersTableModel, - myReturnTypeCodeFragment, - getMethodDescriptor(), - getVisibility(), - getMethodName(), - myDefaultValueContext - ); - return changeInfo.getNewSignature(getMethodDescriptor().getOriginalPrimaryCallable()); - } - - @Override - protected VisibilityPanelBase createVisibilityControl() { - return new ComboBoxVisibilityPanel(new Visibility[]{ - Visibilities.INTERNAL, Visibilities.PRIVATE, Visibilities.PROTECTED, Visibilities.PUBLIC } - ); - } - - @Override - protected void updateSignatureAlarmFired() { - super.updateSignatureAlarmFired(); - validateButtons(); - } - - @Nullable - @Override - protected String validateAndCommitData() { - return null; - } - - @Override - protected void canRun() throws ConfigurationException { - if (myNamePanel.isVisible() && myMethod.canChangeName() && !JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(getMethodName())) - throw new ConfigurationException(JetRefactoringBundle.message("function.name.is.invalid")); - if (myMethod.canChangeReturnType() == MethodDescriptor.ReadWriteOption.ReadWrite && getReturnType() == null) - throw new ConfigurationException(JetRefactoringBundle.message("return.type.is.invalid")); - - List> parameterInfos = myParametersTableModel.getItems(); - - for (ParameterTableModelItemBase item : parameterInfos) { - String parameterName = item.parameter.getName(); - - if (item.parameter != myParametersTableModel.getReceiver() - && !JavaPsiFacade.getInstance(myProject).getNameHelper().isIdentifier(parameterName)) - throw new ConfigurationException(JetRefactoringBundle.message("parameter.name.is.invalid", parameterName)); - if (getType((JetTypeCodeFragment) item.typeCodeFragment) == null) - throw new ConfigurationException(JetRefactoringBundle.message("parameter.type.is.invalid", item.typeCodeFragment.getText())); + val returnTypeText = if (returnTypeCodeFragment != null) returnTypeCodeFragment.getText().trim() else "" + val returnType = getType(returnTypeCodeFragment as JetTypeCodeFragment?) + return JetChangeInfo(methodDescriptor.original, + methodName, + returnType, + returnTypeText, + visibility, + parameters, + parametersModel.getReceiver(), + defaultValueContext) } } - - @Override - @NotNull - protected BaseRefactoringProcessor createRefactoringProcessor() { - JetChangeInfo changeInfo = evaluateChangeInfo( - myParametersTableModel, - myReturnTypeCodeFragment, - getMethodDescriptor(), - getVisibility(), - getMethodName(), - myDefaultValueContext - ); - return new JetChangeSignatureProcessor(myProject, changeInfo, commandName != null ? commandName : getTitle()); - } - - @NotNull - public static BaseRefactoringProcessor createRefactoringProcessorForSilentChangeSignature( - @NotNull Project project, - @NotNull String commandName, - @NotNull JetMethodDescriptor method, - @NotNull PsiElement defaultValueContext - ) { - JetCallableParameterTableModel parameterTableModel = createParametersInfoModel(method, defaultValueContext); - parameterTableModel.setParameterInfos(method.getParameters()); - JetChangeInfo changeInfo = evaluateChangeInfo( - parameterTableModel, - createReturnTypeCodeFragment(project, method), - method, - method.getVisibility(), - method.getName(), - defaultValueContext - ); - return new JetChangeSignatureProcessor(project, changeInfo, commandName); - } - - @NotNull - public JetMethodDescriptor getMethodDescriptor() { - return myMethod; - } - - private static JetChangeInfo evaluateChangeInfo( - @NotNull JetCallableParameterTableModel parametersModel, - @Nullable PsiCodeFragment returnTypeCodeFragment, - @NotNull JetMethodDescriptor methodDescriptor, - @Nullable Visibility visibility, - @NotNull String methodName, - @NotNull PsiElement defaultValueContext - ) { - List parameters = new ArrayList(parametersModel.getRowCount()); - - for (ParameterTableModelItemBase parameter : parametersModel.getItems()) { - parameter.parameter.setCurrentTypeText(parameter.typeCodeFragment.getText().trim()); - - parameters.add(parameter.parameter); - - JetExpressionCodeFragment codeFragment = (JetExpressionCodeFragment) parameter.defaultValueCodeFragment; - JetExpression oldDefaultValue = parameter.parameter.getDefaultValueForCall(); - if (!codeFragment.getText().equals(oldDefaultValue != null ? oldDefaultValue.getText() : "")) { - parameter.parameter.setDefaultValueForCall(codeFragment.getContentElement()); - } - } - - String returnTypeText = returnTypeCodeFragment != null ? returnTypeCodeFragment.getText().trim() : ""; - JetType returnType = getType((JetTypeCodeFragment) returnTypeCodeFragment); - return new JetChangeInfo(methodDescriptor.getOriginal(), methodName, returnType, returnTypeText, - visibility, parameters, parametersModel.getReceiver(), defaultValueContext); - } - - @Override - protected int getSelectedIdx() { - List parameters = myMethod.getParameters(); - for (int i = 0; i < parameters.size(); i++) { - JetParameterInfo info = parameters.get(i); - if (info.getIsNewParameter()) return i; - } - return super.getSelectedIdx(); - } } From e8f5a2db7caa9defefb1b1ba313c6dfad7c2ea7e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 9 Jul 2015 20:26:45 +0300 Subject: [PATCH 174/450] Minor: Fix compilation-breaking nullability issues --- .../changeSignature/JetChangeSignatureProcessor.kt | 3 ++- .../changeSignature/ui/JetChangeSignatureDialog.kt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt index 9018f70e4b6..78b4af28e32 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt @@ -29,6 +29,7 @@ import com.intellij.refactoring.rename.RenameUtil import com.intellij.usageView.UsageInfo import com.intellij.usageView.UsageViewDescriptor import com.intellij.util.containers.MultiMap +import org.jetbrains.annotations.NotNull import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetUsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos import java.util.* @@ -101,7 +102,7 @@ public class JetChangeSignatureProcessor(project: Project, return true } - override fun isPreviewUsages(usages: Array?) = isPreviewUsages() + override fun isPreviewUsages(NotNull usages: Array): Boolean = isPreviewUsages() override fun getCommandName() = commandName } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt index f2d89067473..b18bd7add18 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt @@ -406,7 +406,7 @@ public class JetChangeSignatureDialog( private fun evaluateChangeInfo(parametersModel: JetCallableParameterTableModel, returnTypeCodeFragment: PsiCodeFragment?, methodDescriptor: JetMethodDescriptor, - visibility: Visibility, + visibility: Visibility?, methodName: String, defaultValueContext: PsiElement): JetChangeInfo { val parameters = parametersModel.getItems().map { parameter -> @@ -428,7 +428,7 @@ public class JetChangeSignatureDialog( methodName, returnType, returnTypeText, - visibility, + visibility ?: Visibilities.INTERNAL, parameters, parametersModel.getReceiver(), defaultValueContext) From 8104b899aa5abc1d792b26820808d3025ceb9964 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 11 Jun 2015 16:33:09 +0300 Subject: [PATCH 175/450] Find Usages: Unify usage highlighting and full usage search --- .../handlers/KotlinFindUsagesHandler.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java index 14761483af2..fc38d063080 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java @@ -28,8 +28,10 @@ import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.List; public abstract class KotlinFindUsagesHandler extends FindUsagesHandler { private final KotlinFindUsagesHandlerFactory factory; @@ -115,4 +117,26 @@ public abstract class KotlinFindUsagesHandler extends Find protected abstract boolean searchReferences( @NotNull PsiElement element, @NotNull Processor processor, @NotNull FindUsagesOptions options ); + + @NotNull + @Override + public Collection findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope + ) { + final List results = new ArrayList(); + FindUsagesOptions options = getFindUsagesOptions(); + options.searchScope = searchScope; + searchReferences(target, + new Processor() { + @Override + public boolean process(UsageInfo info) { + PsiReference reference = info.getReference(); + if (reference != null) { + results.add(reference); + } + return true; + } + }, + options); + return results; + } } From 46dcfb508e9f28ee65709fea471a10867720f789 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 8 Jul 2015 17:08:07 +0300 Subject: [PATCH 176/450] Call Hierarchy: Find implicit constructor calls in Java code --- .../calls/KotlinCallerMethodsTreeStructure.java | 15 ++++++++++++++- ...imaryConstructorImplicitCalls_verification.xml | 4 ++++ .../main0.kt | 7 +++++++ .../main1.java | 5 +++++ ...ndaryConstructorImplicitCalls_verification.xml | 4 ++++ .../main0.kt | 11 +++++++++++ .../main1.java | 5 +++++ .../idea/hierarchy/HierarchyTestGenerated.java | 12 ++++++++++++ 8 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/KotlinPrimaryConstructorImplicitCalls_verification.xml create mode 100644 idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main0.kt create mode 100644 idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main1.java create mode 100644 idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/KotlinSecondaryConstructorImplicitCalls_verification.xml create mode 100644 idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main0.kt create mode 100644 idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main1.java diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java index 6a7770892e1..5ae8945ba0e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java @@ -23,6 +23,7 @@ import com.intellij.openapi.application.ReadActionProcessor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.psi.*; +import com.intellij.psi.impl.light.LightMemberReference; import com.intellij.psi.search.SearchScope; import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.search.searches.ReferencesSearch; @@ -114,7 +115,14 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure { processPsiMethodCallers(propertyMethods, descriptor, methodToDescriptorMap, searchScope, false); } if (element instanceof JetClassOrObject) { - processJetClassOrObjectCallers((JetClassOrObject) element, descriptor, methodToDescriptorMap, searchScope); + JetPrimaryConstructor constructor = ((JetClassOrObject) element).getPrimaryConstructor(); + if (constructor != null) { + PsiMethod lightMethod = LightClassUtil.getLightClassMethod(constructor); + processPsiMethodCallers(Collections.singleton(lightMethod), descriptor, methodToDescriptorMap, searchScope, false); + } + else { + processJetClassOrObjectCallers((JetClassOrObject) element, descriptor, methodToDescriptorMap, searchScope); + } } Object[] callers = methodToDescriptorMap.values().toArray(new Object[methodToDescriptorMap.size()]); @@ -205,6 +213,11 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure { return true; } } + else if (ref instanceof LightMemberReference) { + PsiElement refTarget = ref.resolve(); + // Accept implicit superclass constructor reference in Java code + if (!(refTarget instanceof PsiMethod && ((PsiMethod) refTarget).isConstructor())) return true; + } PsiElement refElement = ref.getElement(); if (PsiTreeUtil.getParentOfType(refElement, JetImportDirective.class, true) != null) return true; diff --git a/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/KotlinPrimaryConstructorImplicitCalls_verification.xml b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/KotlinPrimaryConstructorImplicitCalls_verification.xml new file mode 100644 index 00000000000..02133749cb7 --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/KotlinPrimaryConstructorImplicitCalls_verification.xml @@ -0,0 +1,4 @@ + + + + diff --git a/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main0.kt b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main0.kt new file mode 100644 index 00000000000..eca85407e5f --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main0.kt @@ -0,0 +1,7 @@ +open class B() + +open class A : B { + constructor(a: Int) { + + } +} \ No newline at end of file diff --git a/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main1.java b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main1.java new file mode 100644 index 00000000000..79760d15bba --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/main1.java @@ -0,0 +1,5 @@ +class JJ extends B { + JJ() { + + } +} \ No newline at end of file diff --git a/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/KotlinSecondaryConstructorImplicitCalls_verification.xml b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/KotlinSecondaryConstructorImplicitCalls_verification.xml new file mode 100644 index 00000000000..5178b80ff8d --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/KotlinSecondaryConstructorImplicitCalls_verification.xml @@ -0,0 +1,4 @@ + + + + diff --git a/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main0.kt b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main0.kt new file mode 100644 index 00000000000..57a5fdc0aa5 --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main0.kt @@ -0,0 +1,11 @@ +open class B { + constructor() { + + } +} + +open class A : B { + constructor(a: Int) { + + } +} \ No newline at end of file diff --git a/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main1.java b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main1.java new file mode 100644 index 00000000000..79760d15bba --- /dev/null +++ b/idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/main1.java @@ -0,0 +1,5 @@ +class JJ extends B { + JJ() { + + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/hierarchy/HierarchyTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/hierarchy/HierarchyTestGenerated.java index 5ee8df26e60..9822367de34 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/hierarchy/HierarchyTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/hierarchy/HierarchyTestGenerated.java @@ -358,6 +358,12 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest { doCallerHierarchyTest(fileName); } + @TestMetadata("kotlinPrimaryConstructorImplicitCalls") + public void testKotlinPrimaryConstructorImplicitCalls() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinPrimaryConstructorImplicitCalls/"); + doCallerHierarchyTest(fileName); + } + @TestMetadata("kotlinPrivateClass") public void testKotlinPrivateClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinPrivateClass/"); @@ -388,6 +394,12 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest { doCallerHierarchyTest(fileName); } + @TestMetadata("kotlinSecondaryConstructorImplicitCalls") + public void testKotlinSecondaryConstructorImplicitCalls() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinSecondaryConstructorImplicitCalls/"); + doCallerHierarchyTest(fileName); + } + @TestMetadata("kotlinUnresolvedFunction") public void testKotlinUnresolvedFunction() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/hierarchy/calls/callers/kotlinUnresolvedFunction/"); From 98539340870db02a7fe6b46343467091adb78f94 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 3 Jul 2015 18:26:12 +0300 Subject: [PATCH 177/450] Change Signature: Implement parameter propagation UI #KT-7902 In progress --- .../KotlinCallHierarchyNodeDescriptor.java | 2 +- .../KotlinCallerMethodsTreeStructure.java | 95 +++++++------ .../ui/JetChangeSignatureDialog.kt | 4 +- .../changeSignature/ui/KotlinCallerChooser.kt | 126 ++++++++++++++++++ 4 files changed, 184 insertions(+), 43 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallHierarchyNodeDescriptor.java b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallHierarchyNodeDescriptor.java index 5ef28e6f5e9..b0a8ebda856 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallHierarchyNodeDescriptor.java +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallHierarchyNodeDescriptor.java @@ -211,7 +211,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i return containerText != null ? containerText + "." + elementText : elementText; } - private static String renderNamedFunction(FunctionDescriptor descriptor) { + public static String renderNamedFunction(FunctionDescriptor descriptor) { DeclarationDescriptor descriptorForName = descriptor instanceof ConstructorDescriptor ? descriptor.getContainingDeclaration() : descriptor; diff --git a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java index 5ae8945ba0e..df1604e4ec7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java +++ b/idea/src/org/jetbrains/kotlin/idea/hierarchy/calls/KotlinCallerMethodsTreeStructure.java @@ -187,29 +187,39 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure { private Processor defaultQueryProcessor( final HierarchyNodeDescriptor descriptor, final Map methodToDescriptorMap, - final boolean kotlinOnly + boolean kotlinOnly ) { - return new ReadActionProcessor() { + return new CalleeReferenceProcessor(kotlinOnly) { @Override - public boolean processInReadAction(PsiReference ref) { - // copied from Java - if (!(ref instanceof PsiReferenceExpression || ref instanceof JetReference)) { - if (!(ref instanceof PsiElement)) { + protected void onAccept(@NotNull PsiReference ref, @NotNull PsiElement element) { + addNodeDescriptorForElement(ref, element, methodToDescriptorMap, descriptor); + } + }; + } + + public static abstract class CalleeReferenceProcessor extends ReadActionProcessor { + private final boolean kotlinOnly; + + public CalleeReferenceProcessor(boolean only) { + kotlinOnly = only; + } + + @Override + public boolean processInReadAction(PsiReference ref) { + // copied from Java + if (!(ref instanceof PsiReferenceExpression || ref instanceof JetReference)) { + if (!(ref instanceof PsiElement)) { + return true; + } + + PsiElement parent = ((PsiElement) ref).getParent(); + if (parent instanceof PsiNewExpression) { + if (((PsiNewExpression) parent).getClassReference() != ref) { return true; } - - PsiElement parent = ((PsiElement) ref).getParent(); - if (parent instanceof PsiNewExpression) { - if (((PsiNewExpression) parent).getClassReference() != ref) { - return true; - } - } - else if (parent instanceof PsiAnonymousClass) { - if (((PsiAnonymousClass) parent).getBaseClassReference() != ref) { - return true; - } - } - else { + } + else if (parent instanceof PsiAnonymousClass) { + if (((PsiAnonymousClass) parent).getBaseClassReference() != ref) { return true; } } @@ -218,28 +228,33 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure { // Accept implicit superclass constructor reference in Java code if (!(refTarget instanceof PsiMethod && ((PsiMethod) refTarget).isConstructor())) return true; } - - PsiElement refElement = ref.getElement(); - if (PsiTreeUtil.getParentOfType(refElement, JetImportDirective.class, true) != null) return true; - - PsiElement element = HierarchyUtils.getCallHierarchyElement(refElement); - - if (kotlinOnly && !(element instanceof JetNamedDeclaration)) return true; - - // If reference belongs to property initializer, show enclosing declaration instead - if (element instanceof JetProperty) { - JetProperty property = (JetProperty) element; - if (PsiTreeUtil.isAncestor(property.getInitializer(), refElement, false)) { - element = HierarchyUtils.getCallHierarchyElement(element.getParent()); - } + else { + return true; } - - if (element != null) { - addNodeDescriptorForElement(ref, element, methodToDescriptorMap, descriptor); - } - - return true; } - }; + + PsiElement refElement = ref.getElement(); + if (PsiTreeUtil.getParentOfType(refElement, JetImportDirective.class, true) != null) return true; + + PsiElement element = HierarchyUtils.getCallHierarchyElement(refElement); + + if (kotlinOnly && !(element instanceof JetNamedDeclaration)) return true; + + // If reference belongs to property initializer, show enclosing declaration instead + if (element instanceof JetProperty) { + JetProperty property = (JetProperty) element; + if (PsiTreeUtil.isAncestor(property.getInitializer(), refElement, false)) { + element = HierarchyUtils.getCallHierarchyElement(element.getParent()); + } + } + + if (element != null) { + onAccept(ref, element); + } + + return true; + } + + protected abstract void onAccept(@NotNull PsiReference ref, @NotNull PsiElement element); } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt index b18bd7add18..3c6d9d51f3b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt @@ -155,8 +155,8 @@ public class JetChangeSignatureDialog( return true } - override fun createCallerChooser(title: String, treeToReuse: Tree, callback: Consumer>) = - throw UnsupportedOperationException() + override fun createCallerChooser(title: String, treeToReuse: Tree?, callback: Consumer>) = + KotlinCallerChooser(myMethod.getMethod(), myProject, title, treeToReuse, callback) override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? { return object : JBTableRowEditor() { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt new file mode 100644 index 00000000000..7c71b4f010a --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt @@ -0,0 +1,126 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature.ui + +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiClassOwner +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiReference +import com.intellij.psi.search.searches.MethodReferencesSearch +import com.intellij.psi.search.searches.ReferencesSearch +import com.intellij.refactoring.changeSignature.CallerChooserBase +import com.intellij.refactoring.changeSignature.MethodNodeBase +import com.intellij.ui.ColoredTreeCellRenderer +import com.intellij.ui.JBColor +import com.intellij.ui.SimpleTextAttributes +import com.intellij.ui.treeStructure.Tree +import com.intellij.util.Consumer +import com.intellij.util.containers +import com.intellij.util.ui.UIUtil +import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod +import org.jetbrains.kotlin.asJava.namedUnwrappedElement +import org.jetbrains.kotlin.asJava.toLightMethods +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor +import org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallHierarchyNodeDescriptor +import org.jetbrains.kotlin.idea.hierarchy.calls.KotlinCallerMethodsTreeStructure +import org.jetbrains.kotlin.psi.JetClass +import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext +import java.util.HashSet +import java.util.LinkedHashSet + +public class KotlinCallerChooser( + declaration: PsiElement, + project: Project, + title: String, + previousTree: Tree?, + callback: Consumer> +): CallerChooserBase(declaration, project, title, previousTree, "dummy." + JetFileType.EXTENSION, callback) { + override fun createTreeNode(method: PsiElement?, called: containers.HashSet, cancelCallback: Runnable): KotlinMethodNode { + return KotlinMethodNode(method, called, myProject, cancelCallback) + } + + override fun findDeepestSuperMethods(method: PsiElement) = + method.toLightMethods().singleOrNull()?.findDeepestSuperMethods() + + override fun getEmptyCallerText() = + "Caller text \nwith highlighted callee call would be shown here" + + override fun getEmptyCalleeText() = + "Callee text would be shown here" +} + +public class KotlinMethodNode( + method: PsiElement?, + called: HashSet, + project: Project, + cancelCallback: Runnable +): MethodNodeBase(method?.namedUnwrappedElement ?: method, called, project, cancelCallback) { + override fun createNode(caller: PsiElement, called: HashSet) = + KotlinMethodNode(caller, called, myProject, myCancelCallback) + + override fun customizeRendererText(renderer: ColoredTreeCellRenderer) { + val descriptor = when (myMethod) { + is JetFunction -> myMethod.resolveToDescriptor() as FunctionDescriptor + is JetClass -> (myMethod.resolveToDescriptor() as ClassDescriptor).getUnsubstitutedPrimaryConstructor() ?: return + is PsiMethod -> myMethod.getJavaMethodDescriptor() + else -> throw AssertionError("Invalid declaration: ${myMethod.getElementTextWithContext()}") + } + val containerName = sequence(descriptor) { it.getContainingDeclaration() } + .firstOrNull { it is ClassDescriptor } + ?.getName() + + val renderedFunction = KotlinCallHierarchyNodeDescriptor.renderNamedFunction(descriptor) + val renderedFunctionWithContainer = + containerName?.let { + "${if (it.isSpecial()) "[Anonymous]" else it.asString()}.$renderedFunction" + } ?: renderedFunction + + val attributes = if (isEnabled()) + SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, UIUtil.getTreeForeground()) + else + SimpleTextAttributes.EXCLUDED_ATTRIBUTES + renderer.append(renderedFunctionWithContainer, attributes) + + val packageName = (myMethod.getContainingFile() as? PsiClassOwner)?.getPackageName() ?: "" + renderer.append(" ($packageName)", SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, JBColor.GRAY)) + } + + override fun computeCallers(): List { + if (myMethod == null) return emptyList() + + val callers = LinkedHashSet() + + val processor = object: KotlinCallerMethodsTreeStructure.CalleeReferenceProcessor(false) { + override fun onAccept(ref: PsiReference, element: PsiElement) { + if ((element is JetFunction || element is JetClass || element is PsiMethod) && element !in myCalled) { + callers.add(element) + } + } + } + val query = myMethod.getRepresentativeLightMethod()?.let { MethodReferencesSearch.search(it, it.getUseScope(), true) } + ?: ReferencesSearch.search(myMethod, myMethod.getUseScope()) + query.forEach { processor.process(it) } + return callers.toList() + } +} \ No newline at end of file From eb7463ed810dc2319adc811957da7825a57facb3 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 3 Jul 2015 18:31:03 +0300 Subject: [PATCH 178/450] Change Signature: Propagate parameters to chosen callers #KT-7902 Fixed --- .../changeSignature/JetChangeInfo.kt | 81 ++++-- .../JetChangeSignatureProcessor.kt | 3 +- .../JetChangeSignatureUsageProcessor.java | 226 +++++++++++++-- .../changeSignature/changeSignatureUtils.kt | 59 ++++ .../ui/JetChangeSignatureDialog.kt | 9 +- .../usages/JavaMethodDeferredKotlinUsage.kt | 40 +-- .../JavaMethodKotlinUsageWithDelegate.kt | 13 +- .../usages/JetCallableDefinitionUsage.java | 3 +- .../JetConstructorDelegationCallUsage.kt | 5 +- .../JetEnumEntryWithoutSuperCallUsage.kt | 5 +- .../usages/JetFunctionCallUsage.java | 25 +- .../usages/JetImplicitThisToParameterUsage.kt | 5 +- .../usages/JetParameterUsage.kt | 3 +- .../usages/JetPropertyCallUsage.kt | 3 +- .../changeSignature/usages/JetUsageInfo.kt | 2 +- .../usages/KotlinCallerUsages.kt | 77 +++++ ...nIntroduceParameterMethodUsageProcessor.kt | 4 +- ...aConstructorParameterPropagationAfter.1.kt | 18 ++ ...aConstructorParameterPropagationAfter.java | 32 +++ ...ConstructorParameterPropagationBefore.1.kt | 18 ++ ...ConstructorParameterPropagationBefore.java | 31 ++ .../JavaParameterPropagationAfter.1.kt | 28 ++ .../JavaParameterPropagationAfter.java | 45 +++ .../JavaParameterPropagationBefore.1.kt | 28 ++ .../JavaParameterPropagationBefore.java | 45 +++ .../ParameterPropagationAfter.1.java | 35 +++ .../ParameterPropagationAfter.kt | 43 +++ .../ParameterPropagationBefore.1.java | 33 +++ .../ParameterPropagationBefore.kt | 43 +++ ...onstructorParameterPropagationAfter.1.java | 22 ++ ...aryConstructorParameterPropagationAfter.kt | 21 ++ ...nstructorParameterPropagationBefore.1.java | 21 ++ ...ryConstructorParameterPropagationBefore.kt | 20 ++ ...PropagateWithParameterDuplicationBefore.kt | 5 + ...pagateWithParameterDuplicationMessages.txt | 1 + ...WithThisQualificationInClassMemberAfter.kt | 7 + ...ithThisQualificationInClassMemberBefore.kt | 7 + ...teWithThisQualificationInExtensionAfter.kt | 7 + ...eWithThisQualificationInExtensionBefore.kt | 7 + .../PropagateWithVariableDuplicationBefore.kt | 7 + ...opagateWithVariableDuplicationMessages.txt | 1 + ...onstructorParameterPropagationAfter.1.java | 22 ++ ...aryConstructorParameterPropagationAfter.kt | 21 ++ ...nstructorParameterPropagationBefore.1.java | 21 ++ ...ryConstructorParameterPropagationBefore.kt | 20 ++ .../JetChangeSignatureTest.java | 264 +++++++++++++++++- 46 files changed, 1334 insertions(+), 102 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt create mode 100644 idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.java create mode 100644 idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.java create mode 100644 idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java create mode 100644 idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.java create mode 100644 idea/testData/refactoring/changeSignature/ParameterPropagationAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/ParameterPropagationAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/ParameterPropagationBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/ParameterPropagationBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationMessages.txt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationBefore.kt create mode 100644 idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationMessages.txt create mode 100644 idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.1.java create mode 100644 idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.kt create mode 100644 idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.1.java create mode 100644 idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 4aa9fd89aa3..d0fd4378a7d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -19,13 +19,14 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import com.intellij.lang.Language import com.intellij.lang.java.JavaLanguage import com.intellij.psi.* -import com.intellij.refactoring.changeSignature.ChangeInfo -import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor -import com.intellij.refactoring.changeSignature.JavaChangeInfo -import com.intellij.refactoring.changeSignature.ParameterInfoImpl +import com.intellij.psi.search.searches.OverridingMethodsSearch +import com.intellij.refactoring.changeSignature.* +import com.intellij.refactoring.util.CanonicalTypes import com.intellij.usageView.UsageInfo import com.intellij.util.VisibilityUtil +import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod import org.jetbrains.kotlin.asJava.toLightMethods +import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.descriptors.CallableDescriptor @@ -37,16 +38,18 @@ import org.jetbrains.kotlin.idea.core.refactoring.j2k import org.jetbrains.kotlin.idea.project.ProjectStructureUtil import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetMethodDescriptor.Kind import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetCallableDefinitionUsage +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallerUsage import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.parameterIndex import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList -import java.util.* +import java.util.ArrayList +import java.util.HashMap +import java.util.LinkedHashSet import kotlin.properties.Delegates public class JetChangeInfo( @@ -57,7 +60,8 @@ public class JetChangeInfo( var newVisibility: Visibility = methodDescriptor.getVisibility(), parameterInfos: List = methodDescriptor.getParameters(), receiver: JetParameterInfo? = methodDescriptor.receiver, - val context: PsiElement + val context: PsiElement, + primaryPropagationTargets: Collection = emptyList() ): ChangeInfo { var receiverParameterInfo: JetParameterInfo? = receiver set(value: JetParameterInfo?) { @@ -148,6 +152,42 @@ public class JetChangeInfo( override fun getLanguage(): Language = JetLanguage.INSTANCE + public var propagationTargetUsageInfos: List = ArrayList() + private set + + public var primaryPropagationTargets: Collection = emptyList() + set(value: Collection) { + $primaryPropagationTargets = value + + val result = LinkedHashSet() + + fun add(element: PsiElement) { + element.unwrapped?.let { + val usageInfo = when (it) { + is JetNamedFunction, is JetConstructor<*>, is JetClassOrObject -> + KotlinCallerUsage(it as JetNamedDeclaration) + is PsiMethod -> + CallerUsageInfo(it, true, true) + else -> + return + } + + result.add(usageInfo) + } + } + + for (caller in value) { + add(caller) + OverridingMethodsSearch.search(caller.getRepresentativeLightMethod() ?: continue).forEach { add(it) } + } + + propagationTargetUsageInfos = result.toList() + } + + init { + this.primaryPropagationTargets = primaryPropagationTargets + } + public fun getNewSignature(inheritedCallable: JetCallableDefinitionUsage): String { val buffer = StringBuilder() @@ -239,13 +279,22 @@ public class JetChangeInfo( VisibilityUtil.getVisibilityModifier(currentPsiMethod.getModifierList()) else PsiModifier.PACKAGE_LOCAL - val javaChangeInfo = ChangeSignatureProcessor(getMethod().getProject(), - originalPsiMethod, - false, - newVisibility, - newName, - newReturnType ?: PsiType.VOID, - newParameters).getChangeInfo() + val propagationTargets = primaryPropagationTargets.asSequence() + .map { it.getRepresentativeLightMethod() } + .filterNotNull() + .toSet() + val javaChangeInfo = ChangeSignatureProcessor( + getMethod().getProject(), + originalPsiMethod, + false, + newVisibility, + newName, + CanonicalTypes.createTypeWrapper(newReturnType ?: PsiType.VOID), + newParameters, + arrayOf(), + propagationTargets, + emptySet() + ).getChangeInfo() javaChangeInfo.updateMethod(currentPsiMethod) return javaChangeInfo @@ -336,7 +385,7 @@ public val JetChangeInfo.kind: Kind get() = methodDescriptor.kind public val JetChangeInfo.oldName: String? get() = (methodDescriptor.getMethod() as? JetFunction)?.getName() -public val JetChangeInfo.affectedFunctions: Collection get() = methodDescriptor.affectedCallables +public fun JetChangeInfo.getAffectedCallables(): Collection = methodDescriptor.affectedCallables + propagationTargetUsageInfos public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMethodDescriptor): JetChangeInfo { val method = getMethod() as PsiMethod @@ -369,7 +418,7 @@ public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMeth name = info.getName(), type = if (oldIndex >= 0) originalParameterDescriptors[oldIndex].getType() else currentType, defaultValueForCall = defaultValueExpr)) { - currentTypeText = IdeDescriptorRenderers.SOURCE_CODE.renderType(currentType) + currentTypeText = IdeDescriptorRenderers.SOURCE_CODE_FOR_TYPE_ARGUMENTS.renderType(currentType) this } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt index 78b4af28e32..7c7e00dcda9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt @@ -26,6 +26,7 @@ import com.intellij.refactoring.changeSignature.ChangeSignatureProcessorBase import com.intellij.refactoring.changeSignature.ChangeSignatureUsageProcessor import com.intellij.refactoring.changeSignature.JavaChangeSignatureUsageProcessor import com.intellij.refactoring.rename.RenameUtil +import com.intellij.refactoring.rename.UnresolvableCollisionUsageInfo import com.intellij.usageView.UsageInfo import com.intellij.usageView.UsageViewDescriptor import com.intellij.util.containers.MultiMap @@ -52,7 +53,7 @@ public class JetChangeSignatureProcessor(project: Project, KotlinWrapperForJavaUsageInfos(it, javaProcessor.findUsages(it), getChangeInfo().getMethod()) } } - super.findUsages().filterIsInstanceTo(allUsages, javaClass>()) + super.findUsages().filterTo(allUsages) { it is JetUsageInfo<*> || it is UnresolvableCollisionUsageInfo } return allUsages.toTypedArray() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index bace90962dd..fd3bd9db57b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -28,6 +28,7 @@ import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.changeSignature.*; import com.intellij.refactoring.rename.ResolveSnapshotProvider; +import com.intellij.refactoring.rename.UnresolvableCollisionUsageInfo; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.refactoring.util.MoveRenameUsageInfo; import com.intellij.refactoring.util.RefactoringUIUtil; @@ -54,6 +55,7 @@ import org.jetbrains.kotlin.idea.core.refactoring.RefactoringPackage; import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.*; import org.jetbrains.kotlin.idea.references.JetSimpleNameReference; import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchPackage; +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.kdoc.psi.impl.KDocName; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.name.Name; @@ -68,6 +70,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; @@ -80,6 +83,8 @@ import java.util.*; public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsageProcessor { @Override public UsageInfo[] findUsages(ChangeInfo info) { + originalJavaMethodDescriptor = null; + Set result = new HashSet(); if (info instanceof JetChangeInfo) { @@ -89,19 +94,29 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro findSAMUsages(info, result); findConstructorDelegationUsages(info, result); findKotlinOverrides(info, result); + if (info instanceof JavaChangeInfo) { + findKotlinCallers((JavaChangeInfo) info, result); + } } return result.toArray(new UsageInfo[result.size()]); } private static void findAllMethodUsages(JetChangeInfo changeInfo, Set result) { - for (UsageInfo functionUsageInfo : ChangeSignaturePackage.getAffectedFunctions(changeInfo)) { + for (UsageInfo functionUsageInfo : ChangeSignaturePackage.getAffectedCallables(changeInfo)) { if (functionUsageInfo instanceof JetCallableDefinitionUsage) { findOneMethodUsages((JetCallableDefinitionUsage) functionUsageInfo, changeInfo, result); } + else if (functionUsageInfo instanceof KotlinCallerUsage) { + findCallerUsages((KotlinCallerUsage) functionUsageInfo, changeInfo, result); + } else { result.add(functionUsageInfo); + boolean propagationTarget = functionUsageInfo instanceof CallerUsageInfo + || (functionUsageInfo instanceof OverriderUsageInfo + && !((OverriderUsageInfo) functionUsageInfo).isOriginalOverrider()); + PsiElement callee = functionUsageInfo.getElement(); if (callee == null) continue; @@ -115,13 +130,89 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro JetCallElement callElement = PsiTreeUtil.getParentOfType(element, JetCallElement.class); JetExpression calleeExpression = callElement != null ? callElement.getCalleeExpression() : null; if (calleeExpression != null && PsiTreeUtil.isAncestor(calleeExpression, element, false)) { - result.add(new JetFunctionCallUsage(callElement, changeInfo.getMethodDescriptor().getOriginalPrimaryCallable())); + result.add(propagationTarget + ? new KotlinCallerCallUsage(callElement) + : new JetFunctionCallUsage(callElement, changeInfo.getMethodDescriptor().getOriginalPrimaryCallable())); } } } } } + private static void findCallerUsages(KotlinCallerUsage callerUsage, JetChangeInfo changeInfo, final Set result) { + result.add(callerUsage); + + JetNamedDeclaration element = callerUsage.getElement(); + if (element == null) return; + + for (PsiReference ref : ReferencesSearch.search(element, element.getUseScope())) { + PsiElement refElement = ref.getElement(); + JetCallElement callElement = PsiTreeUtil.getParentOfType(refElement, JetCallElement.class); + if (callElement != null && PsiTreeUtil.isAncestor(callElement.getCalleeExpression(), refElement, false)) { + result.add(new KotlinCallerCallUsage(callElement)); + } + } + + JetElement body = ChangeSignaturePackage.getDeclarationBody(element); + final Set newParameterNames = KotlinPackage.mapTo( + changeInfo.getNonReceiverParameters(), + new HashSet(), + new Function1() { + @Override + public String invoke(JetParameterInfo info) { + return info.getName(); + } + } + ); + if (body != null) { + final DeclarationDescriptor callerDescriptor = ResolvePackage.resolveToDescriptor(element); + final BindingContext context = ResolvePackage.analyze(body); + body.accept( + new JetTreeVisitorVoid() { + @Override + public void visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression) { + final String currentName = expression.getReferencedName(); + if (!newParameterNames.contains(currentName)) return; + + ResolvedCall resolvedCall = CallUtilPackage.getResolvedCall(expression, context); + if (resolvedCall == null) return; + + if (resolvedCall.getExplicitReceiverKind() != ExplicitReceiverKind.NO_EXPLICIT_RECEIVER) return; + + CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor(); + if (!(resultingDescriptor instanceof VariableDescriptor)) return; + + // Do not report usages of duplicated parameter + if (resultingDescriptor instanceof ValueParameterDescriptor + && resultingDescriptor.getContainingDeclaration() == callerDescriptor) return; + + JetElement callElement = resolvedCall.getCall().getCallElement(); + + ReceiverValue receiver = resolvedCall.getExtensionReceiver(); + if (!(receiver instanceof ThisReceiver)) { + receiver = resolvedCall.getDispatchReceiver(); + } + if (receiver instanceof ThisReceiver) { + result.add(new JetImplicitThisUsage(callElement, ((ThisReceiver) receiver).getDeclarationDescriptor())); + } + else if (!receiver.exists()) { + result.add( + new UnresolvableCollisionUsageInfo(callElement, null) { + @Override + public String getDescription() { + return "There is already a variable '" + currentName + "' in " + + IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(callerDescriptor) + + ". It will conflict with the new parameter."; + } + } + ); + } + } + } + ); + } + } + private static void findOneMethodUsages( @NotNull JetCallableDefinitionUsage functionUsageInfo, final JetChangeInfo changeInfo, @@ -269,7 +360,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro result.add(new JetImplicitThisToParameterUsage(callElement, originalReceiverInfo, functionUsageInfo)); } else { - result.add(new JetImplicitOuterThisToQualifiedThisUsage(callElement, targetDescriptor)); + result.add(new JetImplicitThisUsage(callElement, targetDescriptor)); } } @@ -375,6 +466,25 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } } + private static void findKotlinCallers(JavaChangeInfo changeInfo, Set result) { + PsiElement method = changeInfo.getMethod(); + if (!RefactoringPackage.isTrueJavaMethod(method)) return; + + for (PsiMethod primaryCaller : changeInfo.getMethodsToPropagateParameters()) { + addDeferredCallerIfPossible(result, primaryCaller); + for (PsiMethod overridingCaller : OverridingMethodsSearch.search(primaryCaller)) { + addDeferredCallerIfPossible(result, overridingCaller); + } + } + } + + private static void addDeferredCallerIfPossible(Set result, PsiMethod overridingCaller) { + PsiElement unwrappedElement = AsJavaPackage.getNamedUnwrappedElement(overridingCaller); + if (unwrappedElement instanceof JetFunction || unwrappedElement instanceof JetClass) { + result.add(new DeferredJavaMethodKotlinCallerUsage((JetNamedDeclaration) unwrappedElement)); + } + } + private static void findDeferredUsagesOfParameters( ChangeInfo changeInfo, Set result, @@ -408,7 +518,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro javaMethodChangeInfo) { @NotNull @Override - protected JetUsageInfo getDelegateUsage() { + public JetUsageInfo getDelegateUsage() { return new JetParameterUsage((JetElement) element, getJavaMethodChangeInfo().getNewParameters()[paramIndex], functionInfoForParameters); @@ -428,16 +538,15 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro public MultiMap findConflicts(ChangeInfo info, Ref refUsages) { MultiMap result = new MultiMap(); - // Delete OverriderUsageInfo for Kotlin declarations since they can't be processed correctly - // TODO: Drop when OverriderUsageInfo.getElement() gets deleted + // Delete OverriderUsageInfo and CallerUsageInfo for Kotlin declarations since they can't be processed correctly + // TODO (OverriderUsageInfo only): Drop when OverriderUsageInfo.getElement() gets deleted UsageInfo[] usageInfos = refUsages.get(); List adjustedUsages = KotlinPackage.filterNot( usageInfos, new Function1() { @Override public Boolean invoke(UsageInfo info) { - return info instanceof OverriderUsageInfo && - ((OverriderUsageInfo) info).getOverridingMethod() instanceof KotlinLightMethod; + return getOverriderOrCaller(info) instanceof KotlinLightMethod; } } ); @@ -519,9 +628,47 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro findThisLabelConflicts((JetChangeInfo) info, refUsages, result, changeInfo, function); } + for (UsageInfo usageInfo : usageInfos) { + if (!(usageInfo instanceof KotlinCallerUsage)) continue; + + JetNamedDeclaration caller = (JetNamedDeclaration) usageInfo.getElement(); + DeclarationDescriptor callerDescriptor = ResolvePackage.resolveToDescriptor(caller); + + findParameterDuplicationInCaller(result, changeInfo, caller, callerDescriptor); + } + return result; } + private static void findParameterDuplicationInCaller( + MultiMap result, + JetChangeInfo changeInfo, + JetNamedDeclaration caller, + DeclarationDescriptor callerDescriptor + ) { + List valueParameters = PsiUtilPackage.getValueParameters(caller); + Map existingParameters = KotlinPackage.toMap( + valueParameters, + new Function1() { + @Override + public String invoke(JetParameter parameter) { + return parameter.getName(); + } + } + ); + for (JetParameterInfo parameterInfo : changeInfo.getNonReceiverParameters()) { + if (!(parameterInfo.getIsNewParameter())) continue; + + String name = parameterInfo.getName(); + JetParameter parameter = existingParameters.get(name); + if (parameter != null) { + result.putValue(parameter, "There is already a parameter '" + name + "' in " + + IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(callerDescriptor) + + ". It will conflict with the new parameter."); + } + } + } + private static void findThisLabelConflicts( JetChangeInfo info, Ref refUsages, @@ -666,21 +813,24 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro private JetMethodDescriptor originalJavaMethodDescriptor; private static boolean isJavaMethodUsage(UsageInfo usageInfo) { - if (usageInfo instanceof JavaMethodDeferredKotlinUsage) return true; - // MoveRenameUsageInfo corresponds to non-Java usage of Java method - return usageInfo instanceof MoveRenameUsageInfo - && RefactoringPackage.isTrueJavaMethod(((MoveRenameUsageInfo) usageInfo).getReferencedElement()); + return usageInfo instanceof JavaMethodDeferredKotlinUsage || usageInfo instanceof MoveRenameUsageInfo; } @Nullable - private static UsageInfo createReplacementUsage(UsageInfo originalUsageInfo, JetChangeInfo javaMethodChangeInfo) { + private static UsageInfo createReplacementUsage(UsageInfo originalUsageInfo, JetChangeInfo javaMethodChangeInfo, UsageInfo[] allUsages) { if (originalUsageInfo instanceof JavaMethodDeferredKotlinUsage) { return ((JavaMethodDeferredKotlinUsage) originalUsageInfo).resolve(javaMethodChangeInfo); } JetCallElement callElement = PsiTreeUtil.getParentOfType(originalUsageInfo.getElement(), JetCallElement.class); - return callElement != null ? new JavaMethodKotlinCallUsage(callElement, javaMethodChangeInfo) : null; + if (callElement == null) return null; + + PsiReference ref = originalUsageInfo.getReference(); + PsiElement refTarget = ref != null ? ref.resolve() : null; + return new JavaMethodKotlinCallUsage(callElement, + javaMethodChangeInfo, + refTarget != null && ChangeSignaturePackage.isCaller(refTarget, allUsages)); } private static class NullabilityPropagator { @@ -752,6 +902,20 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } } + private static boolean isOverriderOrCaller(UsageInfo usage) { + return usage instanceof OverriderUsageInfo || usage instanceof CallerUsageInfo; + } + + @Nullable + private static PsiMethod getOverriderOrCaller(UsageInfo usage) { + if (usage instanceof OverriderUsageInfo) return ((OverriderUsageInfo) usage).getOverridingMethod(); + if (usage instanceof CallerUsageInfo) { + PsiElement element = usage.getElement(); + return element instanceof PsiMethod ? (PsiMethod) element : null; + } + return null; + } + @Override public boolean processUsage(ChangeInfo changeInfo, UsageInfo usageInfo, boolean beforeMethodChange, UsageInfo[] usages) { PsiElement method = changeInfo.getMethod(); @@ -772,15 +936,15 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro NullabilityPropagator nullabilityPropagator = new NullabilityPropagator(javaChangeInfo.getMethod()); for (UsageInfo usage : javaUsageInfos) { - if (usage instanceof OverriderUsageInfo && beforeMethodChange) continue; + if (isOverriderOrCaller(usage) && beforeMethodChange) continue; for (ChangeSignatureUsageProcessor processor : processors) { if (processor instanceof JetChangeSignatureUsageProcessor) continue; - if (usage instanceof OverriderUsageInfo) { + if (isOverriderOrCaller(usage)) { processor.processUsage(javaChangeInfo, usage, true, javaUsageInfos); } if (processor.processUsage(javaChangeInfo, usage, beforeMethodChange, javaUsageInfos)) break; } - if (usage instanceof OverriderUsageInfo) { + if (usage instanceof OverriderUsageInfo && ((OverriderUsageInfo) usage).isOriginalOverrider()) { PsiMethod overridingMethod = ((OverriderUsageInfo) usage).getOverridingMethod(); if (overridingMethod != null && !(overridingMethod instanceof KotlinLightMethod)) { nullabilityPropagator.processMethod(overridingMethod); @@ -791,23 +955,29 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } if (beforeMethodChange) { - if (isJavaMethodUsage) { + boolean startedFromJava = method instanceof PsiMethod; + if (startedFromJava && originalJavaMethodDescriptor == null) { FunctionDescriptor methodDescriptor = ResolvePackage.getJavaMethodDescriptor((PsiMethod) method); - JetChangeSignatureData changeSignatureData = - new JetChangeSignatureData(methodDescriptor, method, Collections.singletonList(methodDescriptor)); - if (changeSignatureData != originalJavaMethodDescriptor) { - originalJavaMethodDescriptor = changeSignatureData; - } + originalJavaMethodDescriptor = + new JetChangeSignatureData(methodDescriptor, method, Collections.singletonList(methodDescriptor));; // This change info is used as a placeholder before primary method update // It gets replaced with real change info afterwards JetChangeInfo dummyChangeInfo = - new JetChangeInfo(originalJavaMethodDescriptor, "", null, "", Visibilities.INTERNAL, Collections.emptyList(), null, changeInfo.getMethod()); + new JetChangeInfo(originalJavaMethodDescriptor, + "", + null, + "", + Visibilities.INTERNAL, + Collections.emptyList(), + null, + changeInfo.getMethod(), + Collections.emptyList()); for (int i = 0; i < usages.length; i++) { UsageInfo oldUsageInfo = usages[i]; if (!isJavaMethodUsage(oldUsageInfo)) continue; - UsageInfo newUsageInfo = createReplacementUsage(oldUsageInfo, dummyChangeInfo); + UsageInfo newUsageInfo = createReplacementUsage(oldUsageInfo, dummyChangeInfo, usages); if (newUsageInfo != null) { usages[i] = newUsageInfo; } @@ -832,7 +1002,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro } if (usageInfo instanceof JavaMethodKotlinUsageWithDelegate) { - return ((JavaMethodKotlinUsageWithDelegate) usageInfo).processUsage(); + return ((JavaMethodKotlinUsageWithDelegate) usageInfo).processUsage(usages); } if (usageInfo instanceof MoveRenameUsageInfo && isJavaMethodUsage) { @@ -846,7 +1016,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro return false; } - return usageInfo instanceof JetUsageInfo ? ((JetUsageInfo) usageInfo).processUsage((JetChangeInfo) changeInfo, element) : true; + return usageInfo instanceof JetUsageInfo ? ((JetUsageInfo) usageInfo).processUsage((JetChangeInfo) changeInfo, element, usages) : true; } @Override @@ -855,7 +1025,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro JetChangeInfo jetChangeInfo = (JetChangeInfo) changeInfo; for (JetCallableDefinitionUsage primaryFunction : jetChangeInfo.getMethodDescriptor().getPrimaryCallables()) { - primaryFunction.processUsage(jetChangeInfo, primaryFunction.getDeclaration()); + primaryFunction.processUsage(jetChangeInfo, primaryFunction.getDeclaration(), UsageInfo.EMPTY_ARRAY); } jetChangeInfo.primaryMethodUpdated(); return true; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt new file mode 100644 index 00000000000..3effd19684b --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/changeSignatureUtils.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature + +import com.intellij.psi.PsiElement +import com.intellij.refactoring.changeSignature.CallerUsageInfo +import com.intellij.refactoring.changeSignature.OverriderUsageInfo +import com.intellij.usageView.UsageInfo +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.DeferredJavaMethodKotlinCallerUsage +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JavaMethodKotlinUsageWithDelegate +import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCallerUsage +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf + +private fun JetNamedDeclaration.getDeclarationBody(): JetElement? { + return when { + this is JetClassOrObject -> getDelegationSpecifierList() + this is JetPrimaryConstructor -> getContainingClassOrObject().getDelegationSpecifierList() + this is JetSecondaryConstructor -> getDelegationCall() + this is JetNamedFunction -> getBodyExpression() + else -> null + } +} + +public fun PsiElement.isCaller(allUsages: Array): Boolean { + val elementToSearch = (this as? JetClass)?.getPrimaryConstructor() ?: this + return allUsages + .asSequence() + .filter { + val usage = (it as? JavaMethodKotlinUsageWithDelegate<*>)?.delegateUsage ?: it + usage is KotlinCallerUsage + || usage is DeferredJavaMethodKotlinCallerUsage + || usage is CallerUsageInfo + || (usage is OverriderUsageInfo && !usage.isOriginalOverrider()) + } + .any { it.getElement() == elementToSearch } +} + +public fun JetElement.isInsideOfCallerBody(allUsages: Array): Boolean { + val container = parentsWithSelf.firstOrNull { + it is JetNamedFunction || it is JetConstructor<*> || it is JetClassOrObject + } as? JetNamedDeclaration ?: return false + val body = container.getDeclarationBody() ?: return false + return body.getTextRange().contains(getTextRange()) && container.isCaller(allUsages) +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt index 3c6d9d51f3b..949259ab460 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt @@ -20,7 +20,6 @@ import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.editor.colors.EditorFontType import com.intellij.openapi.editor.event.DocumentAdapter import com.intellij.openapi.editor.event.DocumentEvent -import com.intellij.openapi.fileTypes.LanguageFileType import com.intellij.openapi.options.ConfigurationException import com.intellij.openapi.project.Project import com.intellij.openapi.ui.VerticalFlowLayout @@ -30,18 +29,15 @@ import com.intellij.psi.PsiCodeFragment import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement import com.intellij.refactoring.BaseRefactoringProcessor -import com.intellij.refactoring.changeSignature.CallerChooserBase import com.intellij.refactoring.changeSignature.ChangeSignatureDialogBase import com.intellij.refactoring.changeSignature.MethodDescriptor import com.intellij.refactoring.changeSignature.ParameterTableModelItemBase import com.intellij.refactoring.ui.ComboBoxVisibilityPanel -import com.intellij.refactoring.ui.VisibilityPanelBase import com.intellij.ui.DottedBorder import com.intellij.ui.EditorTextField import com.intellij.ui.components.JBLabel import com.intellij.ui.treeStructure.Tree import com.intellij.util.Consumer -import com.intellij.util.Function import com.intellij.util.IJSwingUtilities import com.intellij.util.ui.UIUtil import com.intellij.util.ui.table.JBTableRow @@ -158,6 +154,10 @@ public class JetChangeSignatureDialog( override fun createCallerChooser(title: String, treeToReuse: Tree?, callback: Consumer>) = KotlinCallerChooser(myMethod.getMethod(), myProject, title, treeToReuse, callback) + // Forbid receiver propagation + override fun mayPropagateParameters() = + getParameters().any { it.isNewParameter && it != parametersTableModel.getReceiver() } + override fun getTableEditor(table: JTable, item: ParameterTableModelItemBase): JBTableRowEditor? { return object : JBTableRowEditor() { private val components = ArrayList() @@ -364,6 +364,7 @@ public class JetChangeSignatureDialog( getVisibility(), getMethodName(), myDefaultValueContext) + changeInfo.primaryPropagationTargets = myMethodsToPropagateParameters ?: emptyList(); return JetChangeSignatureProcessor(myProject, changeInfo, commandName ?: getTitle()) } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt index 488c88f3947..8123e2d3552 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodDeferredKotlinUsage.kt @@ -22,35 +22,41 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.psi.JetConstructorDelegationCall import org.jetbrains.kotlin.psi.JetFunction +import org.jetbrains.kotlin.psi.JetNamedDeclaration import org.jetbrains.kotlin.types.JetType -public abstract class JavaMethodDeferredKotlinUsage(element: T): UsageInfo(element) { - abstract fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate +public abstract class JavaMethodDeferredKotlinUsage(element: T) : UsageInfo(element) { + abstract fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate } public class DeferredJavaMethodOverrideOrSAMUsage( val function: JetFunction, val functionDescriptor: FunctionDescriptor, val samCallType: JetType? -): JavaMethodDeferredKotlinUsage(function) { - override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { - return object : JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { - override val delegateUsage = JetCallableDefinitionUsage( - function, - functionDescriptor, - javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable, - samCallType - ) - } +) : JavaMethodDeferredKotlinUsage(function) { + override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { + return object : JavaMethodKotlinUsageWithDelegate(function, javaMethodChangeInfo) { + override val delegateUsage = JetCallableDefinitionUsage(function, functionDescriptor, javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable, samCallType) } + } +} + +public class DeferredJavaMethodKotlinCallerUsage( + val declaration: JetNamedDeclaration +) : JavaMethodDeferredKotlinUsage(declaration) { + override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { + return object : JavaMethodKotlinUsageWithDelegate(declaration, javaMethodChangeInfo) { + override val delegateUsage = KotlinCallerUsage(declaration) + } + } } public class JavaConstructorDeferredUsageInDelegationCall( val delegationCall: JetConstructorDelegationCall -): JavaMethodDeferredKotlinUsage(delegationCall) { - override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { - return object : JavaMethodKotlinUsageWithDelegate(delegationCall, javaMethodChangeInfo) { - override val delegateUsage = JetConstructorDelegationCallUsage(delegationCall, javaMethodChangeInfo) - } +) : JavaMethodDeferredKotlinUsage(delegationCall) { + override fun resolve(javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate { + return object : JavaMethodKotlinUsageWithDelegate(delegationCall, javaMethodChangeInfo) { + override val delegateUsage = JetConstructorDelegationCallUsage(delegationCall, javaMethodChangeInfo) } + } } \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt index 2a319434b91..5be6bb3f743 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JavaMethodKotlinUsageWithDelegate.kt @@ -26,13 +26,18 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor public abstract class JavaMethodKotlinUsageWithDelegate( val psiElement: T, var javaMethodChangeInfo: JetChangeInfo): UsageInfo(psiElement) { - protected abstract val delegateUsage: JetUsageInfo + abstract val delegateUsage: JetUsageInfo - fun processUsage(): Boolean = delegateUsage.processUsage(javaMethodChangeInfo, psiElement) + fun processUsage(allUsages: Array): Boolean = delegateUsage.processUsage(javaMethodChangeInfo, psiElement, allUsages) } public class JavaMethodKotlinCallUsage( callElement: JetCallElement, - javaMethodChangeInfo: JetChangeInfo): JavaMethodKotlinUsageWithDelegate(callElement, javaMethodChangeInfo) { - override protected val delegateUsage = JetFunctionCallUsage(psiElement, javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable) + javaMethodChangeInfo: JetChangeInfo, + propagationCall: Boolean): JavaMethodKotlinUsageWithDelegate(callElement, javaMethodChangeInfo) { + override val delegateUsage = if (propagationCall) { + KotlinCallerCallUsage(psiElement) + } else { + JetFunctionCallUsage(psiElement, javaMethodChangeInfo.methodDescriptor.originalPrimaryCallable) + } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index 52d2d34ae21..bd89a3ed30c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiWhiteSpace; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.usageView.UsageInfo; import kotlin.KotlinPackage; import kotlin.Pair; import org.jetbrains.annotations.NotNull; @@ -165,7 +166,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn } @Override - public boolean processUsage(@NotNull JetChangeInfo changeInfo, @NotNull PsiElement element) { + public boolean processUsage(@NotNull JetChangeInfo changeInfo, @NotNull PsiElement element, @NotNull UsageInfo[] allUsages) { if (!(element instanceof JetNamedDeclaration)) return true; JetPsiFactory psiFactory = JetPsiFactory(element.getProject()); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt index 617b5e14139..e193950b0af 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetConstructorDelegationCallUsage.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages +import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.psi.JetConstructorDelegationCall import org.jetbrains.kotlin.psi.JetPsiFactory @@ -27,7 +28,7 @@ public class JetConstructorDelegationCallUsage( ) : JetUsageInfo(call) { val delegate = JetFunctionCallUsage(call, changeInfo.methodDescriptor.originalPrimaryCallable) - override fun processUsage(changeInfo: JetChangeInfo, element: JetConstructorDelegationCall): Boolean { + override fun processUsage(changeInfo: JetChangeInfo, element: JetConstructorDelegationCall, allUsages: Array): Boolean { val isThisCall = element.isCallToThis() var elementToWorkWith = element @@ -36,7 +37,7 @@ public class JetConstructorDelegationCallUsage( elementToWorkWith = constructor.replaceImplicitDelegationCallWithExplicit(isThisCall) } - val result = delegate.processUsage(changeInfo, elementToWorkWith) + val result = delegate.processUsage(changeInfo, elementToWorkWith, allUsages) if (changeInfo.getNewParametersCount() == 0 && !isThisCall && !elementToWorkWith.isImplicit()) { (elementToWorkWith.getParent() as? JetSecondaryConstructor)?.getColon()?.delete() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt index d7e3f3cbd8a..d770acd3b2b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetEnumEntryWithoutSuperCallUsage.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages +import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.psi.JetEnumEntry import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.psi.JetPsiFactory @@ -24,7 +25,7 @@ import org.jetbrains.kotlin.psi.JetDelegatorToSuperCall import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType public class JetEnumEntryWithoutSuperCallUsage(enumEntry: JetEnumEntry) : JetUsageInfo(enumEntry) { - override fun processUsage(changeInfo: JetChangeInfo, element: JetEnumEntry): Boolean { + override fun processUsage(changeInfo: JetChangeInfo, element: JetEnumEntry, allUsages: Array): Boolean { if (changeInfo.getNewParameters().size() > 0) { val psiFactory = JetPsiFactory(element) @@ -36,7 +37,7 @@ public class JetEnumEntryWithoutSuperCallUsage(enumEntry: JetEnumEntry) : JetUsa element.addBefore(psiFactory.createColon(), delegatorToSuperCall) return JetFunctionCallUsage(delegatorToSuperCall, changeInfo.methodDescriptor.originalPrimaryCallable) - .processUsage(changeInfo, delegatorToSuperCall) + .processUsage(changeInfo, delegatorToSuperCall, allUsages) } return true diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index e5e155b094d..7d24b78320a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -20,6 +20,7 @@ import com.intellij.openapi.util.Ref; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.usageView.UsageInfo; import com.intellij.util.containers.ContainerUtil; import gnu.trove.TIntArrayList; import gnu.trove.TIntProcedure; @@ -34,6 +35,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.codeInsight.shorten.ShortenPackage; import org.jetbrains.kotlin.idea.core.CorePackage; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignaturePackage; import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo; import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.ExtractionEnginePackage; @@ -89,14 +91,14 @@ public class JetFunctionCallUsage extends JetUsageInfo { } @Override - public boolean processUsage(JetChangeInfo changeInfo, JetCallElement element) { + public boolean processUsage(@NotNull JetChangeInfo changeInfo, @NotNull JetCallElement element, @NotNull UsageInfo[] allUsages) { if (shouldSkipUsage(element)) return true; changeNameIfNeeded(changeInfo, element); if (element.getValueArgumentList() != null) { if (changeInfo.isParameterSetOrOrderChanged()) { - updateArgumentsAndReceiver(changeInfo, element); + updateArgumentsAndReceiver(changeInfo, element, allUsages); } else { changeArgumentNames(changeInfo, element); @@ -319,7 +321,7 @@ public class JetFunctionCallUsage extends JetUsageInfo { return newExpression; } - private void updateArgumentsAndReceiver(JetChangeInfo changeInfo, JetCallElement element) { + private void updateArgumentsAndReceiver(JetChangeInfo changeInfo, JetCallElement element, @NotNull UsageInfo[] allUsages) { JetValueArgumentList arguments = element.getValueArgumentList(); assert arguments != null : "Argument list is expected: " + element.getText(); List oldArguments = element.getValueArguments(); @@ -347,11 +349,18 @@ public class JetFunctionCallUsage extends JetUsageInfo { } JetExpression defaultValueForCall = parameterInfo.getDefaultValueForCall(); - String defaultValueText = defaultValueForCall != null - ? substituteReferences(defaultValueForCall, - parameterInfo.getDefaultValueParameterReferences(), - psiFactory).getText() - : ""; + + String defaultValueText; + if (ChangeSignaturePackage.isInsideOfCallerBody(element, allUsages)) { + defaultValueText = parameterInfo.getName(); + } + else { + defaultValueText = defaultValueForCall != null + ? substituteReferences(defaultValueForCall, + parameterInfo.getDefaultValueParameterReferences(), + psiFactory).getText() + : ""; + } if (isNamedCall) { String newName = parameterInfo.getInheritedName(callee); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt index 72a11726f36..b85e7bcec7e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetImplicitThisToParameterUsage.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages +import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo import org.jetbrains.kotlin.psi.JetPsiFactory @@ -32,7 +33,7 @@ public abstract class JetImplicitReceiverUsage(callElement: JetElement): JetUsag } - override fun processUsage(changeInfo: JetChangeInfo, element: JetElement): Boolean { + override fun processUsage(changeInfo: JetChangeInfo, element: JetElement, allUsages: Array): Boolean { val newQualifiedCall = JetPsiFactory(element.getProject()).createExpression( "${getNewReceiverText()}.${element.getText()}" ) as JetQualifiedExpression @@ -53,7 +54,7 @@ public class JetImplicitThisToParameterUsage( } } -public class JetImplicitOuterThisToQualifiedThisUsage( +public class JetImplicitThisUsage( callElement: JetElement, val targetDescriptor: DeclarationDescriptor ): JetImplicitReceiverUsage(callElement) { diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt index dbc6122a78d..c43224b3226 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetParameterUsage.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages +import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.psi.JetSimpleNameExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo @@ -35,7 +36,7 @@ public abstract class JetExplicitReferenceUsage(element: T) : Jet } - override fun processUsage(changeInfo: JetChangeInfo, element: T): Boolean { + override fun processUsage(changeInfo: JetChangeInfo, element: T, allUsages: Array): Boolean { val newElement = JetPsiFactory(element.getProject()).createExpression(getReplacementText(changeInfo)) val elementToReplace = (element.getParent() as? JetThisExpression) ?: element processReplacedElement(elementToReplace.replace(newElement) as JetElement) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt index 7ae906377bb..36f7adcf46e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetPropertyCallUsage.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages +import com.intellij.usageView.UsageInfo import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo import org.jetbrains.kotlin.psi.JetPsiFactory @@ -29,7 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver public class JetPropertyCallUsage(element: JetSimpleNameExpression): JetUsageInfo(element) { private val resolvedCall = element.getResolvedCall(element.analyze()) - override fun processUsage(changeInfo: JetChangeInfo, element: JetSimpleNameExpression): Boolean { + override fun processUsage(changeInfo: JetChangeInfo, element: JetSimpleNameExpression, allUsages: Array): Boolean { updateName(changeInfo, element) updateReceiver(changeInfo, element) return true diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt index b07bc8bca03..9702a5a5e4f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetUsageInfo.kt @@ -28,5 +28,5 @@ public abstract class JetUsageInfo : UsageInfo { @suppress("UNCHECKED_CAST") override fun getElement() = super.getElement() as T? - public abstract fun processUsage(changeInfo: JetChangeInfo, element: T): Boolean + public abstract fun processUsage(changeInfo: JetChangeInfo, element: T, allUsages: Array): Boolean } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt new file mode 100644 index 00000000000..34da97664ff --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/KotlinCallerUsages.kt @@ -0,0 +1,77 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.refactoring.changeSignature.usages + +import com.intellij.usageView.UsageInfo +import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet +import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo +import org.jetbrains.kotlin.idea.refactoring.changeSignature.getAffectedCallables +import org.jetbrains.kotlin.idea.refactoring.changeSignature.isInsideOfCallerBody +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList + +public class KotlinCallerUsage(element: JetNamedDeclaration): JetUsageInfo(element) { + override fun processUsage(changeInfo: JetChangeInfo, element: JetNamedDeclaration, allUsages: Array): Boolean { + // Do not process function twice + if (changeInfo.getAffectedCallables().any { it is JetCallableDefinitionUsage<*> && it.getElement() == element }) return true + + val parameterList = when (element) { + is JetFunction -> element.getValueParameterList() + is JetClass -> element.createPrimaryConstructorParameterListIfAbsent() + else -> null + } ?: return true + val psiFactory = JetPsiFactory(getProject()) + changeInfo.getNonReceiverParameters() + .withIndex() + .filter { it.value.isNewParameter } + .forEach { + val parameterText = it.value.getDeclarationSignature(it.index, changeInfo.methodDescriptor.originalPrimaryCallable) + parameterList + .addParameter(psiFactory.createParameter(parameterText)) + .addToShorteningWaitSet() + } + + return true + } +} + +public class KotlinCallerCallUsage(element: JetCallElement): JetUsageInfo(element) { + override fun processUsage(changeInfo: JetChangeInfo, element: JetCallElement, allUsages: Array): Boolean { + val argumentList = element.getValueArgumentList() ?: return true + val psiFactory = JetPsiFactory(getProject()) + val isNamedCall = argumentList.getArguments().any { it.getArgumentName() != null } + changeInfo.getNonReceiverParameters() + .filter { it.isNewParameter } + .forEach { + val parameterName = it.getName() + val argumentExpression = if (element.isInsideOfCallerBody(allUsages)) { + psiFactory.createExpression(parameterName) + } + else { + it.defaultValueForCall ?: psiFactory.createExpression("_") + } + val argument = psiFactory.createArgument( + expression = argumentExpression, + name = if (isNamedCall) Name.identifier(parameterName) else null + ) + argumentList.addArgument(argument) + } + + return true + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt index 3cbb070c9f4..ae465fde734 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt @@ -100,7 +100,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe .map { it.unwrapped } .filterIsInstance() return (kotlinFunctions + element).all { - JetCallableDefinitionUsage(it, changeInfo.originalBaseFunctionDescriptor, null, null).processUsage(changeInfo, it) + JetCallableDefinitionUsage(it, changeInfo.originalBaseFunctionDescriptor, null, null).processUsage(changeInfo, it, usages) } } @@ -116,7 +116,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe else { JetFunctionCallUsage(callElement, changeInfo.methodDescriptor.originalPrimaryCallable) } - return delegateUsage.processUsage(changeInfo, callElement) + return delegateUsage.processUsage(changeInfo, callElement, usages) } override fun processAddSuperCall(data: IntroduceParameterData, usage: UsageInfo, usages: Array): Boolean = true diff --git a/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.1.kt new file mode 100644 index 00000000000..281d5538d87 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.1.kt @@ -0,0 +1,18 @@ +open class C(n: Int) : A(n) { + +} + +open class D: A { + constructor(n: Int): super(n) + constructor(b: Boolean, n: Int) : super(n) +} + +fun test(n: Int) { + A(n) + A(false, n) + B(n) + B(false, n) + C(n) + D(n) + D(false, n) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.java b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.java new file mode 100644 index 00000000000..42e2d9eab87 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationAfter.java @@ -0,0 +1,32 @@ +class A { + public A(int n) { + + } + + public A(boolean b, int n) { + this(n); + } +} + +class B extends A { + public B(int n) { + + super(n); + } + + public B(boolean b, int n) { + super(n); + } +} + +class Test { + void test(int n) { + new A(n); + new A(true, n); + new B(n); + new B(true, n); + new C(n); + new D(n); + new D(true, n); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.1.kt b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.1.kt new file mode 100644 index 00000000000..e19235cd9de --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.1.kt @@ -0,0 +1,18 @@ +open class C: A() { + +} + +open class D: A { + constructor(): super() + constructor(b: Boolean) +} + +fun test() { + A() + A(false) + B() + B(false) + C() + D() + D(false) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.java b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.java new file mode 100644 index 00000000000..68d9991540a --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaConstructorParameterPropagationBefore.java @@ -0,0 +1,31 @@ +class A { + public A() { + + } + + public A(boolean b) { + this(); + } +} + +class B extends A { + public B() { + + } + + public B(boolean b) { + super(); + } +} + +class Test { + void test() { + new A(); + new A(true); + new B(); + new B(true); + new C(); + new D(); + new D(true); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt new file mode 100644 index 00000000000..d6c4345f095 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt @@ -0,0 +1,28 @@ +open class C: A() { + override fun foo(n: Int, s: String): Unit { + + } + + override fun bar(b: Boolean, n: Int, s: String) { + foo(n, s) + } + + override fun baz() { + foo(1, "abc") + bar(false, 1, "abc") + } +} + +fun test(n: Int, s: String) { + A().foo(n, s) + A().bar(true, n, s) + A().baz() + + B().foo(n, s) + B().bar(true, n, s) + B().baz() + + C().foo(n, s) + C().bar(true, n, s) + C().baz() +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java new file mode 100644 index 00000000000..1fd062377c9 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java @@ -0,0 +1,45 @@ +class A { + public void foo(int n, String s) { + + } + + public void bar(boolean b, int n, String s) { + foo(n, s); + } + + public void baz() { + foo(1, "abc"); + bar(false, 1, "abc"); + } +} + +class B extends A { + public void foo(int n, String s) { + + } + + public void bar(boolean b, int n, String s) { + foo(1, "abc"); + } + + public void baz() { + foo(1, "abc"); + bar(false, 1, "abc"); + } +} + +class Test { + void test() { + new A().foo(1, "abc"); + new A().bar(true, 1, "abc"); + new A().baz(); + + new B().foo(1, "abc"); + new B().bar(true, 1, "abc"); + new B().baz(); + + new C().foo(1, "abc"); + new C().bar(true, 1, "abc"); + new C().baz(); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.1.kt b/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.1.kt new file mode 100644 index 00000000000..736e32f45ac --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.1.kt @@ -0,0 +1,28 @@ +open class C: A() { + override fun foo() { + + } + + override fun bar(b: Boolean) { + foo() + } + + override fun baz() { + foo() + bar(false) + } +} + +fun test() { + A().foo() + A().bar(true) + A().baz() + + B().foo() + B().bar(true) + B().baz() + + C().foo() + C().bar(true) + C().baz() +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.java b/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.java new file mode 100644 index 00000000000..a9567ca9520 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationBefore.java @@ -0,0 +1,45 @@ +class A { + public void foo() { + + } + + public void bar(boolean b) { + foo(); + } + + public void baz() { + foo(); + bar(false); + } +} + +class B extends A { + public void foo() { + + } + + public void bar(boolean b) { + foo(); + } + + public void baz() { + foo(); + bar(false); + } +} + +class Test { + void test() { + new A().foo(); + new A().bar(true); + new A().baz(); + + new B().foo(); + new B().bar(true); + new B().baz(); + + new C().foo(); + new C().bar(true); + new C().baz(); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.1.java b/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.1.java new file mode 100644 index 00000000000..3784b1d3122 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.1.java @@ -0,0 +1,35 @@ +import org.jetbrains.annotations.NotNull; + +class J extends A { + @Override + public void foo(int n, @NotNull String s) { + + } + + @Override + public void bar(boolean b, int n, String s) { + foo(1, "abc"); // Propagated parameters are not passed to calles in overriding methods + } + + @Override + public void baz() { + foo(1, "abc"); + bar(false, 1, "abc"); + } +} + +class Test { + void test() { + new A().foo(1, "abc"); + new A().bar(true, 1, "abc"); + new A().baz(); + + new B().foo(1, "abc"); + new B().bar(true, 1, "abc"); + new B().baz(); + + new J().foo(1, "abc"); + new J().bar(true, 1, "abc"); + new J().baz(); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.kt b/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.kt new file mode 100644 index 00000000000..07e77360641 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ParameterPropagationAfter.kt @@ -0,0 +1,43 @@ +open class A { + open fun foo(n: Int, s: String) { + + } + + open fun bar(b: Boolean, n: Int, s: String) { + foo(n, s) + } + + open fun baz() { + foo(1, "abc") + bar(false, 1, "abc") + } +} + +class B : A() { + override fun foo(n: Int, s: String) { + + } + + override fun bar(b: Boolean, n: Int, s: String) { + foo(n, s) + } + + override fun baz() { + foo(1, "abc") + bar(false, 1, "abc") + } +} + +fun test(n: Int, s: String) { + A().foo(n, s) + A().bar(true, n, s) + A().baz() + + B().foo(n, s) + B().bar(true, n, s) + B().baz() + + J().foo(n, s) + J().bar(true, n, s) + J().baz() +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.1.java b/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.1.java new file mode 100644 index 00000000000..91fd31f2f9f --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.1.java @@ -0,0 +1,33 @@ +class J extends A { + @Override + public void foo() { + + } + + @Override + public void bar(boolean b) { + foo(); // Propagated parameters are not passed to calles in overriding methods + } + + @Override + public void baz() { + foo(); + bar(false); + } +} + +class Test { + void test() { + new A().foo(); + new A().bar(true); + new A().baz(); + + new B().foo(); + new B().bar(true); + new B().baz(); + + new J().foo(); + new J().bar(true); + new J().baz(); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.kt b/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.kt new file mode 100644 index 00000000000..d9128170eaa --- /dev/null +++ b/idea/testData/refactoring/changeSignature/ParameterPropagationBefore.kt @@ -0,0 +1,43 @@ +open class A { + open fun foo() { + + } + + open fun bar(b: Boolean) { + foo() + } + + open fun baz() { + foo() + bar(false) + } +} + +class B : A() { + override fun foo() { + + } + + override fun bar(b: Boolean) { + foo() + } + + override fun baz() { + foo() + bar(false) + } +} + +fun test() { + A().foo() + A().bar(true) + A().baz() + + B().foo() + B().bar(true) + B().baz() + + J().foo() + J().bar(true) + J().baz() +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.1.java b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.1.java new file mode 100644 index 00000000000..4a5357d8bb4 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.1.java @@ -0,0 +1,22 @@ +class J extends A { + public J(int n) { + + super(n); + } + + public J(boolean b, int n) { + super(n); + } +} + +class Test { + void test(int n) { + new A(n); + new A(true, n); + new B(n); + new B(true, n); + new C(true, n); + new J(n); + new J(true, n); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.kt b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.kt new file mode 100644 index 00000000000..0963b2aa7c7 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationAfter.kt @@ -0,0 +1,21 @@ +open class A(n: Int) { + constructor(b: Boolean, n: Int): this(n) +} + +open class B: A { + constructor(n: Int) : super(n) + + constructor(b: Boolean, n: Int): super(n) +} + +open class C(b: Boolean, n: Int): A(n) + +fun test(n: Int) { + A(n) + A(false, n) + B(n) + B(false, n) + C(false, n) + J(n) + J(false, n) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.1.java b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.1.java new file mode 100644 index 00000000000..647bfef6bee --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.1.java @@ -0,0 +1,21 @@ +class J extends A { + public J() { + + } + + public J(boolean b) { + super(); + } +} + +class Test { + void test() { + new A(); + new A(true); + new B(); + new B(true); + new C(true); + new J(); + new J(true); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.kt b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.kt new file mode 100644 index 00000000000..b7570bd838a --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PrimaryConstructorParameterPropagationBefore.kt @@ -0,0 +1,20 @@ +open class A() { + constructor(b: Boolean): this() +} + +open class B: A { + constructor() + constructor(b: Boolean): super() +} + +open class C(b: Boolean): A() + +fun test() { + A() + A(false) + B() + B(false) + C(false) + J() + J(false) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationBefore.kt b/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationBefore.kt new file mode 100644 index 00000000000..b73e852988b --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationBefore.kt @@ -0,0 +1,5 @@ +fun foo() = 1 + +fun bar(n: Int): Int { + return foo() + n +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationMessages.txt b/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationMessages.txt new file mode 100644 index 00000000000..a262d240b77 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithParameterDuplicationMessages.txt @@ -0,0 +1 @@ +There is already a parameter 'n' in fun bar(n: Int): Int. It will conflict with the new parameter. \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberAfter.kt b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberAfter.kt new file mode 100644 index 00000000000..383e6903700 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberAfter.kt @@ -0,0 +1,7 @@ +fun foo(n: Int): Int = 1 + +class A(val n: Int) { + fun bar(n: Int): Int { + return foo(n) + this.n + } +} diff --git a/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberBefore.kt b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberBefore.kt new file mode 100644 index 00000000000..6ed7e4cef1f --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInClassMemberBefore.kt @@ -0,0 +1,7 @@ +fun foo(): Int = 1 + +class A(val n: Int) { + fun bar(): Int { + return foo() + n + } +} diff --git a/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionAfter.kt b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionAfter.kt new file mode 100644 index 00000000000..01c6a4d0bf3 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionAfter.kt @@ -0,0 +1,7 @@ +fun foo(n: Int): Int = 1 + +class A(val n: Int) + +fun A.bar(n: Int): Int { + return foo(n) + this.n +} diff --git a/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionBefore.kt b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionBefore.kt new file mode 100644 index 00000000000..978ac747033 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithThisQualificationInExtensionBefore.kt @@ -0,0 +1,7 @@ +fun foo(): Int = 1 + +class A(val n: Int) + +fun A.bar(): Int { + return foo() + n +} diff --git a/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationBefore.kt b/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationBefore.kt new file mode 100644 index 00000000000..ce9ddaabb08 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationBefore.kt @@ -0,0 +1,7 @@ +fun foo() = 1 + +val n = 1 + +fun bar(): Int { + return foo() + n +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationMessages.txt b/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationMessages.txt new file mode 100644 index 00000000000..86c4632a539 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/PropagateWithVariableDuplicationMessages.txt @@ -0,0 +1 @@ +There is already a variable 'n' in fun bar(): Int. It will conflict with the new parameter. \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.1.java b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.1.java new file mode 100644 index 00000000000..4a5357d8bb4 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.1.java @@ -0,0 +1,22 @@ +class J extends A { + public J(int n) { + + super(n); + } + + public J(boolean b, int n) { + super(n); + } +} + +class Test { + void test(int n) { + new A(n); + new A(true, n); + new B(n); + new B(true, n); + new C(true, n); + new J(n); + new J(true, n); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.kt b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.kt new file mode 100644 index 00000000000..e3445e7b100 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationAfter.kt @@ -0,0 +1,21 @@ +open class A { + constructor(n: Int) + constructor(b: Boolean, n: Int): this(n) +} + +open class B: A { + constructor(n: Int) : super(n) + + constructor(b: Boolean, n: Int): super(n) +} + +open class C(b: Boolean, n: Int): A(n) + +fun test(n: Int) { + A(n) + A(false, n) + B(n) + B(false, n) + C(false, n) + J(n) +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.1.java b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.1.java new file mode 100644 index 00000000000..647bfef6bee --- /dev/null +++ b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.1.java @@ -0,0 +1,21 @@ +class J extends A { + public J() { + + } + + public J(boolean b) { + super(); + } +} + +class Test { + void test() { + new A(); + new A(true); + new B(); + new B(true); + new C(true); + new J(); + new J(true); + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.kt b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.kt new file mode 100644 index 00000000000..3f7a8e485d1 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/SecondaryConstructorParameterPropagationBefore.kt @@ -0,0 +1,20 @@ +open class A { + constructor() + constructor(b: Boolean): this() +} + +open class B: A { + constructor() + constructor(b: Boolean): super() +} + +open class C(b: Boolean): A() + +fun test() { + A() + A(false) + B() + B(false) + C(false) + J() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index 3176fdee441..f74fb00a8c4 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -22,27 +22,32 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; +import com.intellij.psi.impl.java.stubs.index.JavaFullClassNameIndex; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.refactoring.BaseRefactoringProcessor; import com.intellij.refactoring.changeSignature.ChangeSignatureProcessor; import com.intellij.refactoring.changeSignature.ParameterInfoImpl; import com.intellij.refactoring.changeSignature.ThrownExceptionInfo; +import com.intellij.refactoring.util.CanonicalTypes; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.VisibilityUtil; +import kotlin.KotlinPackage; +import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.asJava.AsJavaPackage; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.descriptors.Visibilities; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.refactoring.JetRefactoringBundle; +import org.jetbrains.kotlin.idea.refactoring.changeSignature.ui.KotlinMethodNode; +import org.jetbrains.kotlin.idea.stubindex.JetFullClassNameIndex; +import org.jetbrains.kotlin.idea.stubindex.JetTopLevelFunctionFqnNameIndex; import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils; import org.jetbrains.kotlin.idea.test.KotlinCodeInsightTestCase; import org.jetbrains.kotlin.idea.test.PluginTestCaseBase; -import org.jetbrains.kotlin.psi.JetElement; -import org.jetbrains.kotlin.psi.JetFile; -import org.jetbrains.kotlin.psi.JetPsiFactory; +import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; @@ -544,7 +549,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { public void testSAMChangeMethodReturnType() throws Exception { doJavaTest( new JavaRefactoringProvider() { - @Nullable + @NotNull @Override PsiType getNewReturnType(@NotNull PsiMethod method) { return PsiType.getJavaLangObject(getPsiManager(), GlobalSearchScope.allScope(getProject())); @@ -567,7 +572,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { return newParameters; } - @Nullable + @NotNull @Override PsiType getNewReturnType(@NotNull PsiMethod method) { return factory.createTypeFromText("X>", method); @@ -978,7 +983,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { public void testJavaMethodOverridesReplaceParam() throws Exception { doJavaTest( new JavaRefactoringProvider() { - @Nullable + @NotNull @Override PsiType getNewReturnType(@NotNull PsiMethod method) { return PsiType.getJavaLangString(getPsiManager(), GlobalSearchScope.allScope(getProject())); @@ -998,7 +1003,7 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { public void testJavaMethodOverridesChangeParam() throws Exception { doJavaTest( new JavaRefactoringProvider() { - @Nullable + @NotNull @Override PsiType getNewReturnType(@NotNull PsiMethod method) { return PsiType.getJavaLangString(getPsiManager(), GlobalSearchScope.allScope(getProject())); @@ -1084,6 +1089,233 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { doTest(changeInfo); } + public void testParameterPropagation() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter1 = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", null, null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + newParameter1.setCurrentTypeText("kotlin.Int"); + changeInfo.addParameter(newParameter1); + + JetParameterInfo newParameter2 = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "s", null, null, + new JetPsiFactory(getProject()).createExpression("\"abc\""), JetValVar.None, null); + newParameter2.setCurrentTypeText("kotlin.String"); + changeInfo.addParameter(newParameter2); + + JetClassOrObject classA = + JetFullClassNameIndex.getInstance().get("A", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + JetDeclaration functionBar = KotlinPackage.first( + classA.getDeclarations(), + new Function1() { + @Override + public Boolean invoke(JetDeclaration declaration) { + return declaration instanceof JetNamedFunction && "bar".equals(declaration.getName()); + } + } + ); + JetNamedFunction functionTest = + JetTopLevelFunctionFqnNameIndex.getInstance().get("test", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + + changeInfo.setPrimaryPropagationTargets(Arrays.asList(functionBar, functionTest)); + + doTest(changeInfo); + } + + public void testJavaParameterPropagation() throws Exception { + doJavaTest( + new JavaRefactoringProvider() { + @NotNull + @Override + ParameterInfoImpl[] getNewParameters(@NotNull PsiMethod method) { + return new ParameterInfoImpl[] { + new ParameterInfoImpl(-1, "n", PsiType.INT, "1"), + new ParameterInfoImpl(-1, + "s", + PsiType.getJavaLangString(getPsiManager(), GlobalSearchScope.allScope(getProject())), + "\"abc\"") + }; + } + + @NotNull + @Override + Set getParameterPropagationTargets(@NotNull PsiMethod method) { + PsiClass classA = KotlinPackage.first( + JavaFullClassNameIndex.getInstance() + .get("A".hashCode(), getProject(), GlobalSearchScope.allScope(getProject())), + new Function1() { + @Override + public Boolean invoke(PsiClass aClass) { + return "A".equals(aClass.getName()); + } + } + ); + PsiMethod methodBar = KotlinPackage.first( + classA.getMethods(), + new Function1() { + @Override + public Boolean invoke(PsiMethod method) { + return "bar".equals(method.getName()); + } + } + ); + JetNamedFunction functionTest = + JetTopLevelFunctionFqnNameIndex.getInstance().get("test", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + + return KotlinPackage.setOf(methodBar, AsJavaPackage.getRepresentativeLightMethod(functionTest)); + } + } + ); + } + + public void testPropagateWithParameterDuplication() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + JetNamedFunction functionBar = + JetTopLevelFunctionFqnNameIndex.getInstance().get("bar", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + + changeInfo.setPrimaryPropagationTargets(Collections.singletonList(functionBar)); + + doTestConflict(changeInfo); + } + + public void testPropagateWithVariableDuplication() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + JetNamedFunction functionBar = + JetTopLevelFunctionFqnNameIndex.getInstance().get("bar", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + + changeInfo.setPrimaryPropagationTargets(Collections.singletonList(functionBar)); + + doTestConflict(changeInfo); + } + + public void testPropagateWithThisQualificationInClassMember() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + JetClassOrObject classA = + JetFullClassNameIndex.getInstance().get("A", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + JetDeclaration functionBar = KotlinPackage.first( + classA.getDeclarations(), + new Function1() { + @Override + public Boolean invoke(JetDeclaration declaration) { + return declaration instanceof JetNamedFunction && "bar".equals(declaration.getName()); + } + } + ); + changeInfo.setPrimaryPropagationTargets(Collections.singletonList(functionBar)); + + doTest(changeInfo); + } + + public void testPropagateWithThisQualificationInExtension() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + JetNamedFunction functionBar = + JetTopLevelFunctionFqnNameIndex.getInstance().get("bar", getProject(), GlobalSearchScope.allScope(getProject())) + .iterator().next(); + + changeInfo.setPrimaryPropagationTargets(Collections.singletonList(functionBar)); + + doTest(changeInfo); + } + + public void testJavaConstructorParameterPropagation() throws Exception { + doJavaTest( + new JavaRefactoringProvider() { + @NotNull + @Override + ParameterInfoImpl[] getNewParameters(@NotNull PsiMethod method) { + return new ParameterInfoImpl[] { new ParameterInfoImpl(-1, "n", PsiType.INT, "1") }; + } + + @NotNull + @Override + Set getParameterPropagationTargets(@NotNull PsiMethod method) { + return findCallers(method); + } + } + ); + } + + public void testPrimaryConstructorParameterPropagation() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + PsiMethod constructor = AsJavaPackage.getRepresentativeLightMethod(changeInfo.getMethod()); + assert constructor != null; + changeInfo.setPrimaryPropagationTargets(findCallers(constructor)); + + doTest(changeInfo); + } + + public void testSecondaryConstructorParameterPropagation() throws Exception { + JetChangeInfo changeInfo = getChangeInfo(); + + JetParameterInfo newParameter = new JetParameterInfo(changeInfo.getMethodDescriptor().getBaseDescriptor(), + -1, "n", KotlinBuiltIns.getInstance().getIntType(), null, + new JetPsiFactory(getProject()).createExpression("1"), JetValVar.None, null); + changeInfo.addParameter(newParameter); + + PsiMethod constructor = AsJavaPackage.getRepresentativeLightMethod(changeInfo.getMethod()); + assert constructor != null; + changeInfo.setPrimaryPropagationTargets(findCallers(constructor)); + + doTest(changeInfo); + } + + @NotNull + private LinkedHashSet findCallers(@NotNull PsiMethod method) { + KotlinMethodNode rootNode = + new KotlinMethodNode(method, + new HashSet(), + getProject(), + new Runnable() { + @Override + public void run() { + + } + }); + LinkedHashSet callers = new LinkedHashSet(); + for (int i = 0; i < rootNode.getChildCount(); i++) { + PsiElement element = ((KotlinMethodNode) rootNode.getChildAt(i)).getMethod(); + callers.addAll(AsJavaPackage.toLightMethods(element)); + } + return callers; + } + @NotNull @Override protected String getTestDataPath() { @@ -1142,9 +1374,10 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { return method.getName(); } - @Nullable + @NotNull PsiType getNewReturnType(@NotNull PsiMethod method) { - return method.getReturnType(); + PsiType type = method.getReturnType(); + return type != null ? type : PsiType.VOID; } @NotNull @@ -1158,6 +1391,11 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { return parameterInfos; } + @NotNull + Set getParameterPropagationTargets(@NotNull PsiMethod method) { + return Collections.emptySet(); + } + @NotNull final ChangeSignatureProcessor getProcessor(@NotNull PsiMethod method) { return new ChangeSignatureProcessor( @@ -1166,9 +1404,11 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { false, VisibilityUtil.getVisibilityModifier(method.getModifierList()), getNewName(method), - getNewReturnType(method), + CanonicalTypes.createTypeWrapper(getNewReturnType(method)), getNewParameters(method), - new ThrownExceptionInfo[0]); + new ThrownExceptionInfo[0], + getParameterPropagationTargets(method), + Collections.emptySet()); } } From a96bd546a1d11011ae9276c1efdb0831f03ab422 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Tue, 7 Jul 2015 17:36:17 +0300 Subject: [PATCH 179/450] Change Signature: Avoid explicit Unit return type --- .../changeSignature/usages/JetCallableDefinitionUsage.java | 3 ++- .../JavaMethodOverridesOmitUnitTypeAfter.1.kt | 5 +++++ .../JavaMethodOverridesOmitUnitTypeAfter.java | 5 +++++ .../JavaMethodOverridesOmitUnitTypeBefore.1.kt | 5 +++++ .../JavaMethodOverridesOmitUnitTypeBefore.java | 5 +++++ .../changeSignature/JavaParameterPropagationAfter.1.kt | 2 +- .../refactoring/changeSignature/JetChangeSignatureTest.java | 4 ++++ 7 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.java create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.1.kt create mode 100644 idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.java diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java index bd89a3ed30c..d25a1132d0b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetCallableDefinitionUsage.java @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.ChangeSignaturePack import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetChangeInfo; import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetParameterInfo; import org.jetbrains.kotlin.idea.refactoring.changeSignature.JetValVar; +import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.idea.util.ShortenReferences; import org.jetbrains.kotlin.idea.util.ShortenReferences.Options; import org.jetbrains.kotlin.lexer.JetModifierKeywordToken; @@ -236,7 +237,7 @@ public class JetCallableDefinitionUsage extends JetUsageIn String returnTypeText = changeInfo.renderReturnType((JetCallableDefinitionUsage) this); //TODO use ChangeFunctionReturnTypeFix.invoke when JetTypeCodeFragment.getType() is ready - if (!KotlinBuiltIns.getInstance().getUnitType().toString().equals(returnTypeText)) { + if (!(returnTypeText.equals("Unit") || returnTypeText.equals("kotlin.Unit"))) { ShortenPackage.addToShorteningWaitSet( callable.setTypeReference(JetPsiFactory(callable).createType(returnTypeText)), Options.DEFAULT diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.1.kt new file mode 100644 index 00000000000..7745d18a451 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.1.kt @@ -0,0 +1,5 @@ +open class X: A() { + override fun foo() { + + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.java new file mode 100644 index 00000000000..3545f8c9d1a --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeAfter.java @@ -0,0 +1,5 @@ +class A { + void foo() { + + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.1.kt b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.1.kt new file mode 100644 index 00000000000..7745d18a451 --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.1.kt @@ -0,0 +1,5 @@ +open class X: A() { + override fun foo() { + + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.java b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.java new file mode 100644 index 00000000000..3545f8c9d1a --- /dev/null +++ b/idea/testData/refactoring/changeSignature/JavaMethodOverridesOmitUnitTypeBefore.java @@ -0,0 +1,5 @@ +class A { + void foo() { + + } +} \ No newline at end of file diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt index d6c4345f095..26d1d3cfb9a 100644 --- a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.1.kt @@ -1,5 +1,5 @@ open class C: A() { - override fun foo(n: Int, s: String): Unit { + override fun foo(n: Int, s: String) { } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java index f74fb00a8c4..e54dd793e57 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureTest.java @@ -1296,6 +1296,10 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase { doTest(changeInfo); } + public void testJavaMethodOverridesOmitUnitType() throws Exception { + doJavaTest(new JavaRefactoringProvider()); + } + @NotNull private LinkedHashSet findCallers(@NotNull PsiMethod method) { KotlinMethodNode rootNode = From f9b836e1442521472f34548dc66a41b734d38189 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Wed, 8 Jul 2015 12:31:24 +0300 Subject: [PATCH 180/450] Change Signature: Error reporting for Java class without an explicit constructor --- .../changeSignature/JetChangeSignatureHandler.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt index 84ad0cce76c..811b31f661a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureHandler.kt @@ -18,13 +18,16 @@ package org.jetbrains.kotlin.idea.refactoring.changeSignature import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.ScrollType import com.intellij.openapi.project.Project +import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.PsiMethod import com.intellij.psi.util.PsiTreeUtil +import com.intellij.refactoring.BaseRefactoringProcessor import com.intellij.refactoring.HelpID import com.intellij.refactoring.RefactoringBundle import com.intellij.refactoring.changeSignature.ChangeSignatureHandler @@ -126,6 +129,16 @@ public class JetChangeSignatureHandler : ChangeSignatureHandler { if (callableDescriptor is JavaCallableMemberDescriptor) { val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, callableDescriptor) + if (declaration is PsiClass) { + val message = RefactoringBundle.getCannotRefactorMessage( + RefactoringBundle.message("error.wrong.caret.position.method.or.class.name") + ) + CommonRefactoringUtil.showErrorHint(project, + editor, + message, + ChangeSignatureHandler.REFACTORING_NAME, "refactoring.changeSignature") + return + } assert(declaration is PsiMethod) { "PsiMethod expected: $callableDescriptor" } ChangeSignatureUtil.invokeChangeSignatureOn(declaration as PsiMethod, project) return From f71f7dd4ddbc74ea6fed013b3f798655328c822b Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 9 Jul 2015 19:04:26 +0300 Subject: [PATCH 181/450] Minor: Drop unused classes --- .../org/jetbrains/kotlin/idea/util/Maybe.kt | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 idea/src/org/jetbrains/kotlin/idea/util/Maybe.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/util/Maybe.kt b/idea/src/org/jetbrains/kotlin/idea/util/Maybe.kt deleted file mode 100644 index 96fcfa6fc67..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/util/Maybe.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.util - -abstract class Maybe -public class MaybeValue(public val value: V) : Maybe() -public class MaybeError(public val error: E) : Maybe() - From aa34fe6352279441caf7498436156b09d19e31a5 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 10 Jul 2015 01:27:52 +0300 Subject: [PATCH 182/450] Minor: Remove useless annotation --- .../changeSignature/JetChangeSignatureProcessor.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt index 7c7e00dcda9..8e14ed1da06 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureProcessor.kt @@ -30,10 +30,11 @@ import com.intellij.refactoring.rename.UnresolvableCollisionUsageInfo import com.intellij.usageView.UsageInfo import com.intellij.usageView.UsageViewDescriptor import com.intellij.util.containers.MultiMap -import org.jetbrains.annotations.NotNull import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.JetUsageInfo import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinWrapperForJavaUsageInfos -import java.util.* +import java.util.ArrayList +import java.util.Arrays +import java.util.LinkedHashSet public class JetChangeSignatureProcessor(project: Project, changeInfo: JetChangeInfo, @@ -103,7 +104,7 @@ public class JetChangeSignatureProcessor(project: Project, return true } - override fun isPreviewUsages(NotNull usages: Array): Boolean = isPreviewUsages() + override fun isPreviewUsages(usages: Array): Boolean = isPreviewUsages() override fun getCommandName() = commandName } From 76648878e0ead58702fea3b559095eefa09f33da Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 10 Jul 2015 08:46:27 +0300 Subject: [PATCH 183/450] Ignore type parameters in value arguments while comparing SAM adapters #KT-8388 Fixed --- .../SamAdapterOverridabilityCondition.java | 18 +++++++--- .../tests/j+k/computeIfAbsentConcurrent.kt | 22 ++++++++++++ .../tests/j+k/computeIfAbsentConcurrent.txt | 29 ++++++++++++++++ .../j+k/overrideWithSamAndTypeParameter.kt | 22 ++++++++++++ .../j+k/overrideWithSamAndTypeParameter.txt | 29 ++++++++++++++++ .../adapters/NoSamForClassTypeParameter.java | 24 +++++++++++++ .../adapters/NoSamForClassTypeParameter.txt | 34 +++++++++++++++++++ .../adapters/NoSamForMethodTypeParameter.java | 20 +++++++++++ .../adapters/NoSamForMethodTypeParameter.txt | 27 +++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 12 +++++++ .../jvm/compiler/LoadJavaTestGenerated.java | 12 +++++++ 11 files changed, 244 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.txt create mode 100644 compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.txt create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.java create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.txt create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.java create mode 100644 compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java index 6606487ef60..59776faff0d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SamAdapterOverridabilityCondition.java @@ -50,19 +50,27 @@ public class SamAdapterOverridabilityCondition implements ExternalOverridability for (ValueParameterDescriptor param1 : parameters1) { ValueParameterDescriptor param2 = parameters2.get(param1.getIndex()); - if (!equalClasses(param2.getType(), param1.getType())) { + if (differentClasses(param2.getType(), param1.getType())) { return false; } } return true; } - private static boolean equalClasses(@NotNull JetType type1, @NotNull JetType type2) { + private static boolean differentClasses(@NotNull JetType type1, @NotNull JetType type2) { DeclarationDescriptor declarationDescriptor1 = type1.getConstructor().getDeclarationDescriptor(); - if (declarationDescriptor1 == null) return false; // No class, classes are not equal + if (declarationDescriptor1 == null) return true; // No class, classes are not equal DeclarationDescriptor declarationDescriptor2 = type2.getConstructor().getDeclarationDescriptor(); - if (declarationDescriptor2 == null) return false; // Class of type1 is not null - return declarationDescriptor1.getOriginal().equals(declarationDescriptor2.getOriginal()); + if (declarationDescriptor2 == null) return true; // Class of type1 is not null + + if (declarationDescriptor1 instanceof TypeParameterDescriptor && declarationDescriptor2 instanceof TypeParameterDescriptor) { + // if type of value parameter is some generic parameter then their equality was checked by OverridingUtil before calling ExternalOverridabilityCondition + // Note that it's true unless we generate sam adapter for type parameter with SAM interface as upper bound: + // void foo(K runnable) {} + return false; + } + + return !declarationDescriptor1.getOriginal().equals(declarationDescriptor2.getOriginal()); } // if function is or overrides declaration, returns null; otherwise, return original of sam adapter with substituted type parameters diff --git a/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt b/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt new file mode 100644 index 00000000000..abd047b6ccd --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt @@ -0,0 +1,22 @@ +// FILE: MyFunc.java +public interface MyFunc { + V apply(K String); +} + +// FILE: ConcMap.java +public interface ConcMap { + V computeIfAbsent(K key, MyFunc mappingFunction); +} + +// FILE: ConcHashMap.java +public class ConcHashMap implements ConcMap { + @Override + V computeIfAbsent(K key, MyFunc mappingFunction) { } +} + +// FILE: main.kt + +public fun concurrentMap() { + val map = ConcHashMap() + map.computeIfAbsent("") { "" } // here +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.txt b/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.txt new file mode 100644 index 00000000000..e66188e9423 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.txt @@ -0,0 +1,29 @@ +package + +public /*synthesized*/ fun ConcMap(/*0*/ function: (K!, MyFunc!) -> V!): ConcMap +public /*synthesized*/ fun MyFunc(/*0*/ function: (K!) -> V!): MyFunc +public fun concurrentMap(): kotlin.Unit + +public open class ConcHashMap : ConcMap { + public constructor ConcHashMap() + java.lang.Override() public/*package*/ final override /*1*/ /*synthesized*/ fun computeIfAbsent(/*0*/ key: K!, /*1*/ mappingFunction: ((K!) -> V!)!): V! + java.lang.Override() public/*package*/ open override /*1*/ fun computeIfAbsent(/*0*/ key: K!, /*1*/ mappingFunction: MyFunc!): V! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface ConcMap { + public final /*synthesized*/ fun computeIfAbsent(/*0*/ key: K!, /*1*/ mappingFunction: ((K!) -> V!)!): V! + public abstract fun computeIfAbsent(/*0*/ key: K!, /*1*/ mappingFunction: MyFunc!): V! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface MyFunc { + public abstract fun apply(/*0*/ String: K!): V! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt b/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt new file mode 100644 index 00000000000..8ce4c73cbd9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt @@ -0,0 +1,22 @@ +// FILE: MyFunc.java + +public interface MyFunc { + String apply(String x); +} + +// FILE: A.java +public interface A { + K foo(K key, MyFunc f); +} + +// FILE: B.java +public class B implements A { + @Override + public E foo(E key, MyFunc f) {return null;} +} + +// FILE: main.kt + +fun main() { + B().foo("") { "" } +} diff --git a/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.txt b/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.txt new file mode 100644 index 00000000000..fb416b164fe --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.txt @@ -0,0 +1,29 @@ +package + +public /*synthesized*/ fun A(/*0*/ function: (K!, MyFunc!) -> K!): A +public /*synthesized*/ fun MyFunc(/*0*/ function: (kotlin.String!) -> kotlin.String!): MyFunc +internal fun main(): kotlin.Unit + +public interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final /*synthesized*/ fun foo(/*0*/ key: K!, /*1*/ f: ((kotlin.String!) -> kotlin.String!)!): K! + public abstract fun foo(/*0*/ key: K!, /*1*/ f: MyFunc!): K! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class B : A { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + java.lang.Override() public final override /*1*/ /*synthesized*/ fun foo(/*0*/ key: E!, /*1*/ f: ((kotlin.String!) -> kotlin.String!)!): E! + java.lang.Override() public open override /*1*/ fun foo(/*0*/ key: E!, /*1*/ f: MyFunc!): E! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface MyFunc { + public abstract fun apply(/*0*/ x: kotlin.String!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.java b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.java new file mode 100644 index 00000000000..9ca4c1a9bfa --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.java @@ -0,0 +1,24 @@ +package test; + +class NoSamForTypeParameter { + void foo(K runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived1 extends NoSamForTypeParameter { + @Override + void foo(Runnable runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived2 extends NoSamForTypeParameter { + void foo(E runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived3 extends NoSamForTypeParameterDerived1 { + @Override + void foo(Runnable runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived4 extends NoSamForTypeParameterDerived2 { + @Override + void foo(Runnable runnable1, Runnable runnable2) {} +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.txt new file mode 100644 index 00000000000..41549d6757e --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.txt @@ -0,0 +1,34 @@ +package test + +public/*package*/ open class NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameter() + public/*package*/ final /*synthesized*/ fun foo(/*0*/ p0: K!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open fun foo(/*0*/ p0: K!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived1 : test.NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameterDerived1() + public/*package*/ final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived2 : test.NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameterDerived2() + public/*package*/ final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: E!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: E!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived3 : test.NoSamForTypeParameterDerived1 { + public/*package*/ constructor NoSamForTypeParameterDerived3() + public/*package*/ final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived4 : test.NoSamForTypeParameterDerived2 { + public/*package*/ constructor NoSamForTypeParameterDerived4() + public/*package*/ final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.java b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.java new file mode 100644 index 00000000000..0b938967e81 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.java @@ -0,0 +1,20 @@ +package test; + +class NoSamForTypeParameter { + void foo(K runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived1 extends NoSamForTypeParameter { + @Override + void foo(Runnable runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived2 extends NoSamForTypeParameter { + @Override + void foo(K runnable1, Runnable runnable2) {} +} + +class NoSamForTypeParameterDerived3 extends NoSamForTypeParameterDerived1 { + @Override + void foo(Runnable runnable1, Runnable runnable2) {} +} diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.txt new file mode 100644 index 00000000000..502943c5a02 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.txt @@ -0,0 +1,27 @@ +package test + +public/*package*/ open class NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameter() + public/*package*/ final /*synthesized*/ fun foo(/*0*/ p0: K!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open fun foo(/*0*/ p0: K!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived1 : test.NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameterDerived1() + public/*package*/ final /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: K!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived2 : test.NoSamForTypeParameter { + public/*package*/ constructor NoSamForTypeParameterDerived2() + public/*package*/ final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: K!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: K!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} + +public/*package*/ open class NoSamForTypeParameterDerived3 : test.NoSamForTypeParameterDerived1 { + public/*package*/ constructor NoSamForTypeParameterDerived3() + public/*package*/ final override /*1*/ /*synthesized*/ fun foo(/*0*/ p0: (() -> kotlin.Unit)!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ final override /*1*/ /*fake_override*/ fun foo(/*0*/ p0: K!, /*1*/ p1: (() -> kotlin.Unit)!): kotlin.Unit + public/*package*/ open override /*1*/ fun foo(/*0*/ p0: java.lang.Runnable!, /*1*/ p1: java.lang.Runnable!): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 20b1715069e..fc9cbd12a0a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -7956,6 +7956,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("computeIfAbsentConcurrent.kt") + public void testComputeIfAbsentConcurrent() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/computeIfAbsentConcurrent.kt"); + doTest(fileName); + } + @TestMetadata("GenericsInSupertypes.kt") public void testGenericsInSupertypes() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/GenericsInSupertypes.kt"); @@ -8100,6 +8106,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("overrideWithSamAndTypeParameter.kt") + public void testOverrideWithSamAndTypeParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/overrideWithSamAndTypeParameter.kt"); + doTest(fileName); + } + @TestMetadata("packagePrivateClassStaticMember.kt") public void testPackagePrivateClassStaticMember() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/packagePrivateClassStaticMember.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 76e902d4c03..8787889e66f 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -1580,6 +1580,18 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava(fileName); } + @TestMetadata("NoSamForClassTypeParameter.java") + public void testNoSamForClassTypeParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForClassTypeParameter.java"); + doTestCompiledJava(fileName); + } + + @TestMetadata("NoSamForMethodTypeParameter.java") + public void testNoSamForMethodTypeParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/NoSamForMethodTypeParameter.java"); + doTestCompiledJava(fileName); + } + @TestMetadata("NonTrivialFunctionType.java") public void testNonTrivialFunctionType() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.java"); From f7dc59e2d691b93c4e5eeb641761933c238cf278 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 27 May 2015 16:02:09 +0300 Subject: [PATCH 184/450] Added 'UNKNOWN' argument mapping for cases with no argument expression --- .../kotlin/resolve/calls/model/ArgumentMapping.kt | 11 ++++++++--- .../jetbrains/kotlin/resolve/calls/util/callUtil.kt | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt index 876de88efc3..39caf37c688 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ArgumentMapping.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.model import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -public trait ArgumentMapping { +public interface ArgumentMapping { public fun isError(): Boolean } @@ -33,7 +33,9 @@ public enum class ArgumentMatchStatus(val isError: Boolean = true) { // The case when there is no type mismatch, but parameter has uninferred types: // fun foo(l: List) {}; val l = foo(emptyList()) - MATCH_MODULO_UNINFERRED_TYPES() + MATCH_MODULO_UNINFERRED_TYPES(), + + UNKNOWN() } public trait ArgumentMatch : ArgumentMapping { @@ -45,11 +47,14 @@ public trait ArgumentMatch : ArgumentMapping { class ArgumentMatchImpl(override val valueParameter: ValueParameterDescriptor): ArgumentMatch { private var _status: ArgumentMatchStatus? = null + override val status: ArgumentMatchStatus - get() = _status!! + get() = _status ?: ArgumentMatchStatus.UNKNOWN + fun recordMatchStatus(status: ArgumentMatchStatus) { _status = status } + fun replaceValueParameter(newValueParameter: ValueParameterDescriptor): ArgumentMatchImpl { val newArgumentMatch = ArgumentMatchImpl(newValueParameter) newArgumentMatch._status = _status diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index fc9d4f6b9a8..fc2352154f1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.utils.sure // resolved call public fun ResolvedCall.noErrorsInValueArguments(): Boolean { - return getCall().getValueArguments().all { argument -> argument.getArgumentExpression() != null/* isError() crashes otherwise!*/ && !getArgumentMapping(argument!!).isError() } + return getCall().getValueArguments().all { argument -> !getArgumentMapping(argument!!).isError() } } public fun ResolvedCall.hasUnmappedArguments(): Boolean { From 918087f475d540d617a665235bd21d41e3215926 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 9 May 2015 11:37:30 +0200 Subject: [PATCH 185/450] Don't render constraint positions in tests for constraint system, it's always SPECIAL anyway --- .../kotlin/diagnostics/rendering/Renderers.kt | 15 +++++++++------ .../checkStatus/conflictingConstraints.bounds | 2 +- .../checkStatus/successful.bounds | 2 +- .../checkStatus/violatedUpperBound.bounds | 2 +- .../computeValues/contradiction.bounds | 2 +- .../computeValues/subTypeOfUpperBounds.bounds | 2 +- .../computeValues/superTypeOfLowerBounds1.bounds | 2 +- .../computeValues/superTypeOfLowerBounds2.bounds | 2 +- .../integerValueTypes/byteOverflow.bounds | 2 +- .../integerValueTypes/defaultLong.bounds | 2 +- .../integerValueTypes/numberAndAny.bounds | 2 +- .../integerValueTypes/numberAndString.bounds | 2 +- .../integerValueTypes/severalNumbers.bounds | 2 +- .../integerValueTypes/simpleByte.bounds | 2 +- .../integerValueTypes/simpleInt.bounds | 2 +- .../integerValueTypes/simpleShort.bounds | 2 +- .../severalVariables/simpleDependency.bounds | 4 ++-- .../constraintSystem/variance/consumer.bounds | 2 +- .../constraintSystem/variance/invariant.bounds | 2 +- .../constraintSystem/variance/producer.bounds | 2 +- .../AbstractConstraintSystemTest.kt | 2 +- 21 files changed, 30 insertions(+), 27 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 40c26d70b52..308617d8603 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -351,23 +351,25 @@ public object Renderers { public val RENDER_COLLECTION_OF_TYPES: Renderer> = Renderer { renderTypes(it) } - private fun renderConstraintSystem(constraintSystem: ConstraintSystem): String { + private fun renderConstraintSystem(constraintSystem: ConstraintSystem, renderTypeBounds: Renderer): String { val typeVariables = constraintSystem.getTypeVariables() val typeBounds = Sets.newLinkedHashSet() for (variable in typeVariables) { typeBounds.add(constraintSystem.getTypeBounds(variable)) } return "type parameter bounds:\n" + - StringUtil.join(typeBounds, { RENDER_TYPE_BOUNDS.render(it) }, "\n") + "\n" + "status:\n" + + StringUtil.join(typeBounds, { renderTypeBounds.render(it) }, "\n") + "\n" + "status:\n" + ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus()) } - public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it) } + public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS) } + public val RENDER_CONSTRAINT_SYSTEM_SHORT: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS_SHORT) } - private fun renderTypeBounds(typeBounds: TypeBounds): String { + private fun renderTypeBounds(typeBounds: TypeBounds, renderPosition: Boolean): String { val renderBound = { bound: Bound -> val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= " - arrow + RENDER_TYPE.render(bound.constrainingType) + '(' + bound.position + ')' + val type = arrow + RENDER_TYPE.render(bound.constrainingType) + if (renderPosition) type + '(' + bound.position + ')' else type } val typeVariableName = typeBounds.typeVariable.getName() return if (typeBounds.isEmpty()) { @@ -377,7 +379,8 @@ public object Renderers { "$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}" } - public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it) } + public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it, renderPosition = true) } + public val RENDER_TYPE_BOUNDS_SHORT: Renderer = Renderer { renderTypeBounds(it, renderPosition = false) } private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder { append(message) diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index 5c41241ab88..59640269ecb 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T String type parameter bounds: -T <: kotlin.Int(SPECIAL), >: kotlin.String(SPECIAL) +T <: kotlin.Int, >: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index bdc70204b1c..cf4f1a3cefc 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T Int type parameter bounds: -T <: kotlin.Int(SPECIAL), >: kotlin.Int(SPECIAL) +T <: kotlin.Int, >: kotlin.Int status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index b2e152f04dc..be6e0376645 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUBTYPE T String weak type parameter bounds: -T <: kotlin.Int(SPECIAL), <: kotlin.String(TYPE_BOUND_POSITION(0)) +T <: kotlin.Int, <: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index 923bf99606b..f01624d7886 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -4,7 +4,7 @@ SUBTYPE T B SUPERTYPE T A type parameter bounds: -T <: B(SPECIAL), >: A(SPECIAL) +T <: B, >: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index a9e09d438c8..61262df4092 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -4,7 +4,7 @@ SUBTYPE T A SUBTYPE T B type parameter bounds: -T <: A(SPECIAL), <: B(SPECIAL) +T <: A, <: B status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index 584a66d7afb..742eefb1444 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -4,7 +4,7 @@ SUBTYPE T A SUPERTYPE T C type parameter bounds: -T <: A(SPECIAL), >: C(SPECIAL) +T <: A, >: C status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index 318ac21cd9b..b126ccd2ba4 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -5,7 +5,7 @@ SUPERTYPE T B SUPERTYPE T C type parameter bounds: -T <: A(SPECIAL), >: B(SPECIAL), >: C(SPECIAL) +T <: A, >: B, >: C status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 94f27a74d2f..4e743ac9e1f 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1000) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1000)(SPECIAL), <: kotlin.Byte(SPECIAL) +T >: IntegerValueType(1000), <: kotlin.Byte status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index b347c499c6d..5e3c96580b7 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T IntegerValueType(10000000000) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: IntegerValueType(10000000000)(SPECIAL) +T >: IntegerValueType(1), >: IntegerValueType(10000000000) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index adadb2fe28c..0b72b4a8149 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Any type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Any(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Any status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index fdb976e6657..89d85abd655 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T String type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: kotlin.String(SPECIAL) +T >: IntegerValueType(1), >: kotlin.String status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index a42d6b14b06..01f148acb8d 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T IntegerValueType(1000) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), >: IntegerValueType(1000)(SPECIAL) +T >: IntegerValueType(1), >: IntegerValueType(1000) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index cc023a871ae..e52555bc4c1 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Byte(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Byte status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index a6961daeb68..0f81067b861 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -3,7 +3,7 @@ VARIABLES T SUPERTYPE T IntegerValueType(1) type parameter bounds: -T >: IntegerValueType(1)(SPECIAL) +T >: IntegerValueType(1) status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 04cdd23bcae..650c63014e9 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Short type parameter bounds: -T >: IntegerValueType(1)(SPECIAL), <: kotlin.Short(SPECIAL) +T >: IntegerValueType(1), <: kotlin.Short status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index d8a26467e48..61c8b0259b7 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -3,8 +3,8 @@ VARIABLES T P SUBTYPE T Int type parameter bounds: -T <: kotlin.Int(SPECIAL) -P <: kotlin.Int(COMPOUND_CONSTRAINT_POSITION(TYPE_BOUND_POSITION(1), SPECIAL) +T <: kotlin.Int +P <: kotlin.Int status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index 460d635c820..e411a250559 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE Consumer Consumer type parameter bounds: -T <: A(SPECIAL) +T <: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 957eb13f98b..68cd39ae8c9 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE My My type parameter bounds: -T := A(SPECIAL) +T := A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index 47b00045c22..77404015b57 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -3,7 +3,7 @@ VARIABLES T SUBTYPE Producer Producer type parameter bounds: -T >: A(SPECIAL) +T >: A status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 780dd7557e1..e8065aec277 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -101,7 +101,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { } constraintSystem.processDeclaredBoundConstraints() - val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM.render(constraintSystem) + val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM_SHORT.render(constraintSystem) val resultingSubstitutor = constraintSystem.getResultingSubstitutor() val result = StringBuilder() append "result:\n" From 5717148bd467235d814d492add3b32af312d130a Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 9 May 2015 12:18:16 +0200 Subject: [PATCH 186/450] Changed test data Added an extra blank line to rendered constraint system --- .../src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt | 2 +- .../constraintSystem/checkStatus/conflictingConstraints.bounds | 1 + .../testData/constraintSystem/checkStatus/successful.bounds | 1 + .../constraintSystem/checkStatus/typeConstructorMismatch.bounds | 1 + .../constraintSystem/checkStatus/unknownParameters.bounds | 1 + .../constraintSystem/checkStatus/violatedUpperBound.bounds | 1 + .../constraintSystem/computeValues/contradiction.bounds | 1 + .../constraintSystem/computeValues/subTypeOfUpperBounds.bounds | 1 + .../computeValues/superTypeOfLowerBounds1.bounds | 1 + .../computeValues/superTypeOfLowerBounds2.bounds | 1 + .../constraintSystem/integerValueTypes/byteOverflow.bounds | 1 + .../constraintSystem/integerValueTypes/defaultLong.bounds | 1 + .../constraintSystem/integerValueTypes/numberAndAny.bounds | 1 + .../constraintSystem/integerValueTypes/numberAndString.bounds | 1 + .../constraintSystem/integerValueTypes/severalNumbers.bounds | 1 + .../constraintSystem/integerValueTypes/simpleByte.bounds | 1 + .../constraintSystem/integerValueTypes/simpleInt.bounds | 1 + .../constraintSystem/integerValueTypes/simpleShort.bounds | 1 + .../constraintSystem/severalVariables/simpleDependency.bounds | 1 + compiler/testData/constraintSystem/variance/consumer.bounds | 1 + compiler/testData/constraintSystem/variance/invariant.bounds | 1 + compiler/testData/constraintSystem/variance/producer.bounds | 1 + 22 files changed, 22 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 308617d8603..2372940ebf2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -358,7 +358,7 @@ public object Renderers { typeBounds.add(constraintSystem.getTypeBounds(variable)) } return "type parameter bounds:\n" + - StringUtil.join(typeBounds, { renderTypeBounds.render(it) }, "\n") + "\n" + "status:\n" + + StringUtil.join(typeBounds, { renderTypeBounds.render(it) }, "\n") + "\n\n" + "status:\n" + ConstraintsUtil.getDebugMessageForStatus(constraintSystem.getStatus()) } diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index 59640269ecb..67adbc29304 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -5,6 +5,7 @@ SUPERTYPE T String type parameter bounds: T <: kotlin.Int, >: kotlin.String + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index cf4f1a3cefc..ee2bdcc9cfa 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -5,6 +5,7 @@ SUPERTYPE T Int type parameter bounds: T <: kotlin.Int, >: kotlin.Int + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index b53d50cc22b..6748b94881d 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -4,6 +4,7 @@ SUBTYPE List Int type parameter bounds: T + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds index f6e6b7f85d6..315a2e41147 100644 --- a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds @@ -4,6 +4,7 @@ SUBTYPE Any Any type parameter bounds: T + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index be6e0376645..7df267a863a 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -5,6 +5,7 @@ SUBTYPE T String weak type parameter bounds: T <: kotlin.Int, <: kotlin.String + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index f01624d7886..ef0403037a0 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -5,6 +5,7 @@ SUPERTYPE T A type parameter bounds: T <: B, >: A + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index 61262df4092..59267c02780 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -5,6 +5,7 @@ SUBTYPE T B type parameter bounds: T <: A, <: B + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index 742eefb1444..67470527396 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -5,6 +5,7 @@ SUPERTYPE T C type parameter bounds: T <: A, >: C + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index b126ccd2ba4..611d210a64a 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -6,6 +6,7 @@ SUPERTYPE T C type parameter bounds: T <: A, >: B, >: C + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 4e743ac9e1f..2b12eb4e771 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -5,6 +5,7 @@ SUBTYPE T Byte type parameter bounds: T >: IntegerValueType(1000), <: kotlin.Byte + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: true diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index 5e3c96580b7..366890eab70 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -5,6 +5,7 @@ SUPERTYPE T IntegerValueType(10000000000) type parameter bounds: T >: IntegerValueType(1), >: IntegerValueType(10000000000) + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index 0b72b4a8149..476a7a7812c 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -5,6 +5,7 @@ SUBTYPE T Any type parameter bounds: T >: IntegerValueType(1), <: kotlin.Any + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index 89d85abd655..e490165dabd 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -5,6 +5,7 @@ SUPERTYPE T String type parameter bounds: T >: IntegerValueType(1), >: kotlin.String + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index 01f148acb8d..baa972d9ddb 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -5,6 +5,7 @@ SUPERTYPE T IntegerValueType(1000) type parameter bounds: T >: IntegerValueType(1), >: IntegerValueType(1000) + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index e52555bc4c1..56018383515 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -5,6 +5,7 @@ SUBTYPE T Byte type parameter bounds: T >: IntegerValueType(1), <: kotlin.Byte + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index 0f81067b861..fc8290b88cd 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -4,6 +4,7 @@ SUPERTYPE T IntegerValueType(1) type parameter bounds: T >: IntegerValueType(1) + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 650c63014e9..846da5f8405 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -5,6 +5,7 @@ SUBTYPE T Short type parameter bounds: T >: IntegerValueType(1), <: kotlin.Short + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index 61c8b0259b7..7d89b1b9557 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -5,6 +5,7 @@ SUBTYPE T Int type parameter bounds: T <: kotlin.Int P <: kotlin.Int + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index e411a250559..da63814af1c 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -4,6 +4,7 @@ SUBTYPE Consumer Consumer type parameter bounds: T <: A + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 68cd39ae8c9..5fd96d59eed 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -4,6 +4,7 @@ SUBTYPE My My type parameter bounds: T := A + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index 77404015b57..0aaa43053f2 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -4,6 +4,7 @@ SUBTYPE Producer Producer type parameter bounds: T >: A + status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false From 8b9cdd1751fd57517449e0f5d4da7d2e7400f4ca Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 11 May 2015 11:33:42 +0200 Subject: [PATCH 187/450] Changes in TypeBounds interface inlined 'isEmpty' (correctly) replaced functions 'getValue, getValues' with properties --- .../kotlin/diagnostics/rendering/Renderers.kt | 6 ++--- .../calls/inference/ConstraintSystemImpl.kt | 6 ++--- .../resolve/calls/inference/TypeBounds.kt | 6 ++--- .../resolve/calls/inference/TypeBoundsImpl.kt | 24 +++++++------------ 4 files changed, 16 insertions(+), 26 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 2372940ebf2..45ab277a171 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -216,7 +216,7 @@ public object Renderers { ): TabledDescriptorRenderer { var firstUnknownParameter: TypeParameterDescriptor? = null for (typeParameter in inferenceErrorData.constraintSystem.getTypeVariables()) { - if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).isEmpty()) { + if (inferenceErrorData.constraintSystem.getTypeBounds(typeParameter).values.isEmpty()) { firstUnknownParameter = typeParameter break } @@ -256,7 +256,7 @@ public object Renderers { return result } - val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).getValue() + val inferredValueForTypeParameter = systemWithoutWeakConstraints.getTypeBounds(typeParameterDescriptor).value if (inferredValueForTypeParameter == null) { LOG.error(renderDebugMessage("System without weak constraints is not successful, there is no value for type parameter " + typeParameterDescriptor.getName() + "\n: " + systemWithoutWeakConstraints, inferenceErrorData)) @@ -372,7 +372,7 @@ public object Renderers { if (renderPosition) type + '(' + bound.position + ')' else type } val typeVariableName = typeBounds.typeVariable.getName() - return if (typeBounds.isEmpty()) { + return if (typeBounds.bounds.isEmpty()) { typeVariableName.asString() } else diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 43c9479c5a8..968451918b4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -68,9 +68,9 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful() - override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.getValues().size() > 1 } + override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.values.size() > 1 } - override fun hasUnknownParameters() = typeParameterBounds.values().any { it.isEmpty() } + override fun hasUnknownParameters() = typeParameterBounds.values().any { it.values.isEmpty() } override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch } @@ -92,7 +92,7 @@ public class ConstraintSystemImpl : ConstraintSystem { val substitutionContext = HashMap() for ((typeParameter, typeBounds) in typeParameterBounds) { val typeProjection: TypeProjection - val value = typeBounds.getValue() + val value = typeBounds.value if (value != null && !TypeUtils.containsSpecialType(value, DONT_CARE)) { typeProjection = TypeProjectionImpl(value) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index 5825ecac958..fc759a211a8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -28,11 +28,9 @@ public trait TypeBounds { public val bounds: Collection - public fun isEmpty(): Boolean + public val value: JetType? - public fun getValue(): JetType? - - public fun getValues(): Collection + public val values: Collection public enum class BoundKind { LOWER_BOUND, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index dcfbedd4970..2b921f82b4a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -45,10 +45,6 @@ public class TypeBoundsImpl( bounds.add(Bound(constrainingType, kind, position)) } - override fun isEmpty(): Boolean { - return getValues().isEmpty() - } - private fun filterBounds(bounds: Collection, kind: BoundKind): Set { return filterBounds(bounds, kind, null) } @@ -81,20 +77,16 @@ public class TypeBoundsImpl( return result } - override fun getValue(): JetType? { - val values = getValues() - if (values.size() == 1) { - return values.iterator().next() - } - return null - } + override val value: JetType? + get() = if (values.size() == 1) values.first() else null - override fun getValues(): Collection { - if (resultValues == null) { - resultValues = computeValues() + override val values: Collection + get() { + if (resultValues == null) { + resultValues = computeValues() + } + return resultValues!! } - return resultValues!! - } private fun computeValues(): Collection { val values = LinkedHashSet() From 0fdfb6b5db7c6939344efbb32edd7b362ac5acf7 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 11 May 2015 12:57:54 +0200 Subject: [PATCH 188/450] Render short names in constraint system tests --- .../kotlin/diagnostics/rendering/Renderers.kt | 11 ++++++----- .../checkStatus/conflictingConstraints.bounds | 2 +- .../constraintSystem/checkStatus/successful.bounds | 4 ++-- .../checkStatus/violatedUpperBound.bounds | 2 +- .../integerValueTypes/byteOverflow.bounds | 2 +- .../integerValueTypes/defaultLong.bounds | 2 +- .../integerValueTypes/numberAndAny.bounds | 4 ++-- .../integerValueTypes/numberAndString.bounds | 4 ++-- .../integerValueTypes/severalNumbers.bounds | 2 +- .../integerValueTypes/simpleByte.bounds | 4 ++-- .../integerValueTypes/simpleInt.bounds | 2 +- .../integerValueTypes/simpleShort.bounds | 4 ++-- .../severalVariables/simpleDependency.bounds | 9 ++++----- .../constraintSystem/AbstractConstraintSystemTest.kt | 3 ++- 14 files changed, 28 insertions(+), 27 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 45ab277a171..f08c04f856b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -365,11 +365,12 @@ public object Renderers { public val RENDER_CONSTRAINT_SYSTEM: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS) } public val RENDER_CONSTRAINT_SYSTEM_SHORT: Renderer = Renderer { renderConstraintSystem(it, RENDER_TYPE_BOUNDS_SHORT) } - private fun renderTypeBounds(typeBounds: TypeBounds, renderPosition: Boolean): String { + private fun renderTypeBounds(typeBounds: TypeBounds, short: Boolean): String { val renderBound = { bound: Bound -> val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= " - val type = arrow + RENDER_TYPE.render(bound.constrainingType) - if (renderPosition) type + '(' + bound.position + ')' else type + val renderer = if (short) DescriptorRenderer.SHORT_NAMES_IN_TYPES else DescriptorRenderer.FQ_NAMES_IN_TYPES + val renderedBound = arrow + renderer.renderType(bound.constrainingType) + if (short) renderedBound else renderedBound + '(' + bound.position + ')' } val typeVariableName = typeBounds.typeVariable.getName() return if (typeBounds.bounds.isEmpty()) { @@ -379,8 +380,8 @@ public object Renderers { "$typeVariableName ${StringUtil.join(typeBounds.bounds, renderBound, ", ")}" } - public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it, renderPosition = true) } - public val RENDER_TYPE_BOUNDS_SHORT: Renderer = Renderer { renderTypeBounds(it, renderPosition = false) } + public val RENDER_TYPE_BOUNDS: Renderer = Renderer { renderTypeBounds(it, short = false) } + public val RENDER_TYPE_BOUNDS_SHORT: Renderer = Renderer { renderTypeBounds(it, short = true) } private fun renderDebugMessage(message: String, inferenceErrorData: InferenceErrorData) = StringBuilder { append(message) diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index 67adbc29304..ca0e8e1b407 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T String type parameter bounds: -T <: kotlin.Int, >: kotlin.String +T <: Int, >: String status: -hasCannotCaptureTypesError: false diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index ee2bdcc9cfa..5fc00e55296 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUPERTYPE T Int type parameter bounds: -T <: kotlin.Int, >: kotlin.Int +T <: Int, >: Int status: -hasCannotCaptureTypesError: false @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Int +T=Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index 7df267a863a..2dd0cc822c1 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -4,7 +4,7 @@ SUBTYPE T Int SUBTYPE T String weak type parameter bounds: -T <: kotlin.Int, <: kotlin.String +T <: Int, <: String status: -hasCannotCaptureTypesError: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 2b12eb4e771..7a95617b2aa 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1000) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1000), <: kotlin.Byte +T >: IntegerValueType(1000), <: Byte status: -hasCannotCaptureTypesError: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index 366890eab70..3d82f18077a 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Long +T=Long \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index 476a7a7812c..909959cb637 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Any type parameter bounds: -T >: IntegerValueType(1), <: kotlin.Any +T >: IntegerValueType(1), <: Any status: -hasCannotCaptureTypesError: false @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Int +T=Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index e490165dabd..ab339288908 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUPERTYPE T String type parameter bounds: -T >: IntegerValueType(1), >: kotlin.String +T >: IntegerValueType(1), >: String status: -hasCannotCaptureTypesError: false @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Comparable +T=Comparable \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index baa972d9ddb..2ac118165c5 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Int +T=Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index 56018383515..6e09380a9ed 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Byte type parameter bounds: -T >: IntegerValueType(1), <: kotlin.Byte +T >: IntegerValueType(1), <: Byte status: -hasCannotCaptureTypesError: false @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Byte +T=Byte \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index fc8290b88cd..5271316e2c3 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -16,4 +16,4 @@ status: -isSuccessful: true result: -T=kotlin.Int +T=Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 846da5f8405..44f7762efa6 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -4,7 +4,7 @@ SUPERTYPE T IntegerValueType(1) SUBTYPE T Short type parameter bounds: -T >: IntegerValueType(1), <: kotlin.Short +T >: IntegerValueType(1), <: Short status: -hasCannotCaptureTypesError: false @@ -17,4 +17,4 @@ status: -isSuccessful: true result: -T=kotlin.Short +T=Short \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index 7d89b1b9557..6b8c2fac7e7 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -3,8 +3,8 @@ VARIABLES T P SUBTYPE T Int type parameter bounds: -T <: kotlin.Int -P <: kotlin.Int +T <: Int +P <: Int status: -hasCannotCaptureTypesError: false @@ -17,6 +17,5 @@ status: -isSuccessful: true result: -T=kotlin.Int -P=kotlin.Int - +T=Int +P=Int \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index e8065aec277..319527fc06f 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.constraintSystem import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.diagnostics.rendering.Renderers +import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL @@ -108,7 +109,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { for ((typeParameter, variance) in typeParameterDescriptors) { val parameterType = testDeclarations.getType(typeParameter.getName().asString()) val resultType = resultingSubstitutor.substitute(parameterType, variance) - result append "${typeParameter.getName()}=${resultType?.let{ Renderers.RENDER_TYPE.render(it) }}\n" + result append "${typeParameter.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}\n" } JetTestUtils.assertEqualsToFile(file, "${getConstraintsText(fileText)}${resultingStatus}\n\n${result}\n") From 07937a27eb5767c29d28a75eb03cbd2d7f2cac31 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 26 Jun 2015 22:07:34 +0300 Subject: [PATCH 189/450] Added GenericCandidateResolver --- .../kotlin/resolve/calls/CallCompleter.kt | 54 ++-- .../kotlin/resolve/calls/CallResolver.java | 8 +- .../resolve/calls/CallResolverUtil.java | 31 ++- .../resolve/calls/CandidateResolver.java | 249 ++---------------- .../resolve/calls/GenericCandidateResolver.kt | 234 ++++++++++++++++ 5 files changed, 307 insertions(+), 269 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 03ac7c51fa4..10f47212712 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -16,35 +16,34 @@ package org.jetbrains.kotlin.resolve.calls -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext -import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl -import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy -import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.resolve.BindingTrace -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem -import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext.CONSTRAINT_SYSTEM_COMPLETER -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl -import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext -import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus -import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext -import org.jetbrains.kotlin.resolve.calls.callUtil.* import org.jetbrains.kotlin.resolve.BindingContextUtils -import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.TemporaryBindingTrace +import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callUtil.getCall +import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl +import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.FROM_COMPLETER +import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo +import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.DataFlowUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS -import org.jetbrains.kotlin.resolve.TemporaryBindingTrace import java.util.ArrayList -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* -import org.jetbrains.kotlin.resolve.calls.model.* public class CallCompleter( val argumentTypeResolver: ArgumentTypeResolver, @@ -211,7 +210,7 @@ public class CallCompleter( for (valueArgument in context.call.getValueArguments()) { val argumentMapping = getArgumentMapping(valueArgument!!) val expectedType = when (argumentMapping) { - is ArgumentMatch -> CandidateResolver.getEffectiveExpectedType(argumentMapping.valueParameter, valueArgument) + is ArgumentMatch -> getEffectiveExpectedType(argumentMapping.valueParameter, valueArgument) else -> TypeUtils.NO_EXPECTED_TYPE } val newContext = context.replaceDataFlowInfo(getDataFlowInfoForArgument(valueArgument)).replaceExpectedType(expectedType) @@ -226,8 +225,7 @@ public class CallCompleter( if (valueArgument.isExternal()) return val expression = valueArgument.getArgumentExpression() ?: return - val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context) - if (deparenthesized == null) return + val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context) ?: return val recordedType = expression.let { context.trace.getType(it) } var updatedType: JetType? = recordedType @@ -263,11 +261,9 @@ public class CallCompleter( ): OverloadResolutionResultsImpl<*>? { if (!ExpressionTypingUtils.dependsOnExpectedType(expression)) return null - val argumentCall = expression.getCall(context.trace.getBindingContext()) - if (argumentCall == null) return null + val argumentCall = expression.getCall(context.trace.getBindingContext()) ?: return null - val cachedDataForCall = context.resolutionResultsCache[argumentCall] - if (cachedDataForCall == null) return null + val cachedDataForCall = context.resolutionResultsCache[argumentCall] ?: return null val (cachedResolutionResults, cachedContext, tracing) = cachedDataForCall @suppress("UNCHECKED_CAST") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index befe4e08b78..80c19ad9380 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -71,6 +71,7 @@ public class CallResolver { private TypeResolver typeResolver; private CandidateResolver candidateResolver; private ArgumentTypeResolver argumentTypeResolver; + private GenericCandidateResolver genericCandidateResolver; private CallCompleter callCompleter; private TaskPrioritizer taskPrioritizer; private AdditionalCheckerProvider additionalCheckerProvider; @@ -98,6 +99,11 @@ public class CallResolver { this.argumentTypeResolver = argumentTypeResolver; } + @Inject + public void setGenericCandidateResolver(GenericCandidateResolver genericCandidateResolver) { + this.genericCandidateResolver = genericCandidateResolver; + } + @Inject public void setCallCompleter(@NotNull CallCompleter callCompleter) { this.callCompleter = callCompleter; @@ -480,7 +486,7 @@ public class CallResolver { CallCandidateResolutionContext candidateContext = CallCandidateResolutionContext.createForCallBeingAnalyzed( results.getResultingCall(), context, tracing); - candidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext); + genericCandidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext); } private static void cacheResults( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java index fbea050b811..d4884e629f9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java @@ -21,14 +21,8 @@ import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.CallableDescriptor; -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor; -import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor; -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; -import org.jetbrains.kotlin.psi.Call; -import org.jetbrains.kotlin.psi.JetExpression; -import org.jetbrains.kotlin.psi.JetSimpleNameExpression; -import org.jetbrains.kotlin.psi.JetSuperExpression; +import org.jetbrains.kotlin.descriptors.*; +import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; @@ -165,4 +159,25 @@ public class CallResolverUtil { } return null; } + + @NotNull + public static JetType getEffectiveExpectedType(@NotNull ValueParameterDescriptor parameterDescriptor, @NotNull ValueArgument argument) { + if (argument.getSpreadElement() != null) { + if (parameterDescriptor.getVarargElementType() == null) { + // Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper + return DONT_CARE; + } + else { + return parameterDescriptor.getType(); + } + } + else { + JetType varargElementType = parameterDescriptor.getVarargElementType(); + if (varargElementType != null) { + return varargElementType; + } + + return parameterDescriptor.getType(); + } + } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java index 8dd1a19901b..8491a71e8f5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.resolve.calls; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Sets; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; @@ -28,12 +27,12 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; -import org.jetbrains.kotlin.resolve.calls.context.*; -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem; -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl; +import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext; +import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext; +import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode; +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext; import org.jetbrains.kotlin.resolve.calls.model.*; import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus; -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory; import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils; @@ -49,29 +48,35 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import javax.inject.Inject; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import static org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT; import static org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER; -import static org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getLastElementDeparenthesized; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType; import static org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke; -import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT; -import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION; -import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION; import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*; -import static org.jetbrains.kotlin.types.TypeUtils.*; +import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType; public class CandidateResolver { @NotNull private ArgumentTypeResolver argumentTypeResolver; + @NotNull + private GenericCandidateResolver genericCandidateResolver; @Inject public void setArgumentTypeResolver(@NotNull ArgumentTypeResolver argumentTypeResolver) { this.argumentTypeResolver = argumentTypeResolver; } + @Inject + public void setGenericCandidateResolver(@NotNull GenericCandidateResolver genericCandidateResolver) { + this.genericCandidateResolver = genericCandidateResolver; + } + public void performResolutionForCandidateCall( @NotNull CallCandidateResolutionContext context, @NotNull ResolutionTask task) { @@ -160,7 +165,7 @@ public class CandidateResolver { if (jetTypeArguments.isEmpty() && !candidate.getTypeParameters().isEmpty() && candidateCall.getKnownTypeParametersSubstitutor() == null) { - candidateCall.addStatus(inferTypeArguments(context)); + candidateCall.addStatus(genericCandidateResolver.inferTypeArguments(context)); } else { candidateCall.addStatus(checkAllValueArguments(context, SHAPE_FUNCTION_ARGUMENTS).status); @@ -287,203 +292,6 @@ public class CandidateResolver { return descriptor instanceof ClassDescriptor ? (ClassDescriptor) descriptor : null; } - public void completeTypeInferenceDependentOnFunctionLiteralsForCall( - CallCandidateResolutionContext context - ) { - MutableResolvedCall resolvedCall = context.candidateCall; - ConstraintSystem constraintSystem = resolvedCall.getConstraintSystem(); - if (constraintSystem == null) return; - - // constraints for function literals - // Value parameters - for (Map.Entry entry : resolvedCall.getValueArguments().entrySet()) { - ResolvedValueArgument resolvedValueArgument = entry.getValue(); - ValueParameterDescriptor valueParameterDescriptor = entry.getKey(); - - for (ValueArgument valueArgument : resolvedValueArgument.getArguments()) { - addConstraintForFunctionLiteral(valueArgument, valueParameterDescriptor, constraintSystem, context); - } - } - resolvedCall.setResultingSubstitutor(constraintSystem.getResultingSubstitutor()); - } - - private void addConstraintForFunctionLiteral( - @NotNull ValueArgument valueArgument, - @NotNull ValueParameterDescriptor valueParameterDescriptor, - @NotNull ConstraintSystem constraintSystem, - @NotNull CallCandidateResolutionContext context - ) { - JetExpression argumentExpression = valueArgument.getArgumentExpression(); - if (argumentExpression == null) return; - if (!ArgumentTypeResolver.isFunctionLiteralArgument(argumentExpression, context)) return; - - JetFunction functionLiteral = ArgumentTypeResolver.getFunctionLiteralArgument(argumentExpression, context); - - JetType effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument); - JetType expectedType = constraintSystem.getCurrentSubstitutor().substitute(effectiveExpectedType, Variance.INVARIANT); - if (expectedType == null || TypeUtils.isDontCarePlaceholder(expectedType)) { - expectedType = argumentTypeResolver.getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, false); - } - if (expectedType == null || !KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType) - || CallResolverUtil.hasUnknownFunctionParameter(expectedType)) { - return; - } - MutableDataFlowInfoForArguments dataFlowInfoForArguments = context.candidateCall.getDataFlowInfoForArguments(); - DataFlowInfo dataFlowInfoForArgument = dataFlowInfoForArguments.getInfo(valueArgument); - - //todo analyze function literal body once in 'dependent' mode, then complete it with respect to expected type - boolean hasExpectedReturnType = !CallResolverUtil.hasUnknownReturnType(expectedType); - if (hasExpectedReturnType) { - TemporaryTraceAndCache temporaryToResolveFunctionLiteral = TemporaryTraceAndCache.create( - context, "trace to resolve function literal with expected return type", argumentExpression); - - JetExpression statementExpression = JetPsiUtil.getExpressionOrLastStatementInBlock(functionLiteral.getBodyExpression()); - if (statementExpression == null) return; - boolean[] mismatch = new boolean[1]; - ObservableBindingTrace errorInterceptingTrace = ExpressionTypingUtils.makeTraceInterceptingTypeMismatch( - temporaryToResolveFunctionLiteral.trace, statementExpression, mismatch); - CallCandidateResolutionContext newContext = context - .replaceBindingTrace(errorInterceptingTrace).replaceExpectedType(expectedType) - .replaceDataFlowInfo(dataFlowInfoForArgument).replaceResolutionResultsCache(temporaryToResolveFunctionLiteral.cache) - .replaceContextDependency(INDEPENDENT); - JetType type = argumentTypeResolver.getFunctionLiteralTypeInfo( - argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).getType(); - if (!mismatch[0]) { - constraintSystem.addSubtypeConstraint( - type, effectiveExpectedType, VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex())); - temporaryToResolveFunctionLiteral.commit(); - return; - } - } - JetType expectedTypeWithoutReturnType = hasExpectedReturnType ? CallResolverUtil.replaceReturnTypeByUnknown(expectedType) : expectedType; - CallCandidateResolutionContext newContext = context - .replaceExpectedType(expectedTypeWithoutReturnType).replaceDataFlowInfo(dataFlowInfoForArgument) - .replaceContextDependency(INDEPENDENT); - JetType type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, - RESOLVE_FUNCTION_ARGUMENTS).getType(); - constraintSystem.addSubtypeConstraint( - type, effectiveExpectedType, VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex())); - } - - private ResolutionStatus inferTypeArguments(CallCandidateResolutionContext context) { - MutableResolvedCall candidateCall = context.candidateCall; - final D candidate = candidateCall.getCandidateDescriptor(); - - ConstraintSystemImpl constraintSystem = new ConstraintSystemImpl(); - - // If the call is recursive, e.g. - // fun foo(t : T) : T = foo(t) - // we can't use same descriptor objects for T's as actual type values and same T's as unknowns, - // because constraints become trivial (T :< T), and inference fails - // - // Thus, we replace the parameters of our descriptor with fresh objects (perform alpha-conversion) - CallableDescriptor candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidate); - - Map typeVariables = Maps.newLinkedHashMap(); - for (TypeParameterDescriptor typeParameterDescriptor : candidateWithFreshVariables.getTypeParameters()) { - typeVariables.put(typeParameterDescriptor, Variance.INVARIANT); // TODO: variance of the occurrences - } - constraintSystem.registerTypeVariables(typeVariables); - - TypeSubstitutor substituteDontCare = - makeConstantSubstitutor(candidateWithFreshVariables.getTypeParameters(), DONT_CARE); - - // Value parameters - for (Map.Entry entry : candidateCall.getValueArguments().entrySet()) { - ResolvedValueArgument resolvedValueArgument = entry.getValue(); - ValueParameterDescriptor valueParameterDescriptor = candidateWithFreshVariables.getValueParameters().get(entry.getKey().getIndex()); - - - for (ValueArgument valueArgument : resolvedValueArgument.getArguments()) { - // TODO : more attempts, with different expected types - - // Here we type check expecting an error type (DONT_CARE, substitution with substituteDontCare) - // and throw the results away - // We'll type check the arguments later, with the inferred types expected - addConstraintForValueArgument(valueArgument, valueParameterDescriptor, substituteDontCare, constraintSystem, - context, SHAPE_FUNCTION_ARGUMENTS); - } - } - - // Receiver - // Error is already reported if something is missing - ReceiverValue receiverArgument = candidateCall.getExtensionReceiver(); - ReceiverParameterDescriptor receiverParameter = candidateWithFreshVariables.getExtensionReceiverParameter(); - if (receiverArgument.exists() && receiverParameter != null) { - JetType receiverType = - context.candidateCall.isSafeCall() - ? TypeUtils.makeNotNullable(receiverArgument.getType()) - : receiverArgument.getType(); - if (receiverArgument instanceof ExpressionReceiver) { - receiverType = updateResultTypeForSmartCasts( - receiverType, ((ExpressionReceiver) receiverArgument).getExpression(), context); - } - constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), RECEIVER_POSITION.position()); - } - - // Restore type variables before alpha-conversion - ConstraintSystem constraintSystemWithRightTypeParameters = constraintSystem.substituteTypeVariables( - new Function1() { - @Override - public TypeParameterDescriptor invoke(@NotNull TypeParameterDescriptor typeParameterDescriptor) { - return candidate.getTypeParameters().get(typeParameterDescriptor.getIndex()); - } - } - ); - candidateCall.setConstraintSystem(constraintSystemWithRightTypeParameters); - - - // Solution - boolean hasContradiction = constraintSystem.getStatus().hasContradiction(); - if (!hasContradiction) { - return INCOMPLETE_TYPE_INFERENCE; - } - return OTHER_ERROR; - } - - private void addConstraintForValueArgument( - @NotNull ValueArgument valueArgument, - @NotNull ValueParameterDescriptor valueParameterDescriptor, - @NotNull TypeSubstitutor substitutor, - @NotNull ConstraintSystem constraintSystem, - @NotNull CallCandidateResolutionContext context, - @NotNull CallResolverUtil.ResolveArgumentsMode resolveFunctionArgumentBodies) { - - JetType effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument); - JetExpression argumentExpression = valueArgument.getArgumentExpression(); - - JetType expectedType = substitutor.substitute(effectiveExpectedType, Variance.INVARIANT); - DataFlowInfo dataFlowInfoForArgument = context.candidateCall.getDataFlowInfoForArguments().getInfo(valueArgument); - CallResolutionContext newContext = context.replaceExpectedType(expectedType).replaceDataFlowInfo(dataFlowInfoForArgument); - - JetTypeInfo typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo( - argumentExpression, newContext, resolveFunctionArgumentBodies); - context.candidateCall.getDataFlowInfoForArguments().updateInfo(valueArgument, typeInfoForCall.getDataFlowInfo()); - - JetType type = updateResultTypeForSmartCasts( - typeInfoForCall.getType(), argumentExpression, context.replaceDataFlowInfo(dataFlowInfoForArgument)); - constraintSystem.addSubtypeConstraint( - type, effectiveExpectedType, VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex())); - } - - @Nullable - private static JetType updateResultTypeForSmartCasts( - @Nullable JetType type, - @Nullable JetExpression argumentExpression, - @NotNull ResolutionContext context - ) { - JetExpression deparenthesizedArgument = getLastElementDeparenthesized(argumentExpression, context); - if (deparenthesizedArgument == null || type == null) return type; - - DataFlowValue dataFlowValue = DataFlowValueFactory.createDataFlowValue(deparenthesizedArgument, type, context); - if (!dataFlowValue.isPredictable()) return type; - - Set possibleTypes = context.dataFlowInfo.getPossibleTypes(dataFlowValue); - if (possibleTypes.isEmpty()) return type; - - return TypeUtils.intersect(JetTypeChecker.DEFAULT, possibleTypes); - } - @NotNull private ValueArgumentsCheckingResult checkAllValueArguments( @NotNull CallCandidateResolutionContext context, @@ -696,27 +504,6 @@ public class CandidateResolver { } } - @NotNull - public static JetType getEffectiveExpectedType(ValueParameterDescriptor parameterDescriptor, ValueArgument argument) { - if (argument.getSpreadElement() != null) { - if (parameterDescriptor.getVarargElementType() == null) { - // Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper - return DONT_CARE; - } - else { - return parameterDescriptor.getType(); - } - } - else { - JetType varargElementType = parameterDescriptor.getVarargElementType(); - if (varargElementType != null) { - return varargElementType; - } - - return parameterDescriptor.getType(); - } - } - private static void checkGenericBoundsInAFunctionCall( @NotNull List jetTypeArguments, @NotNull List typeArguments, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt new file mode 100644 index 00000000000..86b56658ea0 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -0,0 +1,234 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.calls + +import com.google.common.collect.Maps +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.psi.JetExpression +import org.jetbrains.kotlin.psi.JetPsiUtil +import org.jetbrains.kotlin.psi.ValueArgument +import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil +import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getLastElementDeparenthesized +import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.INCOMPLETE_TYPE_INFERENCE +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.OTHER_ERROR +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory +import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE +import org.jetbrains.kotlin.types.TypeUtils.makeConstantSubstitutor +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils + + +class GenericCandidateResolver( + val argumentTypeResolver: ArgumentTypeResolver +) { + + fun inferTypeArguments(context: CallCandidateResolutionContext): ResolutionStatus { + val candidateCall = context.candidateCall + val candidate = candidateCall.getCandidateDescriptor() + + val constraintSystem = ConstraintSystemImpl() + + // If the call is recursive, e.g. + // fun foo(t : T) : T = foo(t) + // we can't use same descriptor objects for T's as actual type values and same T's as unknowns, + // because constraints become trivial (T :< T), and inference fails + // + // Thus, we replace the parameters of our descriptor with fresh objects (perform alpha-conversion) + val candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidate) + + val typeVariables = Maps.newLinkedHashMap() + for (typeParameterDescriptor in candidateWithFreshVariables.getTypeParameters()) { + typeVariables.put(typeParameterDescriptor, Variance.INVARIANT) // TODO: variance of the occurrences + } + constraintSystem.registerTypeVariables(typeVariables) + + val substituteDontCare = makeConstantSubstitutor(candidateWithFreshVariables.getTypeParameters(), DONT_CARE) + + // Value parameters + for (entry in candidateCall.getValueArguments().entrySet()) { + val resolvedValueArgument = entry.getValue() + val valueParameterDescriptor = candidateWithFreshVariables.getValueParameters().get(entry.getKey().getIndex()) + + + for (valueArgument in resolvedValueArgument.getArguments()) { + // TODO : more attempts, with different expected types + + // Here we type check expecting an error type (DONT_CARE, substitution with substituteDontCare) + // and throw the results away + // We'll type check the arguments later, with the inferred types expected + addConstraintForValueArgument(valueArgument, valueParameterDescriptor, substituteDontCare, + constraintSystem, context, SHAPE_FUNCTION_ARGUMENTS) + } + } + + // Receiver + // Error is already reported if something is missing + val receiverArgument = candidateCall.getExtensionReceiver() + val receiverParameter = candidateWithFreshVariables.getExtensionReceiverParameter() + if (receiverArgument.exists() && receiverParameter != null) { + var receiverType: JetType? = if (context.candidateCall.isSafeCall()) + TypeUtils.makeNotNullable(receiverArgument.getType()) + else + receiverArgument.getType() + if (receiverArgument is ExpressionReceiver) { + receiverType = updateResultTypeForSmartCasts(receiverType, receiverArgument.getExpression(), context) + } + constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), RECEIVER_POSITION.position()) + } + + // Restore type variables before alpha-conversion + val constraintSystemWithRightTypeParameters = constraintSystem.substituteTypeVariables { + candidate.getTypeParameters().get(it.getIndex()) + } + candidateCall.setConstraintSystem(constraintSystemWithRightTypeParameters) + + + // Solution + val hasContradiction = constraintSystem.getStatus().hasContradiction() + if (!hasContradiction) { + return INCOMPLETE_TYPE_INFERENCE + } + return OTHER_ERROR + } + + fun addConstraintForValueArgument( + valueArgument: ValueArgument, + valueParameterDescriptor: ValueParameterDescriptor, + substitutor: TypeSubstitutor, + constraintSystem: ConstraintSystem, + context: CallCandidateResolutionContext<*>, + resolveFunctionArgumentBodies: CallResolverUtil.ResolveArgumentsMode + ) { + + val effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument) + val argumentExpression = valueArgument.getArgumentExpression() + + val expectedType = substitutor.substitute(effectiveExpectedType, Variance.INVARIANT) + val dataFlowInfoForArgument = context.candidateCall.getDataFlowInfoForArguments().getInfo(valueArgument) + val newContext = context.replaceExpectedType(expectedType).replaceDataFlowInfo(dataFlowInfoForArgument) + + val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, newContext, resolveFunctionArgumentBodies) + context.candidateCall.getDataFlowInfoForArguments().updateInfo(valueArgument, typeInfoForCall.dataFlowInfo) + + val type = updateResultTypeForSmartCasts(typeInfoForCall.type, argumentExpression, context.replaceDataFlowInfo(dataFlowInfoForArgument)) + constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex())) + } + + private fun updateResultTypeForSmartCasts(type: JetType?, argumentExpression: JetExpression?, context: ResolutionContext<*>): JetType? { + val deparenthesizedArgument = getLastElementDeparenthesized(argumentExpression, context) + if (deparenthesizedArgument == null || type == null) return type + + val dataFlowValue = DataFlowValueFactory.createDataFlowValue(deparenthesizedArgument, type, context) + if (!dataFlowValue.isPredictable()) return type + + val possibleTypes = context.dataFlowInfo.getPossibleTypes(dataFlowValue) + if (possibleTypes.isEmpty()) return type + + return TypeUtils.intersect(JetTypeChecker.DEFAULT, possibleTypes) + } + + public fun completeTypeInferenceDependentOnFunctionLiteralsForCall( + context: CallCandidateResolutionContext + ) { + val resolvedCall = context.candidateCall + val constraintSystem = resolvedCall.getConstraintSystem() ?: return + + // constraints for function literals + // Value parameters + for (entry in resolvedCall.getValueArguments().entrySet()) { + val resolvedValueArgument = entry.getValue() + val valueParameterDescriptor = entry.getKey() + + for (valueArgument in resolvedValueArgument.getArguments()) { + addConstraintForFunctionLiteral(valueArgument, valueParameterDescriptor, constraintSystem, context) + } + } + resolvedCall.setResultingSubstitutor(constraintSystem.getResultingSubstitutor()) + } + + private fun addConstraintForFunctionLiteral( + valueArgument: ValueArgument, + valueParameterDescriptor: ValueParameterDescriptor, + constraintSystem: ConstraintSystem, + context: CallCandidateResolutionContext + ) { + val argumentExpression = valueArgument.getArgumentExpression() ?: return + if (!ArgumentTypeResolver.isFunctionLiteralArgument(argumentExpression, context)) return + + val functionLiteral = ArgumentTypeResolver.getFunctionLiteralArgument(argumentExpression, context) + + val effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument) + var expectedType = constraintSystem.getCurrentSubstitutor().substitute(effectiveExpectedType, Variance.INVARIANT) + if (expectedType == null || TypeUtils.isDontCarePlaceholder(expectedType)) { + expectedType = argumentTypeResolver.getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, false) + } + if (expectedType == null || !KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType) + || CallResolverUtil.hasUnknownFunctionParameter(expectedType)) { + return + } + val dataFlowInfoForArguments = context.candidateCall.getDataFlowInfoForArguments() + val dataFlowInfoForArgument = dataFlowInfoForArguments.getInfo(valueArgument) + + //todo analyze function literal body once in 'dependent' mode, then complete it with respect to expected type + val hasExpectedReturnType = !CallResolverUtil.hasUnknownReturnType(expectedType) + val position = VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex()) + if (hasExpectedReturnType) { + val temporaryToResolveFunctionLiteral = TemporaryTraceAndCache.create( + context, "trace to resolve function literal with expected return type", argumentExpression) + + val statementExpression = JetPsiUtil.getExpressionOrLastStatementInBlock(functionLiteral.getBodyExpression()) ?: return + val mismatch = BooleanArray(1) + val errorInterceptingTrace = ExpressionTypingUtils.makeTraceInterceptingTypeMismatch( + temporaryToResolveFunctionLiteral.trace, statementExpression, mismatch) + val newContext = context.replaceBindingTrace(errorInterceptingTrace).replaceExpectedType(expectedType) + .replaceDataFlowInfo(dataFlowInfoForArgument).replaceResolutionResultsCache(temporaryToResolveFunctionLiteral.cache) + .replaceContextDependency(INDEPENDENT) + val type = argumentTypeResolver.getFunctionLiteralTypeInfo( + argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type + if (!mismatch[0]) { + constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, position) + temporaryToResolveFunctionLiteral.commit() + return + } + } + val expectedTypeWithoutReturnType = if (hasExpectedReturnType) CallResolverUtil.replaceReturnTypeByUnknown(expectedType) else expectedType + val newContext = context.replaceExpectedType(expectedTypeWithoutReturnType).replaceDataFlowInfo(dataFlowInfoForArgument) + .replaceContextDependency(INDEPENDENT) + val type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type + constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, position) + } +} \ No newline at end of file From 82acce476744f7d58c491d0a57c971be670bc0d0 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 27 Jun 2015 15:38:56 +0300 Subject: [PATCH 190/450] Separate input and result data in constraint system test input file: *.constraints result file: *.bounds --- .../conflictingConstraints.constraints | 4 + .../checkStatus/successful.constraints | 4 + .../typeConstructorMismatch.constraints | 3 + .../checkStatus/unknownParameters.constraints | 3 + .../violatedUpperBound.constraints | 4 + .../computeValues/contradiction.constraints | 4 + .../subTypeOfUpperBounds.constraints | 4 + .../superTypeOfLowerBounds1.constraints | 4 + .../superTypeOfLowerBounds2.constraints | 5 + .../byteOverflow.constraints | 4 + .../integerValueTypes/defaultLong.constraints | 4 + .../numberAndAny.constraints | 4 + .../numberAndString.constraints | 4 + .../severalNumbers.constraints | 4 + .../integerValueTypes/simpleByte.constraints | 4 + .../integerValueTypes/simpleInt.constraints | 3 + .../integerValueTypes/simpleShort.constraints | 4 + .../simpleDependency.constraints | 3 + .../variance/consumer.constraints | 3 + .../variance/invariant.constraints | 3 + .../variance/producer.constraints | 3 + .../AbstractConstraintSystemTest.kt | 15 ++- .../ConstraintSystemTestGenerated.java | 96 +++++++++---------- .../kotlin/generators/tests/GenerateTests.kt | 2 +- 24 files changed, 134 insertions(+), 57 deletions(-) create mode 100644 compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints create mode 100644 compiler/testData/constraintSystem/checkStatus/successful.constraints create mode 100644 compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints create mode 100644 compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints create mode 100644 compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints create mode 100644 compiler/testData/constraintSystem/computeValues/contradiction.constraints create mode 100644 compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints create mode 100644 compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints create mode 100644 compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints create mode 100644 compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints create mode 100644 compiler/testData/constraintSystem/variance/consumer.constraints create mode 100644 compiler/testData/constraintSystem/variance/invariant.constraints create mode 100644 compiler/testData/constraintSystem/variance/producer.constraints diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints new file mode 100644 index 00000000000..a5ac8d81123 --- /dev/null +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T Int +SUPERTYPE T String \ No newline at end of file diff --git a/compiler/testData/constraintSystem/checkStatus/successful.constraints b/compiler/testData/constraintSystem/checkStatus/successful.constraints new file mode 100644 index 00000000000..c1b1b12a5fd --- /dev/null +++ b/compiler/testData/constraintSystem/checkStatus/successful.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T Int +SUPERTYPE T Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints new file mode 100644 index 00000000000..2e3b5a78d74 --- /dev/null +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUBTYPE List Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints b/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints new file mode 100644 index 00000000000..9e0d87313e9 --- /dev/null +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUBTYPE Any Any \ No newline at end of file diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints new file mode 100644 index 00000000000..ef8b411f40e --- /dev/null +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T Int +SUBTYPE T String weak \ No newline at end of file diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.constraints b/compiler/testData/constraintSystem/computeValues/contradiction.constraints new file mode 100644 index 00000000000..c90fa4b41d5 --- /dev/null +++ b/compiler/testData/constraintSystem/computeValues/contradiction.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T B +SUPERTYPE T A \ No newline at end of file diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints new file mode 100644 index 00000000000..c7c0b551365 --- /dev/null +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T A +SUBTYPE T B \ No newline at end of file diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints new file mode 100644 index 00000000000..7a4c1d73476 --- /dev/null +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUBTYPE T A +SUPERTYPE T C \ No newline at end of file diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints new file mode 100644 index 00000000000..fc1003c2de3 --- /dev/null +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints @@ -0,0 +1,5 @@ +VARIABLES T + +SUBTYPE T A +SUPERTYPE T B +SUPERTYPE T C \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints new file mode 100644 index 00000000000..008d49843d5 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1000) +SUBTYPE T Byte \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints new file mode 100644 index 00000000000..2ba8bedaa26 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUPERTYPE T IntegerValueType(10000000000) \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints new file mode 100644 index 00000000000..89f32451478 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUBTYPE T Any \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints new file mode 100644 index 00000000000..300daefcb17 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUPERTYPE T String \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints new file mode 100644 index 00000000000..0e58b001f34 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUPERTYPE T IntegerValueType(1000) \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints new file mode 100644 index 00000000000..a8cb3c80fe3 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUBTYPE T Byte \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints new file mode 100644 index 00000000000..2a2545431db --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) \ No newline at end of file diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints new file mode 100644 index 00000000000..2de8feeb212 --- /dev/null +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +SUPERTYPE T IntegerValueType(1) +SUBTYPE T Short \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints b/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints new file mode 100644 index 00000000000..4c5f7e33f88 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints @@ -0,0 +1,3 @@ +VARIABLES T P + +SUBTYPE T Int \ No newline at end of file diff --git a/compiler/testData/constraintSystem/variance/consumer.constraints b/compiler/testData/constraintSystem/variance/consumer.constraints new file mode 100644 index 00000000000..aa4ca88a3ee --- /dev/null +++ b/compiler/testData/constraintSystem/variance/consumer.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUBTYPE Consumer Consumer \ No newline at end of file diff --git a/compiler/testData/constraintSystem/variance/invariant.constraints b/compiler/testData/constraintSystem/variance/invariant.constraints new file mode 100644 index 00000000000..cb2df5faa67 --- /dev/null +++ b/compiler/testData/constraintSystem/variance/invariant.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUBTYPE My My \ No newline at end of file diff --git a/compiler/testData/constraintSystem/variance/producer.constraints b/compiler/testData/constraintSystem/variance/producer.constraints new file mode 100644 index 00000000000..2044f7f1535 --- /dev/null +++ b/compiler/testData/constraintSystem/variance/producer.constraints @@ -0,0 +1,3 @@ +VARIABLES T + +SUBTYPE Producer Producer \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 319527fc06f..1cffd813aba 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -37,7 +37,7 @@ import java.util.regex.Pattern abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { private val typePattern = """([\w|<|>|\(|\)]+)""" - val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE)\s+${typePattern}\s+${typePattern}\s+(weak)?""", Pattern.MULTILINE) + val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE)\s+$typePattern\s+$typePattern\s*(weak)?""") val variablesPattern = Pattern.compile("VARIABLES\\s+(.*)") private var _typeResolver: TypeResolver? = null @@ -78,19 +78,19 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { } public fun doTest(filePath: String) { - val file = File(filePath) - val fileText = JetTestUtils.doLoadFile(file)!! + val constraintsFile = File(filePath) + val constraintsFileText = JetTestUtils.doLoadFile(constraintsFile)!! val constraintSystem = ConstraintSystemImpl() val typeParameterDescriptors = LinkedHashMap() - val variables = parseVariables(fileText) + val variables = parseVariables(constraintsFileText) for (variable in variables) { typeParameterDescriptors.put(testDeclarations.getParameterDescriptor(variable), Variance.INVARIANT) } constraintSystem.registerTypeVariables(typeParameterDescriptors) - val constraints = parseConstraints(fileText) + val constraints = parseConstraints(constraintsFileText) for (constraint in constraints) { val firstType = testDeclarations.getType(constraint.firstType) val secondType = testDeclarations.getType(constraint.secondType) @@ -112,7 +112,8 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { result append "${typeParameter.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}\n" } - JetTestUtils.assertEqualsToFile(file, "${getConstraintsText(fileText)}${resultingStatus}\n\n${result}\n") + val boundsFile = File(filePath.replace("constraints", "bounds")) + JetTestUtils.assertEqualsToFile(boundsFile, "$constraintsFileText\n\n$resultingStatus\n\n$result\n") } class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String, val isWeak: Boolean) @@ -142,6 +143,4 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { } return constraints } - - private fun getConstraintsText(text: String) = text.substring(0, text.indexOf("type parameter bounds")) } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index ad46a55b788..dd7ff89021f 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -32,7 +32,7 @@ import java.util.regex.Pattern; @RunWith(JUnit3RunnerWithInners.class) public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest { public void testAllFilesPresentInConstraintSystem() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem"), Pattern.compile("^(.+)\\.constraints$"), true); } @TestMetadata("compiler/testData/constraintSystem/checkStatus") @@ -40,36 +40,36 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest @RunWith(JUnit3RunnerWithInners.class) public static class CheckStatus extends AbstractConstraintSystemTest { public void testAllFilesPresentInCheckStatus() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/checkStatus"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/checkStatus"), Pattern.compile("^(.+)\\.constraints$"), true); } - @TestMetadata("conflictingConstraints.bounds") + @TestMetadata("conflictingConstraints.constraints") public void testConflictingConstraints() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints"); doTest(fileName); } - @TestMetadata("successful.bounds") + @TestMetadata("successful.constraints") public void testSuccessful() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/successful.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/successful.constraints"); doTest(fileName); } - @TestMetadata("typeConstructorMismatch.bounds") + @TestMetadata("typeConstructorMismatch.constraints") public void testTypeConstructorMismatch() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints"); doTest(fileName); } - @TestMetadata("unknownParameters.bounds") + @TestMetadata("unknownParameters.constraints") public void testUnknownParameters() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints"); doTest(fileName); } - @TestMetadata("violatedUpperBound.bounds") + @TestMetadata("violatedUpperBound.constraints") public void testViolatedUpperBound() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints"); doTest(fileName); } } @@ -79,30 +79,30 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest @RunWith(JUnit3RunnerWithInners.class) public static class ComputeValues extends AbstractConstraintSystemTest { public void testAllFilesPresentInComputeValues() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/computeValues"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/computeValues"), Pattern.compile("^(.+)\\.constraints$"), true); } - @TestMetadata("contradiction.bounds") + @TestMetadata("contradiction.constraints") public void testContradiction() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/contradiction.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/contradiction.constraints"); doTest(fileName); } - @TestMetadata("subTypeOfUpperBounds.bounds") + @TestMetadata("subTypeOfUpperBounds.constraints") public void testSubTypeOfUpperBounds() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints"); doTest(fileName); } - @TestMetadata("superTypeOfLowerBounds1.bounds") + @TestMetadata("superTypeOfLowerBounds1.constraints") public void testSuperTypeOfLowerBounds1() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints"); doTest(fileName); } - @TestMetadata("superTypeOfLowerBounds2.bounds") + @TestMetadata("superTypeOfLowerBounds2.constraints") public void testSuperTypeOfLowerBounds2() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints"); doTest(fileName); } } @@ -112,54 +112,54 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest @RunWith(JUnit3RunnerWithInners.class) public static class IntegerValueTypes extends AbstractConstraintSystemTest { public void testAllFilesPresentInIntegerValueTypes() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/integerValueTypes"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/integerValueTypes"), Pattern.compile("^(.+)\\.constraints$"), true); } - @TestMetadata("byteOverflow.bounds") + @TestMetadata("byteOverflow.constraints") public void testByteOverflow() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints"); doTest(fileName); } - @TestMetadata("defaultLong.bounds") + @TestMetadata("defaultLong.constraints") public void testDefaultLong() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints"); doTest(fileName); } - @TestMetadata("numberAndAny.bounds") + @TestMetadata("numberAndAny.constraints") public void testNumberAndAny() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints"); doTest(fileName); } - @TestMetadata("numberAndString.bounds") + @TestMetadata("numberAndString.constraints") public void testNumberAndString() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints"); doTest(fileName); } - @TestMetadata("severalNumbers.bounds") + @TestMetadata("severalNumbers.constraints") public void testSeveralNumbers() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints"); doTest(fileName); } - @TestMetadata("simpleByte.bounds") + @TestMetadata("simpleByte.constraints") public void testSimpleByte() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints"); doTest(fileName); } - @TestMetadata("simpleInt.bounds") + @TestMetadata("simpleInt.constraints") public void testSimpleInt() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints"); doTest(fileName); } - @TestMetadata("simpleShort.bounds") + @TestMetadata("simpleShort.constraints") public void testSimpleShort() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints"); doTest(fileName); } } @@ -169,12 +169,12 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest @RunWith(JUnit3RunnerWithInners.class) public static class SeveralVariables extends AbstractConstraintSystemTest { public void testAllFilesPresentInSeveralVariables() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables"), Pattern.compile("^(.+)\\.constraints$"), true); } - @TestMetadata("simpleDependency.bounds") + @TestMetadata("simpleDependency.constraints") public void testSimpleDependency() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints"); doTest(fileName); } } @@ -184,24 +184,24 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest @RunWith(JUnit3RunnerWithInners.class) public static class Variance extends AbstractConstraintSystemTest { public void testAllFilesPresentInVariance() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/variance"), Pattern.compile("^(.+)\\.bounds$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/variance"), Pattern.compile("^(.+)\\.constraints$"), true); } - @TestMetadata("consumer.bounds") + @TestMetadata("consumer.constraints") public void testConsumer() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/consumer.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/consumer.constraints"); doTest(fileName); } - @TestMetadata("invariant.bounds") + @TestMetadata("invariant.constraints") public void testInvariant() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/invariant.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/invariant.constraints"); doTest(fileName); } - @TestMetadata("producer.bounds") + @TestMetadata("producer.constraints") public void testProducer() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/producer.bounds"); + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/variance/producer.constraints"); doTest(fileName); } } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index bd33facd22e..a8002afcd25 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -158,7 +158,7 @@ fun main(args: Array) { } testClass(javaClass()) { - model("constraintSystem", extension = "bounds") + model("constraintSystem", extension = "constraints") } testClass(javaClass()) { From 9a5abf368f2c5ef996b8cb7185719bcb78fe2b36 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 27 Jun 2015 13:49:11 +0300 Subject: [PATCH 191/450] Constraint incorporation In a constraint system a new bound is incorporated: all new constrains that can be derived from it (and from existing ones) are added --- .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../kotlin/diagnostics/rendering/Renderers.kt | 4 +- .../resolve/calls/ArgumentTypeResolver.java | 4 +- .../kotlin/resolve/calls/CallCompleter.kt | 11 +- .../resolve/calls/GenericCandidateResolver.kt | 14 +- .../calls/tasks/AbstractTracingStrategy.java | 3 + .../calls/tasks/ResolutionTaskHolder.kt | 2 +- .../inference/extensionProperty.kt | 4 +- .../conflictingSubstitutionsFromUpperBound.kt | 4 +- .../upperBounds/doNotInferFromBoundsOnly.kt | 6 +- .../tests/platformTypes/inference.kt | 5 +- .../regressions/itselfAsUpperBoundLocal.kt | 2 +- .../tests/resolve/nestedCalls/kt7597.kt | 6 +- .../resolve/nestedCalls/twoTypeParameters.kt | 7 +- .../testsWithStdLib/resolve/kt4711.kt | 4 +- .../arguments/realExamples/emptyList.txt | 4 +- .../realExamples/emptyMutableList.txt | 4 +- .../AbstractConstraintSystemTest.kt | 22 +- .../calls/inference/ConstraintError.kt | 12 +- .../calls/inference/ConstraintPosition.kt | 10 +- .../calls/inference/ConstraintSystem.kt | 9 +- .../calls/inference/ConstraintSystemImpl.kt | 264 ++++++++++-------- .../calls/inference/ConstraintSystemStatus.kt | 5 + .../resolve/calls/inference/TypeBounds.kt | 48 +++- .../resolve/calls/inference/TypeBoundsImpl.kt | 89 ++++-- .../inference/constraintIncorporation.kt | 138 +++++++++ .../org/jetbrains/kotlin/types/TypeUtils.java | 3 +- .../org/jetbrains/kotlin/types/TypeUtils.kt | 47 +++- .../jetbrains/kotlin/idea/util/FuzzyType.kt | 23 +- 30 files changed, 531 insertions(+), 225 deletions(-) create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 078556686d8..f337d9fe35d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -459,6 +459,7 @@ public interface Errors { DiagnosticFactory1 TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_CANNOT_CAPTURE_TYPES = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory0 TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 5eed0c12740..b1ae845790f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -593,6 +593,7 @@ public class DefaultErrorMessages { MAP.put(TYPE_INFERENCE_CANNOT_CAPTURE_TYPES, "Type inference failed: {0}", TYPE_INFERENCE_CANNOT_CAPTURE_TYPES_RENDERER); MAP.put(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Type inference failed: {0}", TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER); MAP.put(TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, "Type inference failed: {0}", TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER); + MAP.put(TYPE_INFERENCE_INCORPORATION_ERROR, "Type inference failed. Please try to specify type arguments explicitly."); MAP.put(TYPE_INFERENCE_UPPER_BOUND_VIOLATED, "{0}", TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER); MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, "Type inference failed. Expected type mismatch: found: {1} required: {0}", RENDER_TYPE, RENDER_TYPE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index f08c04f856b..2a1061b0c49 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -228,7 +228,7 @@ public object Renderers { return result .text(newText().normal("Not enough information to infer parameter ") - .strong(firstUnknownParameter!!.getName()) + .strong(firstUnknownParameter.getName()) .normal(" in ")) .table(newTable() .descriptor(inferenceErrorData.descriptor) @@ -246,7 +246,7 @@ public object Renderers { val systemWithoutWeakConstraints = constraintSystem.getSystemWithoutWeakConstraints() val typeParameterDescriptor = inferenceErrorData.descriptor.getTypeParameters().firstOrNull { - !ConstraintsUtil.checkUpperBoundIsSatisfied(systemWithoutWeakConstraints, it, true) + !ConstraintsUtil.checkUpperBoundIsSatisfied(systemWithoutWeakConstraints, it, true) } if (typeParameterDescriptor == null && status.hasConflictingConstraints()) { return renderConflictingSubstitutionsInferenceError(inferenceErrorData, result) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java index e3ad15b08ef..6d57f4c0e68 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java @@ -55,7 +55,7 @@ import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumen import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.DEPENDENT; import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT; -import static org.jetbrains.kotlin.resolve.calls.inference.InferencePackage.createCorrespondingFunctionTypeForFunctionPlaceholder; +import static org.jetbrains.kotlin.resolve.calls.inference.InferencePackage.createTypeForFunctionPlaceholder; import static org.jetbrains.kotlin.types.TypeUtils.DONT_CARE; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; @@ -85,7 +85,7 @@ public class ArgumentTypeResolver { @NotNull JetType expectedType ) { if (ErrorUtils.isFunctionPlaceholder(actualType)) { - JetType functionType = createCorrespondingFunctionTypeForFunctionPlaceholder(actualType, expectedType); + JetType functionType = createTypeForFunctionPlaceholder(actualType, expectedType); return JetTypeChecker.DEFAULT.isSubtypeOf(functionType, expectedType); } return JetTypeChecker.DEFAULT.isSubtypeOf(actualType, expectedType); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 10f47212712..1a0700d8119 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -44,6 +44,9 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.DataFlowUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import java.util.ArrayList +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* +import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.types.ErrorUtils public class CallCompleter( val argumentTypeResolver: ArgumentTypeResolver, @@ -151,8 +154,6 @@ public class CallCompleter( } } - (getConstraintSystem() as ConstraintSystemImpl).processDeclaredBoundConstraints() - if (returnType != null && expectedType === TypeUtils.UNIT_EXPECTED_TYPE) { updateSystemIfSuccessful { system -> @@ -161,6 +162,9 @@ public class CallCompleter( } } + val constraintSystem = getConstraintSystem() as ConstraintSystemImpl + constraintSystem.fixVariables() + setResultingSubstitutor(getConstraintSystem()!!.getResultingSubstitutor()) } @@ -280,7 +284,8 @@ public class CallCompleter( argumentExpression: JetExpression, trace: BindingTrace ): JetType? { - if (recordedType == updatedType || updatedType == null) return updatedType + //workaround for KT-8218 + if ((!ErrorUtils.containsErrorType(recordedType) && recordedType == updatedType) || updatedType == null) return updatedType fun deparenthesizeOrGetSelector(expression: JetExpression?): JetExpression? { val deparenthesized = JetPsiUtil.deparenthesizeOnce(expression, /* deparenthesizeBinaryExpressionWithTypeRHS = */ false) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 86b56658ea0..b784dcb9953 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -70,11 +70,9 @@ class GenericCandidateResolver( // Thus, we replace the parameters of our descriptor with fresh objects (perform alpha-conversion) val candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidate) - val typeVariables = Maps.newLinkedHashMap() - for (typeParameterDescriptor in candidateWithFreshVariables.getTypeParameters()) { - typeVariables.put(typeParameterDescriptor, Variance.INVARIANT) // TODO: variance of the occurrences - } - constraintSystem.registerTypeVariables(typeVariables) + val backConversion = candidateWithFreshVariables.getTypeParameters().zip(candidate.getTypeParameters()).toMap() + + constraintSystem.registerTypeVariables(candidateWithFreshVariables.getTypeParameters(), { Variance.INVARIANT }) val substituteDontCare = makeConstantSubstitutor(candidateWithFreshVariables.getTypeParameters(), DONT_CARE) @@ -111,9 +109,7 @@ class GenericCandidateResolver( } // Restore type variables before alpha-conversion - val constraintSystemWithRightTypeParameters = constraintSystem.substituteTypeVariables { - candidate.getTypeParameters().get(it.getIndex()) - } + val constraintSystemWithRightTypeParameters = constraintSystem.substituteTypeVariables { backConversion.get(it) } candidateCall.setConstraintSystem(constraintSystemWithRightTypeParameters) @@ -174,7 +170,7 @@ class GenericCandidateResolver( val valueParameterDescriptor = entry.getKey() for (valueArgument in resolvedValueArgument.getArguments()) { - addConstraintForFunctionLiteral(valueArgument, valueParameterDescriptor, constraintSystem, context) + addConstraintForFunctionLiteral(valueArgument, valueParameterDescriptor, constraintSystem, context) } } resolvedCall.setResultingSubstitutor(constraintSystem.getResultingSubstitutor()) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index a3f1ceaf1f6..69f1fec7b05 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -233,6 +233,9 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { else if (status.hasConflictingConstraints()) { trace.report(TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS.on(reference, data)); } + else if (status.hasTypeInferenceIncorporationError()) { + trace.report(TYPE_INFERENCE_INCORPORATION_ERROR.on(reference)); + } else { assert status.hasUnknownParameters(); trace.report(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER.on(reference, data)); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTaskHolder.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTaskHolder.kt index 13e4117743c..edafbdb4cd4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTaskHolder.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/ResolutionTaskHolder.kt @@ -58,7 +58,7 @@ public class ResolutionTaskHolder( val lazyCandidates = { candidatesList[candidateIndex]().filter { priorityProvider.getPriority(it) == priority }.toReadOnlyList() } - tasks.add(ResolutionTask(basicCallResolutionContext, tracing, lazyCandidates)) + tasks.add(ResolutionTask(basicCallResolutionContext, tracing, lazyCandidates)) } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt index ad3d058475b..6e418323021 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt @@ -1,10 +1,10 @@ package foo open class A { - val B.w: Int by MyProperty() + val B.w: Int by MyProperty() } -val B.r: Int by MyProperty() +val B.r: Int by MyProperty() val A.e: Int by MyProperty() diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt index 091243b2b07..062a40d549d 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt @@ -7,6 +7,6 @@ fun > convert(src: Collection, dest: C): C = throw Except fun test(l: List) { //todo should be inferred - val r = convert(l, HashSet()) - checkSubtype(r) + val r = convert(l, HashSet()) + checkSubtype>(r) } diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt index 1e5cd3be0e3..775f12ec20c 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/doNotInferFromBoundsOnly.kt @@ -29,8 +29,7 @@ fun test3() { fun emptyStrangeMap1(t: T): Map = throw Exception("$t") fun test4() { - //todo we may infer 'Int' for 'R' here - emptyStrangeMap1(1) + emptyStrangeMap1(1) } //-------------- @@ -38,8 +37,7 @@ fun test4() { fun emptyStrangeMap2(t: T): Map where R: A = throw Exception("$t") fun test5(a: A) { - //todo we may infer 'A' for 'R' here - emptyStrangeMap2(a) + emptyStrangeMap2(a) } //-------------- diff --git a/compiler/testData/diagnostics/tests/platformTypes/inference.kt b/compiler/testData/diagnostics/tests/platformTypes/inference.kt index a5fc0a7ff4d..bc322da00d1 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/inference.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/inference.kt @@ -16,11 +16,10 @@ public class HS extends Base {} import foo.*; -import java.util.HashSet fun > convert(src: HS, dest: C): C = throw Exception("$src $dest") fun test(l: HS) { //todo should be inferred - val r = convert(l, HS()) - checkSubtype(r) + val r = convert(l, HS()) + checkSubtype>(r) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/itselfAsUpperBoundLocal.kt b/compiler/testData/diagnostics/tests/regressions/itselfAsUpperBoundLocal.kt index 353988510c3..35af733335a 100644 --- a/compiler/testData/diagnostics/tests/regressions/itselfAsUpperBoundLocal.kt +++ b/compiler/testData/diagnostics/tests/regressions/itselfAsUpperBoundLocal.kt @@ -1,4 +1,4 @@ fun bar() { fun T?> foo() {} - foo() + foo() } diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt index 9d8aac8a083..9e8cb9218b1 100644 --- a/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/kt7597.kt @@ -1,10 +1,8 @@ -// !CHECK_TYPE - interface Inv fun Inv.reduce2(): S = null!! fun test(a: Inv): Int { - val b = 1 + a.reduce2() - return b + val b = 1 + a.reduce2() + return b } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt index ab81fa1efc1..298efdc4e3d 100644 --- a/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt +++ b/compiler/testData/diagnostics/tests/resolve/nestedCalls/twoTypeParameters.kt @@ -6,7 +6,12 @@ fun List>.bar(t: ResolutionTask) = t public class ResolutionTaskHolder { fun test(candidate: ResolutionCandidate, tasks: MutableList>) { - tasks.bar(ResolutionTask(candidate)) + tasks.bar(ResolutionTask(candidate)) + tasks.add(ResolutionTask(candidate)) + + //todo the problem is the type of ResolutionTask is inferred as ResolutionTask too early + tasks.bar(ResolutionTask(candidate)) + tasks.add(ResolutionTask(candidate)) } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt index 0a14b59baa4..1d783be79c8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/kt4711.kt @@ -6,10 +6,10 @@ fun main(args:Array) { val startTimeNanos = System.nanoTime() // the problem sits on the next line: - val pi = 4.0.toDouble() * delta * (1..n).reduce( + val pi = 4.0.toDouble() * delta * (1..n).reduce( {t, i -> val x = (i - 0.5) * delta - t + 1.0 / (1.0 + x * x) + t + 1.0 / (1.0 + x * x) }) // !!! pi has error type here diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt index 24203fd1e26..2ae11394112 100644 --- a/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyList.txt @@ -12,7 +12,7 @@ fun bar() { Resolved call: Candidate descriptor: fun foo(t: T): Unit defined in root package -Resulting descriptor: fun foo(t: List): Unit defined in root package +Resulting descriptor: fun foo(t: ???): Unit defined in root package Explicit receiver kind = NO_EXPLICIT_RECEIVER Dispatch receiver = NO_RECEIVER @@ -20,4 +20,4 @@ Extension receiver = NO_RECEIVER Value arguments mapping: -MATCH_MODULO_UNINFERRED_TYPES t : List = someList() +MATCH_MODULO_UNINFERRED_TYPES t : ??? = someList() diff --git a/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt index 6537d71ccba..55ee516d0d4 100644 --- a/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt +++ b/compiler/testData/resolvedCalls/arguments/realExamples/emptyMutableList.txt @@ -12,7 +12,7 @@ fun bar() { Resolved call: Candidate descriptor: fun foo(t: T): Unit defined in root package -Resulting descriptor: fun foo(t: MutableList): Unit defined in root package +Resulting descriptor: fun foo(t: ???): Unit defined in root package Explicit receiver kind = NO_EXPLICIT_RECEIVER Dispatch receiver = NO_RECEIVER @@ -20,4 +20,4 @@ Extension receiver = NO_RECEIVER Value arguments mapping: -MATCH_MODULO_UNINFERRED_TYPES t : MutableList = someList() +MATCH_MODULO_UNINFERRED_TYPES t : ??? = someList() diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 1cffd813aba..e676fad2428 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -36,9 +36,10 @@ import java.util.LinkedHashMap import java.util.regex.Pattern abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { - private val typePattern = """([\w|<|>|\(|\)]+)""" - val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE)\s+$typePattern\s+$typePattern\s*(weak)?""") + private val typePattern = """([\w|<|\,|>|?|\(|\)]+)""" + val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE|EQUAL)\s+$typePattern\s+$typePattern\s*(weak)?""") val variablesPattern = Pattern.compile("VARIABLES\\s+(.*)") + val fixVariablesPattern = "FIX_VARIABLES" private var _typeResolver: TypeResolver? = null private val typeResolver: TypeResolver @@ -83,12 +84,10 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val constraintSystem = ConstraintSystemImpl() - val typeParameterDescriptors = LinkedHashMap() val variables = parseVariables(constraintsFileText) - for (variable in variables) { - typeParameterDescriptors.put(testDeclarations.getParameterDescriptor(variable), Variance.INVARIANT) - } - constraintSystem.registerTypeVariables(typeParameterDescriptors) + val fixVariables = constraintsFileText.contains(fixVariablesPattern) + val typeParameterDescriptors = variables.map { testDeclarations.getParameterDescriptor(it) } + constraintSystem.registerTypeVariables(typeParameterDescriptors, { Variance.INVARIANT }) val constraints = parseConstraints(constraintsFileText) for (constraint in constraints) { @@ -98,17 +97,18 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { when (constraint.kind) { MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position) MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(firstType, secondType, position) + MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position) } } - constraintSystem.processDeclaredBoundConstraints() + if (fixVariables) constraintSystem.fixVariables() val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM_SHORT.render(constraintSystem) val resultingSubstitutor = constraintSystem.getResultingSubstitutor() val result = StringBuilder() append "result:\n" - for ((typeParameter, variance) in typeParameterDescriptors) { + for (typeParameter in typeParameterDescriptors) { val parameterType = testDeclarations.getType(typeParameter.getName().asString()) - val resultType = resultingSubstitutor.substitute(parameterType, variance) + val resultType = resultingSubstitutor.substitute(parameterType, Variance.INVARIANT) result append "${typeParameter.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}\n" } @@ -118,7 +118,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String, val isWeak: Boolean) enum class MyConstraintKind { - SUBTYPE, SUPERTYPE + SUBTYPE, SUPERTYPE, EQUAL } private fun parseVariables(text: String): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt index 5818c150f54..e3b98365222 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt @@ -16,8 +16,9 @@ package org.jetbrains.kotlin.resolve.calls.inference -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition open class ConstraintError(val constraintPosition: ConstraintPosition) @@ -25,7 +26,12 @@ class TypeConstructorMismatch(constraintPosition: ConstraintPosition): Constrain class ErrorInConstrainingType(constraintPosition: ConstraintPosition): ConstraintError(constraintPosition) +class TypeInferenceError(constraintPosition: ConstraintPosition): ConstraintError(constraintPosition) + class CannotCapture(constraintPosition: ConstraintPosition, val typeVariable: TypeParameterDescriptor): ConstraintError(constraintPosition) -fun ConstraintError.substituteTypeVariable(substitution: (TypeParameterDescriptor) -> TypeParameterDescriptor) = - if (this is CannotCapture) CannotCapture(constraintPosition, substitution(typeVariable)) else this \ No newline at end of file +fun ConstraintError.substituteTypeVariable(substitution: (TypeParameterDescriptor) -> TypeParameterDescriptor?) = + if (this is CannotCapture) CannotCapture(constraintPosition, substitution(typeVariable) ?: typeVariable) else this + +fun newTypeInferenceOrConstructorMismatchError(constraintPosition: ConstraintPosition) = + if (constraintPosition is CompoundConstraintPosition) TypeInferenceError(constraintPosition) else TypeConstructorMismatch(constraintPosition) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt index 169096171a0..ca4b957f452 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.calls.inference.constraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* +import java.util.* public enum class ConstraintPositionKind { RECEIVER_POSITION, @@ -56,9 +57,14 @@ private data class ConstraintPositionWithIndex(override val kind: ConstraintPosi class CompoundConstraintPosition( vararg positions: ConstraintPosition ) : ConstraintPositionImpl(ConstraintPositionKind.COMPOUND_CONSTRAINT_POSITION) { - val positions: Collection = positions.toList() + val positions: Collection = + positions.flatMap { if (it is CompoundConstraintPosition) it.positions else listOf(it) }.toCollection(LinkedHashSet()) override fun isStrong() = positions.any { it.isStrong() } - override fun toString() = "$kind(${positions.joinToString()}" + override fun toString() = "$kind(${positions.joinToString()})" } + +fun ConstraintPosition.equalsOrContains(position: ConstraintPosition): Boolean { + return if (this !is CompoundConstraintPosition) this == position else positions.any { it == position } +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt index 8a41660f50d..3e18a4c3b7f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt @@ -26,11 +26,16 @@ public trait ConstraintSystem { /** * Registers variables in a constraint system. + * The type variables for the corresponding function are local, the type variables of inner arguments calls are non-local. */ - public fun registerTypeVariables(typeVariables: Map) + public fun registerTypeVariables( + typeVariables: Collection, + typeVariableVariance: (TypeParameterDescriptor) -> Variance, + external: Boolean = false + ) /** - * Returns a set of all registered type variables. + * Returns a set of all non-external registered type variables. */ public fun getTypeVariables(): Set diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 968451918b4..4e620384132 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -16,35 +16,31 @@ package org.jetbrains.kotlin.resolve.calls.inference -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.types.TypeProjection -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE -import org.jetbrains.kotlin.types.TypeProjectionImpl -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.ErrorUtils.FunctionPlaceholderTypeConstructor -import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.equalsOrContains +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.ErrorUtils.FunctionPlaceholderTypeConstructor +import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks -import org.jetbrains.kotlin.types.TypeConstructor -import java.util.LinkedHashMap -import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.* -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.* -import java.util.HashMap +import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments import java.util.ArrayList -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition -import org.jetbrains.kotlin.types.getCustomTypeVariable -import org.jetbrains.kotlin.types.isFlexible -import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound -import org.jetbrains.kotlin.types.TypeSubstitution -import org.jetbrains.kotlin.types.checker.JetTypeChecker +import java.util.HashMap +import java.util.HashSet +import java.util.LinkedHashMap public class ConstraintSystemImpl : ConstraintSystem { @@ -53,7 +49,15 @@ public class ConstraintSystemImpl : ConstraintSystem { EQUAL } - private val typeParameterBounds = LinkedHashMap() + fun ConstraintKind.toBound() = if (this == SUB_TYPE) UPPER_BOUND else EXACT_BOUND + + private val allTypeParameterBounds = LinkedHashMap() + private val externalTypeParameters = HashSet() + private val typeParameterBounds: Map + get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds + else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) } + + private val usedInBounds = HashMap>() private val errors = ArrayList() public val constraintErrors: List @@ -64,7 +68,8 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() - override fun hasContradiction() = hasTypeConstructorMismatch() || hasConflictingConstraints() || hasCannotCaptureTypesError() + override fun hasContradiction() = hasTypeConstructorMismatch() || hasTypeInferenceIncorporationError() + || hasConflictingConstraints() || hasCannotCaptureTypesError() override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful() @@ -77,12 +82,14 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasOnlyErrorsFromPosition(constraintPosition: ConstraintPosition): Boolean { if (isSuccessful()) return false if (filterConstraintsOut(constraintPosition).getStatus().isSuccessful()) return true - return errors.isNotEmpty() && errors.all { it.constraintPosition == constraintPosition } + return errors.isNotEmpty() && errors.all { it.constraintPosition.equalsOrContains(constraintPosition) } } override fun hasErrorInConstrainingTypes() = errors.any { it is ErrorInConstrainingType } override fun hasCannotCaptureTypesError() = errors.any { it is CannotCapture } + + override fun hasTypeInferenceIncorporationError() = errors.any { it is TypeInferenceError } } private fun getParameterToInferredValueMap( @@ -105,7 +112,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } private fun replaceUninferredBy(getDefaultValue: (TypeParameterDescriptor) -> TypeProjection): TypeSubstitutor { - return TypeUtils.makeSubstitutorForTypeParametersMap(getParameterToInferredValueMap(typeParameterBounds, getDefaultValue)) + return TypeUtils.makeSubstitutorForTypeParametersMap(getParameterToInferredValueMap(allTypeParameterBounds, getDefaultValue)) } private fun replaceUninferredBy(defaultValue: JetType): TypeSubstitutor { @@ -118,63 +125,78 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun getStatus(): ConstraintSystemStatus = constraintSystemStatus - override fun registerTypeVariables(typeVariables: Map) { - for ((typeVariable, positionVariance) in typeVariables) { - typeParameterBounds.put(typeVariable, TypeBoundsImpl(typeVariable, positionVariance)) + override fun registerTypeVariables( + typeVariables: Collection, + typeVariableVariance: (TypeParameterDescriptor) -> Variance, + external: Boolean + ) { + if (external) externalTypeParameters.addAll(typeVariables) + + for (typeVariable in typeVariables) { + allTypeParameterBounds.put(typeVariable, TypeBoundsImpl(typeVariable, typeVariableVariance(typeVariable))) } - val constantSubstitutor = TypeUtils.makeConstantSubstitutor(typeParameterBounds.keySet(), DONT_CARE) - for ((typeVariable, typeBounds) in typeParameterBounds) { + for ((typeVariable, typeBounds) in allTypeParameterBounds) { for (declaredUpperBound in typeVariable.getUpperBounds()) { if (KotlinBuiltIns.getInstance().getNullableAnyType() == declaredUpperBound) continue //todo remove this line (?) - val substitutedBound = constantSubstitutor?.substitute(declaredUpperBound, Variance.INVARIANT) val position = TYPE_BOUND_POSITION.position(typeVariable.getIndex()) - if (substitutedBound != null && !isErrorOrSpecialType(substitutedBound, position)) { - typeBounds.addBound(UPPER_BOUND, substitutedBound, position) - } + val variableType = JetTypeImpl(Annotations.EMPTY, typeVariable.getTypeConstructor(), false, listOf(), JetScope.Empty) + addBound(variableType, Bound(declaredUpperBound, UPPER_BOUND, position, declaredUpperBound.isProper())) } } } - public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis({ it }, { it.copy() }, { true }) - - public fun substituteTypeVariables(typeVariablesMap: (TypeParameterDescriptor) -> TypeParameterDescriptor): ConstraintSystem { - // type bounds are proper types and don't contain other variables - return createNewConstraintSystemFromThis(typeVariablesMap, { it }, { true }) + fun JetType.isProper() = !TypeUtils.containsSpecialType(this) { + type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } - public fun filterConstraintsOut(vararg excludePositions: ConstraintPosition): ConstraintSystem { - val positions = excludePositions.toSet() - return filterConstraints { !positions.contains(it) } + fun JetType.getNestedTypeVariables(): List { + return getNestedTypeArguments().map { typeProjection -> + typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor + + }.filterNotNull().filter { it in getAllTypeVariables() } + } + + public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis({ it }, { true }) + + public fun substituteTypeVariables(typeVariablesMap: (TypeParameterDescriptor) -> TypeParameterDescriptor?): ConstraintSystem { + // type bounds are proper types and don't contain other variables + return createNewConstraintSystemFromThis(typeVariablesMap, { true }) + } + + public fun filterConstraintsOut(excludePosition: ConstraintPosition): ConstraintSystem { + return filterConstraints { !it.equalsOrContains(excludePosition) } } public fun filterConstraints(condition: (ConstraintPosition) -> Boolean): ConstraintSystem { - return createNewConstraintSystemFromThis({ it }, { it.filter(condition) }, condition) + return createNewConstraintSystemFromThis({ it }, condition) } public fun getSystemWithoutWeakConstraints(): ConstraintSystem { - return filterConstraints { - constraintPosition -> + return filterConstraints(fun (constraintPosition): Boolean { + if (constraintPosition !is CompoundConstraintPosition) return constraintPosition.isStrong() + // 'isStrong' for compound means 'has some strong constraints' // but for testing absence of weak constraints we need 'has only strong constraints' here - if (constraintPosition is CompoundConstraintPosition) { - constraintPosition.positions.all { it.isStrong() } - } - else { - constraintPosition.isStrong() - } - } + return constraintPosition.positions.all { it.isStrong() } + }) } private fun createNewConstraintSystemFromThis( - substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor, - replaceTypeBounds: (TypeBoundsImpl) -> TypeBoundsImpl, + substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?, filterConstraintPosition: (ConstraintPosition) -> Boolean ): ConstraintSystem { val newSystem = ConstraintSystemImpl() - for ((typeParameter, typeBounds) in typeParameterBounds) { - val newTypeParameter = substituteTypeVariable(typeParameter) - newSystem.typeParameterBounds.put(newTypeParameter, replaceTypeBounds(typeBounds)) + for ((typeParameter, typeBounds) in allTypeParameterBounds) { + val newTypeParameter = substituteTypeVariable(typeParameter) ?: typeParameter + newSystem.allTypeParameterBounds.put(newTypeParameter, typeBounds.copy(substituteTypeVariable).filter(filterConstraintPosition)) } + for ((typeVariable, bounds) in usedInBounds) { + if (bounds.isNotEmpty()) { + val newTypeVariable = substituteTypeVariable(typeVariable) ?: typeVariable + newSystem.usedInBounds.put(newTypeVariable, ArrayList(bounds.substitute(substituteTypeVariable))) + } + } + newSystem.externalTypeParameters.addAll(externalTypeParameters.map { substituteTypeVariable(it) ?: it }) newSystem.errors.addAll(errors.filter { filterConstraintPosition(it.constraintPosition) }.map { it.substituteTypeVariable(substituteTypeVariable) }) return newSystem } @@ -189,7 +211,7 @@ public class ConstraintSystemImpl : ConstraintSystem { addConstraint(SUB_TYPE, constrainingType, subjectType, constraintPosition) } - private fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) { + fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) { val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks { private var depth = 0 @@ -213,7 +235,9 @@ public class ConstraintSystemImpl : ConstraintSystem { } override fun capture(typeVariable: JetType, typeProjection: TypeProjection): Boolean { + if (isMyTypeVariable(typeProjection.getType())) return false val myTypeVariable = getMyTypeVariable(typeVariable) + if (myTypeVariable != null && constraintPosition.isCaptureAllowed()) { if (depth > 0) { errors.add(CannotCapture(constraintPosition, myTypeVariable)) @@ -225,7 +249,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } override fun noCorrespondingSupertype(subtype: JetType, supertype: JetType): Boolean { - errors.add(TypeConstructorMismatch(constraintPosition)) + errors.add(newTypeInferenceOrConstructorMismatchError(constraintPosition)) return true } }) @@ -266,42 +290,54 @@ public class ConstraintSystemImpl : ConstraintSystem { // we don't add it without knowing whether it's a function type or an extension function type return } - createCorrespondingFunctionTypeForFunctionPlaceholder(subType, superType) + createTypeForFunctionPlaceholder(subType, superType) } else { subType } fun simplifyConstraint(subType: JetType, superType: JetType) { - // can be equal for the recursive invocations: fun foo(i: Int) : T { ... return foo(i); } => T <: T - // the right processing of constraints connecting type variables is not supported yet - if (isMyTypeVariable(subType) && isMyTypeVariable(superType)) return - if (isMyTypeVariable(subType)) { - val boundKind = if (constraintKind == SUB_TYPE) UPPER_BOUND else EXACT_BOUND - generateTypeParameterConstraint(subType, superType, boundKind, constraintPosition) + generateTypeParameterBound(subType, superType, constraintKind.toBound(), constraintPosition) return } if (isMyTypeVariable(superType)) { - val boundKind = if (constraintKind == SUB_TYPE) LOWER_BOUND else EXACT_BOUND - generateTypeParameterConstraint(superType, subType, boundKind, constraintPosition) + generateTypeParameterBound(superType, subType, constraintKind.toBound().reverse(), constraintPosition) return } // if superType is nullable and subType is not nullable, unsafe call or type mismatch error will be generated later, // but constraint system should be solved anyway val subTypeNotNullable = TypeUtils.makeNotNullable(subType) val superTypeNotNullable = TypeUtils.makeNotNullable(superType) - if (constraintKind == EQUAL) { + val result = if (constraintKind == EQUAL) { typeCheckingProcedure.equalTypes(subTypeNotNullable, superTypeNotNullable) } else { - typeCheckingProcedure.isSubtypeOf(subTypeNotNullable, superTypeNotNullable) + typeCheckingProcedure.isSubtypeOf(subTypeNotNullable, superType) } + if (!result) errors.add(newTypeInferenceOrConstructorMismatchError(constraintPosition)) } simplifyConstraint(newSubType, superType) + } - private fun generateTypeParameterConstraint( + fun addBound(variable: JetType, bound: Bound) { + val typeBounds = getTypeBounds(variable) + if (typeBounds.bounds.contains(bound)) return + + typeBounds.addBound(bound) + + if (!bound.isProper) { + for (dependentTypeVariable in bound.constrainingType.getNestedTypeVariables()) { + val dependentBounds = usedInBounds.getOrPut(dependentTypeVariable) { arrayListOf() } + dependentBounds.add(bound) + } + } + + incorporateBound(variable, bound) + } + + private fun generateTypeParameterBound( parameterType: JetType, constrainingType: JetType, boundKind: TypeBounds.BoundKind, @@ -324,10 +360,8 @@ public class ConstraintSystemImpl : ConstraintSystem { } } - val typeBounds = getTypeBounds(parameterType) - if (!parameterType.isMarkedNullable() || !TypeUtils.isNullableType(newConstrainingType)) { - typeBounds.addBound(boundKind, newConstrainingType, constraintPosition) + addBound(parameterType, Bound(newConstrainingType, boundKind, constraintPosition, newConstrainingType.isProper())) return } // For parameter type T: @@ -335,13 +369,14 @@ public class ConstraintSystemImpl : ConstraintSystem { // constraint T? = Int! should transform to T >: Int and T <: Int! // constraints T? >: Int?; T? >: Int! should transform to T >: Int + val notNullParameterType = TypeUtils.makeNotNullable(parameterType) val notNullConstrainingType = TypeUtils.makeNotNullable(newConstrainingType) if (boundKind == EXACT_BOUND || boundKind == LOWER_BOUND) { - typeBounds.addBound(LOWER_BOUND, notNullConstrainingType, constraintPosition) + addBound(notNullParameterType, Bound(notNullConstrainingType, LOWER_BOUND, constraintPosition, notNullConstrainingType.isProper())) } // constraints T? <: Int?; T? <: Int! should transform to T <: Int?; T <: Int! correspondingly if (boundKind == EXACT_BOUND || boundKind == UPPER_BOUND) { - typeBounds.addBound(UPPER_BOUND, newConstrainingType, constraintPosition) + addBound(notNullParameterType, Bound(newConstrainingType, UPPER_BOUND, constraintPosition, newConstrainingType.isProper())) } } @@ -355,7 +390,6 @@ public class ConstraintSystemImpl : ConstraintSystem { && constrainingTypeProjection.getProjectionKind() == Variance.IN_VARIANCE) { errors.add(CannotCapture(constraintPosition, typeVariable)) } - val typeBounds = getTypeBounds(typeVariable) val typeProjection = if (parameterType.isMarkedNullable()) { TypeProjectionImpl(constrainingTypeProjection.getProjectionKind(), TypeUtils.makeNotNullable(constrainingTypeProjection.getType())) } @@ -363,51 +397,32 @@ public class ConstraintSystemImpl : ConstraintSystem { constrainingTypeProjection } val capturedType = createCapturedType(typeProjection) - typeBounds.addBound(EXACT_BOUND, capturedType, constraintPosition) - } - - public fun processDeclaredBoundConstraints() { - for ((typeParameterDescriptor, typeBounds) in typeParameterBounds) { - fun compoundPosition(bound: Bound) = CompoundConstraintPosition( - TYPE_BOUND_POSITION.position(typeParameterDescriptor.getIndex()), bound.position) - - // todo order matters here - // it's important to create a separate variable here, - // because the following code may add new elements to typeBounds.bounds collection - val bounds = ArrayList(typeBounds.bounds) - for (declaredUpperBound in typeParameterDescriptor.getUpperBounds()) { - bounds.filter { it.kind != UPPER_BOUND }.forEach { - lowerOrExactBound -> - addSubtypeConstraint(lowerOrExactBound.constrainingType, declaredUpperBound, compoundPosition(lowerOrExactBound)) - } - if (!isMyTypeVariable(declaredUpperBound)) continue - getTypeBounds(declaredUpperBound).bounds.filter { it.kind != LOWER_BOUND }.forEach { - upperOrExactBound -> - typeBounds.addBound(UPPER_BOUND, upperOrExactBound.constrainingType, compoundPosition(upperOrExactBound)) - } - } - } + addBound(TypeUtils.makeNotNullable(parameterType), Bound(capturedType, EXACT_BOUND, constraintPosition)) } override fun getTypeVariables() = typeParameterBounds.keySet() + fun getAllTypeVariables() = allTypeParameterBounds.keySet() + + fun getBoundsUsedIn(typeVariable: TypeParameterDescriptor): List = usedInBounds[typeVariable] ?: emptyList() + override fun getTypeBounds(typeVariable: TypeParameterDescriptor): TypeBoundsImpl { if (!isMyTypeVariable(typeVariable)) { throw IllegalArgumentException("TypeParameterDescriptor is not a type variable for constraint system: $typeVariable") } - return typeParameterBounds[typeVariable]!! + return allTypeParameterBounds[typeVariable]!! } - private fun getTypeBounds(parameterType: JetType): TypeBoundsImpl { + fun getTypeBounds(parameterType: JetType): TypeBoundsImpl { assert (isMyTypeVariable(parameterType)) { "Type is not a type variable for constraint system: $parameterType" } return getTypeBounds(getMyTypeVariable(parameterType)!!) } - private fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = typeParameterBounds.contains(typeVariable) + fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = allTypeParameterBounds.contains(typeVariable) - private fun isMyTypeVariable(type: JetType): Boolean = getMyTypeVariable(type) != null + fun isMyTypeVariable(type: JetType): Boolean = getMyTypeVariable(type) != null - private fun getMyTypeVariable(type: JetType): TypeParameterDescriptor? { + fun getMyTypeVariable(type: JetType): TypeParameterDescriptor? { val typeParameterDescriptor = type.getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor return if (typeParameterDescriptor != null && isMyTypeVariable(typeParameterDescriptor)) typeParameterDescriptor else null } @@ -415,13 +430,36 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun getResultingSubstitutor() = replaceUninferredBySpecialErrorType().setApproximateCapturedTypes() override fun getCurrentSubstitutor() = replaceUninferredBy(TypeUtils.DONT_CARE).setApproximateCapturedTypes() + + fun fixVariable(typeVariable: TypeParameterDescriptor) { + val typeBounds = getTypeBounds(typeVariable) + if (typeBounds.isFixed) return + typeBounds.setFixed() + + val nestedTypeVariables = typeBounds.bounds.flatMap { it.constrainingType.getNestedTypeVariables() } + nestedTypeVariables.forEach { fixVariable(it) } + + val value = typeBounds.value ?: return + + val type = JetTypeImpl(Annotations.EMPTY, typeVariable.getTypeConstructor(), false, emptyList(), JetScope.Empty) + addBound(type, TypeBounds.Bound(value, TypeBounds.BoundKind.EXACT_BOUND, ConstraintPositionKind.FROM_COMPLETER.position())) + } + + fun fixVariables() { + // todo variables should be fixed in the right order + val (external, functionTypeParameters) = getAllTypeVariables().partition { externalTypeParameters.contains(it) } + external.forEach { fixVariable(it) } + functionTypeParameters.forEach { fixVariable(it) } + } + } -fun createCorrespondingFunctionTypeForFunctionPlaceholder( +fun createTypeForFunctionPlaceholder( functionPlaceholder: JetType, expectedType: JetType ): JetType { - assert(ErrorUtils.isFunctionPlaceholder(functionPlaceholder)) { "Function placeholder type expected: $functionPlaceholder" } + if (!ErrorUtils.isFunctionPlaceholder(functionPlaceholder)) return functionPlaceholder + val functionPlaceholderTypeConstructor = functionPlaceholder.getConstructor() as FunctionPlaceholderTypeConstructor val isExtension = KotlinBuiltIns.isExtensionFunctionType(expectedType) @@ -450,3 +488,7 @@ private class SubstitutionWithCapturedTypeApproximation(val substitution: TypeSu override fun isEmpty() = substitution.isEmpty() override fun approximateCapturedTypes() = true } + +public fun ConstraintSystemImpl.registerTypeVariables(typeVariables: Map) { + registerTypeVariables(typeVariables.keySet(), { typeVariables[it]!! }) +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt index 367ec7c1479..1b403fb513a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt @@ -84,4 +84,9 @@ public trait ConstraintSystemStatus { * in invocation foo(array) where array has type Array<Array<out Int>>. */ public fun hasCannotCaptureTypesError(): Boolean + + /** + * Returns true if there's an error in constraint system incorporation. + */ + public fun hasTypeInferenceIncorporationError(): Boolean } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index fc759a211a8..4ac4d79d743 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -16,10 +16,15 @@ package org.jetbrains.kotlin.resolve.calls.inference -import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.Variance +import kotlin.properties.Delegates public trait TypeBounds { public val varianceOfPosition: Variance @@ -29,6 +34,7 @@ public trait TypeBounds { public val bounds: Collection public val value: JetType? + get() = if (values.size() == 1) values.first() else null public val values: Collection @@ -38,5 +44,41 @@ public trait TypeBounds { EXACT_BOUND } - public class Bound(public val constrainingType: JetType, public val kind: BoundKind, public val position: ConstraintPosition) + public class Bound( + public val constrainingType: JetType, + public val kind: BoundKind, + public val position: ConstraintPosition, + public val isProper: Boolean = true + ) { + public var typeVariable: TypeParameterDescriptor by Delegates.notNull() + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + val bound = other as Bound + + if (constrainingType != bound.constrainingType) return false + if (kind != bound.kind) return false + + if (position.isStrong() != bound.position.isStrong()) return false + + return true + } + + override fun hashCode(): Int { + var result = constrainingType.hashCode() + result = 31 * result + kind.hashCode() + result = 31 * result + if (position.isStrong()) 1 else 0 + return result + } + + override fun toString() = "Bound($constrainingType, $kind, $position, isProper = $isProper)" + } +} + +fun BoundKind.reverse() = when (this) { + LOWER_BOUND -> UPPER_BOUND + UPPER_BOUND -> LOWER_BOUND + EXACT_BOUND -> EXACT_BOUND } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index 2b921f82b4a..1a05aaeef8d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -17,32 +17,40 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound -import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind -import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.CommonSupertypes -import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.types.checker.JetTypeChecker -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor -import java.util.LinkedHashSet -import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.* +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.types.singleBestRepresentative +import java.util.ArrayList +import java.util.LinkedHashSet public class TypeBoundsImpl( override val typeVariable: TypeParameterDescriptor, override val varianceOfPosition: Variance ) : TypeBounds { - override val bounds = LinkedHashSet() + override val bounds = ArrayList() private var resultValues: Collection? = null - public fun addBound(kind: BoundKind, constrainingType: JetType, position: ConstraintPosition) { + var isFixed: Boolean = false + private set + + public fun setFixed() { + isFixed = true + } + + public fun addBound(bound: Bound) { resultValues = null - bounds.add(Bound(constrainingType, kind, position)) + bound.typeVariable = typeVariable + bounds.add(bound) } private fun filterBounds(bounds: Collection, kind: BoundKind): Set { @@ -64,9 +72,14 @@ public class TypeBoundsImpl( return result } - fun copy(): TypeBoundsImpl { - val typeBounds = TypeBoundsImpl(typeVariable, varianceOfPosition) - typeBounds.bounds.addAll(bounds) + fun copy(substituteTypeVariable: ((TypeParameterDescriptor) -> TypeParameterDescriptor?)? = null): TypeBoundsImpl { + val typeBounds = TypeBoundsImpl(substituteTypeVariable?.invoke(typeVariable) ?: typeVariable, varianceOfPosition) + if (substituteTypeVariable == null) { + typeBounds.bounds.addAll(bounds) + } + else { + typeBounds.bounds.addAll(bounds.substitute(substituteTypeVariable)) + } typeBounds.resultValues = resultValues return typeBounds } @@ -77,9 +90,6 @@ public class TypeBoundsImpl( return result } - override val value: JetType? - get() = if (values.size() == 1) values.first() else null - override val values: Collection get() { if (resultValues == null) { @@ -90,6 +100,8 @@ public class TypeBoundsImpl( private fun computeValues(): Collection { val values = LinkedHashSet() + val bounds = bounds.filter { it.isProper } + if (bounds.isEmpty()) { return listOf() } @@ -101,7 +113,7 @@ public class TypeBoundsImpl( val exactBounds = filterBounds(bounds, EXACT_BOUND, values) val bestFit = exactBounds.singleBestRepresentative() if (bestFit != null) { - if (tryPossibleAnswer(bestFit)) { + if (tryPossibleAnswer(bounds, bestFit)) { return listOf(bestFit) } } @@ -111,7 +123,7 @@ public class TypeBoundsImpl( filterBounds(bounds, LOWER_BOUND, values).partition { it.getConstructor() is IntegerValueTypeConstructor } val superTypeOfLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes(generalLowerBounds) - if (tryPossibleAnswer(superTypeOfLowerBounds)) { + if (tryPossibleAnswer(bounds, superTypeOfLowerBounds)) { return setOf(superTypeOfLowerBounds!!) } values.addIfNotNull(superTypeOfLowerBounds) @@ -121,14 +133,14 @@ public class TypeBoundsImpl( //foo(1, c: Consumer) - infer Int, not Any here val superTypeOfNumberLowerBounds = TypeUtils.commonSupertypeForNumberTypes(numberLowerBounds) - if (tryPossibleAnswer(superTypeOfNumberLowerBounds)) { + if (tryPossibleAnswer(bounds, superTypeOfNumberLowerBounds)) { return setOf(superTypeOfNumberLowerBounds!!) } values.addIfNotNull(superTypeOfNumberLowerBounds) if (superTypeOfLowerBounds != null && superTypeOfNumberLowerBounds != null) { val superTypeOfAllLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes(listOf(superTypeOfLowerBounds, superTypeOfNumberLowerBounds)) - if (tryPossibleAnswer(superTypeOfAllLowerBounds)) { + if (tryPossibleAnswer(bounds, superTypeOfAllLowerBounds)) { return setOf(superTypeOfAllLowerBounds!!) } } @@ -136,7 +148,7 @@ public class TypeBoundsImpl( val upperBounds = filterBounds(bounds, TypeBounds.BoundKind.UPPER_BOUND, values) val intersectionOfUpperBounds = TypeUtils.intersect(JetTypeChecker.DEFAULT, upperBounds) if (!upperBounds.isEmpty() && intersectionOfUpperBounds != null) { - if (tryPossibleAnswer(intersectionOfUpperBounds)) { + if (tryPossibleAnswer(bounds, intersectionOfUpperBounds)) { return setOf(intersectionOfUpperBounds) } } @@ -146,7 +158,7 @@ public class TypeBoundsImpl( return values } - private fun tryPossibleAnswer(possibleAnswer: JetType?): Boolean { + private fun tryPossibleAnswer(bounds: Collection, possibleAnswer: JetType?): Boolean { if (possibleAnswer == null) return false // a captured type might be an answer if (!possibleAnswer.getConstructor().isDenotable() && !possibleAnswer.isCaptured()) return false @@ -169,3 +181,30 @@ public class TypeBoundsImpl( return true } } + +fun Collection.substitute(substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?): List { + val typeSubstitutor = TypeSubstitutor.create(object : TypeSubstitution() { + override fun get(key: TypeConstructor): TypeProjection? { + val descriptor = key.getDeclarationDescriptor() + if (descriptor !is TypeParameterDescriptor) return null + val typeParameterDescriptor = substituteTypeVariable(descriptor) ?: return null + + val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) + return TypeProjectionImpl(type) + } + }) + + return map { + //todo captured types + val substitutedType = if (it.constrainingType.getConstructor().isDenotable()) { + typeSubstitutor.substitute(it.constrainingType, Variance.INVARIANT) + } else { + it.constrainingType + } + substitutedType?.let { type -> + val newBound = Bound(type, it.kind, it.position, it.isProper) + newBound.typeVariable = substituteTypeVariable(it.typeVariable) ?: it.typeVariable + newBound + } + }.filterNotNull() +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt new file mode 100644 index 00000000000..821a129c10b --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -0,0 +1,138 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.calls.inference + +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.Variance.INVARIANT +import org.jetbrains.kotlin.types.Variance.IN_VARIANCE +import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments +import java.util.ArrayList + +fun ConstraintSystemImpl.incorporateBound(variable: JetType, newBound: Bound) { + val typeVariable = getMyTypeVariable(variable)!! + val typeBounds = getTypeBounds(typeVariable) + + for (oldBoundIndex in typeBounds.bounds.indices) { + addConstraintFromBounds(typeBounds.bounds[oldBoundIndex], newBound) + } + val boundsUsedIn = getBoundsUsedIn(typeVariable) + for (index in boundsUsedIn.indices) { + val boundUsedIn = boundsUsedIn[index] + val type = JetTypeImpl(Annotations.EMPTY, boundUsedIn.typeVariable.getTypeConstructor(), false, listOf(), JetScope.Empty) + generateNewBound(type, boundUsedIn, newBound) + } + + val constrainingType = newBound.constrainingType + if (isMyTypeVariable(constrainingType)) { + val bound = Bound(variable, newBound.kind.reverse(), newBound.position, isProper = false) + addBound(constrainingType, bound) + return + } + constrainingType.getNestedTypeVariables().forEach { + val boundsForNestedVariable = getTypeBounds(it).bounds + for (index in boundsForNestedVariable.indices) { + generateNewBound(variable, newBound, boundsForNestedVariable[index]) + } + } +} + +private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound) { + if (old == new) return + + val oldType = old.constrainingType + val newType = new.constrainingType + val position = CompoundConstraintPosition(old.position, new.position) + + when (old.kind to new.kind) { + LOWER_BOUND to UPPER_BOUND, LOWER_BOUND to EXACT_BOUND, EXACT_BOUND to UPPER_BOUND -> + addConstraint(SUB_TYPE, oldType, newType, position) + + UPPER_BOUND to LOWER_BOUND, UPPER_BOUND to EXACT_BOUND, EXACT_BOUND to LOWER_BOUND -> + addConstraint(SUB_TYPE, newType, oldType, position) + + EXACT_BOUND to EXACT_BOUND -> + addConstraint(EQUAL, oldType, newType, position) + } +} + +private fun ConstraintSystemImpl.generateNewBound( + variable: JetType, + bound: Bound, + substitution: Bound +) { + // Let's have a variable T, a bound 'T <=> My', and a substitution 'R <=> Type'. + // Here <=> means lower_bound, upper_bound or exact_bound constraint. + // Then a new bound 'T <=> My' can be generated. + + // A variance of R in 'My' (with respect to both use-site and declaration-site variance). + val substitutionVariance: Variance = bound.constrainingType.getNestedTypeArguments().firstOrNull { + getMyTypeVariable(it.getType()) === substitution.typeVariable + }?.getProjectionKind() ?: return + + // We don't substitute anything into recursive constraints + if (substitution.typeVariable == bound.typeVariable) return + + //todo variance checker + val newKind = computeKindOfNewBound(bound.kind, substitutionVariance, substitution.kind) ?: return + + val newTypeProjection = TypeProjectionImpl(substitutionVariance, substitution.constrainingType) + val substitutor = TypeSubstitutor.create(mapOf(substitution.typeVariable.getTypeConstructor() to newTypeProjection)) + val newConstrainingType = substitutor.substitute(bound.constrainingType, INVARIANT)!! + + // We don't generate new recursive constraints + val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() + if (nestedTypeVariables.contains(bound.typeVariable) || nestedTypeVariables.contains(substitution.typeVariable)) return + + val position = CompoundConstraintPosition(bound.position, substitution.position) + addBound(variable, Bound(newConstrainingType, newKind, position, newConstrainingType.isProper())) +} + +private fun computeKindOfNewBound(constrainingKind: BoundKind, substitutionVariance: Variance, substitutionKind: BoundKind): BoundKind? { + // In examples below: List, MutableList, Comparator, the variance of My may be any. + + // T <=> My, R <=> Type -> T <=> My + + // T < My, R = Int -> T < My + if (substitutionKind == EXACT_BOUND) return constrainingKind + + // T < MutableList, R < Number - nothing can be inferred (R might become 'Int' later) + // todo T < MutableList, R < Int => T < MutableList + if (substitutionVariance == INVARIANT) return null + + val kind = if (substitutionVariance == IN_VARIANCE) substitutionKind.reverse() else substitutionKind + + // T = List, R < Int -> T < List; T = Consumer, R < Int -> T > Consumer + if (constrainingKind == EXACT_BOUND) return kind + + // T < List, R < Int -> T < List; T < Consumer, R > Int -> T < Consumer + if (constrainingKind == kind) return kind + + // otherwise we can generate no new constraints + return null +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index 32cd7348529..9c03dd4c489 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.utils.UtilsPackage; import java.util.*; +import static org.jetbrains.kotlin.resolve.calls.inference.InferencePackage.registerTypeVariables; import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL; public class TypeUtils { @@ -301,7 +302,7 @@ public class TypeUtils { processAllTypeParameters(withParameters, Variance.INVARIANT, processor); processAllTypeParameters(expected, Variance.INVARIANT, processor); ConstraintSystemImpl constraintSystem = new ConstraintSystemImpl(); - constraintSystem.registerTypeVariables(parameters); + registerTypeVariables(constraintSystem, parameters); constraintSystem.addSubtypeConstraint(withParameters, expected, SPECIAL.position()); return constraintSystem.getStatus().isSuccessful(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 071e9567383..43f0a4984a8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -16,23 +16,17 @@ package org.jetbrains.kotlin.types.typeUtil -import java.util.LinkedHashSet +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.Flexibility -import org.jetbrains.kotlin.types.TypeConstructor -import org.jetbrains.kotlin.utils.toReadOnlyList -import org.jetbrains.kotlin.types.checker.JetTypeChecker -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.types.isDynamic -import org.jetbrains.kotlin.types.TypeProjection -import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.DelegatingType +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.utils.toReadOnlyList +import java.util.* private fun JetType.getContainedTypeParameters(): Collection { val declarationDescriptor = getConstructor().getDeclarationDescriptor() @@ -63,7 +57,8 @@ fun DeclarationDescriptor.getCapturedTypeParameters(): Collection { // todo type arguments (instead of type parameters) of the type of outer class must be considered; KT-6325 - val typeParameters = getContainedTypeParameters() + getConstructor().getDeclarationDescriptor()!!.getCapturedTypeParameters() + val capturedTypeParameters = getConstructor().getDeclarationDescriptor()?.getCapturedTypeParameters() ?: emptyList() + val typeParameters = getContainedTypeParameters() + capturedTypeParameters return typeParameters.map { it.getTypeConstructor() }.toReadOnlyList() } @@ -90,4 +85,32 @@ public fun JetTypeChecker.equalTypesOrNulls(type1: JetType?, type2: JetType?): B if (type1 identityEquals type2) return true if (type1 == null || type2 == null) return false return equalTypes(type1, type2) +} + +fun JetType.getNestedTypeArguments(): List { + val result = ArrayList() + + val stack = ArrayDeque() + stack.push(TypeProjectionImpl(this)) + + while (!stack.isEmpty()) { + val typeProjection = stack.pop() + if (typeProjection.isStarProjection()) continue + + result.add(typeProjection) + + val type = typeProjection.getType() + + type.getConstructor().getParameters().zip(type.getArguments()).forEach { + val (parameter, argument) = it + val newTypeProjection = if (argument.getProjectionKind() == Variance.INVARIANT && parameter.getVariance() != Variance.INVARIANT) { + TypeProjectionImpl(parameter.getVariance(), argument.getType()) + } + else { + argument + } + stack.add(newTypeProjection) + } + } + return result } \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 48f8687fbed..d2be701309b 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -16,18 +16,15 @@ package org.jetbrains.kotlin.idea.util -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.utils.addIfNotNull -import java.util.HashSet +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl -import java.util.LinkedHashMap -import org.jetbrains.kotlin.types.Variance -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintsUtil -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf +import java.util.HashSet fun CallableDescriptor.fuzzyReturnType(): FuzzyType? { val returnType = getReturnType() ?: return null @@ -103,18 +100,14 @@ class FuzzyType( } val constraintSystem = ConstraintSystemImpl() - val typeVariables = LinkedHashMap() - for (typeParameter in freeParameters) { - typeVariables[typeParameter] = Variance.INVARIANT - } - constraintSystem.registerTypeVariables(typeVariables) + constraintSystem.registerTypeVariables(freeParameters, { Variance.INVARIANT }) when (matchKind) { MatchKind.IS_SUBTYPE -> constraintSystem.addSubtypeConstraint(type, otherType, ConstraintPositionKind.SPECIAL.position()) MatchKind.IS_SUPERTYPE -> constraintSystem.addSubtypeConstraint(otherType, type, ConstraintPositionKind.SPECIAL.position()) } - constraintSystem.processDeclaredBoundConstraints() + constraintSystem.fixVariables() if (!constraintSystem.getStatus().hasContradiction()) { // currently ConstraintSystem return successful status in case there are problems with nullability From cf64687b0290179c2c0c057b8f5f082c4cd4587f Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 27 Jun 2015 14:26:03 +0300 Subject: [PATCH 192/450] More accurate error reporting with type inference error for delegated properties Add the constraints from completer if they don't lead to errors except errors from upper bounds to improve diagnostics --- .../kotlin/resolve/calls/CallCompleter.kt | 13 +++++++------ .../inference/extensionProperty.kt | 4 ++-- .../substitutions/delegationAndInference.kt | 12 ++++++++++++ .../substitutions/delegationAndInference.txt | 14 ++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ 5 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt create mode 100644 compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 1a0700d8119..c61593f9d4f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -32,8 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.FROM_COMPLETER +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus @@ -132,8 +131,8 @@ public class CallCompleter( expectedType: JetType, trace: BindingTrace ) { - fun updateSystemIfSuccessful(update: (ConstraintSystem) -> Boolean) { - val copy = (getConstraintSystem() as ConstraintSystemImpl).copy() + fun updateSystemIfSuccessful(update: (ConstraintSystemImpl) -> Boolean) { + val copy = (getConstraintSystem() as ConstraintSystemImpl).copy() as ConstraintSystemImpl if (update(copy)) { setConstraintSystem(copy) } @@ -146,11 +145,13 @@ public class CallCompleter( val constraintSystemCompleter = trace[CONSTRAINT_SYSTEM_COMPLETER, getCall().getCalleeExpression()] if (constraintSystemCompleter != null) { - //todo improve error reporting with errors in constraints from completer + // todo improve error reporting with errors in constraints from completer + // todo add constraints from completer unconditionally; improve constraints from completer for generic methods + // add the constraints only if they don't lead to errors (except errors from upper bounds to improve diagnostics) updateSystemIfSuccessful { system -> constraintSystemCompleter.completeConstraintSystem(system, this) - !system.getStatus().hasOnlyErrorsFromPosition(FROM_COMPLETER.position()) + !system.filterConstraintsOut(TYPE_BOUND_POSITION).getStatus().hasOnlyErrorsDerivedFrom(FROM_COMPLETER) } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt index 6e418323021..ad3d058475b 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/extensionProperty.kt @@ -1,10 +1,10 @@ package foo open class A { - val B.w: Int by MyProperty() + val B.w: Int by MyProperty() } -val B.r: Int by MyProperty() +val B.r: Int by MyProperty() val A.e: Int by MyProperty() diff --git a/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt b/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt new file mode 100644 index 00000000000..d0cad0fb02a --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class A(val map: MutableMap) { + + var a: String by map.withDefault1 { "foo" } +} + +fun MutableMap.get(thisRef: Any?, property: PropertyMetadata): G = throw Exception() + +fun MutableMap.set(thisRef: Any?, property: PropertyMetadata, value: S) {} + +fun MutableMap.withDefault1(default: (key: K) -> V): MutableMap = this \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.txt b/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.txt new file mode 100644 index 00000000000..2faa56775f4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.txt @@ -0,0 +1,14 @@ +package + +internal fun kotlin.MutableMap.get(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.PropertyMetadata): G +internal fun kotlin.MutableMap.set(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.PropertyMetadata, /*2*/ value: S): kotlin.Unit +internal fun kotlin.MutableMap.withDefault1(/*0*/ default: (K) -> V): kotlin.MutableMap + +internal final class A { + public constructor A(/*0*/ map: kotlin.MutableMap) + internal final var a: kotlin.String + internal final val map: kotlin.MutableMap + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index fc9cbd12a0a..23be88f7365 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -7142,6 +7142,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/substitutions"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("delegationAndInference.kt") + public void testDelegationAndInference() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/substitutions/delegationAndInference.kt"); + doTest(fileName); + } + @TestMetadata("kt6081SubstituteIntoClassCorrectly.kt") public void testKt6081SubstituteIntoClassCorrectly() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/substitutions/kt6081SubstituteIntoClassCorrectly.kt"); From 1463ff7258c7fb34579c8bf065d41f31c0841931 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 27 Jun 2015 15:50:39 +0300 Subject: [PATCH 193/450] Updated constraint system tests --- .../checkStatus/conflictingConstraints.bounds | 1 + .../constraintSystem/checkStatus/successful.bounds | 3 ++- .../checkStatus/typeConstructorMismatch.bounds | 1 + .../checkStatus/unknownParameters.bounds | 1 + .../checkStatus/violatedUpperBound.bounds | 1 + .../computeValues/contradiction.bounds | 1 + .../computeValues/subTypeOfUpperBounds.bounds | 1 + .../computeValues/superTypeOfLowerBounds1.bounds | 1 + .../computeValues/superTypeOfLowerBounds2.bounds | 1 + .../integerValueTypes/byteOverflow.bounds | 1 + .../integerValueTypes/defaultLong.bounds | 3 ++- .../integerValueTypes/numberAndAny.bounds | 3 ++- .../integerValueTypes/numberAndString.bounds | 3 ++- .../integerValueTypes/severalNumbers.bounds | 3 ++- .../integerValueTypes/simpleByte.bounds | 3 ++- .../integerValueTypes/simpleInt.bounds | 3 ++- .../integerValueTypes/simpleShort.bounds | 3 ++- .../severalVariables/simpleDependency.bounds | 7 ++++--- .../constraintSystem/variance/consumer.bounds | 1 + .../constraintSystem/variance/invariant.bounds | 1 + .../constraintSystem/variance/producer.bounds | 1 + .../constraintSystem/AbstractConstraintSystemTest.kt | 11 +++++------ 22 files changed, 37 insertions(+), 17 deletions(-) diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index ca0e8e1b407..d54e4653ded 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index 5fc00e55296..583a8c21113 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Int \ No newline at end of file +T=Int diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index 6748b94881d..1a59c9c2394 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -11,6 +11,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: true +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds index 315a2e41147..d31138ba9ec 100644 --- a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds @@ -11,6 +11,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index 2dd0cc822c1..c04981d28da 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: true -isSuccessful: false diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index ef0403037a0..efb7e8b91ae 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index 59267c02780..c186adc7a48 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index 67470527396..2f87b1baa2e 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index 611d210a64a..0b752ee190d 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -13,6 +13,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 7a95617b2aa..430a365cdaf 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -12,6 +12,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index 3d82f18077a..2abed7f9db8 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Long \ No newline at end of file +T=Long diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index 909959cb637..c65b5ee1928 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Int \ No newline at end of file +T=Int diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index ab339288908..2b80c6cc94a 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Comparable \ No newline at end of file +T=Comparable diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index 2ac118165c5..8a3bb3af4ad 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Int \ No newline at end of file +T=Int diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index 6e09380a9ed..7668d5a7d25 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Byte \ No newline at end of file +T=Byte diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index 5271316e2c3..4bf5959b522 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -11,9 +11,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Int \ No newline at end of file +T=Int diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 44f7762efa6..1b31cf385cb 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -12,9 +12,10 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: -T=Short \ No newline at end of file +T=Short diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index 6b8c2fac7e7..b00387cb86b 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -3,8 +3,8 @@ VARIABLES T P SUBTYPE T Int type parameter bounds: -T <: Int -P <: Int +T >: P, <: Int +P <: T, <: Int status: -hasCannotCaptureTypesError: false @@ -12,10 +12,11 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true result: T=Int -P=Int \ No newline at end of file +P=Int diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index da63814af1c..f0c5d30a279 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -11,6 +11,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 5fd96d59eed..6e911a8ca3d 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -11,6 +11,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index 0aaa43053f2..cc230ad432e 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -11,6 +11,7 @@ status: -hasContradiction: false -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: true diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index e676fad2428..8ed593b72fb 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -105,15 +105,14 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val resultingStatus = Renderers.RENDER_CONSTRAINT_SYSTEM_SHORT.render(constraintSystem) val resultingSubstitutor = constraintSystem.getResultingSubstitutor() - val result = StringBuilder() append "result:\n" - for (typeParameter in typeParameterDescriptors) { - val parameterType = testDeclarations.getType(typeParameter.getName().asString()) + val result = typeParameterDescriptors.map { + val parameterType = testDeclarations.getType(it.getName().asString()) val resultType = resultingSubstitutor.substitute(parameterType, Variance.INVARIANT) - result append "${typeParameter.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}\n" - } + "${it.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}" + }.join("\n", prefix = "result:\n") val boundsFile = File(filePath.replace("constraints", "bounds")) - JetTestUtils.assertEqualsToFile(boundsFile, "$constraintsFileText\n\n$resultingStatus\n\n$result\n") + JetTestUtils.assertEqualsToFile(boundsFile, "$constraintsFileText\n\n$resultingStatus\n\n$result") } class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String, val isWeak: Boolean) From 179c5e3c3a6c2ddd5f087e5d177bc3001b80d11d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Sat, 27 Jun 2015 17:19:20 +0300 Subject: [PATCH 194/450] Add a constraint for nested call if there are no bounds on variables in this call return type --- .../kotlin/resolve/calls/CallCompleter.kt | 8 +-- .../resolve/calls/GenericCandidateResolver.kt | 57 ++++++++++++++++++- .../tests/inference/regressions/kt2200.kt | 2 +- .../conflictingSubstitutionsFromUpperBound.kt | 2 +- .../tests/platformTypes/inference.kt | 2 +- 5 files changed, 60 insertions(+), 11 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index c61593f9d4f..a06e16920ab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -264,13 +264,9 @@ public class CallCompleter( expression: JetExpression, context: BasicCallResolutionContext ): OverloadResolutionResultsImpl<*>? { - if (!ExpressionTypingUtils.dependsOnExpectedType(expression)) return null + val cachedData = getResolutionResultsCachedData(expression, context) ?: return null + val (cachedResolutionResults, cachedContext, tracing) = cachedData - val argumentCall = expression.getCall(context.trace.getBindingContext()) ?: return null - - val cachedDataForCall = context.resolutionResultsCache[argumentCall] ?: return null - - val (cachedResolutionResults, cachedContext, tracing) = cachedDataForCall @suppress("UNCHECKED_CAST") val cachedResults = cachedResolutionResults as OverloadResolutionResultsImpl val contextForArgument = cachedContext.replaceBindingTrace(context.trace) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index b784dcb9953..cbde47b02c5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -29,12 +29,15 @@ import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getLastElementDep import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.ResolutionResultsCache import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus @@ -140,11 +143,54 @@ class GenericCandidateResolver( val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, newContext, resolveFunctionArgumentBodies) context.candidateCall.getDataFlowInfoForArguments().updateInfo(valueArgument, typeInfoForCall.dataFlowInfo) + val constraintPosition = VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex()) + + if (addConstraintForNestedCall(argumentExpression, constraintPosition, constraintSystem, newContext, effectiveExpectedType)) return + val type = updateResultTypeForSmartCasts(typeInfoForCall.type, argumentExpression, context.replaceDataFlowInfo(dataFlowInfoForArgument)) - constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex())) + constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, constraintPosition) } - private fun updateResultTypeForSmartCasts(type: JetType?, argumentExpression: JetExpression?, context: ResolutionContext<*>): JetType? { + private fun addConstraintForNestedCall( + argumentExpression: JetExpression?, + constraintPosition: ConstraintPosition, + constraintSystem: ConstraintSystem, + context: CallCandidateResolutionContext<*>, + effectiveExpectedType: JetType + ): Boolean { + val resolutionResults = getResolutionResultsCachedData(argumentExpression, context)?.resolutionResults + if (resolutionResults == null || !resolutionResults.isSingleResult()) return false + + val resultingCall = resolutionResults.getResultingCall() + if (resultingCall.isCompleted()) return false + + val argumentConstraintSystem = resultingCall.getConstraintSystem() as ConstraintSystemImpl? ?: return false + + val candidateDescriptor = resultingCall.getCandidateDescriptor() + val returnType = candidateDescriptor.getReturnType() ?: return false + + val nestedTypeVariables = with (argumentConstraintSystem) { + returnType.getNestedTypeVariables() + } + // we add an additional type variable only if no information is inferred for it. + // otherwise we add currently inferred return type as before + if (nestedTypeVariables.any { argumentConstraintSystem.getTypeBounds(it).bounds.isNotEmpty() }) return false + + val candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidateDescriptor) + val conversion = candidateDescriptor.getTypeParameters().zip(candidateWithFreshVariables.getTypeParameters()).toMap() + + val freshVariables = nestedTypeVariables.map { conversion[it] }.filterNotNull() + constraintSystem.registerTypeVariables(freshVariables, { Variance.INVARIANT }, external = true) + + constraintSystem.addSubtypeConstraint(candidateWithFreshVariables.getReturnType(), effectiveExpectedType, constraintPosition) + return true + } + + private fun updateResultTypeForSmartCasts( + type: JetType?, + argumentExpression: JetExpression?, + context: ResolutionContext<*> + ): JetType? { val deparenthesizedArgument = getLastElementDeparenthesized(argumentExpression, context) if (deparenthesizedArgument == null || type == null) return type @@ -227,4 +273,11 @@ class GenericCandidateResolver( val type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, position) } +} + +fun getResolutionResultsCachedData(expression: JetExpression?, context: ResolutionContext<*>): ResolutionResultsCache.CachedData? { + if (!ExpressionTypingUtils.dependsOnExpectedType(expression)) return null + val argumentCall = expression?.getCall(context.trace.getBindingContext()) ?: return null + + return context.resolutionResultsCache[argumentCall] } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt index ba518ebc253..d3e473eedb8 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2200.kt @@ -4,7 +4,7 @@ package n fun main(args: Array) { - val a = array(array()) + val a = array(array()) val a0 : Array> = array(array()) val a1 = array(array()) checkSubtype>>(a1) diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt index 062a40d549d..0fe2041a8e8 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/conflictingSubstitutionsFromUpperBound.kt @@ -8,5 +8,5 @@ fun > convert(src: Collection, dest: C): C = throw Except fun test(l: List) { //todo should be inferred val r = convert(l, HashSet()) - checkSubtype>(r) + r checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/platformTypes/inference.kt b/compiler/testData/diagnostics/tests/platformTypes/inference.kt index bc322da00d1..f6818460b8b 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/inference.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/inference.kt @@ -21,5 +21,5 @@ fun > convert(src: HS, dest: C): C = throw Exception("$src $des fun test(l: HS) { //todo should be inferred val r = convert(l, HS()) - checkSubtype>(r) + r checkType { _>() } } \ No newline at end of file From db8085c399356d7a69d94e81ba29b03bafeddccd Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 29 Jun 2015 18:58:06 +0300 Subject: [PATCH 195/450] Incorporation tests --- .../kotlin/diagnostics/rendering/Renderers.kt | 2 +- .../declarations/declarations.kt | 7 +- .../direct/contravariant/varEqDepEq.bounds | 23 + .../contravariant/varEqDepEq.constraints | 4 + .../direct/contravariant/varEqDepSub.bounds | 23 + .../contravariant/varEqDepSub.constraints | 4 + .../direct/contravariant/varEqDepSuper.bounds | 23 + .../contravariant/varEqDepSuper.constraints | 4 + .../direct/contravariant/varSubDepEq.bounds | 23 + .../contravariant/varSubDepEq.constraints | 4 + .../direct/contravariant/varSubDepSub.bounds | 23 + .../contravariant/varSubDepSub.constraints | 4 + .../contravariant/varSubDepSuper.bounds | 23 + .../contravariant/varSubDepSuper.constraints | 4 + .../direct/contravariant/varSuperDepEq.bounds | 23 + .../contravariant/varSuperDepEq.constraints | 4 + .../contravariant/varSuperDepSub.bounds | 23 + .../contravariant/varSuperDepSub.constraints | 4 + .../contravariant/varSuperDepSuper.bounds | 23 + .../varSuperDepSuper.constraints | 4 + .../direct/covariant/varEqDepEq.bounds | 23 + .../direct/covariant/varEqDepEq.constraints | 4 + .../direct/covariant/varEqDepSub.bounds | 23 + .../direct/covariant/varEqDepSub.constraints | 4 + .../direct/covariant/varEqDepSuper.bounds | 23 + .../covariant/varEqDepSuper.constraints | 4 + .../direct/covariant/varSubDepEq.bounds | 23 + .../direct/covariant/varSubDepEq.constraints | 4 + .../direct/covariant/varSubDepSub.bounds | 23 + .../direct/covariant/varSubDepSub.constraints | 4 + .../direct/covariant/varSubDepSuper.bounds | 23 + .../covariant/varSubDepSuper.constraints | 4 + .../direct/covariant/varSuperDepEq.bounds | 23 + .../covariant/varSuperDepEq.constraints | 4 + .../direct/covariant/varSuperDepSub.bounds | 23 + .../covariant/varSuperDepSub.constraints | 4 + .../direct/covariant/varSuperDepSuper.bounds | 23 + .../covariant/varSuperDepSuper.constraints | 4 + .../direct/invariant/varEqDepEq.bounds | 23 + .../direct/invariant/varEqDepEq.constraints | 4 + .../direct/invariant/varEqDepSub.bounds | 23 + .../direct/invariant/varEqDepSub.constraints | 4 + .../direct/invariant/varEqDepSuper.bounds | 23 + .../invariant/varEqDepSuper.constraints | 4 + .../direct/invariant/varSubDepEq.bounds | 23 + .../direct/invariant/varSubDepEq.constraints | 4 + .../direct/invariant/varSubDepSub.bounds | 23 + .../direct/invariant/varSubDepSub.constraints | 4 + .../direct/invariant/varSubDepSuper.bounds | 23 + .../invariant/varSubDepSuper.constraints | 4 + .../direct/invariant/varSuperDepEq.bounds | 23 + .../invariant/varSuperDepEq.constraints | 4 + .../direct/invariant/varSuperDepSub.bounds | 23 + .../invariant/varSuperDepSub.constraints | 4 + .../direct/invariant/varSuperDepSuper.bounds | 23 + .../invariant/varSuperDepSuper.constraints | 4 + .../interdependency/interdependency1.bounds | 27 + .../interdependency1.constraints | 6 + .../interdependency/interdependency2.bounds | 27 + .../interdependency2.constraints | 6 + .../interdependency/interdependency3.bounds | 27 + .../interdependency3.constraints | 6 + .../recursive/mutuallyRecursive.bounds | 23 + .../recursive/mutuallyRecursive.constraints | 4 + .../recursive/simpleRecursive.bounds | 21 + .../recursive/simpleRecursive.constraints | 4 + .../reversed/contravariant/varEqDepEq.bounds | 23 + .../contravariant/varEqDepEq.constraints | 4 + .../reversed/contravariant/varEqDepSub.bounds | 23 + .../contravariant/varEqDepSub.constraints | 4 + .../contravariant/varEqDepSuper.bounds | 23 + .../contravariant/varEqDepSuper.constraints | 4 + .../reversed/contravariant/varSubDepEq.bounds | 23 + .../contravariant/varSubDepEq.constraints | 4 + .../contravariant/varSubDepSub.bounds | 23 + .../contravariant/varSubDepSub.constraints | 4 + .../contravariant/varSubDepSuper.bounds | 23 + .../contravariant/varSubDepSuper.constraints | 4 + .../contravariant/varSuperDepEq.bounds | 23 + .../contravariant/varSuperDepEq.constraints | 4 + .../contravariant/varSuperDepSub.bounds | 23 + .../contravariant/varSuperDepSub.constraints | 4 + .../contravariant/varSuperDepSuper.bounds | 23 + .../varSuperDepSuper.constraints | 4 + .../reversed/covariant/varEqDepEq.bounds | 23 + .../reversed/covariant/varEqDepEq.constraints | 4 + .../reversed/covariant/varEqDepSub.bounds | 23 + .../covariant/varEqDepSub.constraints | 4 + .../reversed/covariant/varEqDepSuper.bounds | 23 + .../covariant/varEqDepSuper.constraints | 4 + .../reversed/covariant/varSubDepEq.bounds | 23 + .../covariant/varSubDepEq.constraints | 4 + .../reversed/covariant/varSubDepSub.bounds | 23 + .../covariant/varSubDepSub.constraints | 4 + .../reversed/covariant/varSubDepSuper.bounds | 23 + .../covariant/varSubDepSuper.constraints | 4 + .../reversed/covariant/varSuperDepEq.bounds | 23 + .../covariant/varSuperDepEq.constraints | 4 + .../reversed/covariant/varSuperDepSub.bounds | 23 + .../covariant/varSuperDepSub.constraints | 4 + .../covariant/varSuperDepSuper.bounds | 23 + .../covariant/varSuperDepSuper.constraints | 4 + .../reversed/invariant/varEqDepEq.bounds | 23 + .../reversed/invariant/varEqDepEq.constraints | 4 + .../reversed/invariant/varEqDepSub.bounds | 23 + .../invariant/varEqDepSub.constraints | 4 + .../reversed/invariant/varEqDepSuper.bounds | 23 + .../invariant/varEqDepSuper.constraints | 4 + .../reversed/invariant/varSubDepEq.bounds | 23 + .../invariant/varSubDepEq.constraints | 4 + .../reversed/invariant/varSubDepSub.bounds | 23 + .../invariant/varSubDepSub.constraints | 4 + .../reversed/invariant/varSubDepSuper.bounds | 23 + .../invariant/varSubDepSuper.constraints | 4 + .../reversed/invariant/varSuperDepEq.bounds | 23 + .../invariant/varSuperDepEq.constraints | 4 + .../reversed/invariant/varSuperDepSub.bounds | 23 + .../invariant/varSuperDepSub.constraints | 4 + .../invariant/varSuperDepSuper.bounds | 23 + .../invariant/varSuperDepSuper.constraints | 4 + .../severalVariables/simpleDependency.bounds | 10 +- .../severalVariables/simpleEquality.bounds | 23 + .../simpleEquality.constraints | 4 + .../severalVariables/simpleEquality1.bounds | 23 + .../simpleEquality1.constraints | 4 + .../simpleReversedDependency.bounds | 23 + .../simpleReversedDependency.constraints | 4 + .../severalVariables/simpleSubtype.bounds | 23 + .../simpleSubtype.constraints | 4 + .../severalVariables/simpleSubtype1.bounds | 23 + .../simpleSubtype1.constraints | 4 + .../ConstraintSystemTestGenerated.java | 474 ++++++++++++++++++ 132 files changed, 2229 insertions(+), 8 deletions(-) create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 2a1061b0c49..46879fbc1b0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -369,7 +369,7 @@ public object Renderers { val renderBound = { bound: Bound -> val arrow = if (bound.kind == LOWER_BOUND) ">: " else if (bound.kind == UPPER_BOUND) "<: " else ":= " val renderer = if (short) DescriptorRenderer.SHORT_NAMES_IN_TYPES else DescriptorRenderer.FQ_NAMES_IN_TYPES - val renderedBound = arrow + renderer.renderType(bound.constrainingType) + val renderedBound = arrow + renderer.renderType(bound.constrainingType) + if (!bound.isProper) "*" else "" if (short) renderedBound else renderedBound + '(' + bound.position + ')' } val typeVariableName = typeBounds.typeVariable.getName() diff --git a/compiler/testData/constraintSystem/declarations/declarations.kt b/compiler/testData/constraintSystem/declarations/declarations.kt index 832e99dd7f9..43edc7fdd90 100644 --- a/compiler/testData/constraintSystem/declarations/declarations.kt +++ b/compiler/testData/constraintSystem/declarations/declarations.kt @@ -1,4 +1,4 @@ -fun foo() = 42 +fun foo() = 42 interface A interface B : A @@ -7,4 +7,7 @@ interface C : B interface Consumer interface Producer -interface My \ No newline at end of file +interface My +interface Successor : My + +interface Two \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds new file mode 100644 index 00000000000..8024f737d4f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Consumer + +type parameter bounds: +T := Int +P := Consumer*, := Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints new file mode 100644 index 00000000000..e0751422bfb --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds new file mode 100644 index 00000000000..c2fc7ab00de --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Consumer + +type parameter bounds: +T := Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints new file mode 100644 index 00000000000..75fcfd4c9ff --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..0b0061363ab --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Consumer + +type parameter bounds: +T := Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..7a1aec72d51 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds new file mode 100644 index 00000000000..6f65f248bfa --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Consumer + +type parameter bounds: +T <: Int +P := Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints new file mode 100644 index 00000000000..656c4453f9b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds new file mode 100644 index 00000000000..36a2e0520dc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Consumer + +type parameter bounds: +T <: Int +P <: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints new file mode 100644 index 00000000000..2350a783ecd --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..39f56ee5890 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Consumer + +type parameter bounds: +T <: Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..9aecf5e8d88 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..4834575e0ad --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Consumer + +type parameter bounds: +T >: Int +P := Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..cbfda275da8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..0a23d492e16 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Consumer + +type parameter bounds: +T >: Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..568af53e3ad --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..4f3044bf3b6 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Consumer + +type parameter bounds: +T >: Int +P >: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..8b0dfe5cacc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds new file mode 100644 index 00000000000..97cfc9021cc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Producer + +type parameter bounds: +T := Int +P := Producer*, := Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints new file mode 100644 index 00000000000..2746dec14a2 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds new file mode 100644 index 00000000000..a64e6b35110 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Producer + +type parameter bounds: +T := Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints new file mode 100644 index 00000000000..bbf66b8dc5c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..a7d277e6d78 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Producer + +type parameter bounds: +T := Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..bf14baf3586 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds new file mode 100644 index 00000000000..2e6d9556f28 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Producer + +type parameter bounds: +T <: Int +P := Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints new file mode 100644 index 00000000000..ffb31352379 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds new file mode 100644 index 00000000000..361dc47e8f3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer + +type parameter bounds: +T <: Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints new file mode 100644 index 00000000000..6393295827d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..8639d321f5e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Producer + +type parameter bounds: +T <: Int +P >: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..b5020891ab8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..23c0cb99974 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Producer + +type parameter bounds: +T >: Int +P := Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..879c938ebd8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..415a1a067ac --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Producer + +type parameter bounds: +T >: Int +P <: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..f433623b950 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..4fa524d6a8b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Producer + +type parameter bounds: +T >: Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..8138eb7582f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds new file mode 100644 index 00000000000..e44ed01c3c5 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P My + +type parameter bounds: +T := Int +P := My*, := My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints new file mode 100644 index 00000000000..a422162d64a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds new file mode 100644 index 00000000000..5db77f8abf4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P My + +type parameter bounds: +T := Int +P <: My*, <: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints new file mode 100644 index 00000000000..b04f0ca41a0 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..2607d61fdeb --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P My + +type parameter bounds: +T := Int +P >: My*, >: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..3b0b9ae47e3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds new file mode 100644 index 00000000000..882513d21b3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P My + +type parameter bounds: +T <: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints new file mode 100644 index 00000000000..877c4529d1b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds new file mode 100644 index 00000000000..d9bcc3cf734 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My + +type parameter bounds: +T <: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints new file mode 100644 index 00000000000..90ae60529e4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..981743dc98c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P My + +type parameter bounds: +T <: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..d51ee811788 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..e15e5a52141 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P My + +type parameter bounds: +T >: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..785f2d53719 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..a83b3d88707 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P My + +type parameter bounds: +T >: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..9d1ebe0beac --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..0b14956e976 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P My + +type parameter bounds: +T >: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..e5f1c829e43 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds new file mode 100644 index 00000000000..c1fc7b01a62 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds @@ -0,0 +1,27 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE P My +SUBTYPE Successor P +SUBTYPE Int T + +type parameter bounds: +T := T*, := E*, >: Int, := Int +P <: My*, >: Successor*, >: Successor*, <: My*, <: My, >: Successor, := Successor +E := T*, := E*, >: Int, := Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Successor +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints new file mode 100644 index 00000000000..2652dc43ebc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints @@ -0,0 +1,6 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE P My +SUBTYPE Successor P +SUBTYPE Int T diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds new file mode 100644 index 00000000000..35b97462777 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds @@ -0,0 +1,27 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE P My +SUBTYPE Int T +SUBTYPE Successor P + +type parameter bounds: +T >: Int, := T*, := E*, := Int +P <: My*, >: Successor*, >: Successor*, <: My*, <: My, >: Successor, := Successor +E := T*, >: Int, := E*, := Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Successor +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints new file mode 100644 index 00000000000..3ca6e06e52a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints @@ -0,0 +1,6 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE P My +SUBTYPE Int T +SUBTYPE Successor P diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds new file mode 100644 index 00000000000..4cfdbef528f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds @@ -0,0 +1,27 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE Int T +SUBTYPE Successor P +SUBTYPE P My + +type parameter bounds: +T >: Int, := T*, := E*, := Int +P >: Successor*, <: My*, >: Successor*, <: My*, <: My, >: Successor, := Successor +E := T*, >: Int, := E*, := Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Successor +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints new file mode 100644 index 00000000000..f97c8a922fe --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints @@ -0,0 +1,6 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE Int T +SUBTYPE Successor P +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds new file mode 100644 index 00000000000..ba87365ac36 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T My

+EQUAL P Two + +type parameter bounds: +T := My

* +P := Two* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=??? +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints new file mode 100644 index 00000000000..67356268c6e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T My

+EQUAL P Two diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds new file mode 100644 index 00000000000..ec71b874753 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds @@ -0,0 +1,21 @@ +VARIABLES T + +EQUAL T Int +EQUAL T My + +type parameter bounds: +T := Int, := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: true +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints new file mode 100644 index 00000000000..855ddd3e6d8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints @@ -0,0 +1,4 @@ +VARIABLES T + +EQUAL T Int +EQUAL T My diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds new file mode 100644 index 00000000000..2bd66db1772 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Consumer +EQUAL T Int + +type parameter bounds: +T := Int +P := Consumer*, := Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints new file mode 100644 index 00000000000..8d549c39c52 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Consumer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds new file mode 100644 index 00000000000..afa3652f02f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Consumer +EQUAL T Int + +type parameter bounds: +T := Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints new file mode 100644 index 00000000000..ec2fdfb23cf --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Consumer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..c6d316d75d2 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Consumer +EQUAL T Int + +type parameter bounds: +T := Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..988014d00a0 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Consumer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds new file mode 100644 index 00000000000..89a9dcf5f2e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Consumer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P := Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints new file mode 100644 index 00000000000..1108481bcc7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Consumer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds new file mode 100644 index 00000000000..8c13f889136 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Consumer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P <: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints new file mode 100644 index 00000000000..f6b480df105 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Consumer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..59dc38abb16 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Consumer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..ba5d75b2383 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Consumer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..9c49f3eef8c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Consumer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P := Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..987c65f823a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Consumer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..984211dd519 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Consumer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..6cd684ec46d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Consumer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..3303bd7f335 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Consumer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P >: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..39ed31fc197 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Consumer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds new file mode 100644 index 00000000000..2a54eaf7bef --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Producer +EQUAL T Int + +type parameter bounds: +T := Int +P := Producer*, := Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints new file mode 100644 index 00000000000..bf63226aebd --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Producer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds new file mode 100644 index 00000000000..a2fedd419a4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Producer +EQUAL T Int + +type parameter bounds: +T := Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints new file mode 100644 index 00000000000..dfe4439d966 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Producer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..6ef6d2c6a5d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Producer +EQUAL T Int + +type parameter bounds: +T := Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..40fe9f33785 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Producer +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds new file mode 100644 index 00000000000..33f852ef188 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Producer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P := Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints new file mode 100644 index 00000000000..f36cf11bb11 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Producer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds new file mode 100644 index 00000000000..8511989ba6b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Producer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints new file mode 100644 index 00000000000..adfb3431ffd --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Producer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..894de55e226 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Producer +SUBTYPE T Int + +type parameter bounds: +T <: Int +P >: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..5d73d96277c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Producer +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..c52306a9b47 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P Producer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P := Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..aee017d21bc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P Producer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..6788c3c5227 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P Producer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P <: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..ee18e2cfff3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P Producer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..0b499eab01c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P Producer +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..154bc6eccfb --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P Producer +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds new file mode 100644 index 00000000000..121d0523caa --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P My +EQUAL T Int + +type parameter bounds: +T := Int +P := My*, := My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints new file mode 100644 index 00000000000..2ab72319604 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P My +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds new file mode 100644 index 00000000000..dc29c6058dc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P My +EQUAL T Int + +type parameter bounds: +T := Int +P <: My*, <: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints new file mode 100644 index 00000000000..0e4e6decd53 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P My +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..edd7c9937c2 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P My +EQUAL T Int + +type parameter bounds: +T := Int +P >: My*, >: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..ff801041f1a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P My +EQUAL T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds new file mode 100644 index 00000000000..8fa34297795 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P My +SUBTYPE T Int + +type parameter bounds: +T <: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints new file mode 100644 index 00000000000..cc25624bebb --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P My +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds new file mode 100644 index 00000000000..910cc6da5c6 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P My +SUBTYPE T Int + +type parameter bounds: +T <: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints new file mode 100644 index 00000000000..8d20982d465 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P My +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..8388ad7a2ad --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P My +SUBTYPE T Int + +type parameter bounds: +T <: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..58df9d3ee81 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P My +SUBTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..632b3f91681 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL P My +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..21247db3972 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL P My +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..7e3aa9c5a0e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE P My +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..35025b0d1b7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE P My +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..0cfdde90f94 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE P My +SUPERTYPE T Int + +type parameter bounds: +T >: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..8679f0410bf --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE P My +SUPERTYPE T Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index b00387cb86b..31d0bbe9090 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -3,8 +3,8 @@ VARIABLES T P SUBTYPE T Int type parameter bounds: -T >: P, <: Int -P <: T, <: Int +T <: Int +P status: -hasCannotCaptureTypesError: false @@ -13,10 +13,10 @@ status: -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false -hasTypeInferenceIncorporationError: false --hasUnknownParameters: false +-hasUnknownParameters: true -hasViolatedUpperBound: false --isSuccessful: true +-isSuccessful: false result: T=Int -P=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds new file mode 100644 index 00000000000..e17af150262 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL T P + +type parameter bounds: +T <: Int, := P* +P <: Int, := T* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints b/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints new file mode 100644 index 00000000000..b34fd87f315 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL T P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds new file mode 100644 index 00000000000..31d1e7cf1ad --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +EQUAL T P + +type parameter bounds: +T >: Int, := P* +P >: Int, := T* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints new file mode 100644 index 00000000000..e395d91e7d8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +EQUAL T P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds new file mode 100644 index 00000000000..0e05381bf41 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE T P + +type parameter bounds: +T <: Int, <: P* +P >: T* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints new file mode 100644 index 00000000000..6823743fa36 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE T P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds new file mode 100644 index 00000000000..53e9e8a7941 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P T + +type parameter bounds: +T <: Int, >: P* +P <: T*, <: Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints new file mode 100644 index 00000000000..902c73f7a6a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P T diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds new file mode 100644 index 00000000000..8580fda0452 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE T P + +type parameter bounds: +T >: Int, <: P* +P >: Int, >: T* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints new file mode 100644 index 00000000000..68687efd421 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE T P diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index dd7ff89021f..8186137e300 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -177,6 +177,480 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints"); doTest(fileName); } + + @TestMetadata("simpleEquality.constraints") + public void testSimpleEquality() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleEquality1.constraints") + public void testSimpleEquality1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleReversedDependency.constraints") + public void testSimpleReversedDependency() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleSubtype.constraints") + public void testSimpleSubtype() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleSubtype1.constraints") + public void testSimpleSubtype1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints"); + doTest(fileName); + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/direct") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Direct extends AbstractConstraintSystemTest { + public void testAllFilesPresentInDirect() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/direct"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Contravariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInContravariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/direct/contravariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Covariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInCovariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/direct/covariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Invariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInInvariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/direct/invariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/interdependency") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Interdependency extends AbstractConstraintSystemTest { + public void testAllFilesPresentInInterdependency() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/interdependency"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("interdependency1.constraints") + public void testInterdependency1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints"); + doTest(fileName); + } + + @TestMetadata("interdependency2.constraints") + public void testInterdependency2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints"); + doTest(fileName); + } + + @TestMetadata("interdependency3.constraints") + public void testInterdependency3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/recursive") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Recursive extends AbstractConstraintSystemTest { + public void testAllFilesPresentInRecursive() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/recursive"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("mutuallyRecursive.constraints") + public void testMutuallyRecursive() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleRecursive.constraints") + public void testSimpleRecursive() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/reversed") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Reversed extends AbstractConstraintSystemTest { + public void testAllFilesPresentInReversed() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/reversed"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Contravariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInContravariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/reversed/contravariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Covariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInCovariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/reversed/covariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Invariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInInvariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/reversed/invariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + } } @TestMetadata("compiler/testData/constraintSystem/variance") From ac578f7e5bfa7d8638082440ee5062f4bc3826b7 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 29 Jun 2015 20:10:30 +0300 Subject: [PATCH 196/450] Cache type corresponding to type variable --- .../calls/inference/ConstraintSystemImpl.kt | 42 ++++++++++++------- .../resolve/calls/inference/TypeBounds.kt | 7 ++-- .../resolve/calls/inference/TypeBoundsImpl.kt | 8 ++-- .../inference/constraintIncorporation.kt | 15 +++---- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 4e620384132..64ab20e08e2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -57,6 +57,8 @@ public class ConstraintSystemImpl : ConstraintSystem { get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) } + private val cachedTypeForVariable = HashMap() + private val usedInBounds = HashMap>() private val errors = ArrayList() @@ -139,12 +141,16 @@ public class ConstraintSystemImpl : ConstraintSystem { for (declaredUpperBound in typeVariable.getUpperBounds()) { if (KotlinBuiltIns.getInstance().getNullableAnyType() == declaredUpperBound) continue //todo remove this line (?) val position = TYPE_BOUND_POSITION.position(typeVariable.getIndex()) - val variableType = JetTypeImpl(Annotations.EMPTY, typeVariable.getTypeConstructor(), false, listOf(), JetScope.Empty) - addBound(variableType, Bound(declaredUpperBound, UPPER_BOUND, position, declaredUpperBound.isProper())) + addBound(typeVariable, declaredUpperBound, UPPER_BOUND, position) } } } + val TypeParameterDescriptor.correspondingType: JetType + get() = cachedTypeForVariable.getOrPut(this) { + JetTypeImpl(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), JetScope.Empty) + } + fun JetType.isProper() = !TypeUtils.containsSpecialType(this) { type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } @@ -321,8 +327,14 @@ public class ConstraintSystemImpl : ConstraintSystem { } - fun addBound(variable: JetType, bound: Bound) { - val typeBounds = getTypeBounds(variable) + fun addBound( + typeVariable: TypeParameterDescriptor, + constrainingType: JetType, + kind: TypeBounds.BoundKind, + position: ConstraintPosition + ) { + val bound = Bound(typeVariable, constrainingType, kind, position, constrainingType.isProper()) + val typeBounds = getTypeBounds(typeVariable) if (typeBounds.bounds.contains(bound)) return typeBounds.addBound(bound) @@ -334,7 +346,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } } - incorporateBound(variable, bound) + incorporateBound(bound) } private fun generateTypeParameterBound( @@ -343,6 +355,8 @@ public class ConstraintSystemImpl : ConstraintSystem { boundKind: TypeBounds.BoundKind, constraintPosition: ConstraintPosition ) { + val typeVariable = getMyTypeVariable(parameterType)!! + var newConstrainingType = constrainingType // Here we are handling the case when T! gets a bound Foo (or Foo?) @@ -354,14 +368,14 @@ public class ConstraintSystemImpl : ConstraintSystem { // Foo >: T! // both Foo and Foo? transform to Foo! here if (parameterType.isFlexible()) { - val typeVariable = parameterType.getCustomTypeVariable() - if (typeVariable != null) { - newConstrainingType = typeVariable.substitutionResult(constrainingType) + val customTypeVariable = parameterType.getCustomTypeVariable() + if (customTypeVariable != null) { + newConstrainingType = customTypeVariable.substitutionResult(constrainingType) } } if (!parameterType.isMarkedNullable() || !TypeUtils.isNullableType(newConstrainingType)) { - addBound(parameterType, Bound(newConstrainingType, boundKind, constraintPosition, newConstrainingType.isProper())) + addBound(typeVariable, newConstrainingType, boundKind, constraintPosition) return } // For parameter type T: @@ -369,14 +383,13 @@ public class ConstraintSystemImpl : ConstraintSystem { // constraint T? = Int! should transform to T >: Int and T <: Int! // constraints T? >: Int?; T? >: Int! should transform to T >: Int - val notNullParameterType = TypeUtils.makeNotNullable(parameterType) val notNullConstrainingType = TypeUtils.makeNotNullable(newConstrainingType) if (boundKind == EXACT_BOUND || boundKind == LOWER_BOUND) { - addBound(notNullParameterType, Bound(notNullConstrainingType, LOWER_BOUND, constraintPosition, notNullConstrainingType.isProper())) + addBound(typeVariable, notNullConstrainingType, LOWER_BOUND, constraintPosition) } // constraints T? <: Int?; T? <: Int! should transform to T <: Int?; T <: Int! correspondingly if (boundKind == EXACT_BOUND || boundKind == UPPER_BOUND) { - addBound(notNullParameterType, Bound(newConstrainingType, UPPER_BOUND, constraintPosition, newConstrainingType.isProper())) + addBound(typeVariable, newConstrainingType, UPPER_BOUND, constraintPosition) } } @@ -397,7 +410,7 @@ public class ConstraintSystemImpl : ConstraintSystem { constrainingTypeProjection } val capturedType = createCapturedType(typeProjection) - addBound(TypeUtils.makeNotNullable(parameterType), Bound(capturedType, EXACT_BOUND, constraintPosition)) + addBound(typeVariable, capturedType, EXACT_BOUND, constraintPosition) } override fun getTypeVariables() = typeParameterBounds.keySet() @@ -441,8 +454,7 @@ public class ConstraintSystemImpl : ConstraintSystem { val value = typeBounds.value ?: return - val type = JetTypeImpl(Annotations.EMPTY, typeVariable.getTypeConstructor(), false, emptyList(), JetScope.Empty) - addBound(type, TypeBounds.Bound(value, TypeBounds.BoundKind.EXACT_BOUND, ConstraintPositionKind.FROM_COMPLETER.position())) + addBound(typeVariable, value, TypeBounds.BoundKind.EXACT_BOUND, ConstraintPositionKind.FROM_COMPLETER.position()) } fun fixVariables() { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index 4ac4d79d743..ff52b07e878 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -45,19 +45,19 @@ public trait TypeBounds { } public class Bound( + public val typeVariable: TypeParameterDescriptor, public val constrainingType: JetType, public val kind: BoundKind, public val position: ConstraintPosition, public val isProper: Boolean = true ) { - public var typeVariable: TypeParameterDescriptor by Delegates.notNull() - override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null || javaClass != other.javaClass) return false val bound = other as Bound + if (typeVariable != bound.typeVariable) return false if (constrainingType != bound.constrainingType) return false if (kind != bound.kind) return false @@ -67,7 +67,8 @@ public trait TypeBounds { } override fun hashCode(): Int { - var result = constrainingType.hashCode() + var result = typeVariable.hashCode(); + result = 31 * result + constrainingType.hashCode() result = 31 * result + kind.hashCode() result = 31 * result + if (position.isStrong()) 1 else 0 return result diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index 1a05aaeef8d..0137e7062cb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -49,7 +49,9 @@ public class TypeBoundsImpl( public fun addBound(bound: Bound) { resultValues = null - bound.typeVariable = typeVariable + assert(bound.typeVariable == typeVariable) { + "$bound is added for incorrect type variable ${bound.typeVariable.getName()}. Expected: ${typeVariable.getName()}" + } bounds.add(bound) } @@ -202,9 +204,7 @@ fun Collection.substitute(substituteTypeVariable: (TypeParameterDescripto it.constrainingType } substitutedType?.let { type -> - val newBound = Bound(type, it.kind, it.position, it.isProper) - newBound.typeVariable = substituteTypeVariable(it.typeVariable) ?: it.typeVariable - newBound + Bound(substituteTypeVariable(it.typeVariable) ?: it.typeVariable, type, it.kind, it.position, it.isProper) } }.filterNotNull() } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 821a129c10b..b1167b1a5bf 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -34,8 +34,8 @@ import org.jetbrains.kotlin.types.Variance.IN_VARIANCE import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments import java.util.ArrayList -fun ConstraintSystemImpl.incorporateBound(variable: JetType, newBound: Bound) { - val typeVariable = getMyTypeVariable(variable)!! +fun ConstraintSystemImpl.incorporateBound(newBound: Bound) { + val typeVariable = newBound.typeVariable val typeBounds = getTypeBounds(typeVariable) for (oldBoundIndex in typeBounds.bounds.indices) { @@ -44,20 +44,18 @@ fun ConstraintSystemImpl.incorporateBound(variable: JetType, newBound: Bound) { val boundsUsedIn = getBoundsUsedIn(typeVariable) for (index in boundsUsedIn.indices) { val boundUsedIn = boundsUsedIn[index] - val type = JetTypeImpl(Annotations.EMPTY, boundUsedIn.typeVariable.getTypeConstructor(), false, listOf(), JetScope.Empty) - generateNewBound(type, boundUsedIn, newBound) + generateNewBound(boundUsedIn, newBound) } val constrainingType = newBound.constrainingType if (isMyTypeVariable(constrainingType)) { - val bound = Bound(variable, newBound.kind.reverse(), newBound.position, isProper = false) - addBound(constrainingType, bound) + addBound(getMyTypeVariable(constrainingType)!!, typeVariable.correspondingType, newBound.kind.reverse(), newBound.position) return } constrainingType.getNestedTypeVariables().forEach { val boundsForNestedVariable = getTypeBounds(it).bounds for (index in boundsForNestedVariable.indices) { - generateNewBound(variable, newBound, boundsForNestedVariable[index]) + generateNewBound(newBound, boundsForNestedVariable[index]) } } } @@ -82,7 +80,6 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound) } private fun ConstraintSystemImpl.generateNewBound( - variable: JetType, bound: Bound, substitution: Bound ) { @@ -110,7 +107,7 @@ private fun ConstraintSystemImpl.generateNewBound( if (nestedTypeVariables.contains(bound.typeVariable) || nestedTypeVariables.contains(substitution.typeVariable)) return val position = CompoundConstraintPosition(bound.position, substitution.position) - addBound(variable, Bound(newConstrainingType, newKind, position, newConstrainingType.isProper())) + addBound(bound.typeVariable, newConstrainingType, newKind, position) } private fun computeKindOfNewBound(constrainingKind: BoundKind, substitutionVariance: Variance, substitutionKind: BoundKind): BoundKind? { From c6e698e18d851399b5feec4d6c598d26267d531d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 29 Jun 2015 20:21:15 +0300 Subject: [PATCH 197/450] Minor: simplified code Used BoundKind.ordinal() --- .../kotlin/resolve/calls/inference/TypeBounds.kt | 4 ++-- .../calls/inference/constraintIncorporation.kt | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index ff52b07e878..bee0e0ab739 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -40,8 +40,8 @@ public trait TypeBounds { public enum class BoundKind { LOWER_BOUND, - UPPER_BOUND, - EXACT_BOUND + EXACT_BOUND, + UPPER_BOUND } public class Bound( diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index b1167b1a5bf..2a77ccbbb61 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -67,15 +67,10 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound) val newType = new.constrainingType val position = CompoundConstraintPosition(old.position, new.position) - when (old.kind to new.kind) { - LOWER_BOUND to UPPER_BOUND, LOWER_BOUND to EXACT_BOUND, EXACT_BOUND to UPPER_BOUND -> - addConstraint(SUB_TYPE, oldType, newType, position) - - UPPER_BOUND to LOWER_BOUND, UPPER_BOUND to EXACT_BOUND, EXACT_BOUND to LOWER_BOUND -> - addConstraint(SUB_TYPE, newType, oldType, position) - - EXACT_BOUND to EXACT_BOUND -> - addConstraint(EQUAL, oldType, newType, position) + when { + old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position) + old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position) + old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position) } } From 4c4f99c3568083b4c138ce539e1f0560df936bcc Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 30 Jun 2015 09:01:42 +0300 Subject: [PATCH 198/450] Use approximation of captured types in incorporation to generate new constraints --- .../inference/constraintIncorporation.kt | 81 ++++++++----------- .../org/jetbrains/kotlin/types/TypeUtils.kt | 13 +-- 2 files changed, 35 insertions(+), 59 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 2a77ccbbb61..e39eab674cd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.resolve.calls.inference -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound @@ -26,13 +24,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_B import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind -import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.Variance.INVARIANT -import org.jetbrains.kotlin.types.Variance.IN_VARIANCE import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments -import java.util.ArrayList +import org.jetbrains.kotlin.types.typesApproximation.approximateCapturedTypes fun ConstraintSystemImpl.incorporateBound(newBound: Bound) { val typeVariable = newBound.typeVariable @@ -74,57 +69,49 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound) } } -private fun ConstraintSystemImpl.generateNewBound( - bound: Bound, - substitution: Bound -) { - // Let's have a variable T, a bound 'T <=> My', and a substitution 'R <=> Type'. +private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bound) { + // Let's have a bound 'T <=> My', and a substitution 'R <=> Type'. // Here <=> means lower_bound, upper_bound or exact_bound constraint. - // Then a new bound 'T <=> My' can be generated. - - // A variance of R in 'My' (with respect to both use-site and declaration-site variance). - val substitutionVariance: Variance = bound.constrainingType.getNestedTypeArguments().firstOrNull { - getMyTypeVariable(it.getType()) === substitution.typeVariable - }?.getProjectionKind() ?: return + // Then a new bound 'T <=> My<_/in/out Type>' can be generated. // We don't substitute anything into recursive constraints if (substitution.typeVariable == bound.typeVariable) return - //todo variance checker - val newKind = computeKindOfNewBound(bound.kind, substitutionVariance, substitution.kind) ?: return + val substitutedType = when (substitution.kind) { + EXACT_BOUND -> substitution.constrainingType + UPPER_BOUND -> CapturedType(TypeProjectionImpl(Variance.OUT_VARIANCE, substitution.constrainingType)) + LOWER_BOUND -> CapturedType(TypeProjectionImpl(Variance.IN_VARIANCE, substitution.constrainingType)) + } - val newTypeProjection = TypeProjectionImpl(substitutionVariance, substitution.constrainingType) + val newTypeProjection = TypeProjectionImpl(substitutedType) val substitutor = TypeSubstitutor.create(mapOf(substitution.typeVariable.getTypeConstructor() to newTypeProjection)) - val newConstrainingType = substitutor.substitute(bound.constrainingType, INVARIANT)!! - - // We don't generate new recursive constraints - val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() - if (nestedTypeVariables.contains(bound.typeVariable) || nestedTypeVariables.contains(substitution.typeVariable)) return + val type = substitutor.substitute(bound.constrainingType, INVARIANT) ?: return val position = CompoundConstraintPosition(bound.position, substitution.position) - addBound(bound.typeVariable, newConstrainingType, newKind, position) -} -private fun computeKindOfNewBound(constrainingKind: BoundKind, substitutionVariance: Variance, substitutionKind: BoundKind): BoundKind? { - // In examples below: List, MutableList, Comparator, the variance of My may be any. + fun addNewBound(newConstrainingType: JetType, newBoundKind: BoundKind) { + // We don't generate new recursive constraints + val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() + if (nestedTypeVariables.contains(bound.typeVariable) || nestedTypeVariables.contains(substitution.typeVariable)) return - // T <=> My, R <=> Type -> T <=> My + addBound(bound.typeVariable, newConstrainingType, newBoundKind, position) + } - // T < My, R = Int -> T < My - if (substitutionKind == EXACT_BOUND) return constrainingKind - - // T < MutableList, R < Number - nothing can be inferred (R might become 'Int' later) - // todo T < MutableList, R < Int => T < MutableList - if (substitutionVariance == INVARIANT) return null - - val kind = if (substitutionVariance == IN_VARIANCE) substitutionKind.reverse() else substitutionKind - - // T = List, R < Int -> T < List; T = Consumer, R < Int -> T > Consumer - if (constrainingKind == EXACT_BOUND) return kind - - // T < List, R < Int -> T < List; T < Consumer, R > Int -> T < Consumer - if (constrainingKind == kind) return kind - - // otherwise we can generate no new constraints - return null + if (substitution.kind == EXACT_BOUND) { + addNewBound(type, bound.kind) + return + } + val approximationBounds = approximateCapturedTypes(type) + // todo + // if we allow non-trivial type projections, we bump into errors like + // "Empty intersection for types [MutableCollection, MutableCollection, MutableCollection]" + fun JetType.containsConstrainingTypeWithoutProjection() = this.getNestedTypeArguments().any { + it.getType().getConstructor() == substitution.constrainingType.getConstructor() && it.getProjectionKind() == Variance.INVARIANT + } + if (approximationBounds.upper.containsConstrainingTypeWithoutProjection() && bound.kind != LOWER_BOUND) { + addNewBound(approximationBounds.upper, UPPER_BOUND) + } + if (approximationBounds.lower.containsConstrainingTypeWithoutProjection() && bound.kind != UPPER_BOUND) { + addNewBound(approximationBounds.lower, LOWER_BOUND) + } } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 43f0a4984a8..056ad37ee88 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -99,18 +99,7 @@ fun JetType.getNestedTypeArguments(): List { result.add(typeProjection) - val type = typeProjection.getType() - - type.getConstructor().getParameters().zip(type.getArguments()).forEach { - val (parameter, argument) = it - val newTypeProjection = if (argument.getProjectionKind() == Variance.INVARIANT && parameter.getVariance() != Variance.INVARIANT) { - TypeProjectionImpl(parameter.getVariance(), argument.getType()) - } - else { - argument - } - stack.add(newTypeProjection) - } + typeProjection.getType().getArguments().forEach { stack.add(it) } } return result } \ No newline at end of file From 3b85ac90baef40bdc04366f6c5e74959e0c991e8 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 30 Jun 2015 14:41:02 +0300 Subject: [PATCH 199/450] Check initial constraints in constraint system status --- .../typeConstructorMismatch.bounds | 2 +- .../direct/invariant/varSubDepEq.bounds | 4 +- .../direct/invariant/varSuperDepEq.bounds | 4 +- .../recursive/mutuallyRecursive.bounds | 4 +- .../reversed/invariant/varSubDepEq.bounds | 4 +- .../reversed/invariant/varSuperDepEq.bounds | 4 +- .../platformTypes/methodCall/singleton.kt | 2 +- .../calls/inference/ConstraintSystemImpl.kt | 57 +++++++++++++++---- .../resolve/calls/inference/TypeBoundsImpl.kt | 25 ++++---- 9 files changed, 72 insertions(+), 34 deletions(-) diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index 1a59c9c2394..d3c1d075e01 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -11,7 +11,7 @@ status: -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: true --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds index 882513d21b3..36b349629f5 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds @@ -10,10 +10,10 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: false +-hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds index e15e5a52141..a57a227b879 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds @@ -10,10 +10,10 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: false +-hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds index ba87365ac36..68d1b96ebeb 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds @@ -10,10 +10,10 @@ P := Two* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: false +-hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds index 8fa34297795..236d15a9bd6 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds @@ -10,10 +10,10 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: false +-hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds index 632b3f91681..ea1fff4a0f4 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds @@ -10,10 +10,10 @@ P := My* status: -hasCannotCaptureTypesError: false -hasConflictingConstraints: false --hasContradiction: false +-hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false --hasTypeInferenceIncorporationError: false +-hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false -isSuccessful: false diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt index 6505d5bf312..d03b13d7efd 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/singleton.kt @@ -4,6 +4,6 @@ interface Foo fun test() { var nullable: Foo? = null - val foo: Collection = java.util.Collections.singleton(nullable) + val foo: Collection = java.util.Collections.singleton(nullable) val foo1: Collection = java.util.Collections.singleton(nullable!!) } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 64ab20e08e2..bb55bb1093a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.ErrorUtils.FunctionPlaceholderTypeConstructor import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE +import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments @@ -44,6 +45,8 @@ import java.util.LinkedHashMap public class ConstraintSystemImpl : ConstraintSystem { + data class Constraint(val kind: ConstraintKind, val subtype: JetType, val superType: JetType, val position: ConstraintPosition) + public enum class ConstraintKind { SUB_TYPE, EQUAL @@ -65,13 +68,15 @@ public class ConstraintSystemImpl : ConstraintSystem { public val constraintErrors: List get() = errors + private val initialConstraints = ArrayList() + private val constraintSystemStatus = object : ConstraintSystemStatus { // for debug ConstraintsUtil.getDebugMessageForStatus might be used override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() - override fun hasContradiction() = hasTypeConstructorMismatch() || hasTypeInferenceIncorporationError() - || hasConflictingConstraints() || hasCannotCaptureTypesError() + override fun hasContradiction() = hasTypeConstructorMismatch() || hasConflictingConstraints() + || hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError() override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful() @@ -91,7 +96,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasCannotCaptureTypesError() = errors.any { it is CannotCapture } - override fun hasTypeInferenceIncorporationError() = errors.any { it is TypeInferenceError } + override fun hasTypeInferenceIncorporationError() = errors.any { it is TypeInferenceError } || !satisfyInitialConstraints() } private fun getParameterToInferredValueMap( @@ -204,6 +209,13 @@ public class ConstraintSystemImpl : ConstraintSystem { } newSystem.externalTypeParameters.addAll(externalTypeParameters.map { substituteTypeVariable(it) ?: it }) newSystem.errors.addAll(errors.filter { filterConstraintPosition(it.constraintPosition) }.map { it.substituteTypeVariable(substituteTypeVariable) }) + + val typeSubstitutor = createTypeSubstitutor(substituteTypeVariable) + newSystem.initialConstraints.addAll(initialConstraints.filter { filterConstraintPosition(it.position) }.map { + val newSubType = typeSubstitutor.substitute(it.subtype, Variance.INVARIANT) + val newSuperType = typeSubstitutor.substitute(it.superType, Variance.INVARIANT) + if (newSubType != null && newSuperType != null) Constraint(it.kind, newSubType, newSuperType, it.position) else null + }) return newSystem } @@ -223,7 +235,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun assertEqualTypes(a: JetType, b: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { depth++ - doAddConstraint(EQUAL, a, b, constraintPosition, typeCheckingProcedure) + doAddConstraint(EQUAL, a, b, constraintPosition, typeCheckingProcedure, topLevel = false) depth-- return true @@ -235,7 +247,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun assertSubtype(subtype: JetType, supertype: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { depth++ - doAddConstraint(SUB_TYPE, subtype, supertype, constraintPosition, typeCheckingProcedure) + doAddConstraint(SUB_TYPE, subtype, supertype, constraintPosition, typeCheckingProcedure, topLevel = false) depth-- return true } @@ -259,7 +271,7 @@ public class ConstraintSystemImpl : ConstraintSystem { return true } }) - doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure) + doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure, topLevel = true) } private fun isErrorOrSpecialType(type: JetType?, constraintPosition: ConstraintPosition): Boolean { @@ -279,7 +291,8 @@ public class ConstraintSystemImpl : ConstraintSystem { subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition, - typeCheckingProcedure: TypeCheckingProcedure + typeCheckingProcedure: TypeCheckingProcedure, + topLevel: Boolean ) { if (isErrorOrSpecialType(subType, constraintPosition) || isErrorOrSpecialType(superType, constraintPosition)) return if (subType == null || superType == null) return @@ -311,10 +324,10 @@ public class ConstraintSystemImpl : ConstraintSystem { generateTypeParameterBound(superType, subType, constraintKind.toBound().reverse(), constraintPosition) return } - // if superType is nullable and subType is not nullable, unsafe call or type mismatch error will be generated later, + // if subType is nullable and superType is not nullable, unsafe call or type mismatch error will be generated later, // but constraint system should be solved anyway - val subTypeNotNullable = TypeUtils.makeNotNullable(subType) - val superTypeNotNullable = TypeUtils.makeNotNullable(superType) + val subTypeNotNullable = if (topLevel) TypeUtils.makeNotNullable(subType) else subType + val superTypeNotNullable = if (topLevel) TypeUtils.makeNotNullable(superType) else superType val result = if (constraintKind == EQUAL) { typeCheckingProcedure.equalTypes(subTypeNotNullable, superTypeNotNullable) } @@ -323,8 +336,10 @@ public class ConstraintSystemImpl : ConstraintSystem { } if (!result) errors.add(newTypeInferenceOrConstructorMismatchError(constraintPosition)) } + if (topLevel) { + storeInitialConstraint(constraintKind, subType, superType, constraintPosition) + } simplifyConstraint(newSubType, superType) - } fun addBound( @@ -444,6 +459,26 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun getCurrentSubstitutor() = replaceUninferredBy(TypeUtils.DONT_CARE).setApproximateCapturedTypes() + private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) { + if (position is CompoundConstraintPosition) return + initialConstraints.add(Constraint(constraintKind, subType, superType, position)) + } + + private fun satisfyInitialConstraints(): Boolean { + fun JetType.substituteAndMakeNotNullable(): JetType? { + val result = getResultingSubstitutor().substitute(this, Variance.INVARIANT) ?: return null + return TypeUtils.makeNotNullable(result) + } + return initialConstraints.all { + val resultSubType = it.subtype.substituteAndMakeNotNullable() ?: return false + val resultSuperType = it.superType.substituteAndMakeNotNullable() ?: return false + when (it.kind) { + SUB_TYPE -> JetTypeChecker.DEFAULT.isSubtypeOf(resultSubType, resultSuperType) + EQUAL -> JetTypeChecker.DEFAULT.equalTypes(resultSubType, resultSuperType) + } + } + } + fun fixVariable(typeVariable: TypeParameterDescriptor) { val typeBounds = getTypeBounds(typeVariable) if (typeBounds.isFixed) return diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index 0137e7062cb..cd640e14e55 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -185,17 +185,7 @@ public class TypeBoundsImpl( } fun Collection.substitute(substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?): List { - val typeSubstitutor = TypeSubstitutor.create(object : TypeSubstitution() { - override fun get(key: TypeConstructor): TypeProjection? { - val descriptor = key.getDeclarationDescriptor() - if (descriptor !is TypeParameterDescriptor) return null - val typeParameterDescriptor = substituteTypeVariable(descriptor) ?: return null - - val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) - return TypeProjectionImpl(type) - } - }) - + val typeSubstitutor = createTypeSubstitutor(substituteTypeVariable) return map { //todo captured types val substitutedType = if (it.constrainingType.getConstructor().isDenotable()) { @@ -207,4 +197,17 @@ fun Collection.substitute(substituteTypeVariable: (TypeParameterDescripto Bound(substituteTypeVariable(it.typeVariable) ?: it.typeVariable, type, it.kind, it.position, it.isProper) } }.filterNotNull() +} + +fun createTypeSubstitutor(substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?): TypeSubstitutor { + return TypeSubstitutor.create(object : TypeSubstitution() { + override fun get(key: TypeConstructor): TypeProjection? { + val descriptor = key.getDeclarationDescriptor() + if (descriptor !is TypeParameterDescriptor) return null + val typeParameterDescriptor = substituteTypeVariable(descriptor) ?: return null + + val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) + return TypeProjectionImpl(type) + } + }) } \ No newline at end of file From 89e16ecbcc1671ad4be22bce62dda94548c8a3bf Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 30 Jun 2015 22:05:21 +0300 Subject: [PATCH 200/450] Don't generate constraint if a type variable was substituted twice to prevent infinite recursion --- .../recursive/implicitlyRecursive.bounds | 26 +++++++++++++++++++ .../recursive/implicitlyRecursive.constraints | 5 ++++ .../ConstraintSystemTestGenerated.java | 6 +++++ .../calls/inference/ConstraintSystemImpl.kt | 5 ++-- .../resolve/calls/inference/TypeBounds.kt | 4 ++- .../resolve/calls/inference/TypeBoundsImpl.kt | 3 ++- .../inference/constraintIncorporation.kt | 10 +++++-- 7 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds new file mode 100644 index 00000000000..b3a8ecb359c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds @@ -0,0 +1,26 @@ +VARIABLES T P E + +SUBTYPE T Producer

+SUBTYPE P Producer +SUBTYPE E Producer

+ +type parameter bounds: +T <: Producer

*, <: Producer>*, <: Producer>>* +P <: Producer* +E <: Producer

* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=??? +P=??? +E=??? diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints new file mode 100644 index 00000000000..da4f2840fc4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints @@ -0,0 +1,5 @@ +VARIABLES T P E + +SUBTYPE T Producer

+SUBTYPE P Producer +SUBTYPE E Producer

diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index 8186137e300..1557eceb704 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -441,6 +441,12 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/recursive"), Pattern.compile("^(.+)\\.constraints$"), true); } + @TestMetadata("implicitlyRecursive.constraints") + public void testImplicitlyRecursive() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints"); + doTest(fileName); + } + @TestMetadata("mutuallyRecursive.constraints") public void testMutuallyRecursive() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index bb55bb1093a..d424a67d23b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -346,9 +346,10 @@ public class ConstraintSystemImpl : ConstraintSystem { typeVariable: TypeParameterDescriptor, constrainingType: JetType, kind: TypeBounds.BoundKind, - position: ConstraintPosition + position: ConstraintPosition, + derivedFrom: Set = emptySet() ) { - val bound = Bound(typeVariable, constrainingType, kind, position, constrainingType.isProper()) + val bound = Bound(typeVariable, constrainingType, kind, position, constrainingType.isProper(), derivedFrom) val typeBounds = getTypeBounds(typeVariable) if (typeBounds.bounds.contains(bound)) return diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index bee0e0ab739..78d7963dd8f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -49,7 +49,9 @@ public trait TypeBounds { public val constrainingType: JetType, public val kind: BoundKind, public val position: ConstraintPosition, - public val isProper: Boolean = true + public val isProper: Boolean, + // to prevent infinite recursion in incorporation we store the variables that was substituted to derive this bound + public val derivedFrom: Set ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index cd640e14e55..cc84ca284fb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -194,7 +194,8 @@ fun Collection.substitute(substituteTypeVariable: (TypeParameterDescripto it.constrainingType } substitutedType?.let { type -> - Bound(substituteTypeVariable(it.typeVariable) ?: it.typeVariable, type, it.kind, it.position, it.isProper) + Bound(substituteTypeVariable(it.typeVariable) ?: it.typeVariable, type, it.kind, it.position, it.isProper, + it.derivedFrom.map { substituteTypeVariable(it) ?: it }.toSet()) } }.filterNotNull() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index e39eab674cd..8066ab7ea18 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.Variance.INVARIANT import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments import org.jetbrains.kotlin.types.typesApproximation.approximateCapturedTypes +import java.util.* fun ConstraintSystemImpl.incorporateBound(newBound: Bound) { val typeVariable = newBound.typeVariable @@ -92,9 +93,14 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo fun addNewBound(newConstrainingType: JetType, newBoundKind: BoundKind) { // We don't generate new recursive constraints val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() - if (nestedTypeVariables.contains(bound.typeVariable) || nestedTypeVariables.contains(substitution.typeVariable)) return + if (nestedTypeVariables.contains(bound.typeVariable)) return - addBound(bound.typeVariable, newConstrainingType, newBoundKind, position) + // We don't generate constraint if a type variable was substituted twice + val derivedFrom = HashSet(bound.derivedFrom + substitution.derivedFrom) + if (derivedFrom.contains(substitution.typeVariable)) return + + derivedFrom.add(substitution.typeVariable) + addBound(bound.typeVariable, newConstrainingType, newBoundKind, position, derivedFrom) } if (substitution.kind == EXACT_BOUND) { From 690a46bbb478840fb43c5dc1ce1fdbc132558ab2 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 11 Jun 2015 23:49:39 +0300 Subject: [PATCH 201/450] Removed obsolete use of resolution results cache the other usage is still relevant --- .../kotlin/resolve/calls/CallResolver.java | 29 ++++++------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 80c19ad9380..c012a961f52 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -440,28 +440,17 @@ public class CallResolver { Call call = context.call; tracing.bindCall(context.trace, call); - OverloadResolutionResultsImpl results = null; TemporaryBindingTrace traceToResolveCall = TemporaryBindingTrace.create(context.trace, "trace to resolve call", call); - if (!CallResolverUtil.isInvokeCallOnVariable(call)) { - ResolutionResultsCache.CachedData data = context.resolutionResultsCache.get(call); - if (data != null) { - DelegatingBindingTrace deltasTraceForResolve = data.getResolutionTrace(); - deltasTraceForResolve.addOwnDataTo(traceToResolveCall); - //noinspection unchecked - results = (OverloadResolutionResultsImpl) data.getResolutionResults(); - } - } - if (results == null) { - BasicCallResolutionContext newContext = context.replaceBindingTrace(traceToResolveCall); - recordScopeAndDataFlowInfo(newContext, newContext.call.getCalleeExpression()); - results = doResolveCall(newContext, prioritizedTasks, callTransformer, tracing); - DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace(); - if (deltasTraceForTypeInference != null) { - deltasTraceForTypeInference.addOwnDataTo(traceToResolveCall); - } - completeTypeInferenceDependentOnFunctionLiterals(newContext, results, tracing); - cacheResults(context, results, traceToResolveCall, tracing); + BasicCallResolutionContext newContext = context.replaceBindingTrace(traceToResolveCall); + + recordScopeAndDataFlowInfo(newContext, newContext.call.getCalleeExpression()); + OverloadResolutionResultsImpl results = doResolveCall(newContext, prioritizedTasks, callTransformer, tracing); + DelegatingBindingTrace deltasTraceForTypeInference = ((OverloadResolutionResultsImpl) results).getTrace(); + if (deltasTraceForTypeInference != null) { + deltasTraceForTypeInference.addOwnDataTo(traceToResolveCall); } + completeTypeInferenceDependentOnFunctionLiterals(newContext, results, tracing); + cacheResults(context, results, traceToResolveCall, tracing); traceToResolveCall.commit(); if (context.contextDependency == ContextDependency.INDEPENDENT) { From 086e69e132e96835236bb007ea85b45fdddb0bbb Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 10 Jun 2015 19:32:58 +0300 Subject: [PATCH 202/450] Added tests for obsolete tasks --- .../boxWithStdlib/regressions/kt3850.kt | 6 +++ .../tests/inference/regressions/kt2057.kt | 11 +++++ .../tests/inference/regressions/kt2057.txt | 6 +++ .../tests/inference/regressions/kt2588.kt | 18 +++++++ .../tests/inference/regressions/kt2588.txt | 37 ++++++++++++++ .../tests/inference/regressions/kt2754.kt | 28 +++++++++++ .../tests/inference/regressions/kt2754.txt | 38 +++++++++++++++ .../tests/inference/regressions/kt3496.kt | 9 ++++ .../tests/inference/regressions/kt3496.txt | 10 ++++ .../tests/inference/regressions/kt3496_2.kt | 11 +++++ .../tests/inference/regressions/kt3496_2.txt | 11 +++++ .../tests/inference/regressions/kt3559.kt | 10 ++++ .../tests/inference/regressions/kt3559.txt | 4 ++ .../tests/inference/regressions/kt4420.kt | 10 ++++ .../tests/inference/regressions/kt4420.txt | 11 +++++ .../tests/smartCasts/inference/kt1275.kt | 11 +++++ .../tests/smartCasts/inference/kt1275.txt | 3 ++ .../testsWithStdLib/inference/kt3458.kt | 9 ++++ .../testsWithStdLib/inference/kt3458.txt | 3 ++ .../testsWithStdLib/inference/kt4975.kt | 10 ++++ .../testsWithStdLib/inference/kt4975.txt | 4 ++ .../checkers/JetDiagnosticsTestGenerated.java | 48 +++++++++++++++++++ ...JetDiagnosticsTestWithStdLibGenerated.java | 12 +++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 6 +++ 24 files changed, 326 insertions(+) create mode 100644 compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2057.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2588.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt2754.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3496.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt3559.txt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt4420.txt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.txt diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt new file mode 100644 index 00000000000..ca5e250355d --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt @@ -0,0 +1,6 @@ +class One { + val a1 = arrayOf( + object { val fy = "text"} + )} + +fun box() = if (One().a1[0].fy == "text") "OK" else "fail" \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt new file mode 100644 index 00000000000..9f6cf54e955 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import java.util.ArrayList + +fun foo(a : T, b : Collection, c : Int) { +} + +fun arrayListOf(vararg values: T): ArrayList = throw Exception("$values") + +val bar = foo("", arrayListOf(), ) +val bar2 = foo("", arrayListOf(), ) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2057.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt2057.txt new file mode 100644 index 00000000000..451227671c1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2057.txt @@ -0,0 +1,6 @@ +package + +internal val bar: kotlin.Unit +internal val bar2: kotlin.Unit +internal fun arrayListOf(/*0*/ vararg values: T /*kotlin.Array*/): java.util.ArrayList +internal fun foo(/*0*/ a: T, /*1*/ b: kotlin.Collection, /*2*/ c: kotlin.Int): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt new file mode 100644 index 00000000000..504f5f7909f --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt @@ -0,0 +1,18 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +//T-2588 Allow to specify exact super type (expected) in inference if many + +import java.util.HashSet + +class MyClass() + +interface A +interface D +class B : A, D +class C : A, D + +fun hashSetOf(vararg values: T): HashSet = throw Exception("$values") + +fun foo(b: MyClass, c: MyClass) { + val set1 : Set> = hashSetOf(b, c) //type inference expected type mismatch + val set2 = hashSetOf(b, c) //Set> is inferred +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2588.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt2588.txt new file mode 100644 index 00000000000..8efcc0c878e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2588.txt @@ -0,0 +1,37 @@ +package + +internal fun foo(/*0*/ b: MyClass, /*1*/ c: MyClass): kotlin.Unit +internal fun hashSetOf(/*0*/ vararg values: T /*kotlin.Array*/): java.util.HashSet + +internal interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class B : A, D { + public constructor B() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class C : A, D { + public constructor C() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface D { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class MyClass { + public constructor MyClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt new file mode 100644 index 00000000000..6b5394796c3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt @@ -0,0 +1,28 @@ +// !CHECK_TYPE +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// T is the immutable type +interface Builder { + fun build(): T +} + +// T is the immutable type, U is the builder +interface Copyable> { + fun builder(): U +} + +fun , U : Builder> T.copy(fn: U.() -> Unit): T = throw Exception() + +open class Foo(val x: Int, val y: Int) : Copyable { + override fun builder(): FooBuilder = FooBuilder(x, y) + + open class FooBuilder(var x: Int, var y: Int): Builder { + override fun build(): Foo = Foo(x, y) + } +} + +fun test() { + val foo1 = Foo(x = 1, y = 2) + val foo2 = foo1.copy { y = 3 } // this doesn't work + foo2 checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2754.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt2754.txt new file mode 100644 index 00000000000..507f19c225e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2754.txt @@ -0,0 +1,38 @@ +package + +internal fun test(): kotlin.Unit +internal fun , /*1*/ U : Builder> T.copy(/*0*/ fn: U.() -> kotlin.Unit): T + +internal interface Builder { + internal abstract fun build(): T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface Copyable> { + internal abstract fun builder(): U + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal open class Foo : Copyable { + public constructor Foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + internal final val x: kotlin.Int + internal final val y: kotlin.Int + internal open override /*1*/ fun builder(): Foo.FooBuilder + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + internal open class FooBuilder : Builder { + public constructor FooBuilder(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + internal final var x: kotlin.Int + internal final var y: kotlin.Int + internal open override /*1*/ fun build(): Foo + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt new file mode 100644 index 00000000000..5180621417f --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt @@ -0,0 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +// KT-3496 Type inference bug on y[""] + +class B { + fun x (y: B>) { + val z: S = y[""] // does not work with [], but works with .get() + } + fun get(s : String): S = throw Exception() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3496.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt3496.txt new file mode 100644 index 00000000000..c404da8b297 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3496.txt @@ -0,0 +1,10 @@ +package + +internal final class B { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun get(/*0*/ s: kotlin.String): S + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun x(/*0*/ y: B>): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt new file mode 100644 index 00000000000..19716e3ba80 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt @@ -0,0 +1,11 @@ +// !CHECK_TYPE +// !DIAGNOSTICS: -UNUSED_VARIABLE + +import java.util.ArrayList + +class F { + fun x (y: F>, w: ArrayList) { + val z: ArrayList = y["", w] + } +} +fun Any.get(s: String, w: ArrayList): ArrayList = throw Exception() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.txt new file mode 100644 index 00000000000..9439ea910a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.txt @@ -0,0 +1,11 @@ +package + +internal fun kotlin.Any.get(/*0*/ s: kotlin.String, /*1*/ w: java.util.ArrayList): java.util.ArrayList + +internal final class F { + public constructor F() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + internal final fun x(/*0*/ y: F>, /*1*/ w: java.util.ArrayList): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt new file mode 100644 index 00000000000..4cd430d0752 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt @@ -0,0 +1,10 @@ +// KT-3559 Strange inference failure error message + +public inline fun let(subj: T?, body: (T) -> R): R? { + return if (subj != null) body(subj) else null +} + + +fun test(s: String?): String? { + return let(s) {s} // Reports: "Inference failed. Expected jet.String? but found jet.String?" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3559.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.txt new file mode 100644 index 00000000000..dd9e3b06ea9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.txt @@ -0,0 +1,4 @@ +package + +kotlin.inline() public fun let(/*0*/ subj: T?, /*1*/ body: (T) -> R): R? +internal fun test(/*0*/ s: kotlin.String?): kotlin.String? diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt new file mode 100644 index 00000000000..031c92f9445 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt @@ -0,0 +1,10 @@ +// !CHECK_TYPE +//KT-4420 Type inference with type projections + +class Foo +fun Foo.bar(): T = throw Exception() + +fun main(args: Array) { + val f: Foo = Foo() + f.bar() checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt4420.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt4420.txt new file mode 100644 index 00000000000..7f1125d18ed --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt4420.txt @@ -0,0 +1,11 @@ +package + +internal fun main(/*0*/ args: kotlin.Array): kotlin.Unit +internal fun Foo.bar(): T + +internal final class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt new file mode 100644 index 00000000000..d3a519cc2d0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt @@ -0,0 +1,11 @@ +// !CHECK_TYPE + +fun foo(s : String?, b : Boolean) { + if (s == null) return + + val s1 = if (b) "" else s + s1 checkType { _() } + + val s2 = s + s2 checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.txt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.txt new file mode 100644 index 00000000000..420da32d346 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.txt @@ -0,0 +1,3 @@ +package + +internal fun foo(/*0*/ s: kotlin.String?, /*1*/ b: kotlin.Boolean): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt new file mode 100644 index 00000000000..03cf7f8b523 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt @@ -0,0 +1,9 @@ +// !CHECK_TYPE + +import java.io.File + +fun test() { + val dir = File("dir") + val files = dir.listFiles()?.toList() ?: listOf() // error + files checkType { _>() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.txt new file mode 100644 index 00000000000..b8def46715c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.txt @@ -0,0 +1,3 @@ +package + +internal fun test(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt new file mode 100644 index 00000000000..921a68f7936 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt @@ -0,0 +1,10 @@ +// !CHECK_TYPE + +fun bar(f: () -> T) : T = f() + +fun test(map: MutableMap) { + val r = bar { + map[1] = 2 + } + r checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.txt new file mode 100644 index 00000000000..3eab57374a6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.txt @@ -0,0 +1,4 @@ +package + +internal fun bar(/*0*/ f: () -> T): T +internal fun test(/*0*/ map: kotlin.MutableMap): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 23be88f7365..9827f921490 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -6896,6 +6896,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt2057.kt") + public void testKt2057() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt"); + doTest(fileName); + } + @TestMetadata("kt2179.kt") public void testKt2179() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt"); @@ -6974,12 +6980,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt2588.kt") + public void testKt2588() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt"); + doTest(fileName); + } + @TestMetadata("kt2741.kt") public void testKt2741() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt"); doTest(fileName); } + @TestMetadata("kt2754.kt") + public void testKt2754() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt"); + doTest(fileName); + } + @TestMetadata("kt2838.kt") public void testKt2838() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2838.kt"); @@ -7058,6 +7076,30 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt3496.kt") + public void testKt3496() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt"); + doTest(fileName); + } + + @TestMetadata("kt3496_2.kt") + public void testKt3496_2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt"); + doTest(fileName); + } + + @TestMetadata("kt3559.kt") + public void testKt3559() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt"); + doTest(fileName); + } + + @TestMetadata("kt4420.kt") + public void testKt4420() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt"); + doTest(fileName); + } + @TestMetadata("kt702.kt") public void testKt702() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt702.kt"); @@ -12344,6 +12386,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt1275.kt") + public void testKt1275() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt"); + doTest(fileName); + } + @TestMetadata("kt1355.kt") public void testKt1355() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java index dd046cf6fa6..15df05dcafd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -531,6 +531,18 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt"); doTest(fileName); } + + @TestMetadata("kt3458.kt") + public void testKt3458() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt"); + doTest(fileName); + } + + @TestMetadata("kt4975.kt") + public void testKt4975() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/kotlinSignature") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index e228260576b..0bd0f75a57e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -3301,6 +3301,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("kt3850.kt") + public void testKt3850() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("kt4142.kt") public void testKt4142() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt4142.kt"); From b8526e7048bb8aac44b318554bb966ba63077b27 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 1 Jul 2015 11:59:32 +0300 Subject: [PATCH 203/450] Added diagnostic tests for inference and incorporation --- .../commonSystem/boundOnNullableVariable.kt | 6 ++ .../commonSystem/boundOnNullableVariable.txt | 5 ++ .../commonSystem/dontCaptureTypeVariable.kt | 11 +++ .../commonSystem/dontCaptureTypeVariable.txt | 4 + .../commonSystem/fixVariablesInRightOrder.kt | 17 +++++ .../commonSystem/fixVariablesInRightOrder.txt | 21 ++++++ .../genericCandidateInGenericClass.kt | 9 +++ .../genericCandidateInGenericClass.txt | 12 +++ .../inferenceWithUpperBoundsInLambda.kt | 13 ++++ .../inferenceWithUpperBoundsInLambda.txt | 18 +++++ .../commonSystem/kt3372toCollection.kt | 12 +++ .../commonSystem/kt3372toCollection.txt | 4 + .../inference/commonSystem/nestedLambdas.kt | 10 +++ .../inference/commonSystem/nestedLambdas.txt | 4 + .../commonSystem/theSameFunctionInArgs.kt | 8 ++ .../commonSystem/theSameFunctionInArgs.txt | 4 + ...iguityWithTwoCorrespondingFunctionTypes.kt | 11 +++ ...guityWithTwoCorrespondingFunctionTypes.txt | 6 ++ .../tests/resolve/inferenceInLinkedLambdas.kt | 8 ++ .../resolve/inferenceInLinkedLambdas.txt | 4 + ...eInLinkedLambdasDependentOnExpectedType.kt | 7 ++ ...InLinkedLambdasDependentOnExpectedType.txt | 5 ++ ...solveWithSpecifiedFunctionLiteralWithId.kt | 34 ++++----- .../checkers/JetDiagnosticsTestGenerated.java | 75 +++++++++++++++++++ 24 files changed, 291 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.txt create mode 100644 compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.txt create mode 100644 compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.txt create mode 100644 compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.txt diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt new file mode 100644 index 00000000000..72afc526eaf --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt @@ -0,0 +1,6 @@ +fun test(f: (T) -> T?) { + doFun(f.ext()) +} + +fun Function1.ext(): Function0 = throw Exception() +fun doFun(f: () -> R?) = f diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.txt new file mode 100644 index 00000000000..e1ca5592c90 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.txt @@ -0,0 +1,5 @@ +package + +internal fun doFun(/*0*/ f: () -> R?): () -> R? +internal fun test(/*0*/ f: (T) -> T?): kotlin.Unit +internal fun ((E) -> E?).ext(): () -> E? diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt new file mode 100644 index 00000000000..56b7f5657a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import java.util.* + +fun test(list: ArrayList, comparatorFun: (Int, Int) -> Int) { + sort(list, Comparator(comparatorFun)) +} + + +public fun sort(list: List, c: Comparator) { +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.txt new file mode 100644 index 00000000000..6085ec7dd70 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.txt @@ -0,0 +1,4 @@ +package + +public fun sort(/*0*/ list: kotlin.List, /*1*/ c: java.util.Comparator): kotlin.Unit +internal fun test(/*0*/ list: java.util.ArrayList, /*1*/ comparatorFun: (kotlin.Int, kotlin.Int) -> kotlin.Int): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.kt new file mode 100644 index 00000000000..72673750ba9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class GenericClass + +public fun GenericClass>.foo() {} + +public fun bar(t: T, ext: GenericClass.() -> Unit) {} + +fun test() { + bar(mapOf(2 to 3)) { foo() } +} + +// from library +class Pair +fun mapOf(keyValuePair: Pair): Map = throw Exception() +fun A.to(that: B): Pair = throw Exception() + diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.txt new file mode 100644 index 00000000000..2f49bcdfb65 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.txt @@ -0,0 +1,21 @@ +package + +public fun bar(/*0*/ t: T, /*1*/ ext: GenericClass.() -> kotlin.Unit): kotlin.Unit +internal fun mapOf(/*0*/ keyValuePair: Pair): kotlin.Map +internal fun test(): kotlin.Unit +public fun GenericClass>.foo(): kotlin.Unit +internal fun A.to(/*0*/ that: B): Pair + +internal final class GenericClass { + public constructor GenericClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class Pair { + public constructor Pair() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.kt new file mode 100644 index 00000000000..3acf44efad9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.kt @@ -0,0 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class GenericClass(val value: T) { + public fun foo

(extension: T.() -> P) {} +} + +public fun GenericClass>.bar() { + foo( { listIterator() }) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.txt new file mode 100644 index 00000000000..b0c56b38ada --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.txt @@ -0,0 +1,12 @@ +package + +public fun GenericClass>.bar(): kotlin.Unit + +internal final class GenericClass { + public constructor GenericClass(/*0*/ value: T) + internal final val value: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ extension: T.() -> P): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.kt new file mode 100644 index 00000000000..7ab48bdff17 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.kt @@ -0,0 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import java.util.* + +interface Foo +class Bar(val list: MutableList) {} + +fun test(map: MutableMap>) { + + map.getOrPut1("", { Bar(ArrayList()) }) +} + +fun MutableMap.getOrPut1(key: K, defaultValue: () -> V): V = throw Exception() diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.txt new file mode 100644 index 00000000000..be4b7ba4273 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.txt @@ -0,0 +1,18 @@ +package + +internal fun test(/*0*/ map: kotlin.MutableMap>): kotlin.Unit +internal fun kotlin.MutableMap.getOrPut1(/*0*/ key: K, /*1*/ defaultValue: () -> V): V + +internal final class Bar { + public constructor Bar(/*0*/ list: kotlin.MutableList) + internal final val list: kotlin.MutableList + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt new file mode 100644 index 00000000000..ea1f2c3b8de --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE +// KT-3372 Use upper bound in type argument inference + +import java.util.HashSet + +fun > Iterable.toCollection(result: C) : C = throw Exception() + +fun test(list: List) { + val set = list.toCollection(HashSet()) + set checkType { _>() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.txt new file mode 100644 index 00000000000..2f6681972e4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.txt @@ -0,0 +1,4 @@ +package + +internal fun test(/*0*/ list: kotlin.List): kotlin.Unit +internal fun > kotlin.Iterable.toCollection(/*0*/ result: C): C diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt new file mode 100644 index 00000000000..636000acb4c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +fun Collection.map(transform : (T) -> R) : List = throw Exception() + +fun test(list: List>) { + + val list1 = list.map { it.map { "$it" } } + list1 checkType { _>>() } +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.txt new file mode 100644 index 00000000000..225cd969604 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.txt @@ -0,0 +1,4 @@ +package + +internal fun test(/*0*/ list: kotlin.List>): kotlin.Unit +internal fun kotlin.Collection.map(/*0*/ transform: (T) -> R): kotlin.List diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt new file mode 100644 index 00000000000..65b81903685 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt @@ -0,0 +1,8 @@ +// !CHECK_TYPE + +fun arrayOf(vararg t : T) : Array = t as Array + +fun test() { + val array = arrayOf(arrayOf(1)) + array checkType { _>>() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.txt new file mode 100644 index 00000000000..e4c746ca220 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.txt @@ -0,0 +1,4 @@ +package + +internal fun arrayOf(/*0*/ vararg t: T /*kotlin.Array*/): kotlin.Array +internal fun test(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.kt b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.kt new file mode 100644 index 00000000000..984dbdb2c74 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(a: Any, f: ()->Int) = f() +fun foo(a: Any, f: (Any)->Int) = f(a) +fun foo(i: Int, f: Int.()->Int) = i.f() + +fun test1() { + foo(1) { -> + this + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.txt b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.txt new file mode 100644 index 00000000000..8fc9fe6c93c --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.txt @@ -0,0 +1,6 @@ +package + +internal fun foo(/*0*/ a: kotlin.Any, /*1*/ f: () -> kotlin.Int): kotlin.Int +internal fun foo(/*0*/ a: kotlin.Any, /*1*/ f: (kotlin.Any) -> kotlin.Int): kotlin.Int +internal fun foo(/*0*/ i: kotlin.Int, /*1*/ f: kotlin.Int.() -> kotlin.Int): kotlin.Int +internal fun test1(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.kt b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.kt new file mode 100644 index 00000000000..b6e7f1bc6dd --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +fun foo(first: () -> T, second: (T) -> R): R = throw Exception() +fun test() { + val r = foo( { 4 }, { "${it + 1}" } ) + r checkType { _() } +} diff --git a/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.txt b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.txt new file mode 100644 index 00000000000..452f937be9e --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.txt @@ -0,0 +1,4 @@ +package + +internal fun foo(/*0*/ first: () -> T, /*1*/ second: (T) -> R): R +internal fun test(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt new file mode 100644 index 00000000000..6c2ba39d404 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(f: () -> Collection, p: (T) -> Boolean): Collection = throw Exception() + +fun emptyList(): List = throw Exception() + +fun test(): Collection = foo({ emptyList() }, { x -> x > 0 }) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.txt b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.txt new file mode 100644 index 00000000000..3ddf0a9d9ab --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.txt @@ -0,0 +1,5 @@ +package + +internal fun emptyList(): kotlin.List +internal fun foo(/*0*/ f: () -> kotlin.Collection, /*1*/ p: (T) -> kotlin.Boolean): kotlin.Collection +internal fun test(): kotlin.Collection diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt index bb0bd0b58f5..ad2dc2764be 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt @@ -10,26 +10,26 @@ fun foo(s: String, a: Any) = s + a fun foo(a: Any, s: String) = s + a fun foo(i: Int, j: Int) = i + j fun foo(a: Any, i: Int) = "$a$i" -fun foo(f: (Int)->Int, i: Int) = f(i) -fun foo(f: (String)->Int, s: String) = f(s) -fun foo(f: (Any)->Int, a: Any) = f(a) -fun foo(s: String, f: (String)->Int) = f(s) -fun foo(a: Any, f: (Any)->Int) = f(a) +fun foo(f: (Int) -> Int, i: Int) = f(i) +fun foo(f: (String) -> Int, s: String) = f(s) +fun foo(f: (Any) -> Int, a: Any) = f(a) +fun foo(s: String, f: (String) -> Int) = f(s) +fun foo(a: Any, f: (Any) -> Int) = f(a) //appropriate function -fun foo(i: Int, f: (Int)->Int) = f(i) +fun foo(i: Int, f: (Int) -> Int) = f(i) fun id(t: T) = t fun test() { - foo(1, id { (x1: Int):Int -> - foo(2, id { (x2: Int): Int -> - foo(3, id { (x3: Int): Int -> - foo(4, id { (x4: Int): Int -> - foo(5, id { (x5: Int): Int -> - x1 + x2 + x3 + x4 + x5 + A.iii - }) - }) - }) - }) - }) + foo(1, id(fun(x1: Int) = + foo(2, id(fun(x2: Int) = + foo(3, id(fun(x3: Int) = + foo(4, id(fun(x4: Int) = + foo(5, id(fun(x5: Int) = + x1 + x2 + x3 + x4 + x5 + A.iii + )) + )) + )) + )) + )) } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 9827f921490..52722331fd9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -6696,6 +6696,63 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { } } + @TestMetadata("compiler/testData/diagnostics/tests/inference/commonSystem") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CommonSystem extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInCommonSystem() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/commonSystem"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("boundOnNullableVariable.kt") + public void testBoundOnNullableVariable() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt"); + doTest(fileName); + } + + @TestMetadata("dontCaptureTypeVariable.kt") + public void testDontCaptureTypeVariable() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt"); + doTest(fileName); + } + + @TestMetadata("fixVariablesInRightOrder.kt") + public void testFixVariablesInRightOrder() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/fixVariablesInRightOrder.kt"); + doTest(fileName); + } + + @TestMetadata("genericCandidateInGenericClass.kt") + public void testGenericCandidateInGenericClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/genericCandidateInGenericClass.kt"); + doTest(fileName); + } + + @TestMetadata("inferenceWithUpperBoundsInLambda.kt") + public void testInferenceWithUpperBoundsInLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/inferenceWithUpperBoundsInLambda.kt"); + doTest(fileName); + } + + @TestMetadata("kt3372toCollection.kt") + public void testKt3372toCollection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt"); + doTest(fileName); + } + + @TestMetadata("nestedLambdas.kt") + public void testNestedLambdas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); + doTest(fileName); + } + + @TestMetadata("theSameFunctionInArgs.kt") + public void testTheSameFunctionInArgs() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inference/constraints") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -11085,12 +11142,30 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("ambiguityWithTwoCorrespondingFunctionTypes.kt") + public void testAmbiguityWithTwoCorrespondingFunctionTypes() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/ambiguityWithTwoCorrespondingFunctionTypes.kt"); + doTest(fileName); + } + @TestMetadata("incompleteConstructorInvocation.kt") public void testIncompleteConstructorInvocation() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/incompleteConstructorInvocation.kt"); doTest(fileName); } + @TestMetadata("inferenceInLinkedLambdas.kt") + public void testInferenceInLinkedLambdas() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdas.kt"); + doTest(fileName); + } + + @TestMetadata("inferenceInLinkedLambdasDependentOnExpectedType.kt") + public void testInferenceInLinkedLambdasDependentOnExpectedType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/inferenceInLinkedLambdasDependentOnExpectedType.kt"); + doTest(fileName); + } + @TestMetadata("objectLiteralAsArgument.kt") public void testObjectLiteralAsArgument() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/objectLiteralAsArgument.kt"); From 517c2b35209ae6d60e9fcf77b1ab2332a4b1d923 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 1 Jul 2015 21:46:31 +0300 Subject: [PATCH 204/450] Rename to kt: CallResolverUtil --- .../resolve/calls/{CallResolverUtil.java => CallResolverUtil.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/{CallResolverUtil.java => CallResolverUtil.kt} (100%) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.java rename to compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt From a714de783f100c9deca019fc6469ee3d473589a1 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 1 Jul 2015 22:08:27 +0300 Subject: [PATCH 205/450] Converted CallResolverUtil to kotlin --- .../kotlin/backend/common/CodegenUtil.java | 5 +- .../kotlin/backend/common/bridges/impl.kt | 4 +- .../kotlin/codegen/ExpressionCodegen.java | 4 +- .../kotlin/codegen/FunctionCodegen.java | 4 +- .../codegen/ImplementationBodyCodegen.java | 4 +- .../checkers/TraitDefaultMethodCallChecker.kt | 5 +- .../kotlin/resolve/OverrideResolver.java | 4 +- .../resolve/calls/ArgumentTypeResolver.java | 6 +- .../kotlin/resolve/calls/CallCompleter.kt | 14 +- .../kotlin/resolve/calls/CallResolver.java | 9 +- .../kotlin/resolve/calls/CallResolverUtil.kt | 286 ++++++++---------- .../resolve/calls/CandidateResolver.java | 17 +- .../resolve/calls/GenericCandidateResolver.kt | 16 +- .../resolve/calls/model/ResolvedCallImpl.java | 5 +- .../resolve/calls/tasks/TaskPrioritizer.kt | 2 +- .../codeInsight/OverrideMethodsHandler.java | 4 +- .../callTranslator/CallTranslator.kt | 4 +- 17 files changed, 176 insertions(+), 217 deletions(-) diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java index 92e576a916b..b6b55e1067d 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/CodegenUtil.java @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.backend.common; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; @@ -29,7 +28,7 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.types.JetType; @@ -62,7 +61,7 @@ public class CodegenUtil { ) { Collection functions = owner.getDefaultType().getMemberScope().getFunctions(name); for (FunctionDescriptor function : functions) { - if (!CallResolverUtil.isOrOverridesSynthesized(function) + if (!CallResolverUtilPackage.isOrOverridesSynthesized(function) && function.getTypeParameters().isEmpty() && valueParameterClassesMatch(function.getValueParameters(), Arrays.asList(valueParameterClassifiers)) && rawTypeMatches(function.getReturnType(), returnedClassifier)) { diff --git a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt index 63399e7628a..06b84441db6 100644 --- a/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt +++ b/compiler/backend-common/src/org/jetbrains/kotlin/backend/common/bridges/impl.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.OverrideResolver -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized public fun generateBridgesForFunctionDescriptor( descriptor: FunctionDescriptor, @@ -69,7 +69,7 @@ private data class DescriptorBasedFunctionHandle(val descriptor: FunctionDescrip */ public fun findTraitImplementation(descriptor: CallableMemberDescriptor): CallableMemberDescriptor? { if (descriptor.getKind().isReal()) return null - if (CallResolverUtil.isOrOverridesSynthesized(descriptor)) return null + if (isOrOverridesSynthesized(descriptor)) return null val implementation = findImplementationFromInterface(descriptor) ?: return null val immediateConcreteSuper = firstSuperMethodFromKotlin(descriptor, implementation) ?: return null diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 384cfe537f0..3bff774576d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -60,7 +60,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.*; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject; @@ -2330,7 +2330,7 @@ public class ExpressionCodegen extends JetVisitor implem @NotNull public StackValue invokeFunction(@NotNull Call call, @NotNull ResolvedCall resolvedCall, @NotNull StackValue receiver) { FunctionDescriptor fd = accessibleFunctionDescriptor(resolvedCall); - JetSuperExpression superCallExpression = CallResolverUtil.getSuperCallExpression(call); + JetSuperExpression superCallExpression = CallResolverUtilPackage.getSuperCallExpression(call); boolean superCall = superCallExpression != null; if (superCall && !isInterface(fd.getContainingDeclaration())) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index c0f2e76d315..cd7016c3f68 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.constants.ArrayValue; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.KClassValue; @@ -502,7 +502,7 @@ public class FunctionCodegen { if (isMethodOfAny(descriptor)) return; // If the function doesn't have a physical declaration among super-functions, it's a SAM adapter or alike and doesn't need bridges - if (CallResolverUtil.isOrOverridesSynthesized(descriptor)) return; + if (CallResolverUtilPackage.isOrOverridesSynthesized(descriptor)) return; Set> bridgesToGenerate = BridgesPackage.generateBridgesForFunctionDescriptor( descriptor, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 8e43cb0b89b..83258ee3ce4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -49,7 +49,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument; import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument; @@ -403,7 +403,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private boolean isGenericToArrayPresent() { Collection functions = descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray")); for (FunctionDescriptor function : functions) { - if (CallResolverUtil.isOrOverridesSynthesized(function)) { + if (CallResolverUtilPackage.isOrOverridesSynthesized(function)) { continue; } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/TraitDefaultMethodCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/TraitDefaultMethodCallChecker.kt index bb556a97549..647447207fe 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/TraitDefaultMethodCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/TraitDefaultMethodCallChecker.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.psi.JetExpression import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall @@ -31,8 +31,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm public class TraitDefaultMethodCallChecker : CallChecker { override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { - val jetSuperExpression = CallResolverUtil.getSuperCallExpression(resolvedCall.getCall()) - if (jetSuperExpression == null) return + if (getSuperCallExpression(resolvedCall.getCall()) == null) return val targetDescriptor = resolvedCall.getResultingDescriptor().getOriginal() val containerDescriptor = targetDescriptor.getContainingDeclaration() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java index e9400dff332..2d70bbd2730 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.types.*; @@ -361,7 +361,7 @@ public class OverrideResolver { @NotNull List concreteOverridden ) { for (CallableMemberDescriptor overridden : allOverriddenDeclarations) { - if (!CallResolverUtil.isOrOverridesSynthesized(overridden)) { + if (!CallResolverUtilPackage.isOrOverridesSynthesized(overridden)) { if (overridden.getModality() == Modality.ABSTRACT) { abstractOverridden.add(overridden); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java index 6d57f4c0e68..68c09c6bad1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext; import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode; @@ -50,9 +51,8 @@ import java.util.Collections; import java.util.List; import static org.jetbrains.kotlin.resolve.BindingContextUtils.getRecordedTypeInfo; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.DEPENDENT; import static org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT; import static org.jetbrains.kotlin.resolve.calls.inference.InferencePackage.createTypeForFunctionPlaceholder; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index a06e16920ab..9bda02e0631 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -23,13 +23,12 @@ import org.jetbrains.kotlin.resolve.BindingContext.CONSTRAINT_SYSTEM_COMPLETER import org.jetbrains.kotlin.resolve.BindingContextUtils import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.TemporaryBindingTrace -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType -import org.jetbrains.kotlin.resolve.calls.callUtil.getCall +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInvokeCallOnVariable import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* @@ -38,14 +37,11 @@ import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsImpl import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy +import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.DataFlowUtils -import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import java.util.ArrayList -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.* -import org.jetbrains.kotlin.resolve.calls.model.* -import org.jetbrains.kotlin.types.ErrorUtils public class CallCompleter( val argumentTypeResolver: ArgumentTypeResolver, @@ -61,7 +57,7 @@ public class CallCompleter( // for the case 'foo(a)' where 'foo' is a variable, the call 'foo.invoke(a)' shouldn't be completed separately, // it's completed when the outer (variable as function call) is completed - if (!CallResolverUtil.isInvokeCallOnVariable(context.call)) { + if (!isInvokeCallOnVariable(context.call)) { val temporaryTrace = TemporaryBindingTrace.create(context.trace, "Trace to complete a resulting call") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index c012a961f52..950460736c4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker; import org.jetbrains.kotlin.resolve.calls.context.*; @@ -59,8 +60,8 @@ import java.util.List; import static org.jetbrains.kotlin.diagnostics.Errors.*; import static org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilPackage.recordScopeAndDataFlowInfo; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.CANDIDATES_WITH_WRONG_RECEIVER; import static org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.INCOMPLETE_TYPE_INFERENCE; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; @@ -465,7 +466,7 @@ public class CallResolver { @NotNull OverloadResolutionResultsImpl results, @NotNull TracingStrategy tracing ) { - if (CallResolverUtil.isInvokeCallOnVariable(context.call)) return; + if (CallResolverUtilPackage.isInvokeCallOnVariable(context.call)) return; if (!results.isSingleResult()) { if (results.getResultCode() == INCOMPLETE_TYPE_INFERENCE) { argumentTypeResolver.checkTypesWithNoCallee(context, RESOLVE_FUNCTION_ARGUMENTS); @@ -485,7 +486,7 @@ public class CallResolver { @NotNull TracingStrategy tracing ) { Call call = context.call; - if (CallResolverUtil.isInvokeCallOnVariable(call)) return; + if (CallResolverUtilPackage.isInvokeCallOnVariable(call)) return; DelegatingBindingTrace deltasTraceToCacheResolve = new DelegatingBindingTrace( BindingContext.EMPTY, "delta trace for caching resolve of", context.call); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index d4884e629f9..09075e793f5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -14,170 +14,134 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.calls; +package org.jetbrains.kotlin.resolve.calls.callResolverUtil -import com.google.common.collect.Lists; -import com.intellij.util.SmartList; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem; -import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; -import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.*; +import com.google.common.collect.Lists +import com.intellij.util.containers.ContainerUtil +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.psi.Call +import org.jetbrains.kotlin.psi.JetSimpleNameExpression +import org.jetbrains.kotlin.psi.JetSuperExpression +import org.jetbrains.kotlin.psi.ValueArgument +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION +import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE -import java.util.Collections; -import java.util.List; - -import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION; -import static org.jetbrains.kotlin.types.TypeUtils.DONT_CARE; - -public class CallResolverUtil { - public static enum ResolveArgumentsMode { - RESOLVE_FUNCTION_ARGUMENTS, - SHAPE_FUNCTION_ARGUMENTS - } - - private CallResolverUtil() {} +public enum class ResolveArgumentsMode { + RESOLVE_FUNCTION_ARGUMENTS, + SHAPE_FUNCTION_ARGUMENTS +} - public static boolean hasUnknownFunctionParameter(@NotNull JetType type) { - assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type); - List arguments = type.getArguments(); - // last argument is return type of function type - List functionParameters = arguments.subList(0, arguments.size() - 1); - for (TypeProjection functionParameter : functionParameters) { - if (TypeUtils.containsSpecialType(functionParameter.getType(), DONT_CARE) - || ErrorUtils.containsUninferredParameter(functionParameter.getType())) { - return true; - } - } - return false; - } - - public static boolean hasUnknownReturnType(@NotNull JetType type) { - assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type); - JetType returnTypeFromFunctionType = KotlinBuiltIns.getReturnTypeFromFunctionType(type); - return ErrorUtils.containsErrorType(returnTypeFromFunctionType); - } - - public static JetType replaceReturnTypeByUnknown(@NotNull JetType type) { - assert KotlinBuiltIns.isFunctionOrExtensionFunctionType(type); - List arguments = type.getArguments(); - List newArguments = Lists.newArrayList(); - newArguments.addAll(arguments.subList(0, arguments.size() - 1)); - newArguments.add(new TypeProjectionImpl(Variance.INVARIANT, DONT_CARE)); - return new JetTypeImpl(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()); - } - - private static boolean hasReturnTypeDependentOnUninferredParams( - @NotNull CallableDescriptor candidateDescriptor, - @NotNull ConstraintSystem constraintSystem - ) { - JetType returnType = candidateDescriptor.getReturnType(); - if (returnType == null) return false; - - for (TypeParameterDescriptor typeVariable : constraintSystem.getTypeVariables()) { - JetType inferredValueForTypeVariable = constraintSystem.getTypeBounds(typeVariable).getValue(); - if (inferredValueForTypeVariable == null) { - if (TypeUtils.dependsOnTypeParameters(returnType, Collections.singleton(typeVariable))) { - return true; - } - } - } - return false; - } - - public static boolean hasInferredReturnType( - @NotNull CallableDescriptor candidateDescriptor, - @NotNull ConstraintSystem constraintSystem - ) { - if (hasReturnTypeDependentOnUninferredParams(candidateDescriptor, constraintSystem)) return false; - - // Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH' - if (constraintSystem.getStatus().hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position())) return false; - return true; - } - - @NotNull - public static JetType getErasedReceiverType( - @NotNull ReceiverParameterDescriptor receiverParameterDescriptor, - @NotNull CallableDescriptor descriptor - ) { - JetType receiverType = receiverParameterDescriptor.getType(); - for (TypeParameterDescriptor typeParameter : descriptor.getTypeParameters()) { - if (typeParameter.getTypeConstructor().equals(receiverType.getConstructor())) { - receiverType = typeParameter.getUpperBoundsAsType(); - } - } - List fakeTypeArguments = ContainerUtil.newSmartList(); - for (TypeProjection typeProjection : receiverType.getArguments()) { - fakeTypeArguments.add(new TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE)); - } - return new JetTypeImpl( - receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), - fakeTypeArguments, ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)); - } - - public static boolean isOrOverridesSynthesized(@NotNull CallableMemberDescriptor descriptor) { - if (descriptor.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) { - return true; - } - if (descriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { - for (CallableMemberDescriptor overridden : descriptor.getOverriddenDescriptors()) { - if (!isOrOverridesSynthesized(overridden)) { - return false; - } - } - return true; - } - return false; - } - - public static boolean isInvokeCallOnVariable(@NotNull Call call) { - if (call.getCallType() != Call.CallType.INVOKE) return false; - ReceiverValue dispatchReceiver = call.getDispatchReceiver(); - //calleeExpressionAsDispatchReceiver for invoke is always ExpressionReceiver, see CallForImplicitInvoke - JetExpression expression = ((ExpressionReceiver) dispatchReceiver).getExpression(); - return expression instanceof JetSimpleNameExpression; - } - - public static boolean isInvokeCallOnExpressionWithBothReceivers(@NotNull Call call) { - if (call.getCallType() != Call.CallType.INVOKE || isInvokeCallOnVariable(call)) return false; - return call.getExplicitReceiver().exists() && call.getDispatchReceiver().exists(); - } - - public static JetSuperExpression getSuperCallExpression(@NotNull Call call) { - ReceiverValue explicitReceiver = call.getExplicitReceiver(); - if (explicitReceiver instanceof ExpressionReceiver) { - JetExpression receiverExpression = ((ExpressionReceiver) explicitReceiver).getExpression(); - if (receiverExpression instanceof JetSuperExpression) { - return (JetSuperExpression) receiverExpression; - } - } - return null; - } - - @NotNull - public static JetType getEffectiveExpectedType(@NotNull ValueParameterDescriptor parameterDescriptor, @NotNull ValueArgument argument) { - if (argument.getSpreadElement() != null) { - if (parameterDescriptor.getVarargElementType() == null) { - // Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper - return DONT_CARE; - } - else { - return parameterDescriptor.getType(); - } - } - else { - JetType varargElementType = parameterDescriptor.getVarargElementType(); - if (varargElementType != null) { - return varargElementType; - } - - return parameterDescriptor.getType(); - } +public fun hasUnknownFunctionParameter(type: JetType): Boolean { + assert(KotlinBuiltIns.isFunctionOrExtensionFunctionType(type)) + val arguments = type.getArguments() + // last argument is return type of function type + val functionParameters = arguments.subList(0, arguments.size() - 1) + return functionParameters.any { + TypeUtils.containsSpecialType(it.getType(), DONT_CARE) || ErrorUtils.containsUninferredParameter(it.getType()) } } + +public fun hasUnknownReturnType(type: JetType): Boolean { + assert(KotlinBuiltIns.isFunctionOrExtensionFunctionType(type)) + val returnTypeFromFunctionType = KotlinBuiltIns.getReturnTypeFromFunctionType(type) + return ErrorUtils.containsErrorType(returnTypeFromFunctionType) +} + +public fun replaceReturnTypeByUnknown(type: JetType): JetType { + assert(KotlinBuiltIns.isFunctionOrExtensionFunctionType(type)) + val arguments = type.getArguments() + val newArguments = Lists.newArrayList() + newArguments.addAll(arguments.subList(0, arguments.size() - 1)) + newArguments.add(TypeProjectionImpl(Variance.INVARIANT, DONT_CARE)) + return JetTypeImpl(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) +} + +private fun hasReturnTypeDependentOnUninferredParams(candidateDescriptor: CallableDescriptor, constraintSystem: ConstraintSystem): Boolean { + val returnType = candidateDescriptor.getReturnType() ?: return false + + for (typeVariable in constraintSystem.getTypeVariables()) { + val inferredValueForTypeVariable = constraintSystem.getTypeBounds(typeVariable).value + if (inferredValueForTypeVariable == null) { + if (TypeUtils.dependsOnTypeParameters(returnType, setOf(typeVariable))) { + return true + } + } + } + return false +} + +public fun hasInferredReturnType(candidateDescriptor: CallableDescriptor, constraintSystem: ConstraintSystem): Boolean { + if (hasReturnTypeDependentOnUninferredParams(candidateDescriptor, constraintSystem)) return false + + // Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH' + if (constraintSystem.getStatus().hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position())) return false + return true +} + +public fun getErasedReceiverType(receiverParameterDescriptor: ReceiverParameterDescriptor, descriptor: CallableDescriptor): JetType { + var receiverType = receiverParameterDescriptor.getType() + for (typeParameter in descriptor.getTypeParameters()) { + if (typeParameter.getTypeConstructor() == receiverType.getConstructor()) { + receiverType = typeParameter.getUpperBoundsAsType() + } + } + val fakeTypeArguments = ContainerUtil.newSmartList() + for (typeProjection in receiverType.getArguments()) { + fakeTypeArguments.add(TypeProjectionImpl(typeProjection.getProjectionKind(), DONT_CARE)) + } + return JetTypeImpl(receiverType.getAnnotations(), receiverType.getConstructor(), receiverType.isMarkedNullable(), fakeTypeArguments, + ErrorUtils.createErrorScope("Error scope for erased receiver type", /*throwExceptions=*/true)) +} + +public fun isOrOverridesSynthesized(descriptor: CallableMemberDescriptor): Boolean { + if (descriptor.getKind() == CallableMemberDescriptor.Kind.SYNTHESIZED) { + return true + } + if (descriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { + return descriptor.getOverriddenDescriptors().all { + isOrOverridesSynthesized(it) + } + } + return false +} + +public fun isInvokeCallOnVariable(call: Call): Boolean { + if (call.getCallType() !== Call.CallType.INVOKE) return false + val dispatchReceiver = call.getDispatchReceiver() + //calleeExpressionAsDispatchReceiver for invoke is always ExpressionReceiver, see CallForImplicitInvoke + val expression = (dispatchReceiver as ExpressionReceiver).getExpression() + return expression is JetSimpleNameExpression +} + +public fun isInvokeCallOnExpressionWithBothReceivers(call: Call): Boolean { + if (call.getCallType() !== Call.CallType.INVOKE || isInvokeCallOnVariable(call)) return false + return call.getExplicitReceiver().exists() && call.getDispatchReceiver().exists() +} + +public fun getSuperCallExpression(call: Call): JetSuperExpression? { + return (call.getExplicitReceiver() as? ExpressionReceiver)?.getExpression() as? JetSuperExpression +} + +public fun getEffectiveExpectedType(parameterDescriptor: ValueParameterDescriptor, argument: ValueArgument): JetType { + if (argument.getSpreadElement() != null) { + if (parameterDescriptor.getVarargElementType() == null) { + // Spread argument passed to a non-vararg parameter, an error is already reported by ValueArgumentsToParametersMapper + return DONT_CARE + } + return parameterDescriptor.getType() + } + val varargElementType = parameterDescriptor.getVarargElementType() + if (varargElementType != null) { + return varargElementType + } + + return parameterDescriptor.getType() +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java index 8491a71e8f5..15ea32feb42 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.calls; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; @@ -26,6 +25,8 @@ import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStat import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext; import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext; @@ -55,9 +56,9 @@ import java.util.Map; import static org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT; import static org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; -import static org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType; import static org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage.getEffectiveExpectedType; +import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*; import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType; @@ -295,7 +296,7 @@ public class CandidateResolver { @NotNull private ValueArgumentsCheckingResult checkAllValueArguments( @NotNull CallCandidateResolutionContext context, - @NotNull CallResolverUtil.ResolveArgumentsMode resolveFunctionArgumentBodies) { + @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies) { return checkAllValueArguments(context, context.candidateCall.getTrace(), resolveFunctionArgumentBodies); } @@ -303,7 +304,7 @@ public class CandidateResolver { public ValueArgumentsCheckingResult checkAllValueArguments( @NotNull CallCandidateResolutionContext context, @NotNull BindingTrace trace, - @NotNull CallResolverUtil.ResolveArgumentsMode resolveFunctionArgumentBodies + @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies ) { ValueArgumentsCheckingResult checkingResult = checkValueArgumentTypes( context, context.candidateCall, trace, resolveFunctionArgumentBodies); @@ -346,7 +347,7 @@ public class CandidateResolver { @NotNull CallResolutionContext context, @NotNull MutableResolvedCall candidateCall, @NotNull BindingTrace trace, - @NotNull CallResolverUtil.ResolveArgumentsMode resolveFunctionArgumentBodies) { + @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies) { ResolutionStatus resultStatus = SUCCESS; List argumentTypes = Lists.newArrayList(); MutableDataFlowInfoForArguments infoForArguments = candidateCall.getDataFlowInfoForArguments(); @@ -423,7 +424,7 @@ public class CandidateResolver { ResolutionStatus status = SUCCESS; // For the expressions like '42.(f)()' where f: String.() -> Unit we'd like to generate a type mismatch error on '1', // not to throw away the candidate, so the following check is skipped. - if (!CallResolverUtil.isInvokeCallOnExpressionWithBothReceivers(context.call)) { + if (!CallResolverUtilPackage.isInvokeCallOnExpressionWithBothReceivers(context.call)) { status = status.combine(checkReceiverTypeError(context, extensionReceiver, candidateCall.getExtensionReceiver())); } status = status.combine(checkReceiverTypeError(context, dispatchReceiver, candidateCall.getDispatchReceiver())); @@ -439,7 +440,7 @@ public class CandidateResolver { D candidateDescriptor = context.candidateCall.getCandidateDescriptor(); - JetType erasedReceiverType = CallResolverUtil.getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor); + JetType erasedReceiverType = CallResolverUtilPackage.getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor); boolean isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, context); if (!isSubtypeBySmartCast) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index cbde47b02c5..624c889111c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -16,19 +16,17 @@ package org.jetbrains.kotlin.resolve.calls -import com.google.common.collect.Maps import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.psi.JetExpression import org.jetbrains.kotlin.psi.JetPsiUtil import org.jetbrains.kotlin.psi.ValueArgument import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver.getLastElementDeparenthesized -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.* +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT @@ -130,7 +128,7 @@ class GenericCandidateResolver( substitutor: TypeSubstitutor, constraintSystem: ConstraintSystem, context: CallCandidateResolutionContext<*>, - resolveFunctionArgumentBodies: CallResolverUtil.ResolveArgumentsMode + resolveFunctionArgumentBodies: ResolveArgumentsMode ) { val effectiveExpectedType = getEffectiveExpectedType(valueParameterDescriptor, valueArgument) @@ -239,14 +237,14 @@ class GenericCandidateResolver( expectedType = argumentTypeResolver.getShapeTypeOfFunctionLiteral(functionLiteral, context.scope, context.trace, false) } if (expectedType == null || !KotlinBuiltIns.isFunctionOrExtensionFunctionType(expectedType) - || CallResolverUtil.hasUnknownFunctionParameter(expectedType)) { + || hasUnknownFunctionParameter(expectedType)) { return } val dataFlowInfoForArguments = context.candidateCall.getDataFlowInfoForArguments() val dataFlowInfoForArgument = dataFlowInfoForArguments.getInfo(valueArgument) //todo analyze function literal body once in 'dependent' mode, then complete it with respect to expected type - val hasExpectedReturnType = !CallResolverUtil.hasUnknownReturnType(expectedType) + val hasExpectedReturnType = !hasUnknownReturnType(expectedType) val position = VALUE_PARAMETER_POSITION.position(valueParameterDescriptor.getIndex()) if (hasExpectedReturnType) { val temporaryToResolveFunctionLiteral = TemporaryTraceAndCache.create( @@ -267,7 +265,7 @@ class GenericCandidateResolver( return } } - val expectedTypeWithoutReturnType = if (hasExpectedReturnType) CallResolverUtil.replaceReturnTypeByUnknown(expectedType) else expectedType + val expectedTypeWithoutReturnType = if (hasExpectedReturnType) replaceReturnTypeByUnknown(expectedType) else expectedType val newContext = context.replaceExpectedType(expectedTypeWithoutReturnType).replaceDataFlowInfo(dataFlowInfoForArgument) .replaceContextDependency(INDEPENDENT) val type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java index c2ecc238381..5b6ac901d68 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/model/ResolvedCallImpl.java @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.psi.Call; import org.jetbrains.kotlin.psi.ValueArgument; import org.jetbrains.kotlin.resolve.DelegatingBindingTrace; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem; import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus; @@ -300,7 +300,8 @@ public class ResolvedCallImpl implements MutableRe @Override public boolean hasInferredReturnType() { if (!completed) { - hasInferredReturnType = constraintSystem == null || CallResolverUtil.hasInferredReturnType(candidateDescriptor, constraintSystem); + hasInferredReturnType = constraintSystem == null || + CallResolverUtilPackage.hasInferredReturnType(candidateDescriptor, constraintSystem); } assert hasInferredReturnType != null : "The property 'hasInferredReturnType' was not set when the call was completed."; return hasInferredReturnType; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index dadc7605f71..1c7ae65a94e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.Call import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil.isOrOverridesSynthesized +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.BOTH_RECEIVERS diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/OverrideMethodsHandler.java b/idea/src/org/jetbrains/kotlin/idea/codeInsight/OverrideMethodsHandler.java index c18e016f439..38aa59bb999 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/OverrideMethodsHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/OverrideMethodsHandler.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.idea.core.codeInsight.OverrideImplementMethodsHandler; import org.jetbrains.kotlin.resolve.OverrideResolver; import org.jetbrains.kotlin.resolve.OverridingUtil; -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil; +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.types.JetType; import java.util.HashSet; @@ -49,7 +49,7 @@ public class OverrideMethodsHandler extends OverrideImplementMethodsHandler { Set result = new HashSet(); for (CallableMemberDescriptor superMethod : superMethods) { if (superMethod.getModality().isOverridable()) { - if (!CallResolverUtil.isOrOverridesSynthesized(superMethod)) { + if (!CallResolverUtilPackage.isOrOverridesSynthesized(superMethod)) { result.add(superMethod); } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt index 488903971a1..ffb71b7b279 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.js.translate.general.Translation import org.jetbrains.kotlin.js.translate.reference.CallArgumentTranslator import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils import org.jetbrains.kotlin.psi.Call.CallType -import org.jetbrains.kotlin.resolve.calls.CallResolverUtil +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInvokeCallOnVariable import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind @@ -102,7 +102,7 @@ private fun translateCall(context: TranslationContext, } val call = resolvedCall.getCall() - if (call.getCallType() == CallType.INVOKE && !CallResolverUtil.isInvokeCallOnVariable(call)) { + if (call.getCallType() == CallType.INVOKE && !isInvokeCallOnVariable(call)) { val explicitReceiversForInvoke = computeExplicitReceiversForInvoke(context, resolvedCall, explicitReceivers) return translateFunctionCall(context, resolvedCall, explicitReceiversForInvoke) } From f25f59bb6e2eb64aff9673c49816e1696a82183e Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 1 Jul 2015 21:34:50 +0300 Subject: [PATCH 206/450] Solve the constraint system for alpha-converted variables, store initial and backward conversions for substituting new constraints and the result --- .../kotlin/resolve/calls/CallResolverUtil.kt | 20 ++--- .../resolve/calls/GenericCandidateResolver.kt | 22 ++--- .../tests/inference/constraints/kt6320.kt | 2 +- .../notNullConstraintOnNullableType.kt | 4 +- .../tests/inference/immutableArrayList.kt | 2 +- .../AbstractConstraintSystemTest.kt | 1 + .../calls/inference/ConstraintSystem.kt | 7 +- .../calls/inference/ConstraintSystemImpl.kt | 82 ++++++++++++------- .../jetbrains/kotlin/idea/util/FuzzyType.kt | 1 + 9 files changed, 80 insertions(+), 61 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index 09075e793f5..b2243f1ed0f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.psi.JetSimpleNameExpression import org.jetbrains.kotlin.psi.JetSuperExpression import org.jetbrains.kotlin.psi.ValueArgument import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.types.* @@ -64,22 +65,17 @@ public fun replaceReturnTypeByUnknown(type: JetType): JetType { return JetTypeImpl(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) } -private fun hasReturnTypeDependentOnUninferredParams(candidateDescriptor: CallableDescriptor, constraintSystem: ConstraintSystem): Boolean { - val returnType = candidateDescriptor.getReturnType() ?: return false +private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constraintSystem: ConstraintSystem): Boolean { + val returnType = getReturnType() ?: return false - for (typeVariable in constraintSystem.getTypeVariables()) { - val inferredValueForTypeVariable = constraintSystem.getTypeBounds(typeVariable).value - if (inferredValueForTypeVariable == null) { - if (TypeUtils.dependsOnTypeParameters(returnType, setOf(typeVariable))) { - return true - } - } + val nestedTypeVariables = with (constraintSystem as ConstraintSystemImpl) { + returnType.getNestedTypeVariables(original = true) } - return false + return nestedTypeVariables.any { constraintSystem.getTypeBounds(it).value == null } } -public fun hasInferredReturnType(candidateDescriptor: CallableDescriptor, constraintSystem: ConstraintSystem): Boolean { - if (hasReturnTypeDependentOnUninferredParams(candidateDescriptor, constraintSystem)) return false +public fun CallableDescriptor.hasInferredReturnType(constraintSystem: ConstraintSystem): Boolean { + if (hasReturnTypeDependentOnUninferredParams(constraintSystem)) return false // Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH' if (constraintSystem.getStatus().hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position())) return false diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 624c889111c..57a4c612e67 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus @@ -62,6 +63,7 @@ class GenericCandidateResolver( val candidate = candidateCall.getCandidateDescriptor() val constraintSystem = ConstraintSystemImpl() + candidateCall.setConstraintSystem(constraintSystem) // If the call is recursive, e.g. // fun foo(t : T) : T = foo(t) @@ -71,16 +73,15 @@ class GenericCandidateResolver( // Thus, we replace the parameters of our descriptor with fresh objects (perform alpha-conversion) val candidateWithFreshVariables = FunctionDescriptorUtil.alphaConvertTypeParameters(candidate) - val backConversion = candidateWithFreshVariables.getTypeParameters().zip(candidate.getTypeParameters()).toMap() + val conversionToOriginal = candidateWithFreshVariables.getTypeParameters().zip(candidate.getTypeParameters()).toMap() + constraintSystem.registerTypeVariables(candidateWithFreshVariables.getTypeParameters(), { Variance.INVARIANT }, { conversionToOriginal[it]!! }) - constraintSystem.registerTypeVariables(candidateWithFreshVariables.getTypeParameters(), { Variance.INVARIANT }) - - val substituteDontCare = makeConstantSubstitutor(candidateWithFreshVariables.getTypeParameters(), DONT_CARE) + val substituteDontCare = makeConstantSubstitutor(candidate.getTypeParameters(), DONT_CARE) // Value parameters for (entry in candidateCall.getValueArguments().entrySet()) { val resolvedValueArgument = entry.getValue() - val valueParameterDescriptor = candidateWithFreshVariables.getValueParameters().get(entry.getKey().getIndex()) + val valueParameterDescriptor = candidate.getValueParameters().get(entry.getKey().getIndex()) for (valueArgument in resolvedValueArgument.getArguments()) { @@ -97,7 +98,7 @@ class GenericCandidateResolver( // Receiver // Error is already reported if something is missing val receiverArgument = candidateCall.getExtensionReceiver() - val receiverParameter = candidateWithFreshVariables.getExtensionReceiverParameter() + val receiverParameter = candidate.getExtensionReceiverParameter() if (receiverArgument.exists() && receiverParameter != null) { var receiverType: JetType? = if (context.candidateCall.isSafeCall()) TypeUtils.makeNotNullable(receiverArgument.getType()) @@ -109,11 +110,6 @@ class GenericCandidateResolver( constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), RECEIVER_POSITION.position()) } - // Restore type variables before alpha-conversion - val constraintSystemWithRightTypeParameters = constraintSystem.substituteTypeVariables { backConversion.get(it) } - candidateCall.setConstraintSystem(constraintSystemWithRightTypeParameters) - - // Solution val hasContradiction = constraintSystem.getStatus().hasContradiction() if (!hasContradiction) { @@ -168,7 +164,7 @@ class GenericCandidateResolver( val returnType = candidateDescriptor.getReturnType() ?: return false val nestedTypeVariables = with (argumentConstraintSystem) { - returnType.getNestedTypeVariables() + returnType.getNestedTypeVariables(original = true) } // we add an additional type variable only if no information is inferred for it. // otherwise we add currently inferred return type as before @@ -178,7 +174,7 @@ class GenericCandidateResolver( val conversion = candidateDescriptor.getTypeParameters().zip(candidateWithFreshVariables.getTypeParameters()).toMap() val freshVariables = nestedTypeVariables.map { conversion[it] }.filterNotNull() - constraintSystem.registerTypeVariables(freshVariables, { Variance.INVARIANT }, external = true) + constraintSystem.registerTypeVariables(freshVariables, { Variance.INVARIANT }, { it }, external = true) constraintSystem.addSubtypeConstraint(candidateWithFreshVariables.getReturnType(), effectiveExpectedType, constraintPosition) return true diff --git a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt index aa90703e00a..fd2b06233bc 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/kt6320.kt @@ -15,6 +15,6 @@ class C class D(foo: C) { fun test(a: C) { - val d: D = D(a) + val d: D = D(a) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt index ebb32733fdf..723967042de 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/notNullConstraintOnNullableType.kt @@ -17,8 +17,8 @@ fun test(out: Out, i: In, inv: A) { r checkType { _() } // T? <: Int => error - doIn(i) + doIn(i) // T? >: Int => error - doA(inv) + doA(inv) } diff --git a/compiler/testData/diagnostics/tests/inference/immutableArrayList.kt b/compiler/testData/diagnostics/tests/inference/immutableArrayList.kt index db6c4843960..6b8be3fbbdb 100644 --- a/compiler/testData/diagnostics/tests/inference/immutableArrayList.kt +++ b/compiler/testData/diagnostics/tests/inference/immutableArrayList.kt @@ -12,6 +12,6 @@ import p.J.* class Foo: Sub { fun foo(): Super { - return Foo() + return Foo() } } \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 8ed593b72fb..6cf755ac65b 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION +import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariables import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.JetLiteFixture diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt index 3e18a4c3b7f..1a0071ed007 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystem.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.types.Variance public trait ConstraintSystem { @@ -30,7 +30,8 @@ public trait ConstraintSystem { */ public fun registerTypeVariables( typeVariables: Collection, - typeVariableVariance: (TypeParameterDescriptor) -> Variance, + variance: (TypeParameterDescriptor) -> Variance, + mapToOriginal: (TypeParameterDescriptor) -> TypeParameterDescriptor, external: Boolean = false ) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index d424a67d23b..b4c0e6e804d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL @@ -28,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_B import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.equalsOrContains import org.jetbrains.kotlin.resolve.scopes.JetScope @@ -70,6 +72,12 @@ public class ConstraintSystemImpl : ConstraintSystem { private val initialConstraints = ArrayList() + private val originalToVariablesSubstitutor: TypeSubstitutor by lazy { + createTypeSubstitutor { originalToVariables[it] } + } + private val originalToVariables = LinkedHashMap() + private val variablesToOriginal = LinkedHashMap() + private val constraintSystemStatus = object : ConstraintSystemStatus { // for debug ConstraintsUtil.getDebugMessageForStatus might be used @@ -101,7 +109,8 @@ public class ConstraintSystemImpl : ConstraintSystem { private fun getParameterToInferredValueMap( typeParameterBounds: Map, - getDefaultTypeProjection: (TypeParameterDescriptor) -> TypeProjection + getDefaultTypeProjection: (TypeParameterDescriptor) -> TypeProjection, + substituteOriginal: Boolean ): Map { val substitutionContext = HashMap() for ((typeParameter, typeBounds) in typeParameterBounds) { @@ -113,34 +122,34 @@ public class ConstraintSystemImpl : ConstraintSystem { else { typeProjection = getDefaultTypeProjection(typeParameter) } - substitutionContext.put(typeParameter, typeProjection) + substitutionContext.put(if (substituteOriginal) variablesToOriginal[typeParameter]!! else typeParameter, typeProjection) } return substitutionContext } - private fun replaceUninferredBy(getDefaultValue: (TypeParameterDescriptor) -> TypeProjection): TypeSubstitutor { - return TypeUtils.makeSubstitutorForTypeParametersMap(getParameterToInferredValueMap(allTypeParameterBounds, getDefaultValue)) - } - - private fun replaceUninferredBy(defaultValue: JetType): TypeSubstitutor { - return replaceUninferredBy { TypeProjectionImpl(defaultValue) } - } - - private fun replaceUninferredBySpecialErrorType(): TypeSubstitutor { - return replaceUninferredBy { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) } + private fun replaceUninferredBy( + getDefaultValue: (TypeParameterDescriptor) -> TypeProjection, + substituteOriginal: Boolean + ): TypeSubstitutor { + val parameterToInferredValueMap = getParameterToInferredValueMap(allTypeParameterBounds, getDefaultValue, substituteOriginal) + return TypeUtils.makeSubstitutorForTypeParametersMap(parameterToInferredValueMap) } override fun getStatus(): ConstraintSystemStatus = constraintSystemStatus override fun registerTypeVariables( typeVariables: Collection, - typeVariableVariance: (TypeParameterDescriptor) -> Variance, + variance: (TypeParameterDescriptor) -> Variance, + mapToOriginal: (TypeParameterDescriptor) -> TypeParameterDescriptor, external: Boolean ) { if (external) externalTypeParameters.addAll(typeVariables) for (typeVariable in typeVariables) { - allTypeParameterBounds.put(typeVariable, TypeBoundsImpl(typeVariable, typeVariableVariance(typeVariable))) + allTypeParameterBounds.put(typeVariable, TypeBoundsImpl(typeVariable, variance(typeVariable))) + val original = mapToOriginal(typeVariable) + originalToVariables[original] = typeVariable + variablesToOriginal[typeVariable] = original } for ((typeVariable, typeBounds) in allTypeParameterBounds) { for (declaredUpperBound in typeVariable.getUpperBounds()) { @@ -160,11 +169,10 @@ public class ConstraintSystemImpl : ConstraintSystem { type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } - fun JetType.getNestedTypeVariables(): List { + fun JetType.getNestedTypeVariables(original: Boolean = false): List { return getNestedTypeArguments().map { typeProjection -> typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor - - }.filterNotNull().filter { it in getAllTypeVariables() } + }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } } public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis({ it }, { true }) @@ -216,17 +224,21 @@ public class ConstraintSystemImpl : ConstraintSystem { val newSuperType = typeSubstitutor.substitute(it.superType, Variance.INVARIANT) if (newSubType != null && newSuperType != null) Constraint(it.kind, newSubType, newSuperType, it.position) else null }) + newSystem.originalToVariables.putAll(originalToVariables) + newSystem.variablesToOriginal.putAll(variablesToOriginal) return newSystem } override fun addSupertypeConstraint(constrainingType: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) { if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return - addConstraint(SUB_TYPE, subjectType, constrainingType, constraintPosition) + val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) + addConstraint(SUB_TYPE, newSubjectType, constrainingType, constraintPosition) } override fun addSubtypeConstraint(constrainingType: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) { - addConstraint(SUB_TYPE, constrainingType, subjectType, constraintPosition) + val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) + addConstraint(SUB_TYPE, constrainingType, newSubjectType, constraintPosition) } fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) { @@ -429,24 +441,23 @@ public class ConstraintSystemImpl : ConstraintSystem { addBound(typeVariable, capturedType, EXACT_BOUND, constraintPosition) } - override fun getTypeVariables() = typeParameterBounds.keySet() + override fun getTypeVariables() = originalToVariables.keySet() fun getAllTypeVariables() = allTypeParameterBounds.keySet() fun getBoundsUsedIn(typeVariable: TypeParameterDescriptor): List = usedInBounds[typeVariable] ?: emptyList() override fun getTypeBounds(typeVariable: TypeParameterDescriptor): TypeBoundsImpl { + val variableForOriginal = originalToVariables[typeVariable] + if (variableForOriginal != null && variableForOriginal != typeVariable) { + return getTypeBounds(variableForOriginal) + } if (!isMyTypeVariable(typeVariable)) { throw IllegalArgumentException("TypeParameterDescriptor is not a type variable for constraint system: $typeVariable") } return allTypeParameterBounds[typeVariable]!! } - fun getTypeBounds(parameterType: JetType): TypeBoundsImpl { - assert (isMyTypeVariable(parameterType)) { "Type is not a type variable for constraint system: $parameterType" } - return getTypeBounds(getMyTypeVariable(parameterType)!!) - } - fun isMyTypeVariable(typeVariable: TypeParameterDescriptor) = allTypeParameterBounds.contains(typeVariable) fun isMyTypeVariable(type: JetType): Boolean = getMyTypeVariable(type) != null @@ -456,9 +467,14 @@ public class ConstraintSystemImpl : ConstraintSystem { return if (typeParameterDescriptor != null && isMyTypeVariable(typeParameterDescriptor)) typeParameterDescriptor else null } - override fun getResultingSubstitutor() = replaceUninferredBySpecialErrorType().setApproximateCapturedTypes() + override fun getResultingSubstitutor() = + getSubstitutor(substituteOriginal = true) { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) } - override fun getCurrentSubstitutor() = replaceUninferredBy(TypeUtils.DONT_CARE).setApproximateCapturedTypes() + override fun getCurrentSubstitutor() = + getSubstitutor(substituteOriginal = true) { TypeProjectionImpl(TypeUtils.DONT_CARE) } + + private fun getSubstitutor(substituteOriginal: Boolean, getDefaultValue: (TypeParameterDescriptor) -> TypeProjection) = + replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes() private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) { if (position is CompoundConstraintPosition) return @@ -467,7 +483,8 @@ public class ConstraintSystemImpl : ConstraintSystem { private fun satisfyInitialConstraints(): Boolean { fun JetType.substituteAndMakeNotNullable(): JetType? { - val result = getResultingSubstitutor().substitute(this, Variance.INVARIANT) ?: return null + val substitutor = getSubstitutor(substituteOriginal = false) { TypeProjectionImpl(ErrorUtils.createUninferredParameterType(it)) } + val result = substitutor.substitute(this, Variance.INVARIANT) ?: return null return TypeUtils.makeNotNullable(result) } return initialConstraints.all { @@ -538,5 +555,12 @@ private class SubstitutionWithCapturedTypeApproximation(val substitution: TypeSu } public fun ConstraintSystemImpl.registerTypeVariables(typeVariables: Map) { - registerTypeVariables(typeVariables.keySet(), { typeVariables[it]!! }) + registerTypeVariables(typeVariables.keySet(), { typeVariables[it]!! }, { it }) +} + +public fun ConstraintSystemImpl.registerTypeVariables( + typeVariables: Collection, + variance: (TypeParameterDescriptor) -> Variance +) { + registerTypeVariables(typeVariables, variance, { it }) } \ No newline at end of file diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index d2be701309b..c62bf2b3c20 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariables import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance From d1e9f00e5f24fd1f4b591d973d5abdd89aca32e9 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 1 Jul 2015 22:47:12 +0300 Subject: [PATCH 207/450] Removed obsolete type parameter substitution logic when copy constraint system --- .../calls/inference/ConstraintError.kt | 3 -- .../calls/inference/ConstraintSystemImpl.kt | 49 +++++++++---------- .../resolve/calls/inference/TypeBounds.kt | 1 - .../resolve/calls/inference/TypeBoundsImpl.kt | 43 ---------------- 4 files changed, 23 insertions(+), 73 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt index e3b98365222..2f73688f0b1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt @@ -30,8 +30,5 @@ class TypeInferenceError(constraintPosition: ConstraintPosition): ConstraintErro class CannotCapture(constraintPosition: ConstraintPosition, val typeVariable: TypeParameterDescriptor): ConstraintError(constraintPosition) -fun ConstraintError.substituteTypeVariable(substitution: (TypeParameterDescriptor) -> TypeParameterDescriptor?) = - if (this is CannotCapture) CannotCapture(constraintPosition, substitution(typeVariable) ?: typeVariable) else this - fun newTypeInferenceOrConstructorMismatchError(constraintPosition: ConstraintPosition) = if (constraintPosition is CompoundConstraintPosition) TypeInferenceError(constraintPosition) else TypeConstructorMismatch(constraintPosition) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index b4c0e6e804d..d8dbe991601 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL @@ -29,7 +28,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_B import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.equalsOrContains import org.jetbrains.kotlin.resolve.scopes.JetScope @@ -175,19 +173,14 @@ public class ConstraintSystemImpl : ConstraintSystem { }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } } - public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis({ it }, { true }) - - public fun substituteTypeVariables(typeVariablesMap: (TypeParameterDescriptor) -> TypeParameterDescriptor?): ConstraintSystem { - // type bounds are proper types and don't contain other variables - return createNewConstraintSystemFromThis(typeVariablesMap, { true }) - } + public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis { true } public fun filterConstraintsOut(excludePosition: ConstraintPosition): ConstraintSystem { return filterConstraints { !it.equalsOrContains(excludePosition) } } public fun filterConstraints(condition: (ConstraintPosition) -> Boolean): ConstraintSystem { - return createNewConstraintSystemFromThis({ it }, condition) + return createNewConstraintSystemFromThis(condition) } public fun getSystemWithoutWeakConstraints(): ConstraintSystem { @@ -201,29 +194,20 @@ public class ConstraintSystemImpl : ConstraintSystem { } private fun createNewConstraintSystemFromThis( - substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?, filterConstraintPosition: (ConstraintPosition) -> Boolean ): ConstraintSystem { val newSystem = ConstraintSystemImpl() for ((typeParameter, typeBounds) in allTypeParameterBounds) { - val newTypeParameter = substituteTypeVariable(typeParameter) ?: typeParameter - newSystem.allTypeParameterBounds.put(newTypeParameter, typeBounds.copy(substituteTypeVariable).filter(filterConstraintPosition)) + newSystem.allTypeParameterBounds.put(typeParameter, typeBounds.filter(filterConstraintPosition)) } - for ((typeVariable, bounds) in usedInBounds) { - if (bounds.isNotEmpty()) { - val newTypeVariable = substituteTypeVariable(typeVariable) ?: typeVariable - newSystem.usedInBounds.put(newTypeVariable, ArrayList(bounds.substitute(substituteTypeVariable))) - } - } - newSystem.externalTypeParameters.addAll(externalTypeParameters.map { substituteTypeVariable(it) ?: it }) - newSystem.errors.addAll(errors.filter { filterConstraintPosition(it.constraintPosition) }.map { it.substituteTypeVariable(substituteTypeVariable) }) + newSystem.usedInBounds.putAll(usedInBounds.map { + val (variable, bounds) = it + variable to bounds.filterTo(arrayListOf()) { filterConstraintPosition(it.position )} + }.toMap()) + newSystem.externalTypeParameters.addAll(externalTypeParameters ) + newSystem.errors.addAll(errors.filter { filterConstraintPosition(it.constraintPosition) }) - val typeSubstitutor = createTypeSubstitutor(substituteTypeVariable) - newSystem.initialConstraints.addAll(initialConstraints.filter { filterConstraintPosition(it.position) }.map { - val newSubType = typeSubstitutor.substitute(it.subtype, Variance.INVARIANT) - val newSuperType = typeSubstitutor.substitute(it.superType, Variance.INVARIANT) - if (newSubType != null && newSuperType != null) Constraint(it.kind, newSubType, newSuperType, it.position) else null - }) + newSystem.initialConstraints.addAll(initialConstraints.filter { filterConstraintPosition(it.position) }) newSystem.originalToVariables.putAll(originalToVariables) newSystem.variablesToOriginal.putAll(variablesToOriginal) return newSystem @@ -563,4 +547,17 @@ public fun ConstraintSystemImpl.registerTypeVariables( variance: (TypeParameterDescriptor) -> Variance ) { registerTypeVariables(typeVariables, variance, { it }) +} + +public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypeParameterDescriptor?): TypeSubstitutor { + return TypeSubstitutor.create(object : TypeSubstitution() { + override fun get(key: TypeConstructor): TypeProjection? { + val descriptor = key.getDeclarationDescriptor() + if (descriptor !is TypeParameterDescriptor) return null + val typeParameterDescriptor = conversion(descriptor) ?: return null + + val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) + return TypeProjectionImpl(type) + } + }) } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt index 78d7963dd8f..947cc001d9b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBounds.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_B import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.Variance -import kotlin.properties.Delegates public trait TypeBounds { public val varianceOfPosition: Variance diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt index cc84ca284fb..2be71975086 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/TypeBoundsImpl.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.resolve.calls.inference import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.EXACT_BOUND @@ -25,7 +24,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_B import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstructor -import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.utils.addIfNotNull @@ -74,18 +72,6 @@ public class TypeBoundsImpl( return result } - fun copy(substituteTypeVariable: ((TypeParameterDescriptor) -> TypeParameterDescriptor?)? = null): TypeBoundsImpl { - val typeBounds = TypeBoundsImpl(substituteTypeVariable?.invoke(typeVariable) ?: typeVariable, varianceOfPosition) - if (substituteTypeVariable == null) { - typeBounds.bounds.addAll(bounds) - } - else { - typeBounds.bounds.addAll(bounds.substitute(substituteTypeVariable)) - } - typeBounds.resultValues = resultValues - return typeBounds - } - public fun filter(condition: (ConstraintPosition) -> Boolean): TypeBoundsImpl { val result = TypeBoundsImpl(typeVariable, varianceOfPosition) result.bounds.addAll(bounds.filter { condition(it.position) }) @@ -182,33 +168,4 @@ public class TypeBoundsImpl( } return true } -} - -fun Collection.substitute(substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?): List { - val typeSubstitutor = createTypeSubstitutor(substituteTypeVariable) - return map { - //todo captured types - val substitutedType = if (it.constrainingType.getConstructor().isDenotable()) { - typeSubstitutor.substitute(it.constrainingType, Variance.INVARIANT) - } else { - it.constrainingType - } - substitutedType?.let { type -> - Bound(substituteTypeVariable(it.typeVariable) ?: it.typeVariable, type, it.kind, it.position, it.isProper, - it.derivedFrom.map { substituteTypeVariable(it) ?: it }.toSet()) - } - }.filterNotNull() -} - -fun createTypeSubstitutor(substituteTypeVariable: (TypeParameterDescriptor) -> TypeParameterDescriptor?): TypeSubstitutor { - return TypeSubstitutor.create(object : TypeSubstitution() { - override fun get(key: TypeConstructor): TypeProjection? { - val descriptor = key.getDeclarationDescriptor() - if (descriptor !is TypeParameterDescriptor) return null - val typeParameterDescriptor = substituteTypeVariable(descriptor) ?: return null - - val type = JetTypeImpl(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), JetScope.Empty) - return TypeProjectionImpl(type) - } - }) } \ No newline at end of file From 4c1eedce3bce8ce4211322a5391853b1a0057af4 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 2 Jul 2015 14:23:07 +0300 Subject: [PATCH 208/450] Added tests for incorporation with nullable type parameter --- .../nullable/contravariant/varEqDepEq.bounds | 23 ++ .../contravariant/varEqDepEq.constraints | 4 + .../nullable/contravariant/varEqDepSub.bounds | 23 ++ .../contravariant/varEqDepSub.constraints | 4 + .../contravariant/varEqDepSuper.bounds | 23 ++ .../contravariant/varEqDepSuper.constraints | 4 + .../nullable/contravariant/varSubDepEq.bounds | 23 ++ .../contravariant/varSubDepEq.constraints | 4 + .../contravariant/varSubDepSub.bounds | 23 ++ .../contravariant/varSubDepSub.constraints | 4 + .../contravariant/varSubDepSuper.bounds | 23 ++ .../contravariant/varSubDepSuper.constraints | 4 + .../contravariant/varSuperDepEq.bounds | 23 ++ .../contravariant/varSuperDepEq.constraints | 4 + .../contravariant/varSuperDepSub.bounds | 23 ++ .../contravariant/varSuperDepSub.constraints | 4 + .../contravariant/varSuperDepSuper.bounds | 23 ++ .../varSuperDepSuper.constraints | 4 + .../nullable/covariant/varEqDepEq.bounds | 23 ++ .../nullable/covariant/varEqDepEq.constraints | 4 + .../nullable/covariant/varEqDepSub.bounds | 23 ++ .../covariant/varEqDepSub.constraints | 4 + .../nullable/covariant/varEqDepSuper.bounds | 23 ++ .../covariant/varEqDepSuper.constraints | 4 + .../nullable/covariant/varSubDepEq.bounds | 23 ++ .../covariant/varSubDepEq.constraints | 4 + .../nullable/covariant/varSubDepSub.bounds | 23 ++ .../covariant/varSubDepSub.constraints | 4 + .../nullable/covariant/varSubDepSuper.bounds | 23 ++ .../covariant/varSubDepSuper.constraints | 4 + .../nullable/covariant/varSuperDepEq.bounds | 23 ++ .../covariant/varSuperDepEq.constraints | 4 + .../nullable/covariant/varSuperDepSub.bounds | 23 ++ .../covariant/varSuperDepSub.constraints | 4 + .../covariant/varSuperDepSuper.bounds | 23 ++ .../covariant/varSuperDepSuper.constraints | 4 + .../nullable/invariant/varEqDepEq.bounds | 23 ++ .../nullable/invariant/varEqDepEq.constraints | 4 + .../nullable/invariant/varEqDepSub.bounds | 23 ++ .../invariant/varEqDepSub.constraints | 4 + .../nullable/invariant/varEqDepSuper.bounds | 23 ++ .../invariant/varEqDepSuper.constraints | 4 + .../nullable/invariant/varSubDepEq.bounds | 23 ++ .../invariant/varSubDepEq.constraints | 4 + .../nullable/invariant/varSubDepSub.bounds | 23 ++ .../invariant/varSubDepSub.constraints | 4 + .../nullable/invariant/varSubDepSuper.bounds | 23 ++ .../invariant/varSubDepSuper.constraints | 4 + .../nullable/invariant/varSuperDepEq.bounds | 23 ++ .../invariant/varSuperDepEq.constraints | 4 + .../nullable/invariant/varSuperDepSub.bounds | 23 ++ .../invariant/varSuperDepSub.constraints | 4 + .../invariant/varSuperDepSuper.bounds | 23 ++ .../invariant/varSuperDepSuper.constraints | 4 + .../ConstraintSystemTestGenerated.java | 198 ++++++++++++++++++ 55 files changed, 927 insertions(+) create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds new file mode 100644 index 00000000000..9288e38c616 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Consumer + +type parameter bounds: +T := Int, >: Int, <: Int? +P := Consumer*, := Consumer, <: Consumer, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints new file mode 100644 index 00000000000..3b81189be3a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds new file mode 100644 index 00000000000..73a23b485b7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Consumer + +type parameter bounds: +T := Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints new file mode 100644 index 00000000000..960d36fb28b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..b63d9d9b28d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Consumer + +type parameter bounds: +T := Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..b9b310e4a6d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds new file mode 100644 index 00000000000..9a003bf92b4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Consumer + +type parameter bounds: +T <: Int, <: Int? +P := Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints new file mode 100644 index 00000000000..7c34b1d8080 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds new file mode 100644 index 00000000000..8821b18fa86 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Consumer + +type parameter bounds: +T <: Int +P <: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints new file mode 100644 index 00000000000..10ace6ad50f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..3dbaf11c438 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Consumer + +type parameter bounds: +T <: Int +P >: Consumer*, >: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..ae5462e8c59 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..2e3d20ba19a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Consumer + +type parameter bounds: +T >: Int +P := Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..ae38a91ed57 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..c20560721c9 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Consumer + +type parameter bounds: +T >: Int +P <: Consumer*, <: Consumer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..b100806bf89 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..bf5bf4045da --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Consumer + +type parameter bounds: +T >: Int +P >: Consumer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..dffa79e2c6b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds new file mode 100644 index 00000000000..13417f5a50e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Producer + +type parameter bounds: +T := Int, >: Int, <: Int? +P := Producer*, := Producer, >: Producer, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints new file mode 100644 index 00000000000..6948d6c0b3b --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds new file mode 100644 index 00000000000..11f554606b3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Producer + +type parameter bounds: +T := Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints new file mode 100644 index 00000000000..a505a22a8b6 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..b36241e4391 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Producer + +type parameter bounds: +T := Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..7220d3f21a0 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds new file mode 100644 index 00000000000..2dc4bfe36bf --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Producer + +type parameter bounds: +T <: Int, <: Int? +P := Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints new file mode 100644 index 00000000000..b22b4c68253 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds new file mode 100644 index 00000000000..8f3c6e275c7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer + +type parameter bounds: +T <: Int +P <: Producer*, <: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints new file mode 100644 index 00000000000..7bd66f85cd3 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..aa177cdd9c4 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Producer + +type parameter bounds: +T <: Int +P >: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..f68d9fc5a41 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..ef1c2e2faec --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Producer + +type parameter bounds: +T >: Int +P := Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..6257394ddff --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..c4dcdf26169 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Producer + +type parameter bounds: +T >: Int +P <: Producer* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..a1f80514814 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..b3a5d5b691c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Producer + +type parameter bounds: +T >: Int +P >: Producer*, >: Producer + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..2b1331f8bed --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds new file mode 100644 index 00000000000..bec3fb0c825 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P My + +type parameter bounds: +T := Int, >: Int, <: Int? +P := My*, := My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints new file mode 100644 index 00000000000..88264911d2c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds new file mode 100644 index 00000000000..ab6d8053d17 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P My + +type parameter bounds: +T := Int +P <: My*, <: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints new file mode 100644 index 00000000000..197a280d8ff --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds new file mode 100644 index 00000000000..0f8e83c76de --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P My + +type parameter bounds: +T := Int +P >: My*, >: My + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints new file mode 100644 index 00000000000..cf7a4a42f5a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +EQUAL T Int +SUPERTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds new file mode 100644 index 00000000000..8b1d7787e9f --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P My + +type parameter bounds: +T <: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: true +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints new file mode 100644 index 00000000000..ff5bbb95a3e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds new file mode 100644 index 00000000000..6effa72428c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My + +type parameter bounds: +T <: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints new file mode 100644 index 00000000000..47a4cbb90f6 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds new file mode 100644 index 00000000000..e914ef48855 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P My + +type parameter bounds: +T <: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints new file mode 100644 index 00000000000..3c9bb446453 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUPERTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds new file mode 100644 index 00000000000..5d69a46a15a --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P My + +type parameter bounds: +T >: Int +P := My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: true +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints new file mode 100644 index 00000000000..1065f6916e5 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +EQUAL P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds new file mode 100644 index 00000000000..70c1d6c6b5d --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P My + +type parameter bounds: +T >: Int +P <: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints new file mode 100644 index 00000000000..841df121682 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUBTYPE P My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds new file mode 100644 index 00000000000..ed393cb0a37 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P My + +type parameter bounds: +T >: Int +P >: My* + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=??? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints new file mode 100644 index 00000000000..2ec50dca2bc --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUPERTYPE T Int +SUPERTYPE P My diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index 1557eceb704..12ea42f21fd 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -433,6 +433,204 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest } } + @TestMetadata("compiler/testData/constraintSystem/severalVariables/nullable") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Nullable extends AbstractConstraintSystemTest { + public void testAllFilesPresentInNullable() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/nullable"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Contravariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInContravariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/nullable/contravariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Covariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInCovariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/nullable/covariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + + @TestMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Invariant extends AbstractConstraintSystemTest { + public void testAllFilesPresentInInvariant() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/nullable/invariant"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("varEqDepEq.constraints") + public void testVarEqDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSub.constraints") + public void testVarEqDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varEqDepSuper.constraints") + public void testVarEqDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepEq.constraints") + public void testVarSubDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSub.constraints") + public void testVarSubDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSubDepSuper.constraints") + public void testVarSubDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepEq.constraints") + public void testVarSuperDepEq() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSub.constraints") + public void testVarSuperDepSub() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints"); + doTest(fileName); + } + + @TestMetadata("varSuperDepSuper.constraints") + public void testVarSuperDepSuper() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints"); + doTest(fileName); + } + } + } + @TestMetadata("compiler/testData/constraintSystem/severalVariables/recursive") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From fc69cf1b5e6e46d84dd29f349df1365b58974eca Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 2 Jul 2015 19:56:36 +0300 Subject: [PATCH 209/450] Added more tests on incorporation --- .../declarations/declarations.kt | 3 +- .../other/constraintForNullables.bounds | 23 ++++++ .../other/constraintForNullables.constraints | 4 + .../other/nestedConsumer.bounds | 23 ++++++ .../other/nestedConsumer.constraints | 4 + .../other/nestedConsumer1.bounds | 23 ++++++ .../other/nestedConsumer1.constraints | 4 + .../other/nestedInvConsumer.bounds | 23 ++++++ .../other/nestedInvConsumer.constraints | 4 + .../other/nestedInvProducer.bounds | 23 ++++++ .../other/nestedInvProducer.constraints | 4 + .../other/nestedProducer.bounds | 23 ++++++ .../other/nestedProducer.constraints | 4 + .../other/nestedProducerAndConsumer.bounds | 23 ++++++ .../nestedProducerAndConsumer.constraints | 4 + .../other/severalOccurrences.bounds | 23 ++++++ .../other/severalOccurrences.constraints | 4 + .../severalVariables/other/simpleFun.bounds | 26 ++++++ .../other/simpleFun.constraints | 5 ++ .../other/simpleThreeVars.bounds | 26 ++++++ .../other/simpleThreeVars.constraints | 5 ++ .../simpleThreeVarsNoIncorporation.bounds | 26 ++++++ ...simpleThreeVarsNoIncorporation.constraints | 5 ++ ...simpleThreeVarsNoIncorporationFixed.bounds | 27 +++++++ ...eThreeVarsNoIncorporationFixed.constraints | 6 ++ .../ConstraintSystemTestGenerated.java | 81 +++++++++++++++++++ 26 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds create mode 100644 compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints diff --git a/compiler/testData/constraintSystem/declarations/declarations.kt b/compiler/testData/constraintSystem/declarations/declarations.kt index 43edc7fdd90..7c8614eadfa 100644 --- a/compiler/testData/constraintSystem/declarations/declarations.kt +++ b/compiler/testData/constraintSystem/declarations/declarations.kt @@ -10,4 +10,5 @@ interface Producer interface My interface Successor : My -interface Two \ No newline at end of file +interface Two +interface Fun \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds new file mode 100644 index 00000000000..98791a29dbb --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T? P? +SUBTYPE P Int + +type parameter bounds: +T <: P?*, <: P*, <: Int, <: Int? +P >: T*, <: Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints new file mode 100644 index 00000000000..df99da1ee94 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T? P? +SUBTYPE P Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds new file mode 100644 index 00000000000..9a062be9167 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +EQUAL P Consumer> + +type parameter bounds: +T >: Int +P := Consumer>*, >: Consumer> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints new file mode 100644 index 00000000000..11a84f8f0bf --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +EQUAL P Consumer> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds new file mode 100644 index 00000000000..a5d0d904597 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P Consumer>> + +type parameter bounds: +T >: Int +P <: Consumer>>*, <: Consumer>> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Consumer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints new file mode 100644 index 00000000000..37ec32c12f6 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P Consumer>> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds new file mode 100644 index 00000000000..4394d6f956e --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P My>> + +type parameter bounds: +T >: Int +P <: My>>*, <: My>> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: true +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=My>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints new file mode 100644 index 00000000000..9550d7f43e8 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P My>> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds new file mode 100644 index 00000000000..c76dbdb7182 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My>> + +type parameter bounds: +T <: Int +P <: My>>*, <: My>> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: true +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: true +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=Int +P=My>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints new file mode 100644 index 00000000000..cf13d9fe377 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P My>> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds new file mode 100644 index 00000000000..01b0c37731c --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer>> + +type parameter bounds: +T <: Int +P <: Producer>>*, <: Producer>> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints new file mode 100644 index 00000000000..ac48c96fd07 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Producer>> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds new file mode 100644 index 00000000000..c9f33c564c7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P Producer>> + +type parameter bounds: +T >: Int +P <: Producer>>*, <: Producer>> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Producer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints new file mode 100644 index 00000000000..5b65fe00289 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE Int T +SUBTYPE P Producer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds new file mode 100644 index 00000000000..6b1a1f6daf0 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds @@ -0,0 +1,23 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Fun,Producer> + +type parameter bounds: +T <: Int +P <: Fun, Producer>*, <: Fun, Producer> + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Fun, Producer> diff --git a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints new file mode 100644 index 00000000000..21995bde4f7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints @@ -0,0 +1,4 @@ +VARIABLES T P + +SUBTYPE T Int +SUBTYPE P Fun,Producer> \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds new file mode 100644 index 00000000000..379589a6bf2 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds @@ -0,0 +1,26 @@ +VARIABLES T P E + +SUBTYPE Int T +SUBTYPE P String +SUBTYPE E Fun + +type parameter bounds: +T >: Int +P <: String +E <: Fun*, <: Fun + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=String +E=Fun diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints new file mode 100644 index 00000000000..29ac24ec9fe --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints @@ -0,0 +1,5 @@ +VARIABLES T P E + +SUBTYPE Int T +SUBTYPE P String +SUBTYPE E Fun \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds new file mode 100644 index 00000000000..68700b96962 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds @@ -0,0 +1,26 @@ +VARIABLES T P E + +SUBTYPE T P +SUBTYPE P E +SUBTYPE E Int + +type parameter bounds: +T <: P*, <: E*, <: Int +P >: T*, <: E*, <: Int +E >: T*, >: P*, <: Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints new file mode 100644 index 00000000000..f41341a3ef0 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints @@ -0,0 +1,5 @@ +VARIABLES T P E + +SUBTYPE T P +SUBTYPE P E +SUBTYPE E Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds new file mode 100644 index 00000000000..6e90c63a897 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds @@ -0,0 +1,26 @@ +VARIABLES T P E + +SUBTYPE T P +SUBTYPE P E +SUBTYPE Int E + +type parameter bounds: +T <: P*, <: E* +P >: T*, <: E* +E >: T*, >: P*, >: Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: true +-hasViolatedUpperBound: false +-isSuccessful: false + +result: +T=??? +P=??? +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints new file mode 100644 index 00000000000..0c5479367b1 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints @@ -0,0 +1,5 @@ +VARIABLES T P E + +SUBTYPE T P +SUBTYPE P E +SUBTYPE Int E diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds new file mode 100644 index 00000000000..14fe73be6f7 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds @@ -0,0 +1,27 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE T P +SUBTYPE P E +SUBTYPE Int E + +type parameter bounds: +T <: P*, <: E*, <: Int, := Int +P >: T*, <: E*, <: Int, := Int, >: Int +E >: T*, >: P*, >: Int, := Int + +status: +-hasCannotCaptureTypesError: false +-hasConflictingConstraints: false +-hasContradiction: false +-hasErrorInConstrainingTypes: false +-hasTypeConstructorMismatch: false +-hasTypeInferenceIncorporationError: false +-hasUnknownParameters: false +-hasViolatedUpperBound: false +-isSuccessful: true + +result: +T=Int +P=Int +E=Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints new file mode 100644 index 00000000000..83e149c9e95 --- /dev/null +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints @@ -0,0 +1,6 @@ +VARIABLES T P E +FIX_VARIABLES + +SUBTYPE T P +SUBTYPE P E +SUBTYPE Int E diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index 12ea42f21fd..8ccbd2d42c1 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -631,6 +631,87 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest } } + @TestMetadata("compiler/testData/constraintSystem/severalVariables/other") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Other extends AbstractConstraintSystemTest { + public void testAllFilesPresentInOther() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/constraintSystem/severalVariables/other"), Pattern.compile("^(.+)\\.constraints$"), true); + } + + @TestMetadata("constraintForNullables.constraints") + public void testConstraintForNullables() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedConsumer.constraints") + public void testNestedConsumer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedConsumer1.constraints") + public void testNestedConsumer1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedInvConsumer.constraints") + public void testNestedInvConsumer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedInvProducer.constraints") + public void testNestedInvProducer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedProducer.constraints") + public void testNestedProducer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints"); + doTest(fileName); + } + + @TestMetadata("nestedProducerAndConsumer.constraints") + public void testNestedProducerAndConsumer() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints"); + doTest(fileName); + } + + @TestMetadata("severalOccurrences.constraints") + public void testSeveralOccurrences() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleFun.constraints") + public void testSimpleFun() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleThreeVars.constraints") + public void testSimpleThreeVars() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleThreeVarsNoIncorporation.constraints") + public void testSimpleThreeVarsNoIncorporation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints"); + doTest(fileName); + } + + @TestMetadata("simpleThreeVarsNoIncorporationFixed.constraints") + public void testSimpleThreeVarsNoIncorporationFixed() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/constraintSystem/severalVariables/recursive") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 4c8b75928e2d3731ad62c7e00018e5f83e98a9a4 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Fri, 3 Jul 2015 01:33:11 +0300 Subject: [PATCH 210/450] Added tests #KT-6179 Fixed #KT-8132 Fixed --- .../diagnostics/tests/inference/regressions/kt8132.kt | 11 +++++++++++ .../tests/inference/regressions/kt8132.txt | 4 ++++ .../kotlin/checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ .../testData/handlers/smart/kt6179filterTo.kt | 10 ++++++++++ .../testData/handlers/smart/kt6179filterTo.kt.after | 10 ++++++++++ .../handlers/SmartCompletionHandlerTestGenerated.java | 6 ++++++ 6 files changed, 47 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt8132.kt create mode 100644 compiler/testData/diagnostics/tests/inference/regressions/kt8132.txt create mode 100644 idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt create mode 100644 idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt.after diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt8132.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt8132.kt new file mode 100644 index 00000000000..03aa63118db --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt8132.kt @@ -0,0 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// KT-8132 Can't omit lambda parameter types + +fun test(foo: List): T { + return if (true) + throw IllegalStateException() + else + foo.reduce { left, right -> left } // error: inferred type T is not subtype Nothing +} + +fun Iterable.reduce(operation: (S, T) -> S): S = throw Exception() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt8132.txt b/compiler/testData/diagnostics/tests/inference/regressions/kt8132.txt new file mode 100644 index 00000000000..4a0ea42f804 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt8132.txt @@ -0,0 +1,4 @@ +package + +internal fun test(/*0*/ foo: kotlin.List): T +internal fun kotlin.Iterable.reduce(/*0*/ operation: (S, T) -> S): S diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 52722331fd9..f636caee210 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -7175,6 +7175,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt8132.kt") + public void testKt8132() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt8132.kt"); + doTest(fileName); + } + @TestMetadata("kt832.kt") public void testKt832() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt832.kt"); diff --git a/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt b/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt new file mode 100644 index 00000000000..bb10324dc66 --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt @@ -0,0 +1,10 @@ +import java.util.ArrayList + +fun foo(c: Collection) { + val list = ArrayList() + c.filterTo0() +} + +fun > Iterable.filterTo0(destination: C, predicate: (T) -> Boolean): C = destination + +//ELEMENT: list \ No newline at end of file diff --git a/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt.after b/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt.after new file mode 100644 index 00000000000..8b056cd34df --- /dev/null +++ b/idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt.after @@ -0,0 +1,10 @@ +import java.util.ArrayList + +fun foo(c: Collection) { + val list = ArrayList() + c.filterTo0(list) +} + +fun > Iterable.filterTo0(destination: C, predicate: (T) -> Boolean): C = destination + +//ELEMENT: list \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java index a1116032f39..f49c5a68b8a 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/SmartCompletionHandlerTestGenerated.java @@ -443,6 +443,12 @@ public class SmartCompletionHandlerTestGenerated extends AbstractSmartCompletion doTest(fileName); } + @TestMetadata("kt6179filterTo.kt") + public void testKt6179filterTo() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/smart/kt6179filterTo.kt"); + doTest(fileName); + } + @TestMetadata("Lambda1.kt") public void testLambda1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/smart/Lambda1.kt"); From 3c698992e0f6ca4fbc60a8bf2cef2bd94e2493e3 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 7 Jul 2015 21:26:20 +0300 Subject: [PATCH 211/450] Generate specific type inference error only for bounds from 'parameter' positions (receiver & value arguments). They can be marked as error (with red color) explicitly later. Replaced getSystemWithoutWeakConstraints() with filterConstraintsOut(TYPE_BOUND_POSITION) --- .../kotlin/diagnostics/rendering/Renderers.kt | 3 +- .../kotlin/resolve/calls/CallResolverUtil.kt | 2 +- .../calls/tasks/AbstractTracingStrategy.java | 4 +-- .../ControlStructureTypingUtils.java | 2 +- .../typeConstructorMismatch.bounds | 2 +- .../calls/inference/ConstraintError.kt | 2 +- .../calls/inference/ConstraintPosition.kt | 8 ++--- .../calls/inference/ConstraintSystemImpl.kt | 30 +++++-------------- .../calls/inference/ConstraintSystemStatus.kt | 4 +-- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index 46879fbc1b0..a3becd143a2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.Bound import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_BOUND import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.RECEIVER_POSITION import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall @@ -244,7 +245,7 @@ public object Renderers { LOG.assertTrue(status.hasViolatedUpperBound(), renderDebugMessage("Upper bound violated renderer is applied for incorrect status", inferenceErrorData)) - val systemWithoutWeakConstraints = constraintSystem.getSystemWithoutWeakConstraints() + val systemWithoutWeakConstraints = constraintSystem.filterConstraintsOut(ConstraintPositionKind.TYPE_BOUND_POSITION) val typeParameterDescriptor = inferenceErrorData.descriptor.getTypeParameters().firstOrNull { !ConstraintsUtil.checkUpperBoundIsSatisfied(systemWithoutWeakConstraints, it, true) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index b2243f1ed0f..f37ae53f661 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -78,7 +78,7 @@ public fun CallableDescriptor.hasInferredReturnType(constraintSystem: Constraint if (hasReturnTypeDependentOnUninferredParams(constraintSystem)) return false // Expected type mismatch was reported before as 'TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH' - if (constraintSystem.getStatus().hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position())) return false + if (constraintSystem.getStatus().hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION)) return false return true } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index 69f1fec7b05..27db5955597 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -208,12 +208,12 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { // (it's useful, when the arguments, e.g. lambdas or calls are incomplete) return; } - if (status.hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position())) { + if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION)) { JetType declaredReturnType = data.descriptor.getReturnType(); if (declaredReturnType == null) return; ConstraintSystem systemWithoutExpectedTypeConstraint = - ((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(EXPECTED_TYPE_POSITION.position()); + ((ConstraintSystemImpl) constraintSystem).filterConstraintsOut(EXPECTED_TYPE_POSITION); JetType substitutedReturnType = systemWithoutExpectedTypeConstraint.getResultingSubstitutor().substitute( declaredReturnType, Variance.OUT_VARIANCE); assert substitutedReturnType != null; //todo diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index ea78d9cf643..24c4ac42f9f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -375,7 +375,7 @@ public class ControlStructureTypingUtils { return; } JetExpression expression = (JetExpression) call.getCallElement(); - if (status.hasOnlyErrorsFromPosition(EXPECTED_TYPE_POSITION.position()) || status.hasConflictingConstraints()) { + if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION) || status.hasConflictingConstraints()) { expression.accept(checkTypeVisitor, new CheckTypeContext(trace, data.expectedType)); return; } diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index d3c1d075e01..21e95269ed0 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: true +-hasTypeConstructorMismatch: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt index 2f73688f0b1..d657c6bd3df 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt @@ -31,4 +31,4 @@ class TypeInferenceError(constraintPosition: ConstraintPosition): ConstraintErro class CannotCapture(constraintPosition: ConstraintPosition, val typeVariable: TypeParameterDescriptor): ConstraintError(constraintPosition) fun newTypeInferenceOrConstructorMismatchError(constraintPosition: ConstraintPosition) = - if (constraintPosition is CompoundConstraintPosition) TypeInferenceError(constraintPosition) else TypeConstructorMismatch(constraintPosition) \ No newline at end of file + if (constraintPosition.isParameter()) TypeConstructorMismatch(constraintPosition) else TypeInferenceError(constraintPosition) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt index ca4b957f452..3c454600843 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintPosition.kt @@ -44,7 +44,7 @@ public trait ConstraintPosition { fun isStrong(): Boolean = kind != TYPE_BOUND_POSITION - fun isCaptureAllowed(): Boolean = kind in setOf(VALUE_PARAMETER_POSITION, RECEIVER_POSITION) + fun isParameter(): Boolean = kind in setOf(VALUE_PARAMETER_POSITION, RECEIVER_POSITION) } private open data class ConstraintPositionImpl(override val kind: ConstraintPositionKind) : ConstraintPosition { @@ -58,13 +58,13 @@ class CompoundConstraintPosition( vararg positions: ConstraintPosition ) : ConstraintPositionImpl(ConstraintPositionKind.COMPOUND_CONSTRAINT_POSITION) { val positions: Collection = - positions.flatMap { if (it is CompoundConstraintPosition) it.positions else listOf(it) }.toCollection(LinkedHashSet()) + positions.flatMap { if (it is CompoundConstraintPosition) it.positions else listOf(it) }.toSet() override fun isStrong() = positions.any { it.isStrong() } override fun toString() = "$kind(${positions.joinToString()})" } -fun ConstraintPosition.equalsOrContains(position: ConstraintPosition): Boolean { - return if (this !is CompoundConstraintPosition) this == position else positions.any { it == position } +fun ConstraintPosition.derivedFrom(kind: ConstraintPositionKind): Boolean { + return if (this !is CompoundConstraintPosition) this.kind == kind else positions.any { it.kind == kind } } \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index d8dbe991601..5d8ea25b72c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundC import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.equalsOrContains +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.derivedFrom import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.ErrorUtils.FunctionPlaceholderTypeConstructor @@ -84,7 +84,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasContradiction() = hasTypeConstructorMismatch() || hasConflictingConstraints() || hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError() - override fun hasViolatedUpperBound() = !isSuccessful() && getSystemWithoutWeakConstraints().getStatus().isSuccessful() + override fun hasViolatedUpperBound() = !isSuccessful() && filterConstraintsOut(TYPE_BOUND_POSITION).getStatus().isSuccessful() override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.values.size() > 1 } @@ -92,10 +92,10 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch } - override fun hasOnlyErrorsFromPosition(constraintPosition: ConstraintPosition): Boolean { + override fun hasOnlyErrorsDerivedFrom(kind: ConstraintPositionKind): Boolean { if (isSuccessful()) return false - if (filterConstraintsOut(constraintPosition).getStatus().isSuccessful()) return true - return errors.isNotEmpty() && errors.all { it.constraintPosition.equalsOrContains(constraintPosition) } + if (filterConstraintsOut(kind).getStatus().isSuccessful()) return true + return errors.isNotEmpty() && errors.all { it.constraintPosition.derivedFrom(kind) } } override fun hasErrorInConstrainingTypes() = errors.any { it is ErrorInConstrainingType } @@ -175,22 +175,8 @@ public class ConstraintSystemImpl : ConstraintSystem { public fun copy(): ConstraintSystem = createNewConstraintSystemFromThis { true } - public fun filterConstraintsOut(excludePosition: ConstraintPosition): ConstraintSystem { - return filterConstraints { !it.equalsOrContains(excludePosition) } - } - - public fun filterConstraints(condition: (ConstraintPosition) -> Boolean): ConstraintSystem { - return createNewConstraintSystemFromThis(condition) - } - - public fun getSystemWithoutWeakConstraints(): ConstraintSystem { - return filterConstraints(fun (constraintPosition): Boolean { - if (constraintPosition !is CompoundConstraintPosition) return constraintPosition.isStrong() - - // 'isStrong' for compound means 'has some strong constraints' - // but for testing absence of weak constraints we need 'has only strong constraints' here - return constraintPosition.positions.all { it.isStrong() } - }) + public fun filterConstraintsOut(excludePositionKind: ConstraintPositionKind): ConstraintSystem { + return createNewConstraintSystemFromThis { !it.derivedFrom(excludePositionKind) } } private fun createNewConstraintSystemFromThis( @@ -252,7 +238,7 @@ public class ConstraintSystemImpl : ConstraintSystem { if (isMyTypeVariable(typeProjection.getType())) return false val myTypeVariable = getMyTypeVariable(typeVariable) - if (myTypeVariable != null && constraintPosition.isCaptureAllowed()) { + if (myTypeVariable != null && constraintPosition.isParameter()) { if (depth > 0) { errors.add(CannotCapture(constraintPosition, myTypeVariable)) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt index 1b403fb513a..458b8bcc0c3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.resolve.calls.inference -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPosition +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind public trait ConstraintSystemStatus { /** @@ -69,7 +69,7 @@ public trait ConstraintSystemStatus { * Returns true if there is type constructor mismatch only in constraintPosition or * constraint system is successful without constraints from this position. */ - public fun hasOnlyErrorsFromPosition(constraintPosition: ConstraintPosition): Boolean + public fun hasOnlyErrorsDerivedFrom(kind: ConstraintPositionKind): Boolean /** * Returns true if there is an error in constraining types.

From 92e7ed0425847e5734a1f86f34634e4c0d17ba10 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 7 Jul 2015 21:26:56 +0300 Subject: [PATCH 212/450] Rename: getNestedTypeArguments -> getNestedArguments --- .../kotlin/resolve/calls/inference/ConstraintSystemImpl.kt | 4 ++-- .../kotlin/resolve/calls/inference/constraintIncorporation.kt | 4 ++-- core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 5d8ea25b72c..b768d4917dc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.checker.TypeCheckingProcedure import org.jetbrains.kotlin.types.checker.TypeCheckingProcedureCallbacks -import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments +import org.jetbrains.kotlin.types.typeUtil.getNestedArguments import java.util.ArrayList import java.util.HashMap import java.util.HashSet @@ -168,7 +168,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } fun JetType.getNestedTypeVariables(original: Boolean = false): List { - return getNestedTypeArguments().map { typeProjection -> + return getNestedArguments().map { typeProjection -> typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 8066ab7ea18..a8ee4f0d69f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeBounds.BoundKind.UPPER_B import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.CompoundConstraintPosition import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.Variance.INVARIANT -import org.jetbrains.kotlin.types.typeUtil.getNestedTypeArguments +import org.jetbrains.kotlin.types.typeUtil.getNestedArguments import org.jetbrains.kotlin.types.typesApproximation.approximateCapturedTypes import java.util.* @@ -111,7 +111,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo // todo // if we allow non-trivial type projections, we bump into errors like // "Empty intersection for types [MutableCollection, MutableCollection, MutableCollection]" - fun JetType.containsConstrainingTypeWithoutProjection() = this.getNestedTypeArguments().any { + fun JetType.containsConstrainingTypeWithoutProjection() = this.getNestedArguments().any { it.getType().getConstructor() == substitution.constrainingType.getConstructor() && it.getProjectionKind() == Variance.INVARIANT } if (approximationBounds.upper.containsConstrainingTypeWithoutProjection() && bound.kind != LOWER_BOUND) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 056ad37ee88..e521af97830 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -87,7 +87,7 @@ public fun JetTypeChecker.equalTypesOrNulls(type1: JetType?, type2: JetType?): B return equalTypes(type1, type2) } -fun JetType.getNestedTypeArguments(): List { +fun JetType.getNestedArguments(): List { val result = ArrayList() val stack = ArrayDeque() From 4701310852992938e47c4e848e47bdfa5546fc45 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 7 Jul 2015 21:32:20 +0300 Subject: [PATCH 213/450] Removed unnecessary check to prevent infinite recursion in incorporation --- .../severalVariables/recursive/simpleRecursive.bounds | 6 +++--- .../resolve/calls/inference/constraintIncorporation.kt | 3 --- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds index ec71b874753..884500e81a7 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds @@ -4,11 +4,11 @@ EQUAL T Int EQUAL T My type parameter bounds: -T := Int, := My* +T := Int, := My*, := My status: -hasCannotCaptureTypesError: false --hasConflictingConstraints: false +-hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false -hasTypeConstructorMismatch: false @@ -18,4 +18,4 @@ status: -isSuccessful: false result: -T=Int +T=??? \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index a8ee4f0d69f..669b32d7c83 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -75,9 +75,6 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo // Here <=> means lower_bound, upper_bound or exact_bound constraint. // Then a new bound 'T <=> My<_/in/out Type>' can be generated. - // We don't substitute anything into recursive constraints - if (substitution.typeVariable == bound.typeVariable) return - val substitutedType = when (substitution.kind) { EXACT_BOUND -> substitution.constrainingType UPPER_BOUND -> CapturedType(TypeProjectionImpl(Variance.OUT_VARIANCE, substitution.constrainingType)) From 425a9516db5cf69dbb93876d390eb5501e31db1b Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 7 Jul 2015 21:33:19 +0300 Subject: [PATCH 214/450] Minor. Rename: typeParameterBounds -> localTypeParameterBounds --- .../kotlin/resolve/calls/inference/ConstraintSystemImpl.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index b768d4917dc..77d576e06dc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -56,7 +56,7 @@ public class ConstraintSystemImpl : ConstraintSystem { private val allTypeParameterBounds = LinkedHashMap() private val externalTypeParameters = HashSet() - private val typeParameterBounds: Map + private val localTypeParameterBounds: Map get() = if (externalTypeParameters.isEmpty()) allTypeParameterBounds else allTypeParameterBounds.filter { !externalTypeParameters.contains(it.key) } @@ -86,9 +86,9 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasViolatedUpperBound() = !isSuccessful() && filterConstraintsOut(TYPE_BOUND_POSITION).getStatus().isSuccessful() - override fun hasConflictingConstraints() = typeParameterBounds.values().any { it.values.size() > 1 } + override fun hasConflictingConstraints() = localTypeParameterBounds.values().any { it.values.size() > 1 } - override fun hasUnknownParameters() = typeParameterBounds.values().any { it.values.isEmpty() } + override fun hasUnknownParameters() = localTypeParameterBounds.values().any { it.values.isEmpty() } override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch } From 016a8f69daa740eecff6e8287b3bb6561293e1e4 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Tue, 7 Jul 2015 21:46:16 +0300 Subject: [PATCH 215/450] Removed check for position when storing initial top-level constraints --- .../methodCall/multipleExactBoundsNullable.kt | 2 +- .../methodCall/multipleExactBoundsNullable.txt | 2 +- .../AbstractConstraintSystemTest.kt | 2 +- .../calls/inference/ConstraintSystemImpl.kt | 15 ++++++++++----- .../calls/inference/constraintIncorporation.kt | 6 +++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt index c9de5cf0c8a..60141117617 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.kt @@ -25,7 +25,7 @@ interface WithFoo { fun foo() } -fun foo(delegateResolver: ResolverForProject): ResolverForProject { +fun foo(delegateResolver: ResolverForProject): ResolverForProject { val descriptorByModule = MyMap() val result = ResolverForProjectImpl(descriptorByModule, delegateResolver) result.exposeM.foo() // M is not M2? diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt index 6a283d0e3f9..381ec125c74 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.txt @@ -1,6 +1,6 @@ package -internal fun foo(/*0*/ delegateResolver: ResolverForProject): ResolverForProject +internal fun foo(/*0*/ delegateResolver: ResolverForProject): ResolverForProject public/*package*/ open class MyMap : java.util.AbstractMap { public/*package*/ constructor MyMap() diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index 6cf755ac65b..e554e2b80ec 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -98,7 +98,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { when (constraint.kind) { MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position) MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(firstType, secondType, position) - MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position) + MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position, topLevel = true) } } if (fixVariables) constraintSystem.fixVariables() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index 77d576e06dc..a568bac6795 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -203,15 +203,21 @@ public class ConstraintSystemImpl : ConstraintSystem { if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) - addConstraint(SUB_TYPE, newSubjectType, constrainingType, constraintPosition) + addConstraint(SUB_TYPE, newSubjectType, constrainingType, constraintPosition, topLevel = true) } override fun addSubtypeConstraint(constrainingType: JetType?, subjectType: JetType, constraintPosition: ConstraintPosition) { val newSubjectType = originalToVariablesSubstitutor.substitute(subjectType, Variance.INVARIANT) - addConstraint(SUB_TYPE, constrainingType, newSubjectType, constraintPosition) + addConstraint(SUB_TYPE, constrainingType, newSubjectType, constraintPosition, topLevel = true) } - fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) { + fun addConstraint( + constraintKind: ConstraintKind, + subType: JetType?, + superType: JetType?, + constraintPosition: ConstraintPosition, + topLevel: Boolean + ) { val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks { private var depth = 0 @@ -253,7 +259,7 @@ public class ConstraintSystemImpl : ConstraintSystem { return true } }) - doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure, topLevel = true) + doAddConstraint(constraintKind, subType, superType, constraintPosition, typeCheckingProcedure, topLevel) } private fun isErrorOrSpecialType(type: JetType?, constraintPosition: ConstraintPosition): Boolean { @@ -447,7 +453,6 @@ public class ConstraintSystemImpl : ConstraintSystem { replaceUninferredBy(getDefaultValue, substituteOriginal).setApproximateCapturedTypes() private fun storeInitialConstraint(constraintKind: ConstraintKind, subType: JetType, superType: JetType, position: ConstraintPosition) { - if (position is CompoundConstraintPosition) return initialConstraints.add(Constraint(constraintKind, subType, superType, position)) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 669b32d7c83..25f289886bf 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -64,9 +64,9 @@ private fun ConstraintSystemImpl.addConstraintFromBounds(old: Bound, new: Bound) val position = CompoundConstraintPosition(old.position, new.position) when { - old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position) - old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position) - old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position) + old.kind.ordinal() < new.kind.ordinal() -> addConstraint(SUB_TYPE, oldType, newType, position, topLevel = false) + old.kind.ordinal() > new.kind.ordinal() -> addConstraint(SUB_TYPE, newType, oldType, position, topLevel = false) + old.kind == new.kind && old.kind == EXACT_BOUND -> addConstraint(EQUAL, oldType, newType, position, topLevel = false) } } From 722a49767a951888c04feded0a5fe7038069563d Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 8 Jul 2015 12:07:28 +0300 Subject: [PATCH 216/450] Rename: TypeConstructorMismatch -> ParameterConstraintError --- .../src/org/jetbrains/kotlin/diagnostics/Errors.java | 5 +++-- .../diagnostics/rendering/DefaultErrorMessages.java | 2 +- .../jetbrains/kotlin/diagnostics/rendering/Renderers.kt | 8 ++++---- .../resolve/calls/tasks/AbstractTracingStrategy.java | 4 ++-- .../checkStatus/conflictingConstraints.bounds | 2 +- .../constraintSystem/checkStatus/successful.bounds | 2 +- .../checkStatus/typeConstructorMismatch.bounds | 2 +- .../constraintSystem/checkStatus/unknownParameters.bounds | 2 +- .../checkStatus/violatedUpperBound.bounds | 2 +- .../constraintSystem/computeValues/contradiction.bounds | 2 +- .../computeValues/subTypeOfUpperBounds.bounds | 2 +- .../computeValues/superTypeOfLowerBounds1.bounds | 2 +- .../computeValues/superTypeOfLowerBounds2.bounds | 2 +- .../integerValueTypes/byteOverflow.bounds | 2 +- .../constraintSystem/integerValueTypes/defaultLong.bounds | 2 +- .../integerValueTypes/numberAndAny.bounds | 2 +- .../integerValueTypes/numberAndString.bounds | 2 +- .../integerValueTypes/severalNumbers.bounds | 2 +- .../constraintSystem/integerValueTypes/simpleByte.bounds | 2 +- .../constraintSystem/integerValueTypes/simpleInt.bounds | 2 +- .../constraintSystem/integerValueTypes/simpleShort.bounds | 2 +- .../direct/contravariant/varEqDepEq.bounds | 2 +- .../direct/contravariant/varEqDepSub.bounds | 2 +- .../direct/contravariant/varEqDepSuper.bounds | 2 +- .../direct/contravariant/varSubDepEq.bounds | 2 +- .../direct/contravariant/varSubDepSub.bounds | 2 +- .../direct/contravariant/varSubDepSuper.bounds | 2 +- .../direct/contravariant/varSuperDepEq.bounds | 2 +- .../direct/contravariant/varSuperDepSub.bounds | 2 +- .../direct/contravariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/direct/covariant/varEqDepEq.bounds | 2 +- .../severalVariables/direct/covariant/varEqDepSub.bounds | 2 +- .../direct/covariant/varEqDepSuper.bounds | 2 +- .../severalVariables/direct/covariant/varSubDepEq.bounds | 2 +- .../severalVariables/direct/covariant/varSubDepSub.bounds | 2 +- .../direct/covariant/varSubDepSuper.bounds | 2 +- .../direct/covariant/varSuperDepEq.bounds | 2 +- .../direct/covariant/varSuperDepSub.bounds | 2 +- .../direct/covariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/direct/invariant/varEqDepEq.bounds | 2 +- .../severalVariables/direct/invariant/varEqDepSub.bounds | 2 +- .../direct/invariant/varEqDepSuper.bounds | 2 +- .../severalVariables/direct/invariant/varSubDepEq.bounds | 2 +- .../severalVariables/direct/invariant/varSubDepSub.bounds | 2 +- .../direct/invariant/varSubDepSuper.bounds | 2 +- .../direct/invariant/varSuperDepEq.bounds | 2 +- .../direct/invariant/varSuperDepSub.bounds | 2 +- .../direct/invariant/varSuperDepSuper.bounds | 2 +- .../interdependency/interdependency1.bounds | 2 +- .../interdependency/interdependency2.bounds | 2 +- .../interdependency/interdependency3.bounds | 2 +- .../nullable/contravariant/varEqDepEq.bounds | 2 +- .../nullable/contravariant/varEqDepSub.bounds | 2 +- .../nullable/contravariant/varEqDepSuper.bounds | 2 +- .../nullable/contravariant/varSubDepEq.bounds | 2 +- .../nullable/contravariant/varSubDepSub.bounds | 2 +- .../nullable/contravariant/varSubDepSuper.bounds | 2 +- .../nullable/contravariant/varSuperDepEq.bounds | 2 +- .../nullable/contravariant/varSuperDepSub.bounds | 2 +- .../nullable/contravariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/nullable/covariant/varEqDepEq.bounds | 2 +- .../nullable/covariant/varEqDepSub.bounds | 2 +- .../nullable/covariant/varEqDepSuper.bounds | 2 +- .../nullable/covariant/varSubDepEq.bounds | 2 +- .../nullable/covariant/varSubDepSub.bounds | 2 +- .../nullable/covariant/varSubDepSuper.bounds | 2 +- .../nullable/covariant/varSuperDepEq.bounds | 2 +- .../nullable/covariant/varSuperDepSub.bounds | 2 +- .../nullable/covariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/nullable/invariant/varEqDepEq.bounds | 2 +- .../nullable/invariant/varEqDepSub.bounds | 2 +- .../nullable/invariant/varEqDepSuper.bounds | 2 +- .../nullable/invariant/varSubDepEq.bounds | 2 +- .../nullable/invariant/varSubDepSub.bounds | 2 +- .../nullable/invariant/varSubDepSuper.bounds | 2 +- .../nullable/invariant/varSuperDepEq.bounds | 2 +- .../nullable/invariant/varSuperDepSub.bounds | 2 +- .../nullable/invariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/other/constraintForNullables.bounds | 2 +- .../severalVariables/other/nestedConsumer.bounds | 4 ++-- .../severalVariables/other/nestedConsumer1.bounds | 2 +- .../severalVariables/other/nestedInvConsumer.bounds | 2 +- .../severalVariables/other/nestedInvProducer.bounds | 2 +- .../severalVariables/other/nestedProducer.bounds | 2 +- .../other/nestedProducerAndConsumer.bounds | 2 +- .../severalVariables/other/severalOccurrences.bounds | 2 +- .../severalVariables/other/simpleFun.bounds | 2 +- .../severalVariables/other/simpleThreeVars.bounds | 2 +- .../other/simpleThreeVarsNoIncorporation.bounds | 2 +- .../other/simpleThreeVarsNoIncorporationFixed.bounds | 2 +- .../severalVariables/recursive/implicitlyRecursive.bounds | 2 +- .../severalVariables/recursive/mutuallyRecursive.bounds | 2 +- .../severalVariables/recursive/simpleRecursive.bounds | 4 ++-- .../reversed/contravariant/varEqDepEq.bounds | 2 +- .../reversed/contravariant/varEqDepSub.bounds | 2 +- .../reversed/contravariant/varEqDepSuper.bounds | 2 +- .../reversed/contravariant/varSubDepEq.bounds | 2 +- .../reversed/contravariant/varSubDepSub.bounds | 2 +- .../reversed/contravariant/varSubDepSuper.bounds | 2 +- .../reversed/contravariant/varSuperDepEq.bounds | 2 +- .../reversed/contravariant/varSuperDepSub.bounds | 2 +- .../reversed/contravariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/reversed/covariant/varEqDepEq.bounds | 2 +- .../reversed/covariant/varEqDepSub.bounds | 2 +- .../reversed/covariant/varEqDepSuper.bounds | 2 +- .../reversed/covariant/varSubDepEq.bounds | 2 +- .../reversed/covariant/varSubDepSub.bounds | 2 +- .../reversed/covariant/varSubDepSuper.bounds | 2 +- .../reversed/covariant/varSuperDepEq.bounds | 2 +- .../reversed/covariant/varSuperDepSub.bounds | 2 +- .../reversed/covariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/reversed/invariant/varEqDepEq.bounds | 2 +- .../reversed/invariant/varEqDepSub.bounds | 2 +- .../reversed/invariant/varEqDepSuper.bounds | 2 +- .../reversed/invariant/varSubDepEq.bounds | 2 +- .../reversed/invariant/varSubDepSub.bounds | 2 +- .../reversed/invariant/varSubDepSuper.bounds | 2 +- .../reversed/invariant/varSuperDepEq.bounds | 2 +- .../reversed/invariant/varSuperDepSub.bounds | 2 +- .../reversed/invariant/varSuperDepSuper.bounds | 2 +- .../severalVariables/simpleDependency.bounds | 2 +- .../severalVariables/simpleEquality.bounds | 2 +- .../severalVariables/simpleEquality1.bounds | 2 +- .../severalVariables/simpleReversedDependency.bounds | 2 +- .../severalVariables/simpleSubtype.bounds | 2 +- .../severalVariables/simpleSubtype1.bounds | 2 +- .../testData/constraintSystem/variance/consumer.bounds | 2 +- .../testData/constraintSystem/variance/invariant.bounds | 2 +- .../testData/constraintSystem/variance/producer.bounds | 2 +- .../diagnostics/tests/checkArguments/SpreadVarargs.kt | 4 ++-- .../tests/extensions/extensionMemberInClassObject.kt | 2 +- .../reportingImprovements/FunctionPlaceholder.kt | 6 +++--- .../tests/inference/typeConstructorMismatch.kt | 4 ++-- .../tests/numbers/numbersInSimpleConstraints.kt | 2 +- .../kotlin/resolve/calls/inference/ConstraintError.kt | 6 +++--- .../resolve/calls/inference/ConstraintSystemImpl.kt | 8 ++++---- .../resolve/calls/inference/ConstraintSystemStatus.kt | 2 +- .../kotlin/idea/highlighter/IdeErrorMessages.java | 2 +- .../org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt | 4 ++-- idea/testData/diagnosticMessage/functionPlaceholder.kt | 2 +- idea/testData/diagnosticMessage/numberValueTypes.kt | 2 +- 141 files changed, 159 insertions(+), 158 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index f337d9fe35d..0237d6a49e0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -458,7 +458,7 @@ public interface Errors { DiagnosticFactory1 TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_CANNOT_CAPTURE_TYPES = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory1 TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR = DiagnosticFactory1.create(ERROR); DiagnosticFactory0 TYPE_INFERENCE_INCORPORATION_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); @@ -708,7 +708,8 @@ public interface Errors { UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, VARIABLE_WITH_REDUNDANT_INITIALIZER, UNUSED_FUNCTION_LITERAL, USELESS_CAST, UNUSED_VALUE, USELESS_ELVIS); ImmutableSet> TYPE_INFERENCE_ERRORS = ImmutableSet.of( - TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, + TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, + TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR, TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index b1ae845790f..076ff54bf19 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -592,7 +592,7 @@ public class DefaultErrorMessages { MAP.put(TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, "Type inference failed: {0}", TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER); MAP.put(TYPE_INFERENCE_CANNOT_CAPTURE_TYPES, "Type inference failed: {0}", TYPE_INFERENCE_CANNOT_CAPTURE_TYPES_RENDERER); MAP.put(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Type inference failed: {0}", TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER); - MAP.put(TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, "Type inference failed: {0}", TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER); + MAP.put(TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR, "Type inference failed: {0}", TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER); MAP.put(TYPE_INFERENCE_INCORPORATION_ERROR, "Type inference failed. Please try to specify type arguments explicitly."); MAP.put(TYPE_INFERENCE_UPPER_BOUND_VIOLATED, "{0}", TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER); MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, "Type inference failed. Expected type mismatch: found: {1} required: {0}", RENDER_TYPE, RENDER_TYPE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt index a3becd143a2..13ec5c20b30 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/Renderers.kt @@ -123,8 +123,8 @@ public object Renderers { renderConflictingSubstitutionsInferenceError(it, TabledDescriptorRenderer.create()).toString() } - public val TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER: Renderer = Renderer { - renderTypeConstructorMismatchError(it, TabledDescriptorRenderer.create()).toString() + public val TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER: Renderer = Renderer { + renderParameterConstraintError(it, TabledDescriptorRenderer.create()).toString() } public val TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER: Renderer = Renderer { @@ -195,11 +195,11 @@ public object Renderers { } platformStatic - public fun renderTypeConstructorMismatchError( + public fun renderParameterConstraintError( inferenceErrorData: InferenceErrorData, renderer: TabledDescriptorRenderer ): TabledDescriptorRenderer { val constraintErrors = (inferenceErrorData.constraintSystem as ConstraintSystemImpl).constraintErrors - val errorPositions = constraintErrors.filter { it is TypeConstructorMismatch }.map { it.constraintPosition } + val errorPositions = constraintErrors.filter { it is ParameterConstraintError }.map { it.constraintPosition } return renderer.table( TabledDescriptorRenderer .newTable() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java index 27db5955597..f7747eb3395 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/AbstractTracingStrategy.java @@ -227,8 +227,8 @@ public abstract class AbstractTracingStrategy implements TracingStrategy { else if (status.hasViolatedUpperBound()) { trace.report(TYPE_INFERENCE_UPPER_BOUND_VIOLATED.on(reference, data)); } - else if (status.hasTypeConstructorMismatch()) { - trace.report(TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH.on(reference, data)); + else if (status.hasParameterConstraintError()) { + trace.report(TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR.on(reference, data)); } else if (status.hasConflictingConstraints()) { trace.report(TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS.on(reference, data)); diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index d54e4653ded..3c867761ed0 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index 583a8c21113..43ac39868b2 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index 21e95269ed0..c009c45087d 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds index d31138ba9ec..c0af2c301bb 100644 --- a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds index c04981d28da..1d6590c012d 100644 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: true diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index efb7e8b91ae..24bbf15b783 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index c186adc7a48..377928d944f 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index 2f87b1baa2e..b2ef6ae5068 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index 0b752ee190d..d6b88ca835c 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 430a365cdaf..29d70c2e4d0 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index 2abed7f9db8..b8a0f48d824 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index c65b5ee1928..e2184e2315e 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index 2b80c6cc94a..aed516efeff 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index 8a3bb3af4ad..187b41062f0 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index 7668d5a7d25..a4fae5c8324 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index 4bf5959b522..7cde4a14c94 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index 1b31cf385cb..b1d6044ccdc 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds index 8024f737d4f..767c74294bc 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds index c2fc7ab00de..7576d950b1a 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds index 0b0061363ab..65d4e213440 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds index 6f65f248bfa..6882e64a517 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds index 36a2e0520dc..36ece479442 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds index 39f56ee5890..dc9bd4ee09f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds index 4834575e0ad..aab4a696ef5 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds index 0a23d492e16..e43f73ab278 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds index 4f3044bf3b6..c5e1ad524d5 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds index 97cfc9021cc..fa29eb3243c 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds index a64e6b35110..25302882cae 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds index a7d277e6d78..8f82371393f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds index 2e6d9556f28..994192067e0 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds index 361dc47e8f3..9a1c367b17e 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds index 8639d321f5e..fc04cd651dd 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds index 23c0cb99974..c20ba05af7e 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds index 415a1a067ac..663ed0261f1 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds index 4fa524d6a8b..e687ac76a53 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds index e44ed01c3c5..2bf6c5e8394 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds index 5db77f8abf4..49bb91d9ec6 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds index 2607d61fdeb..bddbf2341d0 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds index 36b349629f5..420b8574da7 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds index d9bcc3cf734..5ce7369428f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds index 981743dc98c..bfd0363ae79 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds index a57a227b879..ce9772e5472 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds index a83b3d88707..2a890311f20 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds index 0b14956e976..50c3e7a4752 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds index c1fc7b01a62..0dd2f8ada64 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds @@ -15,7 +15,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds index 35b97462777..409c0397e2b 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds @@ -15,7 +15,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds index 4cfdbef528f..18ab4706b1a 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds @@ -15,7 +15,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds index 9288e38c616..7a0185605f3 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds index 73a23b485b7..d17252889f9 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds index b63d9d9b28d..5e12daa2b73 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds index 9a003bf92b4..f09b862aa25 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds index 8821b18fa86..56aacfab893 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds index 3dbaf11c438..0cde5ba6e85 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds index 2e3d20ba19a..3da6d94e777 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds index c20560721c9..e89d4a562fc 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds index bf5bf4045da..b495badd3a4 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds index 13417f5a50e..357b1270a3e 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds index 11f554606b3..3d01d408444 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds index b36241e4391..c22ace7b431 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds index 2dc4bfe36bf..b0c6573afd0 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds index 8f3c6e275c7..4036de96dea 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds index aa177cdd9c4..0894f51acb5 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds index ef1c2e2faec..ac9716b151d 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds index c4dcdf26169..42576564a78 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds index b3a5d5b691c..65fd417579b 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds index bec3fb0c825..72fb56675de 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds index ab6d8053d17..1fdc719c1bf 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds index 0f8e83c76de..35370ceea94 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds index 8b1d7787e9f..e8c1cc16eba 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds index 6effa72428c..5bbd2622220 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds index e914ef48855..e4685fb8780 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds index 5d69a46a15a..64218af7abd 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds index 70c1d6c6b5d..dec3f74f059 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds index ed393cb0a37..e0a2bd62868 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds index 98791a29dbb..b3338f2d3ef 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds index 9a062be9167..d91e89886b7 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false @@ -20,4 +20,4 @@ status: result: T=Int -P=Consumer> \ No newline at end of file +P=Consumer> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds index a5d0d904597..e2c18c29f81 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds index 4394d6f956e..bffb550873a 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds index c76dbdb7182..842dc6ea2a4 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds index 01b0c37731c..17b2a13fe09 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds index c9f33c564c7..2d574cc3282 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds index 6b1a1f6daf0..c8f586e0643 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds index 379589a6bf2..14722a37620 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds @@ -14,7 +14,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds index 68700b96962..6f1826c443c 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds @@ -14,7 +14,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds index 6e90c63a897..8dbddcf9c42 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds @@ -14,7 +14,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds index 14fe73be6f7..9647fc7cf43 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds @@ -15,7 +15,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds index b3a8ecb359c..ddc2b06e136 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds @@ -14,7 +14,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds index 68d1b96ebeb..eba72e6eaf5 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds index 884500e81a7..cf7d6634fcd 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds @@ -11,11 +11,11 @@ status: -hasConflictingConstraints: true -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: false -hasViolatedUpperBound: false -isSuccessful: false result: -T=??? \ No newline at end of file +T=??? diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds index 2bd66db1772..cf98cfe1213 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds index afa3652f02f..18ee276ac16 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds index c6d316d75d2..eb228db31bb 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds index 89a9dcf5f2e..f674e15203a 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds index 8c13f889136..a30bca567b7 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds index 59dc38abb16..56f9a03afcf 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds index 9c49f3eef8c..45500b013ed 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds index 984211dd519..67b60d1479f 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds index 3303bd7f335..6fc17a3171a 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds index 2a54eaf7bef..3c66b80507d 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds index a2fedd419a4..749c66cfa9a 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds index 6ef6d2c6a5d..eb1157e8521 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds index 33f852ef188..e58fbc75207 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds index 8511989ba6b..04f286917b3 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds index 894de55e226..023ece28e13 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds index c52306a9b47..0885b3d60bc 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds index 6788c3c5227..ad45ed7c6db 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds index 0b499eab01c..d3157cb8c0e 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds index 121d0523caa..ecedf08544c 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds index dc29c6058dc..81a682e5ca7 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds index edd7c9937c2..8f22965c275 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds index 236d15a9bd6..e518963ba10 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds index 910cc6da5c6..5c15de74f7f 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds index 8388ad7a2ad..7aa3f6787f1 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds index ea1fff4a0f4..6dfc882fe47 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: true -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: true -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds index 7e3aa9c5a0e..39072b45d84 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds index 0cfdde90f94..631127ad0af 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index 31d0bbe9090..3d719cd2c9c 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -11,7 +11,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds index e17af150262..7290a18d89e 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds index 31d1e7cf1ad..c9d7700b5bc 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds index 0e05381bf41..5c91ddf5be8 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: true -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds index 53e9e8a7941..35f2e2d172b 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds index 8580fda0452..806f684e0f6 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds @@ -12,7 +12,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index f0c5d30a279..eb8ee755b49 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 6e911a8ca3d..1012e4008c9 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index cc230ad432e..e13388ee294 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -10,7 +10,7 @@ status: -hasConflictingConstraints: false -hasContradiction: false -hasErrorInConstrainingTypes: false --hasTypeConstructorMismatch: false +-hasParameterConstraintError: false -hasTypeInferenceIncorporationError: false -hasUnknownParameters: false -hasViolatedUpperBound: false diff --git a/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt b/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt index 783a1951a2c..2337f8ca911 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/SpreadVarargs.kt @@ -42,10 +42,10 @@ fun main(args : Array) { joinG(1, "2") joinG(*1, "2") - joinG(1, *"2") + joinG(1, *"2") joinG(x = 1, a = *a) joinG(x = 1, a = "2") - joinG(x = *1, a = *"2") + joinG(x = *1, a = *"2") joinG(1, *a) joinG(1, *a, "3") joinG(1, "4", *a, "3") diff --git a/compiler/testData/diagnostics/tests/extensions/extensionMemberInClassObject.kt b/compiler/testData/diagnostics/tests/extensions/extensionMemberInClassObject.kt index 6c7b9b17d6a..71fd0ed04cb 100644 --- a/compiler/testData/diagnostics/tests/extensions/extensionMemberInClassObject.kt +++ b/compiler/testData/diagnostics/tests/extensions/extensionMemberInClassObject.kt @@ -9,7 +9,7 @@ class Foo { } fun main(args: Array) { - with("", { + with("", { Foo.findByName("") }) } diff --git a/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt b/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt index 7ad420b84b1..39486a0a4b9 100644 --- a/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt +++ b/compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt @@ -6,9 +6,9 @@ fun foo(a: A) = a fun bar(f: (T) -> R) = f fun test() { - foo { it } - foo { x -> x} - foo { x: Int -> x} + foo { it } + foo { x -> x} + foo { x: Int -> x} bar { it + 1 } bar { x -> x + 1} diff --git a/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt b/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt index 37f11cb1236..82e2ca5519e 100644 --- a/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt +++ b/compiler/testData/diagnostics/tests/inference/typeConstructorMismatch.kt @@ -4,9 +4,9 @@ package typeConstructorMismatch import java.util.* fun test(set: Set) { - elemAndList("2", set) + elemAndList("2", set) - "".elemAndListWithReceiver("", set) + "".elemAndListWithReceiver("", set) } fun elemAndList(r: R, t: List): R = r diff --git a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt index a80068ed652..7831173206c 100644 --- a/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt +++ b/compiler/testData/diagnostics/tests/numbers/numbersInSimpleConstraints.kt @@ -28,7 +28,7 @@ fun test() { other(11) - otherGeneric(1) + otherGeneric(1) val r = either(1, "") r checkType { _>() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt index d657c6bd3df..106a4194aed 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintError.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain open class ConstraintError(val constraintPosition: ConstraintPosition) -class TypeConstructorMismatch(constraintPosition: ConstraintPosition): ConstraintError(constraintPosition) +class ParameterConstraintError(constraintPosition: ConstraintPosition): ConstraintError(constraintPosition) class ErrorInConstrainingType(constraintPosition: ConstraintPosition): ConstraintError(constraintPosition) @@ -30,5 +30,5 @@ class TypeInferenceError(constraintPosition: ConstraintPosition): ConstraintErro class CannotCapture(constraintPosition: ConstraintPosition, val typeVariable: TypeParameterDescriptor): ConstraintError(constraintPosition) -fun newTypeInferenceOrConstructorMismatchError(constraintPosition: ConstraintPosition) = - if (constraintPosition.isParameter()) TypeConstructorMismatch(constraintPosition) else TypeInferenceError(constraintPosition) \ No newline at end of file +fun newTypeInferenceOrParameterConstraintError(constraintPosition: ConstraintPosition) = + if (constraintPosition.isParameter()) ParameterConstraintError(constraintPosition) else TypeInferenceError(constraintPosition) \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index a568bac6795..c1e6393e37b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -81,7 +81,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun isSuccessful() = !hasContradiction() && !hasUnknownParameters() - override fun hasContradiction() = hasTypeConstructorMismatch() || hasConflictingConstraints() + override fun hasContradiction() = hasParameterConstraintError() || hasConflictingConstraints() || hasCannotCaptureTypesError() || hasTypeInferenceIncorporationError() override fun hasViolatedUpperBound() = !isSuccessful() && filterConstraintsOut(TYPE_BOUND_POSITION).getStatus().isSuccessful() @@ -90,7 +90,7 @@ public class ConstraintSystemImpl : ConstraintSystem { override fun hasUnknownParameters() = localTypeParameterBounds.values().any { it.values.isEmpty() } - override fun hasTypeConstructorMismatch() = errors.any { it is TypeConstructorMismatch } + override fun hasParameterConstraintError() = errors.any { it is ParameterConstraintError } override fun hasOnlyErrorsDerivedFrom(kind: ConstraintPositionKind): Boolean { if (isSuccessful()) return false @@ -255,7 +255,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } override fun noCorrespondingSupertype(subtype: JetType, supertype: JetType): Boolean { - errors.add(newTypeInferenceOrConstructorMismatchError(constraintPosition)) + errors.add(newTypeInferenceOrParameterConstraintError(constraintPosition)) return true } }) @@ -322,7 +322,7 @@ public class ConstraintSystemImpl : ConstraintSystem { else { typeCheckingProcedure.isSubtypeOf(subTypeNotNullable, superType) } - if (!result) errors.add(newTypeInferenceOrConstructorMismatchError(constraintPosition)) + if (!result) errors.add(newTypeInferenceOrParameterConstraintError(constraintPosition)) } if (topLevel) { storeInitialConstraint(constraintKind, subType, superType, constraintPosition) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt index 458b8bcc0c3..2234da09b49 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemStatus.kt @@ -63,7 +63,7 @@ public trait ConstraintSystemStatus { * For example, for

fun <R> foo(t: List<R>) {}
in invocation foo(hashSet("s")) * there is type constructor mismatch: "HashSet<String> cannot be a subtype of List<R>". */ - public fun hasTypeConstructorMismatch(): Boolean + public fun hasParameterConstraintError(): Boolean /** * Returns true if there is type constructor mismatch only in constraintPosition or diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java index f0ac21fd13e..21fc23f1c03 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeErrorMessages.java @@ -71,7 +71,7 @@ public class IdeErrorMessages { MAP.put(TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, "Type inference failed: {0}", HTML_TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS_RENDERER); MAP.put(TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, "Type inference failed: {0}", HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER); - MAP.put(TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH, "Type inference failed: {0}", HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER); + MAP.put(TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR, "Type inference failed: {0}", HTML_TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER); MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, tableForTypes("Type inference failed. Expected type mismatch: ", "required: ", TextElementType.STRONG, "found: ", TextElementType.ERROR), HTML_RENDER_TYPE, HTML_RENDER_TYPE); diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt index 55647ab662b..21bdc38ae5d 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt @@ -53,8 +53,8 @@ public object IdeRenderers { Renderers.renderConflictingSubstitutionsInferenceError(it, HtmlTabledDescriptorRenderer.create()).toString() } - public val HTML_TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH_RENDERER: Renderer = Renderer { - Renderers.renderTypeConstructorMismatchError(it, HtmlTabledDescriptorRenderer.create()).toString() + public val HTML_TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR_RENDERER: Renderer = Renderer { + Renderers.renderParameterConstraintError(it, HtmlTabledDescriptorRenderer.create()).toString() } public val HTML_TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER_RENDERER: Renderer = Renderer { diff --git a/idea/testData/diagnosticMessage/functionPlaceholder.kt b/idea/testData/diagnosticMessage/functionPlaceholder.kt index f26da6266d6..6528f3994ec 100644 --- a/idea/testData/diagnosticMessage/functionPlaceholder.kt +++ b/idea/testData/diagnosticMessage/functionPlaceholder.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS_NUMBER: 3 -// !DIAGNOSTICS: TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH +// !DIAGNOSTICS: TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR class A fun foo(a: A) = a diff --git a/idea/testData/diagnosticMessage/numberValueTypes.kt b/idea/testData/diagnosticMessage/numberValueTypes.kt index a5a7a2aefcf..2eaac514059 100644 --- a/idea/testData/diagnosticMessage/numberValueTypes.kt +++ b/idea/testData/diagnosticMessage/numberValueTypes.kt @@ -1,5 +1,5 @@ // !DIAGNOSTICS_NUMBER: 4 -// !DIAGNOSTICS: TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS +// !DIAGNOSTICS: TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS package a From d2dc44379e5a511e14fff70a7827ccb0c563706a Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 8 Jul 2015 12:30:22 +0300 Subject: [PATCH 217/450] Changed default value for 'getNestedTypeVariables()' --- .../org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt | 2 +- .../kotlin/resolve/calls/GenericCandidateResolver.kt | 2 +- .../kotlin/resolve/calls/inference/ConstraintSystemImpl.kt | 6 +++--- .../resolve/calls/inference/constraintIncorporation.kt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index f37ae53f661..0e24b91d302 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -69,7 +69,7 @@ private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constrai val returnType = getReturnType() ?: return false val nestedTypeVariables = with (constraintSystem as ConstraintSystemImpl) { - returnType.getNestedTypeVariables(original = true) + returnType.getNestedTypeVariables() } return nestedTypeVariables.any { constraintSystem.getTypeBounds(it).value == null } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 57a4c612e67..721629325d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -164,7 +164,7 @@ class GenericCandidateResolver( val returnType = candidateDescriptor.getReturnType() ?: return false val nestedTypeVariables = with (argumentConstraintSystem) { - returnType.getNestedTypeVariables(original = true) + returnType.getNestedTypeVariables() } // we add an additional type variable only if no information is inferred for it. // otherwise we add currently inferred return type as before diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index c1e6393e37b..daf81d3b5f3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -167,7 +167,7 @@ public class ConstraintSystemImpl : ConstraintSystem { type -> type.getConstructor().getDeclarationDescriptor() in getAllTypeVariables() } - fun JetType.getNestedTypeVariables(original: Boolean = false): List { + fun JetType.getNestedTypeVariables(original: Boolean = true): List { return getNestedArguments().map { typeProjection -> typeProjection.getType().getConstructor().getDeclarationDescriptor() as? TypeParameterDescriptor }.filterNotNull().filter { if (original) it in originalToVariables.keySet() else it in getAllTypeVariables() } @@ -344,7 +344,7 @@ public class ConstraintSystemImpl : ConstraintSystem { typeBounds.addBound(bound) if (!bound.isProper) { - for (dependentTypeVariable in bound.constrainingType.getNestedTypeVariables()) { + for (dependentTypeVariable in bound.constrainingType.getNestedTypeVariables(original = false)) { val dependentBounds = usedInBounds.getOrPut(dependentTypeVariable) { arrayListOf() } dependentBounds.add(bound) } @@ -477,7 +477,7 @@ public class ConstraintSystemImpl : ConstraintSystem { if (typeBounds.isFixed) return typeBounds.setFixed() - val nestedTypeVariables = typeBounds.bounds.flatMap { it.constrainingType.getNestedTypeVariables() } + val nestedTypeVariables = typeBounds.bounds.flatMap { it.constrainingType.getNestedTypeVariables(original = false) } nestedTypeVariables.forEach { fixVariable(it) } val value = typeBounds.value ?: return diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt index 25f289886bf..3abccc2ffde 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/constraintIncorporation.kt @@ -89,7 +89,7 @@ private fun ConstraintSystemImpl.generateNewBound(bound: Bound, substitution: Bo fun addNewBound(newConstrainingType: JetType, newBoundKind: BoundKind) { // We don't generate new recursive constraints - val nestedTypeVariables = newConstrainingType.getNestedTypeVariables() + val nestedTypeVariables = newConstrainingType.getNestedTypeVariables(original = false) if (nestedTypeVariables.contains(bound.typeVariable)) return // We don't generate constraint if a type variable was substituted twice From df07a61a0897a214bc3258d8aee7934cf46d2f2e Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 10 Jul 2015 02:33:08 +0300 Subject: [PATCH 218/450] Control-Flow: Generate instruction for left-hand side of invalid assignments #KT-8390 Fixed --- .../kotlin/cfg/JetControlFlowProcessor.java | 28 ++++++------------- .../expressions/assignmentToThis.instructions | 14 ++++++---- .../cfg/expressions/assignmentToThis.values | 9 ++++-- .../unresolvedWriteLHS.instructions | 14 ++++++---- .../cfg/expressions/unresolvedWriteLHS.values | 8 ++++-- .../diagnostics/tests/LValueAssignment.kt | 4 +-- .../diagnostics/tests/UnusedParameters.kt | 4 +++ .../diagnostics/tests/UnusedParameters.txt | 1 + 8 files changed, 43 insertions(+), 39 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java index f7d478e6a3b..8d34e1869e0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java @@ -585,7 +585,15 @@ public class JetControlFlowProcessor { accessTarget = getDeclarationAccessTarget(left); } - recordWrite(left, accessTarget, rhsDeferredValue.invoke(), receiverValues, parentExpression); + if (accessTarget == AccessTarget.BlackBox.INSTANCE$ && !(left instanceof JetProperty)) { + generateInstructions(left); + createSyntheticValue(left, MagicKind.VALUE_CONSUMER, left); + } + + PseudoValue rightValue = rhsDeferredValue.invoke(); + PseudoValue rValue = + rightValue != null ? rightValue : createSyntheticValue(parentExpression, MagicKind.UNRECOGNIZED_WRITE_RHS); + builder.write(parentExpression, left, rValue, accessTarget, receiverValues); } private void generateArrayAssignment( @@ -663,24 +671,6 @@ public class JetControlFlowProcessor { return argumentValues; } - private void recordWrite( - @NotNull JetExpression left, - @NotNull AccessTarget target, - @Nullable PseudoValue rightValue, - @NotNull Map receiverValues, - @NotNull JetExpression parentExpression - ) { - if (target == AccessTarget.BlackBox.INSTANCE$) { - List values = ContainerUtil.createMaybeSingletonList(rightValue); - builder.magic(parentExpression, parentExpression, values, defaultTypeMap(values), MagicKind.UNSUPPORTED_ELEMENT); - } - else { - PseudoValue rValue = - rightValue != null ? rightValue : createSyntheticValue(parentExpression, MagicKind.UNRECOGNIZED_WRITE_RHS); - builder.write(parentExpression, left, rValue, target, receiverValues); - } - } - private void generateArrayAccess(JetArrayAccessExpression arrayAccessExpression, @Nullable ResolvedCall resolvedCall) { if (builder.getBoundValue(arrayAccessExpression) != null) return; mark(arrayAccessExpression); diff --git a/compiler/testData/cfg/expressions/assignmentToThis.instructions b/compiler/testData/cfg/expressions/assignmentToThis.instructions index 1252b97f023..c060be35c16 100644 --- a/compiler/testData/cfg/expressions/assignmentToThis.instructions +++ b/compiler/testData/cfg/expressions/assignmentToThis.instructions @@ -9,12 +9,14 @@ L0: magic[FAKE_INITIALIZER](c: C) -> w(c|) 2 mark({ this = c }) - r(c) -> - magic[UNSUPPORTED_ELEMENT](this = c|) -> + r(this, ) -> + magic[VALUE_CONSUMER](this|) -> + r(c) -> + w(this|) L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[] + PREV:[] sink: - PREV:[, ] -===================== \ No newline at end of file + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/expressions/assignmentToThis.values b/compiler/testData/cfg/expressions/assignmentToThis.values index 3121c81908d..491d3789f6e 100644 --- a/compiler/testData/cfg/expressions/assignmentToThis.values +++ b/compiler/testData/cfg/expressions/assignmentToThis.values @@ -4,7 +4,10 @@ fun Int.bar(c: C) { } --------------------- : {<: [ERROR : C]} NEW: magic[FAKE_INITIALIZER](c: C) -> -c : * NEW: r(c) -> -this = c : * NEW: magic[UNSUPPORTED_ELEMENT](this = c|) -> -{ this = c } : * COPY + : * NEW: magic[VALUE_CONSUMER](this|) -> +this : * COPY +this : * NEW: r(this, ) -> +c : * NEW: r(c) -> +this = c !: * +{ this = c } !: * COPY ===================== diff --git a/compiler/testData/cfg/expressions/unresolvedWriteLHS.instructions b/compiler/testData/cfg/expressions/unresolvedWriteLHS.instructions index 7a929be8f3f..c5b37f7f1ff 100644 --- a/compiler/testData/cfg/expressions/unresolvedWriteLHS.instructions +++ b/compiler/testData/cfg/expressions/unresolvedWriteLHS.instructions @@ -6,13 +6,15 @@ fun foo() { L0: 1 2 mark({ x = "" }) + magic[UNRESOLVED_CALL](x) -> + magic[VALUE_CONSUMER](x|) -> mark("") - r("") -> - magic[UNSUPPORTED_ELEMENT](x = ""|) -> + r("") -> + w(x|) L1: - 1 NEXT:[] + 1 NEXT:[] error: - PREV:[] + PREV:[] sink: - PREV:[, ] -===================== \ No newline at end of file + PREV:[, ] +===================== diff --git a/compiler/testData/cfg/expressions/unresolvedWriteLHS.values b/compiler/testData/cfg/expressions/unresolvedWriteLHS.values index 70ca650ecb8..a2c04e03388 100644 --- a/compiler/testData/cfg/expressions/unresolvedWriteLHS.values +++ b/compiler/testData/cfg/expressions/unresolvedWriteLHS.values @@ -3,7 +3,9 @@ fun foo() { x = "" } --------------------- -"" : * NEW: r("") -> -x = "" : * NEW: magic[UNSUPPORTED_ELEMENT](x = ""|) -> -{ x = "" } : * COPY + : * NEW: magic[VALUE_CONSUMER](x|) -> +x : * NEW: magic[UNRESOLVED_CALL](x) -> +"" : * NEW: r("") -> +x = "" !: * +{ x = "" } !: * COPY ===================== diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.kt b/compiler/testData/diagnostics/tests/LValueAssignment.kt index 3cdb597d207..ded49c502fc 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.kt +++ b/compiler/testData/diagnostics/tests/LValueAssignment.kt @@ -39,7 +39,7 @@ class D() { fun foo(): Unit {} fun cannotBe() { - var i: Int = 5 + var i: Int = 5 z = 30; "" = ""; @@ -135,4 +135,4 @@ fun Array.checkThis() { abstract class Ab { abstract fun getArray() : Array -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/UnusedParameters.kt b/compiler/testData/diagnostics/tests/UnusedParameters.kt index a160285e259..17e344f27d5 100644 --- a/compiler/testData/diagnostics/tests/UnusedParameters.kt +++ b/compiler/testData/diagnostics/tests/UnusedParameters.kt @@ -26,3 +26,7 @@ fun get(p: Any) { fun set(p: Any) { } + +fun foo(s: String) { + s.xxx = 1 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/UnusedParameters.txt b/compiler/testData/diagnostics/tests/UnusedParameters.txt index d52fc07037f..9ce670bf8e4 100644 --- a/compiler/testData/diagnostics/tests/UnusedParameters.txt +++ b/compiler/testData/diagnostics/tests/UnusedParameters.txt @@ -1,6 +1,7 @@ package internal fun f(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int, /*2*/ c: kotlin.Int = ...): kotlin.Unit +internal fun foo(/*0*/ s: kotlin.String): kotlin.Unit internal fun get(/*0*/ p: kotlin.Any): kotlin.Unit internal fun set(/*0*/ p: kotlin.Any): kotlin.Unit internal fun kotlin.Any.get(/*0*/ thisRef: kotlin.Any?, /*1*/ prop: kotlin.PropertyMetadata): kotlin.String From 236214305f7b845c3731e4f27d1b1b56ec9d72af Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Jun 2015 01:34:10 +0300 Subject: [PATCH 219/450] Support KClass.qualifiedName for non-local classes --- .../classSimpleName.kt | 0 .../localClassSimpleName.kt | 0 .../reflection/classes/qualifiedName.kt | 37 ++++++++++++++++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 39 +++++++++++++------ core/builtins/src/kotlin/reflect/KClass.kt | 9 ++++- .../kotlin/reflect/jvm/internal/KClassImpl.kt | 13 ++++++- 6 files changed, 84 insertions(+), 14 deletions(-) rename compiler/testData/codegen/boxWithStdlib/reflection/{classLiterals => classes}/classSimpleName.kt (100%) rename compiler/testData/codegen/boxWithStdlib/reflection/{classLiterals => classes}/localClassSimpleName.kt (100%) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/classes/qualifiedName.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/classSimpleName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classes/classSimpleName.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/classSimpleName.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/classes/classSimpleName.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/localClassSimpleName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classes/localClassSimpleName.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/localClassSimpleName.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/classes/localClassSimpleName.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classes/qualifiedName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classes/qualifiedName.kt new file mode 100644 index 00000000000..66646bf5ce0 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/classes/qualifiedName.kt @@ -0,0 +1,37 @@ +import kotlin.test.assertEquals +import kotlin.reflect.jvm.kotlin + +class Klass { + class Nested + companion object +} + +fun box(): String { + assertEquals("Klass", Klass::class.qualifiedName) + assertEquals("Klass.Nested", Klass.Nested::class.qualifiedName) + assertEquals("Klass.Companion", Klass.Companion::class.qualifiedName) + + assertEquals("kotlin.Any", Any::class.qualifiedName) + assertEquals("kotlin.Int", Int::class.qualifiedName) + assertEquals("kotlin.Int.Companion", Int.Companion::class.qualifiedName) + assertEquals("kotlin.IntArray", IntArray::class.qualifiedName) + assertEquals("kotlin.List", List::class.qualifiedName) + assertEquals("kotlin.String", String::class.qualifiedName) + assertEquals("kotlin.String", java.lang.String::class.qualifiedName) + + assertEquals("kotlin.Array", Array::class.qualifiedName) + assertEquals("kotlin.Array", Array::class.qualifiedName) + assertEquals("kotlin.Array", Array>::class.qualifiedName) + + assertEquals("java.util.Date", java.util.Date::class.qualifiedName) + assertEquals("kotlin.jvm.internal.KotlinSyntheticClass.Kind", kotlin.jvm.internal.KotlinSyntheticClass.Kind::class.qualifiedName) + assertEquals("java.lang.Void", java.lang.Void::class.qualifiedName) + + class Local + assertEquals(null, Local::class.qualifiedName) + + val o = object {} + assertEquals(null, o.javaClass.kotlin.qualifiedName) + + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 0bd0f75a57e..2da111d3b3f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2775,24 +2775,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("classSimpleName.kt") - public void testClassSimpleName() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/classSimpleName.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("genericClass.kt") public void testGenericClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/genericClass.kt"); doTestWithStdlib(fileName); } - @TestMetadata("localClassSimpleName.kt") - public void testLocalClassSimpleName() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/localClassSimpleName.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("simpleClassLiteral.kt") public void testSimpleClassLiteral() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/simpleClassLiteral.kt"); @@ -2800,6 +2788,33 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Classes extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInClasses() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/classes"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("classSimpleName.kt") + public void testClassSimpleName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/classSimpleName.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("localClassSimpleName.kt") + public void testLocalClassSimpleName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/localClassSimpleName.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("qualifiedName.kt") + public void testQualifiedName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/qualifiedName.kt"); + doTestWithStdlib(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/enclosing") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/builtins/src/kotlin/reflect/KClass.kt b/core/builtins/src/kotlin/reflect/KClass.kt index 3a89c246fdb..12349130007 100644 --- a/core/builtins/src/kotlin/reflect/KClass.kt +++ b/core/builtins/src/kotlin/reflect/KClass.kt @@ -27,10 +27,17 @@ package kotlin.reflect public interface KClass { /** * The simple name of the class as it was declared in the source code, - * or `null` if the class has no name (e.g. anonymous object literals). + * or `null` if the class has no name (if, for example, it is an anonymous object literal). */ public val simpleName: String? + /** + * The fully qualified name of the class which consists of names of the declaring package, + * all outer classes of this class and the class itself separated by dots, + * or `null` if the class is local or it is an anonymous object literal. + */ + public val qualifiedName: String? + /** * Returns non-extension properties declared in this class and all of its superclasses. */ diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index f00a88bd7ed..d2a12db9b16 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -42,9 +42,10 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K override val scope: JetScope get() = descriptor.getDefaultType().getMemberScope() override val simpleName: String? get() { + if (jClass.isAnonymousClass()) return null + val classId = classId return when { - jClass.isAnonymousClass() -> null classId.isLocal() -> calculateLocalClassName(jClass) else -> classId.getShortClassName().asString() } @@ -61,6 +62,16 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K return name.substringAfter('$') } + override val qualifiedName: String? get() { + if (jClass.isAnonymousClass()) return null + + val classId = classId + return when { + classId.isLocal() -> null + else -> classId.asSingleFqName().asString() + } + } + override val properties: Collection> get() = getProperties(declared = false) From bc168c0cbada2bfcb11ced54bd6e64b60dd04635 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Jun 2015 01:53:22 +0300 Subject: [PATCH 220/450] Support KClass.jvmName = java.lang.Class.getName() --- .../reflection/classes/jvmName.kt | 41 +++++++++++++++++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 6 +++ .../src/kotlin/reflect/jvm/classes.kt | 30 ++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt create mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt new file mode 100644 index 00000000000..919900c354e --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt @@ -0,0 +1,41 @@ +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.reflect.jvm.jvmName +import kotlin.reflect.jvm.kotlin + +class Klass { + class Nested + companion object +} + +fun box(): String { + assertEquals("Klass", Klass::class.jvmName) + assertEquals("Klass\$Nested", Klass.Nested::class.jvmName) + assertEquals("Klass\$Companion", Klass.Companion::class.jvmName) + + assertEquals("java.lang.Object", Any::class.jvmName) + assertEquals("int", Int::class.jvmName) + assertEquals("[I", IntArray::class.jvmName) + assertEquals("java.util.List", List::class.jvmName) + assertEquals("java.util.List", MutableList::class.jvmName) + assertEquals("java.lang.String", String::class.jvmName) + assertEquals("java.lang.String", java.lang.String::class.jvmName) + + assertEquals("[Ljava.lang.Object;", Array::class.jvmName) + assertEquals("[Ljava.lang.Integer;", Array::class.jvmName) + assertEquals("[[Ljava.lang.String;", Array>::class.jvmName) + + assertEquals("java.util.Date", java.util.Date::class.jvmName) + assertEquals("kotlin.jvm.internal.KotlinSyntheticClass\$Kind", kotlin.jvm.internal.KotlinSyntheticClass.Kind::class.jvmName) + assertEquals("java.lang.Void", java.lang.Void::class.jvmName) + + class Local + val l = Local::class.jvmName + assertTrue(l != null && l.startsWith("_DefaultPackage\$") && "\$box\$" in l && l.endsWith("\$Local")) + + val obj = object {} + val o = obj.javaClass.kotlin.jvmName + assertTrue(o != null && o.startsWith("_DefaultPackage\$") && "\$box\$" in o && o.endsWith("\$1")) + + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 2da111d3b3f..09519dcd9ba 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2802,6 +2802,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("jvmName.kt") + public void testJvmName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("localClassSimpleName.kt") public void testLocalClassSimpleName() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/localClassSimpleName.kt"); diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt new file mode 100644 index 00000000000..f059b078f0f --- /dev/null +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/classes.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect.jvm + +import kotlin.reflect.KClass +import kotlin.reflect.jvm.internal.KClassImpl + +/** + * Returns the JVM name of the class represented by this [KClass] instance. + * + * @see [java.lang.Class.getName] + */ +public val KClass<*>.jvmName: String + get() { + return (this as KClassImpl).jClass.getName() + } From ab297a4da098eb5e7e59bb318cb36b2129016193 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 10 Jun 2015 03:20:37 +0300 Subject: [PATCH 221/450] Generate reflection info to classes for function references The information includes the owner (class, package, script, or null for local functions) and the JVM signature -- this information will be used by reflection to locate the symbol --- .../kotlin/codegen/ClosureCodegen.java | 92 +++++++++++++++++-- .../kotlin/codegen/ExpressionCodegen.java | 11 ++- .../kotlin/resolve/jvm/AsmTypes.java | 1 + core/builtins/src/kotlin/reflect/KClass.kt | 2 +- .../kotlin/reflect/KDeclarationContainer.kt | 23 +++++ core/builtins/src/kotlin/reflect/KPackage.kt | 2 +- .../jvm/internal/KCallableContainerImpl.kt | 3 +- .../reflect/jvm/internal/KFunctionImpl.kt | 5 +- .../jvm/internal/FunctionReference.java | 29 +++++- 9 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 core/builtins/src/kotlin/reflect/KDeclarationContainer.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index d8906bdf2f7..9c3d1163253 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.kotlin.load.java.JvmAbi; +import org.jetbrains.kotlin.load.kotlin.PackageClassUtils; import org.jetbrains.kotlin.psi.JetElement; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; @@ -46,6 +47,7 @@ import java.util.Collections; import java.util.List; import static org.jetbrains.kotlin.codegen.AsmUtil.*; +import static org.jetbrains.kotlin.codegen.ExpressionCodegen.generateClassLiteralReference; import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isConst; import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.CLOSURE; import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.asmTypeForAnonymousClass; @@ -53,6 +55,7 @@ import static org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticC import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin; +import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.NO_ORIGIN; import static org.jetbrains.org.objectweb.asm.Opcodes.*; public class ClosureCodegen extends MemberCodegen { @@ -61,6 +64,7 @@ public class ClosureCodegen extends MemberCodegen { private final SamType samType; private final JetType superClassType; private final List superInterfaceTypes; + private final FunctionDescriptor functionReferenceTarget; private final FunctionGenerationStrategy strategy; private final CalculatedClosure closure; private final Type asmType; @@ -76,6 +80,7 @@ public class ClosureCodegen extends MemberCodegen { @Nullable SamType samType, @NotNull ClosureContext context, @NotNull KotlinSyntheticClass.Kind syntheticClassKind, + @Nullable FunctionDescriptor functionReferenceTarget, @NotNull FunctionGenerationStrategy strategy, @NotNull MemberCodegen parentCodegen, @NotNull ClassBuilder classBuilder @@ -86,6 +91,7 @@ public class ClosureCodegen extends MemberCodegen { this.classDescriptor = context.getContextDescriptor(); this.samType = samType; this.syntheticClassKind = syntheticClassKind; + this.functionReferenceTarget = functionReferenceTarget; this.strategy = strategy; if (samType == null) { @@ -189,7 +195,11 @@ public class ClosureCodegen extends MemberCodegen { functionCodegen.generateBridges(descriptorForBridges); } - this.constructor = generateConstructor(superClassAsmType); + if (functionReferenceTarget != null) { + generateFunctionReferenceMethods(functionReferenceTarget); + } + + this.constructor = generateConstructor(); if (isConst(closure)) { generateConstInstance(); @@ -214,10 +224,7 @@ public class ClosureCodegen extends MemberCodegen { } @NotNull - public StackValue putInstanceOnStack( - @NotNull final ExpressionCodegen codegen, - @Nullable final FunctionDescriptor functionReferenceTarget - ) { + public StackValue putInstanceOnStack(@NotNull final ExpressionCodegen codegen) { return StackValue.operation(asmType, new Function1() { @Override public Unit invoke(InstructionAdapter v) { @@ -267,7 +274,8 @@ public class ClosureCodegen extends MemberCodegen { MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "", "()V", null, ArrayUtil.EMPTY_STRING_ARRAY); InstructionAdapter iv = new InstructionAdapter(mv); - v.newField(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, asmType.getDescriptor(), null, null); + v.newField(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, asmType.getDescriptor(), + null, null); if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { mv.visitCode(); @@ -316,8 +324,78 @@ public class ClosureCodegen extends MemberCodegen { FunctionCodegen.endVisit(mv, "bridge", element); } + private void generateFunctionReferenceMethods(@NotNull FunctionDescriptor descriptor) { + int flags = ACC_PUBLIC | ACC_FINAL; + boolean generateBody = state.getClassBuilderMode() == ClassBuilderMode.FULL; + + { + MethodVisitor mv = + v.newMethod(NO_ORIGIN, flags, "getOwner", Type.getMethodDescriptor(K_DECLARATION_CONTAINER_TYPE), null, null); + if (generateBody) { + mv.visitCode(); + InstructionAdapter iv = new InstructionAdapter(mv); + generateFunctionReferenceDeclarationContainer(iv, descriptor, typeMapper); + iv.areturn(K_DECLARATION_CONTAINER_TYPE); + FunctionCodegen.endVisit(iv, "function reference getOwner", element); + } + } + + { + MethodVisitor mv = + v.newMethod(NO_ORIGIN, flags, "getName", Type.getMethodDescriptor(JAVA_STRING_TYPE), null, null); + if (generateBody) { + mv.visitCode(); + InstructionAdapter iv = new InstructionAdapter(mv); + iv.aconst(descriptor.getName().asString()); + iv.areturn(JAVA_STRING_TYPE); + FunctionCodegen.endVisit(iv, "function reference getName", element); + } + } + + { + MethodVisitor mv = v.newMethod(NO_ORIGIN, flags, "getSignature", Type.getMethodDescriptor(JAVA_STRING_TYPE), null, null); + if (generateBody) { + mv.visitCode(); + InstructionAdapter iv = new InstructionAdapter(mv); + Method method = typeMapper.mapSignature(descriptor).getAsmMethod(); + iv.aconst(method.getName() + method.getDescriptor()); + iv.areturn(JAVA_STRING_TYPE); + FunctionCodegen.endVisit(iv, "function reference getSignature", element); + } + } + } + + private static void generateFunctionReferenceDeclarationContainer( + @NotNull InstructionAdapter iv, + @NotNull FunctionDescriptor descriptor, + @NotNull JetTypeMapper typeMapper + ) { + DeclarationDescriptor container = descriptor.getContainingDeclaration(); + if (container instanceof ClassDescriptor) { + // TODO: getDefaultType() here is wrong and won't work for arrays + StackValue value = generateClassLiteralReference(typeMapper, ((ClassDescriptor) container).getDefaultType()); + value.put(K_CLASS_TYPE, iv); + } + else if (container instanceof PackageFragmentDescriptor) { + String packageClassInternalName = PackageClassUtils.getPackageClassInternalName( + ((PackageFragmentDescriptor) container).getFqName() + ); + iv.getstatic(packageClassInternalName, JvmAbi.KOTLIN_PACKAGE_FIELD_NAME, K_PACKAGE_TYPE.getDescriptor()); + } + else if (container instanceof ScriptDescriptor) { + // TODO: correct container for scripts (KScript?) + StackValue value = generateClassLiteralReference( + typeMapper, ((ScriptDescriptor) container).getClassDescriptor().getDefaultType() + ); + value.put(K_CLASS_TYPE, iv); + } + else { + iv.aconst(null); + } + } + @NotNull - private Method generateConstructor(@NotNull Type superClassAsmType) { + private Method generateConstructor() { List args = calculateConstructorParameters(typeMapper, closure, asmType); Type[] argTypes = fieldListToTypeArray(args); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 3bff774576d..1c1806566ba 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -1429,7 +1429,8 @@ public class ExpressionCodegen extends JetVisitor implem ); ClosureCodegen closureCodegen = new ClosureCodegen( - state, declaration, samType, context.intoClosure(descriptor, this, typeMapper), kind, strategy, parentCodegen, cv + state, declaration, samType, context.intoClosure(descriptor, this, typeMapper), kind, + functionReferenceTarget, strategy, parentCodegen, cv ); closureCodegen.generate(); @@ -1439,7 +1440,7 @@ public class ExpressionCodegen extends JetVisitor implem propagateChildReifiedTypeParametersUsages(closureCodegen.getReifiedTypeParametersUsages()); } - return closureCodegen.putInstanceOnStack(this, functionReferenceTarget); + return closureCodegen.putInstanceOnStack(this); } @Override @@ -2741,7 +2742,7 @@ public class ExpressionCodegen extends JetVisitor implem assert state.getReflectionTypes().getkClass().getTypeConstructor().equals(type.getConstructor()) : "::class expression should be type checked to a KClass: " + type; - return generateClassLiteralReference(KotlinPackage.single(type.getArguments()).getType()); + return generateClassLiteralReference(typeMapper, KotlinPackage.single(type.getArguments()).getType()); } @Override @@ -2834,7 +2835,7 @@ public class ExpressionCodegen extends JetVisitor implem @Override public Unit invoke(InstructionAdapter v) { v.visitLdcInsn(descriptor.getName().asString()); - StackValue receiverClass = generateClassLiteralReference(containingClass.getDefaultType()); + StackValue receiverClass = generateClassLiteralReference(typeMapper, containingClass.getDefaultType()); receiverClass.put(receiverClass.type, v); v.invokestatic(REFLECTION, factoryMethod.getName(), factoryMethod.getDescriptor(), false); @@ -2844,7 +2845,7 @@ public class ExpressionCodegen extends JetVisitor implem } @NotNull - private StackValue generateClassLiteralReference(@NotNull final JetType type) { + public static StackValue generateClassLiteralReference(@NotNull final JetTypeMapper typeMapper, @NotNull final JetType type) { return StackValue.operation(K_CLASS_TYPE, new Function1() { @Override public Unit invoke(InstructionAdapter v) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index 45aa7eed070..f174878ca74 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -40,6 +40,7 @@ public class AsmTypes { public static final Type K_CLASS_TYPE = reflect("KClass"); public static final Type K_CLASS_ARRAY_TYPE = Type.getObjectType("[" + K_CLASS_TYPE.getDescriptor()); public static final Type K_PACKAGE_TYPE = reflect("KPackage"); + public static final Type K_DECLARATION_CONTAINER_TYPE = reflect("KDeclarationContainer"); public static final Type K_FUNCTION = reflect("KFunction"); public static final Type K_TOP_LEVEL_FUNCTION = reflect("KTopLevelFunction"); diff --git a/core/builtins/src/kotlin/reflect/KClass.kt b/core/builtins/src/kotlin/reflect/KClass.kt index 12349130007..a12536a465a 100644 --- a/core/builtins/src/kotlin/reflect/KClass.kt +++ b/core/builtins/src/kotlin/reflect/KClass.kt @@ -24,7 +24,7 @@ package kotlin.reflect * * @param T the type of the class. */ -public interface KClass { +public interface KClass : KDeclarationContainer { /** * The simple name of the class as it was declared in the source code, * or `null` if the class has no name (if, for example, it is an anonymous object literal). diff --git a/core/builtins/src/kotlin/reflect/KDeclarationContainer.kt b/core/builtins/src/kotlin/reflect/KDeclarationContainer.kt new file mode 100644 index 00000000000..89e02989564 --- /dev/null +++ b/core/builtins/src/kotlin/reflect/KDeclarationContainer.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect + +/** + * Represents an entity which may contain declarations of any other entities, + * such as a class or a package. + */ +public interface KDeclarationContainer diff --git a/core/builtins/src/kotlin/reflect/KPackage.kt b/core/builtins/src/kotlin/reflect/KPackage.kt index 1f26a51565b..a2788d14ac9 100644 --- a/core/builtins/src/kotlin/reflect/KPackage.kt +++ b/core/builtins/src/kotlin/reflect/KPackage.kt @@ -19,4 +19,4 @@ package kotlin.reflect /** * Represents a package and provides introspection capabilities. */ -public interface KPackage +public interface KPackage : KDeclarationContainer diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt index 3c0ebd4b6e8..b9a91a3f4c7 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt @@ -30,8 +30,9 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.JvmType.PrimitiveType. import java.lang.reflect.Field import java.lang.reflect.Method import kotlin.reflect.KotlinReflectionInternalError +import kotlin.reflect.KDeclarationContainer -abstract class KCallableContainerImpl { +abstract class KCallableContainerImpl : KDeclarationContainer { // Note: this is stored here on a soft reference to prevent GC from destroying the weak reference to it in the moduleByClassLoader cache val moduleData by ReflectProperties.lazySoft { jClass.getOrCreateModule() diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt index 33ea57638c5..42534413c73 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt @@ -18,7 +18,4 @@ package kotlin.reflect.jvm.internal import kotlin.jvm.internal.FunctionImpl -/** - * @suppress - */ -public abstract class KFunctionImpl : FunctionImpl() +abstract class KFunctionImpl : FunctionImpl() diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java index 32d6e321a45..2503e3da797 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java @@ -16,9 +16,10 @@ package kotlin.jvm.internal; +import kotlin.jvm.KotlinReflectionNotSupportedError; import kotlin.reflect.*; -public abstract class FunctionReference +public class FunctionReference extends FunctionImpl implements KTopLevelFunction, KMemberFunction, @@ -39,4 +40,30 @@ public abstract class FunctionReference public int getArity() { return arity; } + + // The following methods provide the information identifying this function, which is used by the reflection implementation. + // They are supposed to be overridden in each subclass (each anonymous class generated for a function reference). + + public KDeclarationContainer getOwner() { + throw error(); + } + + // Kotlin name of the function, the one which was declared in the source code (@platformName can't change it) + public String getName() { + throw error(); + } + + // JVM signature of the function, e.g. "println(Ljava/lang/Object;)V" + public String getSignature() { + throw error(); + } + + // The following methods are the stub implementations of reflection functions. + // They are called when you're using reflection on a function reference without the reflection implementation in the classpath. + + // (nothing here yet) + + private static Error error() { + throw new KotlinReflectionNotSupportedError(); + } } From 3549e1e03562273222227e5acd1148c45ec19928 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 17 Jun 2015 20:37:57 +0300 Subject: [PATCH 222/450] Add KFunction.name, support reflection for function references #KT-7694 Fixed --- .../constructors/constructorName.kt | 8 +++ .../reflection/functions/localFunctionName.kt | 5 ++ .../reflection/functions/platformName.kt | 6 ++ .../reflection/functions/simpleNames.kt | 16 +++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 42 ++++++++++++ core/builtins/src/kotlin/reflect/KFunction.kt | 2 +- .../structure/reflect/ReflectJavaClass.kt | 2 +- .../reflect/ReflectJavaTypeParameter.kt | 2 +- .../builtins/functions/FunctionClassScope.kt | 57 ++++++++-------- .../jvm/internal/KCallableContainerImpl.kt | 29 +++++++-- .../kotlin/reflect/jvm/internal/KClassImpl.kt | 5 +- .../reflect/jvm/internal/KFunctionImpl.kt | 37 ++++++++++- .../jvm/internal/ReflectionFactoryImpl.java | 2 +- .../jvm/internal/ReflectionObjectRenderer.kt | 52 ++++++++++----- .../reflect/jvm/internal/RuntimeTypeMapper.kt | 65 ++++++++++++++++++- .../jvm/internal/kFunctionImplementations.kt | 26 ++++++++ 16 files changed, 302 insertions(+), 54 deletions(-) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/constructors/constructorName.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/functions/simpleNames.kt create mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/constructors/constructorName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/constructors/constructorName.kt new file mode 100644 index 00000000000..155efebed30 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/constructors/constructorName.kt @@ -0,0 +1,8 @@ +import kotlin.test.assertEquals + +class A + +fun box(): String { + assertEquals("", ::A.name) + return "OK" +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt new file mode 100644 index 00000000000..361ba4c3ce3 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt @@ -0,0 +1,5 @@ +fun box(): String { + fun OK() {} + + return ::OK.name +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt new file mode 100644 index 00000000000..26692f89c18 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt @@ -0,0 +1,6 @@ +import kotlin.platform.platformName + +@platformName("Fail") +fun OK() {} + +fun box() = ::OK.name diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/functions/simpleNames.kt b/compiler/testData/codegen/boxWithStdlib/reflection/functions/simpleNames.kt new file mode 100644 index 00000000000..417d2391154 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/functions/simpleNames.kt @@ -0,0 +1,16 @@ +import kotlin.test.assertEquals + +fun foo() {} + +class A { + fun bar() = "" +} + +fun Int.baz() = this + +fun box(): String { + assertEquals("foo", ::foo.name) + assertEquals("bar", A::bar.name) + assertEquals("baz", Int::baz.name) + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 09519dcd9ba..a02c2e6c25e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2821,6 +2821,21 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/constructors") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Constructors extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInConstructors() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/constructors"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("constructorName.kt") + public void testConstructorName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/constructors/constructorName.kt"); + doTestWithStdlib(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/enclosing") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -2974,6 +2989,33 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode } } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Functions extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInFunctions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/functions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("localFunctionName.kt") + public void testLocalFunctionName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions/localFunctionName.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("platformName.kt") + public void testPlatformName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions/platformName.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("simpleNames.kt") + public void testSimpleNames() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/functions/simpleNames.kt"); + doTestWithStdlib(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/core/builtins/src/kotlin/reflect/KFunction.kt b/core/builtins/src/kotlin/reflect/KFunction.kt index 127496163cc..a6c21632060 100644 --- a/core/builtins/src/kotlin/reflect/KFunction.kt +++ b/core/builtins/src/kotlin/reflect/KFunction.kt @@ -19,4 +19,4 @@ package kotlin.reflect /** * Represents a function with introspection capabilities. */ -public interface KFunction : Function +public interface KFunction : KCallable, Function diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt index 77677a82328..5c916d36c06 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClass.kt @@ -29,7 +29,7 @@ import java.util.Arrays public class ReflectJavaClass( private val klass: Class<*> ) : ReflectJavaElement(), ReflectJavaAnnotationOwner, ReflectJavaModifierListOwner, JavaClass { - override val element: AnnotatedElement get() = klass + override val element: Class<*> get() = klass override val modifiers: Int get() = klass.getModifiers() diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt index dee11701869..28b7ccf8587 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaTypeParameter.kt @@ -26,7 +26,7 @@ import java.lang.reflect.Method import java.lang.reflect.TypeVariable public class ReflectJavaTypeParameter( - private val typeVariable: TypeVariable<*> + public val typeVariable: TypeVariable<*> ) : ReflectJavaElement(), JavaTypeParameter { override fun getUpperBounds(): List { val bounds = typeVariable.getBounds().map { bound -> ReflectJavaClassifierType(bound) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt index 1efe3d2b79e..97468a9311d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassScope.kt @@ -16,9 +16,7 @@ package org.jetbrains.kotlin.builtins.functions -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.OverridingUtil import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter @@ -32,7 +30,7 @@ class FunctionClassScope( private val storageManager: StorageManager, private val functionClass: FunctionClassDescriptor ) : JetScopeImpl() { - private val allFunctions = storageManager.createLazyValue { + private val allDescriptors = storageManager.createLazyValue { if (functionClass.functionKind == FunctionClassDescriptor.Kind.Function) { val invoke = FunctionInvokeDescriptor.create(functionClass) (listOf(invoke) + createFakeOverrides(invoke)).toReadOnlyList() @@ -45,35 +43,42 @@ class FunctionClassScope( override fun getContainingDeclaration() = functionClass override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { - if (!kindFilter.acceptsKinds(DescriptorKindFilter.FUNCTIONS_MASK)) return listOf() - return allFunctions() + if (!kindFilter.acceptsKinds(DescriptorKindFilter.CALLABLES.kindMask)) return listOf() + return allDescriptors() } override fun getFunctions(name: Name): Collection { - return allFunctions().filter { it.getName() == name } + return allDescriptors().filterIsInstance().filter { it.getName() == name } } - private fun createFakeOverrides(invoke: FunctionDescriptor?): List { - val result = ArrayList(3) - val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes().flatMap { it.getMemberScope().getAllDescriptors() } - for ((name, descriptors) in allSuperDescriptors.groupBy { it.getName() }) { - @suppress("UNCHECKED_CAST") - OverridingUtil.generateOverridesInFunctionGroup( - name, - /* membersFromSupertypes = */ descriptors as Collection, - /* membersFromCurrent = */ if (name == invoke?.getName()) listOf(invoke) else listOf(), - functionClass, - object : OverridingUtil.DescriptorSink { - override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { - OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, null) - result.add(fakeOverride as FunctionDescriptor) - } + override fun getProperties(name: Name): Collection { + return allDescriptors().filterIsInstance().filter { it.getName() == name } + } - override fun conflict(fromSuper: CallableMemberDescriptor, fromCurrent: CallableMemberDescriptor) { - error("Conflict in scope of ${getContainingDeclaration()}: $fromSuper vs $fromCurrent") + private fun createFakeOverrides(invoke: FunctionDescriptor?): List { + val result = ArrayList(3) + val allSuperDescriptors = functionClass.getTypeConstructor().getSupertypes() + .flatMap { it.getMemberScope().getAllDescriptors() } + .filterIsInstance() + for ((name, group) in allSuperDescriptors.groupBy { it.getName() }) { + for ((isFunction, descriptors) in group.groupBy { it is FunctionDescriptor }) { + OverridingUtil.generateOverridesInFunctionGroup( + name, + /* membersFromSupertypes = */ descriptors, + /* membersFromCurrent = */ if (isFunction && name == invoke?.getName()) listOf(invoke) else listOf(), + functionClass, + object : OverridingUtil.DescriptorSink { + override fun addFakeOverride(fakeOverride: CallableMemberDescriptor) { + OverridingUtil.resolveUnknownVisibilityForMember(fakeOverride, null) + result.add(fakeOverride) + } + + override fun conflict(fromSuper: CallableMemberDescriptor, fromCurrent: CallableMemberDescriptor) { + error("Conflict in scope of ${getContainingDeclaration()}: $fromSuper vs $fromCurrent") + } } - } - ) + ) + } } return result diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt index b9a91a3f4c7..bedc410dd47 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt @@ -16,6 +16,7 @@ package kotlin.reflect.jvm.internal +import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.load.java.structure.reflect.classId import org.jetbrains.kotlin.load.java.structure.reflect.classLoader @@ -29,8 +30,8 @@ import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf.JvmType.PrimitiveType.* import java.lang.reflect.Field import java.lang.reflect.Method -import kotlin.reflect.KotlinReflectionInternalError import kotlin.reflect.KDeclarationContainer +import kotlin.reflect.KotlinReflectionInternalError abstract class KCallableContainerImpl : KDeclarationContainer { // Note: this is stored here on a soft reference to prevent GC from destroying the weak reference to it in the moduleByClassLoader cache @@ -44,7 +45,7 @@ abstract class KCallableContainerImpl : KDeclarationContainer { fun findPropertyDescriptor(name: String, receiverDesc: String? = null): PropertyDescriptor { val properties = scope - .getProperties(Name.identifier(name)) + .getProperties(Name.guess(name)) .filter { descriptor -> descriptor is PropertyDescriptor && descriptor.getName().asString() == name && @@ -55,16 +56,34 @@ abstract class KCallableContainerImpl : KDeclarationContainer { } if (properties.size() != 1) { - val debugText = if (receiverDesc == null) name else "$receiverDesc.$name" + val debugText = if (receiverDesc == null) name else "'$receiverDesc.$name'" throw KotlinReflectionInternalError( - if (properties.isEmpty()) "Property '$debugText' not resolved in $this" - else "${properties.size()} properties '$debugText' resolved in $this" + if (properties.isEmpty()) "Property $debugText not resolved in $this" + else "${properties.size()} properties $debugText resolved in $this: $properties" ) } return properties.single() as PropertyDescriptor } + fun findFunctionDescriptor(name: String, signature: String): FunctionDescriptor { + val functions = scope + .getFunctions(Name.guess(name)) + .filter { descriptor -> + RuntimeTypeMapper.mapSignature(descriptor) == signature + } + + if (functions.size() != 1) { + val debugText = "'$name' (JVM signature: $signature)" + throw KotlinReflectionInternalError( + if (functions.isEmpty()) "Function $debugText not resolved in $this" + else "${functions.size()} functions $debugText resolved in $this: $functions" + ) + } + + return functions.single() + } + // TODO: check resulting method's return type fun findMethodBySignature(signature: JvmProtoBuf.JvmMethodSignature, nameResolver: NameResolver, declared: Boolean): Method? { val name = nameResolver.getString(signature.getName()) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index d2a12db9b16..5c534a70b9c 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -19,6 +19,7 @@ package kotlin.reflect.jvm.internal import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.resolve.scopes.ChainedScope import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies import kotlin.reflect.* @@ -39,7 +40,9 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K private val classId: ClassId get() = RuntimeTypeMapper.mapJvmClassToKotlinClassId(jClass) - override val scope: JetScope get() = descriptor.getDefaultType().getMemberScope() + override val scope: JetScope get() = ChainedScope( + descriptor, "KClassImpl scope", descriptor.getDefaultType().getMemberScope(), descriptor.getStaticScope() + ) override val simpleName: String? get() { if (jClass.isAnonymousClass()) return null diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt index 42534413c73..7304bbb3239 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt @@ -16,6 +16,41 @@ package kotlin.reflect.jvm.internal +import org.jetbrains.kotlin.descriptors.FunctionDescriptor import kotlin.jvm.internal.FunctionImpl +import kotlin.reflect.KFunction -abstract class KFunctionImpl : FunctionImpl() +abstract class KFunctionImpl private constructor( + container: KCallableContainerImpl, + name: String, + signature: String, + descriptorInitialValue: FunctionDescriptor? +) : KFunction, FunctionImpl() { + constructor(container: KCallableContainerImpl, name: String, signature: String): this(container, name, signature, null) + + constructor(container: KCallableContainerImpl, descriptor: FunctionDescriptor): this( + container, descriptor.getName().asString(), RuntimeTypeMapper.mapSignature(descriptor), descriptor + ) + + protected val descriptor: FunctionDescriptor by ReflectProperties.lazySoft(descriptorInitialValue) { + container.findFunctionDescriptor(name, signature) + } + + override val name: String get() = descriptor.getName().asString() + + override fun getArity(): Int { + // TODO: test? + return descriptor.getValueParameters().size() + + (if (descriptor.getDispatchReceiverParameter() != null) 1 else 0) + + (if (descriptor.getExtensionReceiverParameter() != null) 1 else 0) + } + + override fun equals(other: Any?): Boolean = + other is KFunctionImpl && descriptor == other.descriptor + + override fun hashCode(): Int = + descriptor.hashCode() + + override fun toString(): String = + ReflectionObjectRenderer.renderFunction(descriptor) +} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java index 59fbdc4b56b..6aab0752308 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java @@ -44,7 +44,7 @@ public class ReflectionFactoryImpl extends ReflectionFactory { @Override public KFunction function(FunctionReference f) { - return f; + return new KTopLevelFreeFunctionImpl((KPackageImpl) f.getOwner(), f.getName(), f.getSignature()); } // Properties diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt index f4eda03bdba..ad55d9aa085 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt @@ -16,6 +16,8 @@ package kotlin.reflect.jvm.internal +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.renderer.DescriptorRenderer @@ -23,29 +25,47 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer object ReflectionObjectRenderer { private val renderer = DescriptorRenderer.FQ_NAMES_IN_TYPES + private fun StringBuilder.appendReceiverType(receiver: ReceiverParameterDescriptor?) { + if (receiver != null) { + append(renderer.renderType(receiver.getType())) + append(".") + } + } + + private fun StringBuilder.appendReceiversAndName(callable: CallableDescriptor) { + val dispatchReceiver = callable.getDispatchReceiverParameter() + val extensionReceiver = callable.getExtensionReceiverParameter() + + appendReceiverType(dispatchReceiver) + + val addParentheses = dispatchReceiver != null && extensionReceiver != null + if (addParentheses) append("(") + appendReceiverType(extensionReceiver) + if (addParentheses) append(")") + + append(renderer.renderName(callable.getName())) + } + // TODO: include visibility, return type fun renderProperty(descriptor: PropertyDescriptor): String { - fun StringBuilder.appendReceiverType(receiver: ReceiverParameterDescriptor?) { - if (receiver != null) { - append(renderer.renderType(receiver.getType())) - append(".") - } - } - return StringBuilder { append(if (descriptor.isVar()) "var " else "val ") + appendReceiversAndName(descriptor) + }.toString() + } - val dispatchReceiver = descriptor.getDispatchReceiverParameter() - val extensionReceiver = descriptor.getExtensionReceiverParameter() + fun renderFunction(descriptor: FunctionDescriptor): String { + // TODO: add tests + return StringBuilder { + append("fun ") + appendReceiversAndName(descriptor) - appendReceiverType(dispatchReceiver) + descriptor.getValueParameters().joinTo(this, separator = ", ", prefix = "(", postfix = ")") { + renderer.renderType(it.getType()) // TODO: vararg + } - val addParentheses = dispatchReceiver != null && extensionReceiver != null - if (addParentheses) append("(") - appendReceiverType(extensionReceiver) - if (addParentheses) append(")") - - append(renderer.renderName(descriptor.getName())) + append(": ") + append(renderer.renderType(descriptor.getReturnType()!!)) }.toString() } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt index 5070f927b96..529f085bf47 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt @@ -19,16 +19,24 @@ package kotlin.reflect.jvm.internal import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.load.java.structure.reflect.classId +import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor +import org.jetbrains.kotlin.load.java.sources.JavaSourceElement +import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.load.java.structure.reflect.* +import org.jetbrains.kotlin.load.kotlin.SignatureDeserializer import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor +import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils +import kotlin.reflect.KotlinReflectionInternalError object RuntimeTypeMapper { // TODO: this logic must be shared with JetTypeMapper @@ -62,6 +70,61 @@ object RuntimeTypeMapper { return classDescriptor.classId.desc } + fun mapSignature(function: FunctionDescriptor): String { + if (function is DeserializedSimpleFunctionDescriptor) { + val proto = function.getProto() + if (!proto.hasExtension(JvmProtoBuf.methodSignature)) { + throw KotlinReflectionInternalError("No metadata found for $function") + } + val signature = proto.getExtension(JvmProtoBuf.methodSignature) + return SignatureDeserializer(function.getNameResolver()).methodSignatureString(signature) + } + else if (function is JavaMethodDescriptor) { + val method = (function.getSource() as? JavaSourceElement)?.javaElement as? JavaMethod ?: + throw KotlinReflectionInternalError("Incorrect resolution sequence for Java method $function") + + return StringBuilder { + append(method.getName().asString()) + + append("(") + for (parameter in method.getValueParameters()) { + appendJavaType(parameter.getType()) + } + append(")") + + appendJavaType(method.getReturnType()) + }.toString() + } + else throw KotlinReflectionInternalError("Unknown origin of $function (${function.javaClass})") + } + + // TODO: verify edge cases when it's possible to reference generic functions + private tailRecursive fun StringBuilder.appendJavaType(type: JavaType) { + when (type) { + is JavaPrimitiveType -> { + append(type.getType()?.let { JvmPrimitiveType.get(it).getDesc() } ?: "V") + } + is JavaArrayType -> { + append("[") + appendJavaType(type.getComponentType()) + } + is JavaWildcardType -> { + val bound = type.getBound() + if (bound != null && type.isExtends()) appendJavaType(bound) + else append("Ljava/lang/Object;") + } + is JavaClassifierType -> { + val classifier = type.getClassifier() + when (classifier) { + is ReflectJavaClass -> + append(classifier.element.desc) + is ReflectJavaTypeParameter -> + appendJavaType(ReflectJavaType.create(classifier.typeVariable.getBounds().first())) + } + } + } + } + fun mapJvmClassToKotlinClassId(klass: Class<*>): ClassId { if (klass.isArray()) { klass.getComponentType().primitiveType?.let { diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt new file mode 100644 index 00000000000..bafd1a4f11f --- /dev/null +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect.jvm.internal + +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import kotlin.reflect.KTopLevelFunction + +class KTopLevelFreeFunctionImpl : KFunctionImpl, KTopLevelFunction { + constructor(container: KPackageImpl, name: String, signature: String): super(container, name, signature) + + constructor(container: KPackageImpl, descriptor: FunctionDescriptor): super(container, descriptor) +} From c3b97e0668e94ef3982cb9b7e7021d397f2a5213 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 23 Jun 2015 20:34:25 +0300 Subject: [PATCH 223/450] Simplify function hierarchy in reflection Get rid of all classes except kotlin.reflect.KFunction, which will be used to represent all kinds of simple functions. Lots of changes to test data are related to the fact that KFunction is not an extension function (as opposed to KMemberFunction and KExtensionFunction who were) and so a member or an extension function reference now requires all arguments be passed to it in the parentheses, including receivers. This is probably temporary until we support calling any function both as a free function and as an extension. In JS, functions and extension functions are not interchangeable, so tests on this behavior are removed until this is supported --- .../kotlin/codegen/ClosureCodegen.java | 64 +++++--------- .../FunctionReferenceGenerationStrategy.java | 11 ++- .../kotlin/resolve/jvm/AsmTypes.java | 4 - .../BasicExpressionTypingVisitor.java | 8 +- .../functionReferenceErasedToKFunction/J.java | 4 +- .../function/abstractClassMember.kt | 2 +- .../function/booleanNotIntrinsic.kt | 4 +- .../function/classMemberFromClass.kt | 2 +- .../function/classMemberFromExtension.kt | 2 +- .../classMemberFromTopLevelStringNoArgs.kt | 2 +- ...assMemberFromTopLevelStringOneStringArg.kt | 2 +- .../classMemberFromTopLevelUnitNoArgs.kt | 2 +- ...classMemberFromTopLevelUnitOneStringArg.kt | 2 +- .../function/enumNameMethod.kt | 2 +- .../function/equalsIntrinsic.kt | 2 +- .../function/extensionFromClass.kt | 2 +- .../function/extensionFromExtension.kt | 2 +- .../extensionFromTopLevelStringNoArgs.kt | 2 +- ...extensionFromTopLevelStringOneStringArg.kt | 2 +- .../extensionFromTopLevelUnitNoArgs.kt | 2 +- .../extensionFromTopLevelUnitOneStringArg.kt | 2 +- .../function/genericMember.kt | 2 +- .../function/innerConstructorFromClass.kt | 2 +- .../function/innerConstructorFromExtension.kt | 2 +- .../innerConstructorFromTopLevelNoArgs.kt | 2 +- ...nnerConstructorFromTopLevelOneStringArg.kt | 2 +- .../function/local/captureOuter.kt | 2 +- .../function/local/classMember.kt | 2 +- .../function/local/enumExtendsTrait.kt | 2 +- .../function/local/extension.kt | 2 +- .../function/local/extensionToLocalClass.kt | 2 +- .../function/local/extensionToPrimitive.kt | 2 +- .../function/local/extensionWithClosure.kt | 2 +- .../function/local/genericMember.kt | 2 +- .../function/local/localClassMember.kt | 2 +- .../function/objectMemberUnitNoArgs.kt | 2 +- .../function/objectMemberUnitOneStringArg.kt | 2 +- .../function/privateClassMember.kt | 2 +- .../traitImplMethodWithClassReceiver.kt | 2 +- .../callableReference/function/traitMember.kt | 2 +- .../platformStatic/callableRef.kt | 10 +-- .../directInvoke/callableReference.kt | 4 +- .../callableRefrenceOnNestedObject.kt | 4 +- .../function/differentPackageClass.kt | 6 +- .../function/differentPackageExtension.kt | 6 +- .../function/extensionFromClass.kt | 6 +- .../function/extensionFromExtension.kt | 6 +- .../function/extensionFromExtensionInClass.kt | 6 +- .../function/extensionFromTopLevel.kt | 12 +-- .../function/extensionOnNullable.kt | 4 +- .../function/extensionOnNullable.txt | 4 +- .../function/genericClassFromTopLevel.kt | 4 +- .../function/innerConstructorFromClass.kt | 12 +-- .../function/innerConstructorFromExtension.kt | 10 +-- .../function/innerConstructorFromTopLevel.kt | 6 +- .../function/longQualifiedName.kt | 4 +- .../function/longQualifiedNameGeneric.kt | 4 +- .../function/memberFromClass.kt | 6 +- .../function/memberFromExtension.kt | 6 +- .../function/memberFromExtensionInClass.kt | 6 +- .../function/memberFromTopLevel.kt | 12 +-- .../function/noAmbiguityMemberVsExtension.kt | 4 +- .../function/noAmbiguityMemberVsTopLevel.kt | 4 +- .../function/renameOnImport.kt | 4 +- .../tests/deprecated/functionUsage.txt | 2 +- .../src/kotlin/reflect/KExtensionFunction.kt | 27 ------ .../src/kotlin/reflect/KLocalFunction.kt | 24 ------ .../src/kotlin/reflect/KMemberFunction.kt | 26 ------ .../reflect/KTopLevelExtensionFunction.kt | 25 ------ .../src/kotlin/reflect/KTopLevelFunction.kt | 22 ----- .../kotlin/platform/JavaToKotlinClassMap.java | 7 +- .../kotlin/builtins/ReflectionTypes.kt | 14 +-- .../BuiltInFictitiousFunctionClassFactory.kt | 19 ++-- .../functions/FunctionClassDescriptor.kt | 86 +++++-------------- .../internal/KFunctionFromReferenceImpl.kt | 69 +++++++++++++++ .../reflect/jvm/internal/KFunctionImpl.kt | 2 +- .../jvm/internal/ReflectionFactoryImpl.java | 2 +- .../jvm/internal/kFunctionImplementations.kt | 26 ------ .../jvm/internal/FunctionReference.java | 10 +-- .../FunctionCallableReferenceTest.java | 2 +- .../callTranslator/FunctionCallCases.kt | 4 +- .../kotlin/js/translate/context/Namer.java | 11 ++- .../reference/CallableReferenceTranslator.kt | 9 +- .../function/cases/abstractClassMember.kt | 2 +- .../function/cases/booleanNotIntrinsic.kt | 4 +- .../function/cases/classMemberAndExtension.kt | 8 +- ...lassMemberAndNonExtensionCompatibility.kt} | 8 +- .../function/cases/classMemberFromClass.kt | 2 +- .../cases/classMemberFromExtension.kt | 2 +- .../classMemberFromTopLevelStringNoArgs.kt | 14 +-- ...assMemberFromTopLevelStringOneStringArg.kt | 12 +-- .../classMemberFromTopLevelUnitNoArgs.kt | 16 +--- ...classMemberFromTopLevelUnitOneStringArg.kt | 16 +--- .../function/cases/classMemberOverridden.kt | 2 +- .../cases/classMemberOverriddenInObject.kt | 2 +- .../function/cases/extension.kt | 2 +- .../function/cases/extensionFromClass.kt | 2 +- .../function/cases/extensionFromExtension.kt | 2 +- .../function/cases/extensionFromTopLevel.kt | 8 +- .../extensionFromTopLevelStringNoArgs.kt | 2 +- ...extensionFromTopLevelStringOneStringArg.kt | 2 +- .../cases/extensionFromTopLevelUnitNoArgs.kt | 10 +-- .../extensionFromTopLevelUnitOneStringArg.kt | 2 +- .../function/cases/extensionToPrimitive.kt | 2 +- .../function/cases/extensionWithClosure.kt | 2 +- .../cases/localAndTopLevelExtensions.kt | 6 +- .../function/cases/stringNativeExtension.kt | 2 +- ...citDispatchReceiverAndExtensionReceiver.kt | 4 +- js/js.translator/testData/kotlin_lib_ecma5.js | 16 +++- .../cases/reflectionFromOtherPackage/b.kt | 10 +-- .../native/cases/nativeExtensionLikeMember.kt | 8 +- .../native/cases/passMemberOrExtFromNative.kt | 6 +- .../native/cases/passMemberOrExtToNative.kt | 10 +-- 113 files changed, 350 insertions(+), 534 deletions(-) delete mode 100644 core/builtins/src/kotlin/reflect/KExtensionFunction.kt delete mode 100644 core/builtins/src/kotlin/reflect/KLocalFunction.kt delete mode 100644 core/builtins/src/kotlin/reflect/KMemberFunction.kt delete mode 100644 core/builtins/src/kotlin/reflect/KTopLevelExtensionFunction.kt delete mode 100644 core/builtins/src/kotlin/reflect/KTopLevelFunction.kt create mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionFromReferenceImpl.kt delete mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt rename js/js.translator/testData/callableReference/function/cases/{classMemberAndExtensionCompatibility.kt => classMemberAndNonExtensionCompatibility.kt} (75%) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index 9c3d1163253..b9f6c7a80d9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -225,53 +225,35 @@ public class ClosureCodegen extends MemberCodegen { @NotNull public StackValue putInstanceOnStack(@NotNull final ExpressionCodegen codegen) { - return StackValue.operation(asmType, new Function1() { - @Override - public Unit invoke(InstructionAdapter v) { - if (isConst(closure)) { - v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); - } - else { - v.anew(asmType); - v.dup(); + return StackValue.operation( + functionReferenceTarget != null ? K_FUNCTION : asmType, + new Function1() { + @Override + public Unit invoke(InstructionAdapter v) { + if (isConst(closure)) { + v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); + } + else { + v.anew(asmType); + v.dup(); - codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator); - v.invokespecial(asmType.getInternalName(), "", constructor.getDescriptor(), false); - } + codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator); + v.invokespecial(asmType.getInternalName(), "", constructor.getDescriptor(), false); + } - if (functionReferenceTarget != null) { - equipFunctionReferenceWithReflection(v, functionReferenceTarget); - } + if (functionReferenceTarget != null) { + v.invokestatic(REFLECTION, "function", Type.getMethodDescriptor(K_FUNCTION, FUNCTION_REFERENCE), false); + } - return Unit.INSTANCE$; - } - }); + return Unit.INSTANCE$; + } + } + ); } - private static void equipFunctionReferenceWithReflection(@NotNull InstructionAdapter v, @NotNull FunctionDescriptor target) { - DeclarationDescriptor container = target.getContainingDeclaration(); - - Type type; - if (container instanceof PackageFragmentDescriptor) { - type = target.getExtensionReceiverParameter() != null - ? K_TOP_LEVEL_EXTENSION_FUNCTION - : K_TOP_LEVEL_FUNCTION; - } - else if (container instanceof ClassDescriptor) { - type = K_MEMBER_FUNCTION; - } - else { - type = K_LOCAL_FUNCTION; - } - - Method method = method("function", K_FUNCTION, FUNCTION_REFERENCE); - v.invokestatic(REFLECTION, method.getName(), method.getDescriptor(), false); - StackValue.coerce(K_FUNCTION, type, v); - } - - private void generateConstInstance() { - MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "", "()V", null, ArrayUtil.EMPTY_STRING_ARRAY); + MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "", "()V", null, + ArrayUtil.EMPTY_STRING_ARRAY); InstructionAdapter iv = new InstructionAdapter(mv); v.newField(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, asmType.getDescriptor(), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java index 92a9f33c3a6..9ea0bc24122 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionReferenceGenerationStrategy.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.codegen; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.codegen.state.GenerationState; @@ -133,8 +134,14 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat } private void computeAndSaveArguments(@NotNull List fakeArguments, @NotNull ExpressionCodegen codegen) { - for (ValueParameterDescriptor parameter : callableDescriptor.getValueParameters()) { - ValueArgument fakeArgument = fakeArguments.get(parameter.getIndex()); + int receivers = (referencedFunction.getDispatchReceiverParameter() != null ? 1 : 0) + + (referencedFunction.getExtensionReceiverParameter() != null ? 1 : 0); + + List parameters = KotlinPackage.drop(callableDescriptor.getValueParameters(), receivers); + for (int i = 0; i < parameters.size(); i++) { + ValueParameterDescriptor parameter = parameters.get(i); + ValueArgument fakeArgument = fakeArguments.get(i); + Type type = state.getTypeMapper().mapType(parameter); int localIndex = codegen.myFrameMap.getIndex(parameter); codegen.tempVariables.put(fakeArgument.getArgumentExpression(), StackValue.local(localIndex, type)); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index f174878ca74..fc1cdc5a981 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -43,10 +43,6 @@ public class AsmTypes { public static final Type K_DECLARATION_CONTAINER_TYPE = reflect("KDeclarationContainer"); public static final Type K_FUNCTION = reflect("KFunction"); - public static final Type K_TOP_LEVEL_FUNCTION = reflect("KTopLevelFunction"); - public static final Type K_MEMBER_FUNCTION = reflect("KMemberFunction"); - public static final Type K_TOP_LEVEL_EXTENSION_FUNCTION = reflect("KTopLevelExtensionFunction"); - public static final Type K_LOCAL_FUNCTION = reflect("KLocalFunction"); public static final Type K_MEMBER_PROPERTY_TYPE = reflect("KMemberProperty"); public static final Type K_MUTABLE_MEMBER_PROPERTY_TYPE = reflect("KMutableMemberProperty"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index e177156ba62..dce191599b6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -704,7 +704,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { boolean isExtension = extensionReceiver != null; if (descriptor instanceof FunctionDescriptor) { - return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType, isExtension); + return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType); } else if (descriptor instanceof PropertyDescriptor) { return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType, isExtension); @@ -722,16 +722,14 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @NotNull JetCallableReferenceExpression expression, @NotNull ExpressionTypingContext context, @NotNull FunctionDescriptor descriptor, - @Nullable JetType receiverType, - boolean isExtension + @Nullable JetType receiverType ) { //noinspection ConstantConditions JetType type = components.reflectionTypes.getKFunctionType( Annotations.EMPTY, receiverType, getValueParametersTypes(descriptor.getValueParameters()), - descriptor.getReturnType(), - isExtension + descriptor.getReturnType() ); AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor( diff --git a/compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction/J.java b/compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction/J.java index 6536c732dea..100310e99de 100644 --- a/compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction/J.java +++ b/compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction/J.java @@ -1,9 +1,9 @@ import kotlin.jvm.functions.Function2; -import kotlin.reflect.KMemberFunction; +import kotlin.reflect.KFunction; public class J { public static String go() { - KMemberFunction fun = K.Companion.getRef(); + KFunction fun = K.Companion.getRef(); Object result = ((Function2) fun).invoke(new K(), "KO"); return (String) result; } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/abstractClassMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/abstractClassMember.kt index a5718485bec..515b25914d0 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/abstractClassMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/abstractClassMember.kt @@ -6,4 +6,4 @@ class B : A() { override fun foo() = "OK" } -fun box(): String = B().(A::foo)() +fun box(): String = (A::foo)(B()) diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/booleanNotIntrinsic.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/booleanNotIntrinsic.kt index 114e328afef..213c8d88996 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/booleanNotIntrinsic.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/booleanNotIntrinsic.kt @@ -1,5 +1,5 @@ fun box(): String { - if (true.(Boolean::not)() != false) return "Fail 1" - if (false.(Boolean::not)() != true) return "Fail 2" + if ((Boolean::not)(true) != false) return "Fail 1" + if ((Boolean::not)(false) != true) return "Fail 2" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt index 1ef4255bbe1..7f5fd04017f 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromClass.kt @@ -1,7 +1,7 @@ class A { fun foo(k: Int) = k - fun result() = this.(::foo)(111) + fun result() = (::foo)(this, 111) } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt index f19e87f864c..607fa3700f5 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromExtension.kt @@ -3,7 +3,7 @@ class A { fun k(k: Int) = k } -fun A.foo() = this.(::o)() + this.(A::k)(222) +fun A.foo() = (::o)(this) + (A::k)(this, 222) fun box(): String { val result = A().foo() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringNoArgs.kt index d7fe34551ef..4ea10740594 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringNoArgs.kt @@ -4,5 +4,5 @@ class A { fun box(): String { val x = A::foo - return A().x() + return x(A()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringOneStringArg.kt index 9e03ba90c63..acdf2f897d5 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelStringOneStringArg.kt @@ -4,5 +4,5 @@ class A { fun box(): String { val x = A::foo - return A().x("OK") + return x(A(), "OK") } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitNoArgs.kt index 4fb93fc926f..37ebbdb72eb 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitNoArgs.kt @@ -9,6 +9,6 @@ class A { fun box(): String { val a = A() val x = A::foo - a.x() + x(a) return a.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitOneStringArg.kt index c982e914210..3b280c28f34 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/classMemberFromTopLevelUnitOneStringArg.kt @@ -9,6 +9,6 @@ class A { fun box(): String { val a = A() val x = A::foo - a.x("OK") + x(a, "OK") return a.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/enumNameMethod.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/enumNameMethod.kt index 1aa7fc633b2..b6a1bf51558 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/enumNameMethod.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/enumNameMethod.kt @@ -3,7 +3,7 @@ enum class E { } fun box(): String { - val i = E.I.(E::name)() + val i = (E::name)(E.I) if (i != "I") return "Fail $i" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/equalsIntrinsic.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/equalsIntrinsic.kt index be58579704b..c83a188802d 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/equalsIntrinsic.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/equalsIntrinsic.kt @@ -1,3 +1,3 @@ class A -fun box() = if (A().(A::equals)(A())) "Fail" else "OK" +fun box() = if ((A::equals)(A(), A())) "Fail" else "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt index 0bbfc45d383..f5dabed6746 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromClass.kt @@ -1,5 +1,5 @@ class A { - fun result() = this.(::foo)("OK") + fun result() = (::foo)(this, "OK") } fun A.foo(x: String) = x diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromExtension.kt index 4f43bb608d8..103ceee5cbc 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromExtension.kt @@ -1,6 +1,6 @@ class A -fun A.foo() = this.(A::bar)("OK") +fun A.foo() = (A::bar)(this, "OK") fun A.bar(x: String) = x diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringNoArgs.kt index 46f1caa4528..b5fd42ad9c6 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringNoArgs.kt @@ -4,5 +4,5 @@ fun A.foo() = "OK" fun box(): String { val x = A::foo - return A().x() + return x(A()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringOneStringArg.kt index 9f371dbf329..69db0311a69 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelStringOneStringArg.kt @@ -4,5 +4,5 @@ fun A.foo(result: String) = result fun box(): String { val x = A::foo - return A().x("OK") + return x(A(), "OK") } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitNoArgs.kt index d90c6c98d28..b590ad2ec91 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitNoArgs.kt @@ -9,6 +9,6 @@ fun A.foo() { fun box(): String { val a = A() val x = A::foo - a.x() + x(a) return a.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitOneStringArg.kt index 68fdd0903e5..aa9d5505bbf 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/extensionFromTopLevelUnitOneStringArg.kt @@ -9,6 +9,6 @@ fun A.foo(newResult: String) { fun box(): String { val a = A() val x = A::foo - a.x("OK") + x(a, "OK") return a.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/genericMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/genericMember.kt index 8608c508dde..25dabc055f2 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/genericMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/genericMember.kt @@ -2,4 +2,4 @@ class A(val t: T) { fun foo(): T = t } -fun box() = A("OK").(A::foo)() +fun box() = (A::foo)(A("OK")) diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt index 8f19b83cb4f..53b31fa77d0 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromClass.kt @@ -4,7 +4,7 @@ class A { val k = 222 } - fun result() = this.(A::Inner)().o + this.(::Inner)().k + fun result() = (A::Inner)(this).o + (::Inner)(this).k } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt index 6fa9653c833..aad8cb2a97a 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromExtension.kt @@ -5,7 +5,7 @@ class A { } } -fun A.foo() = this.(A::Inner)().o + this.(::Inner)().k +fun A.foo() = (A::Inner)(this).o + (::Inner)(this).k fun box(): String { val result = A().foo() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelNoArgs.kt index b974ba82993..577eb19e7af 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelNoArgs.kt @@ -6,7 +6,7 @@ class A { } fun box(): String { - val result = (::A)().(A::Inner)().o + A().(A::Inner)().k + val result = (A::Inner)((::A)()).o + (A::Inner)(A()).k if (result != 333) return "Fail $result" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt index e47bd741210..0eb2b831a2b 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/innerConstructorFromTopLevelOneStringArg.kt @@ -3,7 +3,7 @@ class A { } fun box(): String { - val result = (::A)().(A::Inner)(111).result + A().(A::Inner)(222).result + val result = (A::Inner)((::A)(), 111).result + (A::Inner)(A(), 222).result if (result != 333) return "Fail $result" return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/captureOuter.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/captureOuter.kt index 46bec43ff91..e653f8f0574 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/captureOuter.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/captureOuter.kt @@ -8,5 +8,5 @@ class Outer { fun box(): String { val f = Outer.Inner::foo - return Outer().Inner().f() + return f(Outer().Inner()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/classMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/classMember.kt index 343e9015c84..72bb8af6e81 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/classMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/classMember.kt @@ -4,5 +4,5 @@ fun box(): String { } val ref = Local::foo - return Local().ref() + return ref(Local()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/enumExtendsTrait.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/enumExtendsTrait.kt index 5b28434e19c..f2bfced60f4 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/enumExtendsTrait.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/enumExtendsTrait.kt @@ -7,5 +7,5 @@ enum class E : Named { } fun box(): String { - return E.OK.(Named::name)() + return (Named::name)(E.OK) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extension.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extension.kt index c0ce1217d94..3919a320e81 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extension.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extension.kt @@ -2,5 +2,5 @@ class A fun box(): String { fun A.foo() = "OK" - return A().(A::foo)() + return (A::foo)(A()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToLocalClass.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToLocalClass.kt index 781d8096ea0..43537f177e9 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToLocalClass.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToLocalClass.kt @@ -1,5 +1,5 @@ fun box(): String { class A fun A.foo() = "OK" - return (::A)().(A::foo)() + return (A::foo)((::A)()) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToPrimitive.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToPrimitive.kt index f8db384261a..9cb84f4df07 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToPrimitive.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionToPrimitive.kt @@ -1,4 +1,4 @@ fun box(): String { fun Int.is42With(that: Int) = this + 2 * that == 42 - return if (16.(Int::is42With)(13)) "OK" else "Fail" + return if ((Int::is42With)(16, 13)) "OK" else "Fail" } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionWithClosure.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionWithClosure.kt index a3e02eef8de..cbbbcd219b1 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionWithClosure.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/extensionWithClosure.kt @@ -6,6 +6,6 @@ fun box(): String { fun A.ext() { result = "OK" } val f = A::ext - A().f() + f(A()) return result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/genericMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/genericMember.kt index ad0db326cd9..12e60f50480 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/genericMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/genericMember.kt @@ -4,5 +4,5 @@ fun box(): String { } val ref = Id::invoke - return Id().ref("OK") + return ref(Id(), "OK") } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/localClassMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/localClassMember.kt index abe1c70a0bd..98f62fb5b40 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/localClassMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/local/localClassMember.kt @@ -7,5 +7,5 @@ fun box(): String { val member = Local::foo val instance = Local() - return instance.member() + return member(instance) } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt index 35d45d87c65..15191f36579 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitNoArgs.kt @@ -8,6 +8,6 @@ object A { fun box(): String { val x = A::foo - A.x() + x(A) return A.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt index 1598361da6a..fe7f8a41b7f 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/objectMemberUnitOneStringArg.kt @@ -8,6 +8,6 @@ object A { fun box(): String { val x = A::foo - A.x("OK") + x(A, "OK") return A.result } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt index 1b7ffe85906..c796995fc67 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/privateClassMember.kt @@ -1,7 +1,7 @@ class A { private fun foo() = "OK" - fun bar() = this.(::foo)() + fun bar() = (::foo)(this) } fun box() = A().bar() diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt index b47561d9d03..51923a24746 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitImplMethodWithClassReceiver.kt @@ -4,7 +4,7 @@ interface T { class B : T { inner class C { - fun bar() = this@B.(::foo)() + fun bar() = (::foo)(this@B) } } diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitMember.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitMember.kt index 619220ff65f..88cf738eaa7 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitMember.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/function/traitMember.kt @@ -6,4 +6,4 @@ class B : A { override fun foo() = "OK" } -fun box() = B().(A::foo)() +fun box() = (A::foo)(B()) diff --git a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt b/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt index a0f350cafc5..a02509760fb 100644 --- a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt +++ b/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt @@ -28,15 +28,15 @@ object A { } fun box(): String { - if (A.(A::test1)() != "OK") return "fail 1" + if ((A::test1)(A) != "OK") return "fail 1" - if (A.(A::test2)() != "OK") return "fail 2" + if ((A::test2)(A) != "OK") return "fail 2" - if (A.(A::test3)() != "1OK") return "fail 3" + if ((A::test3)(A) != "1OK") return "fail 3" - if (A.(A::test4)() != "1OK") return "fail 4" + if ((A::test4)(A) != "1OK") return "fail 4" if (((A::c).get(A)) != "OK") return "fail 5" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/bytecodeText/directInvoke/callableReference.kt b/compiler/testData/codegen/bytecodeText/directInvoke/callableReference.kt index 1a4f2bf1324..dd9fd0af1bd 100644 --- a/compiler/testData/codegen/bytecodeText/directInvoke/callableReference.kt +++ b/compiler/testData/codegen/bytecodeText/directInvoke/callableReference.kt @@ -3,8 +3,8 @@ class Z{ fun a(s: Int) {} fun b() { - Z().(Z::a)(1) + (Z::a)(Z(), 1) } } -// 1 invoke \(LZ;I\)V \ No newline at end of file +// 1 invoke \(LZ;I\)V diff --git a/compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.kt b/compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.kt index 6e62db4637a..76c0a667973 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/callableRefrenceOnNestedObject.kt @@ -5,5 +5,5 @@ open class A { } fun test() { - A.B.(A::foo)() -} \ No newline at end of file + (A::foo)(A.B) +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt index 593a279e949..1d0c327455f 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageClass.kt @@ -22,7 +22,7 @@ fun main() { val y = first.A::bar val z = A::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt index 96b8072ed12..6b26e8a0b3b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/differentPackageExtension.kt @@ -14,7 +14,7 @@ fun A.baz() {} package other -import kotlin.reflect.KExtensionFunction0 +import kotlin.reflect.KFunction1 import first.A import first.foo @@ -24,5 +24,5 @@ fun main() { first.A::bar A::baz - checkSubtype>(x) -} \ No newline at end of file + checkSubtype>(x) +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt index 7429eb453e2..273919e3ed7 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromClass.kt @@ -8,9 +8,9 @@ class A { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt index a6d251a97ed..7c7a7ea2b2b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtension.kt @@ -9,9 +9,9 @@ fun A.main() { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } fun A.foo() {} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt index b45cfba2230..b0b4893a4c7 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromExtensionInClass.kt @@ -10,9 +10,9 @@ class A { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt index f19de82cb9a..3d69d34d670 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionFromTopLevel.kt @@ -13,11 +13,11 @@ fun main() { val y = A::bar val z = A::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.kt b/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.kt index aa4f0ba464a..5434e7241ab 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.kt @@ -8,5 +8,5 @@ class A { fun A?.foo() {} -val f: KMemberFunction0 = A::foo -val g: KExtensionFunction0 = A?::foo +val f: KFunction1 = A::foo +val g: KFunction1 = A?::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.txt b/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.txt index 4fc98ce4243..7db185b8dcc 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.txt +++ b/compiler/testData/diagnostics/tests/callableReference/function/extensionOnNullable.txt @@ -1,7 +1,7 @@ package -internal val f: kotlin.reflect.KMemberFunction0 -internal val g: kotlin.reflect.KExtensionFunction0 +internal val f: kotlin.reflect.KFunction1 +internal val g: kotlin.reflect.KFunction1 internal fun A?.foo(): kotlin.Unit internal final class A { diff --git a/compiler/testData/diagnostics/tests/callableReference/function/genericClassFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/genericClassFromTopLevel.kt index 17447b9cc58..4127983d232 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/genericClassFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/genericClassFromTopLevel.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 class A(val t: T) { fun foo(): T = t @@ -9,5 +9,5 @@ class A(val t: T) { fun bar() { val x = A::foo - checkSubtype, String>>(x) + checkSubtype, String>>(x) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt index 8d1a6dce2eb..62e6ab9194d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromClass.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 class A { inner class Inner @@ -9,8 +9,8 @@ class A { val x = ::Inner val y = A::Inner - checkSubtype>(x) - checkSubtype>(y) + checkSubtype>(x) + checkSubtype>(y) } companion object { @@ -18,7 +18,7 @@ class A { ::Inner val y = A::Inner - checkSubtype>(y) + checkSubtype>(y) } } } @@ -28,6 +28,6 @@ class B { ::Inner val y = A::Inner - checkSubtype>(y) + checkSubtype>(y) } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt index c89325b538e..b23bcdf370d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromExtension.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 class A { inner class Inner @@ -10,13 +10,13 @@ fun A.main() { val x = ::Inner val y = A::Inner - checkSubtype>(x) - checkSubtype>(y) + checkSubtype>(x) + checkSubtype>(y) } fun Int.main() { ::Inner val y = A::Inner - checkSubtype>(y) -} \ No newline at end of file + checkSubtype>(y) +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromTopLevel.kt index ad744c2c321..b606d6dbd27 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/innerConstructorFromTopLevel.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE // !DIAGNOSTICS: -UNUSED_EXPRESSION -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 class A { inner class Inner @@ -10,5 +10,5 @@ fun main() { ::Inner val y = A::Inner - checkSubtype>(y) -} \ No newline at end of file + checkSubtype>(y) +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedName.kt b/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedName.kt index bade88299a3..143296f288d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedName.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedName.kt @@ -9,10 +9,10 @@ class D { // FILE: b.kt -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 fun main() { val x = a.b.c.D::foo - checkSubtype>(x) + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedNameGeneric.kt b/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedNameGeneric.kt index 4fdbc8db48a..755f7118aee 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedNameGeneric.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/longQualifiedNameGeneric.kt @@ -9,10 +9,10 @@ class D { // FILE: b.kt -import kotlin.reflect.KMemberFunction2 +import kotlin.reflect.KFunction3 fun main() { val x = a.b.c.D::foo - checkSubtype, String, Int, a.b.c.D>>(x) + checkSubtype, String, Int, a.b.c.D>>(x) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt index da7cdb14875..908e073857b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/memberFromClass.kt @@ -12,8 +12,8 @@ class A { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt index 307e5edcdd2..045edb34120 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtension.kt @@ -13,7 +13,7 @@ fun A.main() { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt index 90b04455703..5789a95e8af 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/memberFromExtensionInClass.kt @@ -14,8 +14,8 @@ class B { val y = ::bar val z = ::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.kt index 4a5a9399be4..68705bf7cbf 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/memberFromTopLevel.kt @@ -13,11 +13,11 @@ fun main() { val y = A::bar val z = A::baz - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt index 773833fcc44..f8cbe71c6b2 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 class A { fun foo() = 42 @@ -11,5 +11,5 @@ fun A.foo() {} fun main() { val x = A::foo - checkSubtype>(x) + checkSubtype>(x) } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt index 542a48f4ffa..6424f6c7f19 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsTopLevel.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberFunction0 +import kotlin.reflect.KFunction1 fun foo() {} @@ -10,6 +10,6 @@ class A { fun main() { val x = ::foo - checkSubtype>(x) + checkSubtype>(x) } } diff --git a/compiler/testData/diagnostics/tests/callableReference/function/renameOnImport.kt b/compiler/testData/diagnostics/tests/callableReference/function/renameOnImport.kt index 287fe53908a..0d7c73d8a06 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/renameOnImport.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/renameOnImport.kt @@ -25,6 +25,6 @@ fun main() { val z = AA::bazbaz checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(y) + checkSubtype>(z) } diff --git a/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt index 1a6a2ce718b..23441709f8e 100644 --- a/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt +++ b/compiler/testData/diagnostics/tests/deprecated/functionUsage.txt @@ -5,7 +5,7 @@ internal fun block(): kotlin.Unit internal fun expression(): UsefulClass internal fun invoker(): kotlin.Unit internal fun reflection(): kotlin.reflect.KFunction1 -internal fun reflection2(): kotlin.reflect.KMemberFunction0 +internal fun reflection2(): kotlin.reflect.KFunction1 kotlin.deprecated(value = "does nothing good") internal fun kotlin.Any.doNothing(): kotlin.String internal final class Delegation { diff --git a/core/builtins/src/kotlin/reflect/KExtensionFunction.kt b/core/builtins/src/kotlin/reflect/KExtensionFunction.kt deleted file mode 100644 index d2b861e14e7..00000000000 --- a/core/builtins/src/kotlin/reflect/KExtensionFunction.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents an extension function. - * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/extensions.html#extension-functions) - * for more information. - * - * @param E the type of the extension receiver. - * @param R the return type of the function. - */ -public interface KExtensionFunction : KFunction diff --git a/core/builtins/src/kotlin/reflect/KLocalFunction.kt b/core/builtins/src/kotlin/reflect/KLocalFunction.kt deleted file mode 100644 index 31a9aae20ee..00000000000 --- a/core/builtins/src/kotlin/reflect/KLocalFunction.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a local function. - * - * @param R the return type of the function. - */ -public interface KLocalFunction : KFunction diff --git a/core/builtins/src/kotlin/reflect/KMemberFunction.kt b/core/builtins/src/kotlin/reflect/KMemberFunction.kt deleted file mode 100644 index 70a1c36faef..00000000000 --- a/core/builtins/src/kotlin/reflect/KMemberFunction.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a member function. - * - * @param T the type of the instance which should be used to call the function. - * Must be derived either from a class declaring this function, or any subclass of that class. - * @param R the return type of the function. - */ -public interface KMemberFunction : KFunction diff --git a/core/builtins/src/kotlin/reflect/KTopLevelExtensionFunction.kt b/core/builtins/src/kotlin/reflect/KTopLevelExtensionFunction.kt deleted file mode 100644 index 133b1bb61d8..00000000000 --- a/core/builtins/src/kotlin/reflect/KTopLevelExtensionFunction.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents an extension function declared in a package. - * - * @param E the type of the extension receiver. - * @param R the return type of the function. - */ -public interface KTopLevelExtensionFunction : KExtensionFunction diff --git a/core/builtins/src/kotlin/reflect/KTopLevelFunction.kt b/core/builtins/src/kotlin/reflect/KTopLevelFunction.kt deleted file mode 100644 index 2f0d18f09bf..00000000000 --- a/core/builtins/src/kotlin/reflect/KTopLevelFunction.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a function declared in a package. - */ -public interface KTopLevelFunction : KFunction diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java index fee5cb32198..f60e27cb0e5 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/platform/JavaToKotlinClassMap.java @@ -80,10 +80,9 @@ public class JavaToKotlinClassMap implements PlatformToKotlinClassMap { for (int i = 0; i < 23; i++) { add(ClassId.topLevel(new FqName("kotlin.jvm.functions.Function" + i)), builtIns.getFunction(i)); - for (FunctionClassDescriptor.Kind kind : FunctionClassDescriptor.Kinds.KFunctions) { - String kFun = kind.getPackageFqName() + "." + kind.getClassNamePrefix(); - addKotlinToJava(new FqNameUnsafe(kFun + i), ClassId.topLevel(new FqName(kFun))); - } + FunctionClassDescriptor.Kind kFunction = FunctionClassDescriptor.Kind.KFunction; + String kFun = kFunction.getPackageFqName() + "." + kFunction.getClassNamePrefix(); + addKotlinToJava(new FqNameUnsafe(kFun + i), ClassId.topLevel(new FqName(kFun))); } addJavaToKotlin(classId(Deprecated.class), builtIns.getDeprecatedAnnotation()); diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index c3e81262a4c..71539e305b8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -48,8 +48,6 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { } public fun getKFunction(n: Int): ClassDescriptor = find("KFunction$n") - public fun getKExtensionFunction(n: Int): ClassDescriptor = find("KExtensionFunction$n") - public fun getKMemberFunction(n: Int): ClassDescriptor = find("KMemberFunction$n") public val kClass: ClassDescriptor by ClassLookup public val kTopLevelVariable: ClassDescriptor by ClassLookup @@ -73,20 +71,16 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { annotations: Annotations, receiverType: JetType?, parameterTypes: List, - returnType: JetType, - extensionFunction: Boolean + returnType: JetType ): JetType { - val arity = parameterTypes.size() - val classDescriptor = - if (extensionFunction) getKExtensionFunction(arity) - else if (receiverType != null) getKMemberFunction(arity) - else getKFunction(arity) + val arguments = KotlinBuiltIns.getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType) + + val classDescriptor = getKFunction(arguments.size() - 1 /* return type */) if (ErrorUtils.isError(classDescriptor)) { return classDescriptor.getDefaultType() } - val arguments = KotlinBuiltIns.getFunctionTypeArgumentProjections(receiverType, parameterTypes, returnType) return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments)) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt index 14208047b9e..be111eb74b8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.storage.StorageManager import kotlin.platform.platformStatic /** - * Produces descriptors representing the fictitious classes for function types, such as kotlin.Function1 or kotlin.reflect.KMemberFunction0. + * Produces descriptors representing the fictitious classes for function types, such as kotlin.Function1 or kotlin.reflect.KFunction2. */ public class BuiltInFictitiousFunctionClassFactory( private val storageManager: StorageManager, @@ -37,17 +37,15 @@ public class BuiltInFictitiousFunctionClassFactory( companion object { platformStatic public fun parseClassName(className: String, packageFqName: FqName): KindWithArity? { - for (kind in FunctionClassDescriptor.Kinds.byPackage(packageFqName)) { - val prefix = kind.classNamePrefix - if (!className.startsWith(prefix)) continue + val kind = FunctionClassDescriptor.Kind.byPackage(packageFqName) ?: return null - val arity = toInt(className.substring(prefix.length())) ?: continue + val prefix = kind.classNamePrefix + if (!className.startsWith(prefix)) return null - // TODO: validate arity, should be <= 255 for functions, <= 254 for members/extensions - return KindWithArity(kind, arity) - } + val arity = toInt(className.substring(prefix.length())) ?: return null - return null + // TODO: validate arity, should be <= 255 + return KindWithArity(kind, arity) } private fun toInt(s: String): Int? { @@ -70,8 +68,7 @@ public class BuiltInFictitiousFunctionClassFactory( if ("Function" !in className) return null // An optimization val packageFqName = classId.getPackageFqName() - val kindWithArity = parseClassName(className, packageFqName) ?: return null - val (kind, arity) = kindWithArity // KT-5100 + val (kind, arity) = parseClassName(className, packageFqName) ?: return null val containingPackageFragment = module.getPackage(packageFqName).fragments.single() diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 8708c36cdac..9ca51bc7e48 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -17,12 +17,10 @@ package org.jetbrains.kotlin.builtins.functions import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor.Kind import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl import org.jetbrains.kotlin.descriptors.impl.AbstractClassDescriptor import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl import org.jetbrains.kotlin.name.FqName @@ -32,18 +30,14 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.ArrayList -import java.util.EnumSet /** - * A [ClassDescriptor] representing the fictitious class for a function type, such as kotlin.Function1 or kotlin.reflect.KMemberFunction0. + * A [ClassDescriptor] representing the fictitious class for a function type, such as kotlin.Function1 or kotlin.reflect.KFunction2. * - * Classes which are represented by this descriptor include (with supertypes): + * If the class represents kotlin.Function1, its only supertype is kotlin.Function. * - * Function1 : Function - * KFunction1 : Function1, KFunction - * KMemberFunction1 : Function2, KMemberFunction - * KExtensionFunction1 : Function2, KExtensionFunction - * (TODO) KMemberExtensionFunction1 : Function3, KMemberExtensionFunction + * If the class represents kotlin.reflect.KFunction1, it has two supertypes: kotlin.Function1 and kotlin.reflect.KFunction. + * This allows to use both 'invoke' and reflection API on function references obtained by '::'. */ public class FunctionClassDescriptor( private val storageManager: StorageManager, @@ -54,24 +48,16 @@ public class FunctionClassDescriptor( public enum class Kind(val packageFqName: FqName, val classNamePrefix: String) { Function(BUILT_INS_PACKAGE_FQ_NAME, "Function"), - KFunction(KOTLIN_REFLECT_FQ_NAME, "KFunction"), - KMemberFunction(KOTLIN_REFLECT_FQ_NAME, "KMemberFunction"), - KExtensionFunction(KOTLIN_REFLECT_FQ_NAME, "KExtensionFunction"); - // TODO: KMemberExtensionFunction + KFunction(KOTLIN_REFLECT_FQ_NAME, "KFunction"); fun numberedClassName(arity: Int) = Name.identifier("$classNamePrefix$arity") - val hasDispatchReceiver: Boolean get() = this == KMemberFunction - val hasExtensionReceiver: Boolean get() = this == KExtensionFunction - } - public object Kinds { - val Functions = EnumSet.of(Kind.Function) - val KFunctions = EnumSet.complementOf(Functions) - - fun byPackage(fqName: FqName) = when (fqName) { - BUILT_INS_PACKAGE_FQ_NAME -> Functions - KOTLIN_REFLECT_FQ_NAME -> KFunctions - else -> error(fqName) + companion object { + fun byPackage(fqName: FqName) = when (fqName) { + BUILT_INS_PACKAGE_FQ_NAME -> Function + KOTLIN_REFLECT_FQ_NAME -> KFunction + else -> null + } } } @@ -110,13 +96,6 @@ public class FunctionClassDescriptor( )) } - if (functionKind.hasDispatchReceiver) { - typeParameter(Variance.IN_VARIANCE, "T") - } - if (functionKind.hasExtensionReceiver) { - typeParameter(Variance.IN_VARIANCE, "E") - } - (1..arity).map { i -> typeParameter(Variance.IN_VARIANCE, "P$i") } @@ -129,48 +108,29 @@ public class FunctionClassDescriptor( private val supertypes = storageManager.createLazyValue { val result = ArrayList(2) - fun add( - packageFragment: PackageFragmentDescriptor, - name: Name, - annotations: Annotations, - supertypeArguments: (superParameters: List) -> List - ) { + fun add(packageFragment: PackageFragmentDescriptor, name: Name) { val descriptor = packageFragment.getMemberScope().getClassifier(name) as? ClassDescriptor ?: error("Class $name not found in $packageFragment") val typeConstructor = descriptor.getTypeConstructor() - val arguments = supertypeArguments(typeConstructor.getParameters()) - result.add(JetTypeImpl(annotations, typeConstructor, false, arguments, descriptor.getMemberScope(arguments))) + // Substitute all type parameters of the super class with our last type parameters + val arguments = getParameters().takeLast(typeConstructor.getParameters().size()).map { + TypeProjectionImpl(it.getDefaultType()) + } + + result.add(JetTypeImpl(Annotations.EMPTY, typeConstructor, false, arguments, descriptor.getMemberScope(arguments))) } - // Add unnumbered base class, e.g. KMemberFunction for KMemberFunction5, or Function for Function0 - add(containingDeclaration, Name.identifier(functionKind.classNamePrefix), Annotations.EMPTY) { superParameters -> - // Substitute type parameters of the super class with our type parameters with the same names - val parametersByName = getParameters().toMap { it.getName() } - superParameters.map { TypeProjectionImpl(parametersByName[it.getName()]!!.getDefaultType()) } - } - - // For K*Functions, add corresponding numbered Function class, e.g. Function2 for KMemberFunction1 - if (functionKind in Kinds.KFunctions) { - var functionArity = arity - if (functionKind.hasDispatchReceiver) functionArity++ - if (functionKind.hasExtensionReceiver) functionArity++ + // Add unnumbered base class, e.g. Function for Function{n}, KFunction for KFunction{n} + add(containingDeclaration, Name.identifier(functionKind.classNamePrefix)) + // For KFunction{n}, add corresponding numbered Function{n} class, e.g. Function2 for KFunction2 + if (functionKind == Kind.KFunction) { val module = containingDeclaration.getContainingDeclaration() val kotlinPackageFragment = module.getPackage(BUILT_INS_PACKAGE_FQ_NAME).fragments.single() - // If this is a KMemberFunction{n} or KExtensionFunction{n}, it extends Function{n} with the annotation kotlin.extension, - // so that the value of this type is callable as an extension function, with the receiver before the dot - val annotations = - if (functionKind.hasDispatchReceiver || functionKind.hasExtensionReceiver) - AnnotationsImpl(listOf(KotlinBuiltIns.getInstance().createExtensionAnnotation())) - else Annotations.EMPTY - - add(kotlinPackageFragment, Kind.Function.numberedClassName(functionArity), annotations) { - // Substitute all type parameters of the super class with all our type parameters - getParameters().map { TypeProjectionImpl(it.getDefaultType()) } - } + add(kotlinPackageFragment, Kind.Function.numberedClassName(arity)) } result.toReadOnlyList() diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionFromReferenceImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionFromReferenceImpl.kt new file mode 100644 index 00000000000..ede7ae70e58 --- /dev/null +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionFromReferenceImpl.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect.jvm.internal + +import org.jetbrains.kotlin.resolve.scopes.JetScope +import kotlin.jvm.internal.FunctionReference +import kotlin.reflect.KotlinReflectionInternalError + +class KFunctionFromReferenceImpl( + val reference: FunctionReference +): KFunctionImpl( + reference.getOwner() as? KCallableContainerImpl ?: EmptyContainerForLocal, + reference.getName(), + reference.getSignature() +) { + override fun getArity() = reference.getArity() + + override val name = reference.getName() + + // The rest of the class is auto-generated. Use the following script: + // (0..22).forEach { n -> println("override fun invoke(" + (1..n).joinToString { "p$it: Any?" } + "): Any? = reference(" + (1..n).joinToString { "p$it" } + ")") } + override fun invoke(): Any? = reference() + override fun invoke(p1: Any?): Any? = reference(p1) + override fun invoke(p1: Any?, p2: Any?): Any? = reference(p1, p2) + override fun invoke(p1: Any?, p2: Any?, p3: Any?): Any? = reference(p1, p2, p3) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?): Any? = reference(p1, p2, p3, p4) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?): Any? = reference(p1, p2, p3, p4, p5) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?): Any? = reference(p1, p2, p3, p4, p5, p6) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, p20: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, p20: Any?, p21: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21) + override fun invoke(p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?, p8: Any?, p9: Any?, p10: Any?, p11: Any?, p12: Any?, p13: Any?, p14: Any?, p15: Any?, p16: Any?, p17: Any?, p18: Any?, p19: Any?, p20: Any?, p21: Any?, p22: Any?): Any? = reference(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22) +} + +object EmptyContainerForLocal : KCallableContainerImpl() { + override val jClass: Class<*> + get() = fail() + + override val scope: JetScope + get() = fail() + + private fun fail() = throw KotlinReflectionInternalError("Introspecting local functions is not yet supported in Kotlin reflection") +} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt index 7304bbb3239..69d3ad41ad9 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import kotlin.jvm.internal.FunctionImpl import kotlin.reflect.KFunction -abstract class KFunctionImpl private constructor( +open class KFunctionImpl protected constructor( container: KCallableContainerImpl, name: String, signature: String, diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java index 6aab0752308..239a77fa24e 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java @@ -44,7 +44,7 @@ public class ReflectionFactoryImpl extends ReflectionFactory { @Override public KFunction function(FunctionReference f) { - return new KTopLevelFreeFunctionImpl((KPackageImpl) f.getOwner(), f.getName(), f.getSignature()); + return new KFunctionFromReferenceImpl(f); } // Properties diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt deleted file mode 100644 index bafd1a4f11f..00000000000 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/kFunctionImplementations.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect.jvm.internal - -import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import kotlin.reflect.KTopLevelFunction - -class KTopLevelFreeFunctionImpl : KFunctionImpl, KTopLevelFunction { - constructor(container: KPackageImpl, name: String, signature: String): super(container, name, signature) - - constructor(container: KPackageImpl, descriptor: FunctionDescriptor): super(container, descriptor) -} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java index 2503e3da797..8b7511305d7 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java @@ -17,14 +17,10 @@ package kotlin.jvm.internal; import kotlin.jvm.KotlinReflectionNotSupportedError; -import kotlin.reflect.*; +import kotlin.reflect.KDeclarationContainer; +import kotlin.reflect.KFunction; -public class FunctionReference - extends FunctionImpl - implements KTopLevelFunction, - KMemberFunction, - KTopLevelExtensionFunction, - KLocalFunction { +public class FunctionReference extends FunctionImpl implements KFunction { private final int arity; public FunctionReference(int arity) { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java index 60efbcdfdb0..efc5855e43c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/FunctionCallableReferenceTest.java @@ -122,7 +122,7 @@ public final class FunctionCallableReferenceTest extends AbstractCallableReferen checkFooBoxIsOk(); } - public void testClassMemberAndExtensionCompatibility() throws Exception { + public void testClassMemberAndNonExtensionCompatibility() throws Exception { checkFooBoxIsOk(); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt index 78fc93659fc..0261621774c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/FunctionCallCases.kt @@ -173,9 +173,7 @@ object InvokeIntrinsic : FunctionCallCase { funDeclaration == callableDescriptor.builtIns.getFunction(parameterCount) || funDeclaration == reflectionTypes.getKFunction(parameterCount) else - funDeclaration == callableDescriptor.builtIns.getExtensionFunction(parameterCount) || - funDeclaration == reflectionTypes.getKExtensionFunction(parameterCount) || - funDeclaration == reflectionTypes.getKMemberFunction(parameterCount) + funDeclaration == callableDescriptor.builtIns.getExtensionFunction(parameterCount) } override fun FunctionCallInfo.dispatchReceiver(): JsExpression { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java index 0128e3a84f2..b547e8a96bc 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/Namer.java @@ -17,8 +17,8 @@ package org.jetbrains.kotlin.js.translate.context; import com.google.dart.compiler.backend.js.ast.*; -import com.google.dart.compiler.backend.js.ast.metadata.TypeCheck; import com.google.dart.compiler.backend.js.ast.metadata.MetadataPackage; +import com.google.dart.compiler.backend.js.ast.metadata.TypeCheck; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; @@ -71,6 +71,7 @@ public final class Namer { private static final String OBJECT_OBJECT_NAME = "createObject"; private static final String CALLABLE_REF_FOR_MEMBER_FUNCTION_NAME = "getCallableRefForMemberFunction"; private static final String CALLABLE_REF_FOR_EXTENSION_FUNCTION_NAME = "getCallableRefForExtensionFunction"; + private static final String CALLABLE_REF_FOR_LOCAL_EXTENSION_FUNCTION_NAME = "getCallableRefForLocalExtensionFunction"; private static final String CALLABLE_REF_FOR_CONSTRUCTOR_NAME = "getCallableRefForConstructor"; private static final String CALLABLE_REF_FOR_TOP_LEVEL_PROPERTY = "getCallableRefForTopLevelProperty"; private static final String CALLABLE_REF_FOR_MEMBER_PROPERTY = "getCallableRefForMemberProperty"; @@ -261,6 +262,8 @@ public final class Namer { @NotNull private final JsName callableRefForExtensionFunctionName; @NotNull + private final JsName callableRefForLocalExtensionFunctionName; + @NotNull private final JsName callableRefForConstructorName; @NotNull private final JsName callableRefForTopLevelProperty; @@ -295,6 +298,7 @@ public final class Namer { objectName = kotlinScope.declareName(OBJECT_OBJECT_NAME); callableRefForMemberFunctionName = kotlinScope.declareName(CALLABLE_REF_FOR_MEMBER_FUNCTION_NAME); callableRefForExtensionFunctionName = kotlinScope.declareName(CALLABLE_REF_FOR_EXTENSION_FUNCTION_NAME); + callableRefForLocalExtensionFunctionName = kotlinScope.declareName(CALLABLE_REF_FOR_LOCAL_EXTENSION_FUNCTION_NAME); callableRefForConstructorName = kotlinScope.declareName(CALLABLE_REF_FOR_CONSTRUCTOR_NAME); callableRefForTopLevelProperty = kotlinScope.declareName(CALLABLE_REF_FOR_TOP_LEVEL_PROPERTY); callableRefForMemberProperty = kotlinScope.declareName(CALLABLE_REF_FOR_MEMBER_PROPERTY); @@ -344,6 +348,11 @@ public final class Namer { return kotlin(callableRefForExtensionFunctionName); } + @NotNull + public JsExpression callableRefForLocalExtensionFunctionReference() { + return kotlin(callableRefForLocalExtensionFunctionName); + } + @NotNull public JsExpression callableRefForConstructorReference() { return kotlin(callableRefForConstructorName); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt index 05541d35f27..bfc9d85fda0 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt @@ -130,15 +130,18 @@ object CallableReferenceTranslator { assert(receiverParameterDescriptor != null, "receiverParameter for extension should not be null") val jsFunctionRef = ReferenceTranslator.translateAsFQReference(descriptor, context) - if (descriptor.getVisibility() == Visibilities.LOCAL) - return jsFunctionRef + if (descriptor.getVisibility() == Visibilities.LOCAL) { + return JsInvocation(context.namer().callableRefForLocalExtensionFunctionReference(), jsFunctionRef) + } + else if (AnnotationsUtils.isNativeObject(descriptor)) { val jetType = receiverParameterDescriptor!!.getType() val receiverClassDescriptor = DescriptorUtils.getClassDescriptorForType(jetType) return translateAsMemberFunctionReference(descriptor, receiverClassDescriptor, context) } - else + else { return JsInvocation(context.namer().callableRefForExtensionFunctionReference(), jsFunctionRef) + } } private fun translateForMemberFunction(descriptor: FunctionDescriptor, context: TranslationContext): JsExpression { diff --git a/js/js.translator/testData/callableReference/function/cases/abstractClassMember.kt b/js/js.translator/testData/callableReference/function/cases/abstractClassMember.kt index e9a395ff2d1..d06c57e9ea9 100644 --- a/js/js.translator/testData/callableReference/function/cases/abstractClassMember.kt +++ b/js/js.translator/testData/callableReference/function/cases/abstractClassMember.kt @@ -9,4 +9,4 @@ class B : A() { override fun foo() = "OK" } -fun box(): String = B().(A::foo)() +fun box(): String = (A::foo)(B()) diff --git a/js/js.translator/testData/callableReference/function/cases/booleanNotIntrinsic.kt b/js/js.translator/testData/callableReference/function/cases/booleanNotIntrinsic.kt index e08772611c0..1366015c246 100644 --- a/js/js.translator/testData/callableReference/function/cases/booleanNotIntrinsic.kt +++ b/js/js.translator/testData/callableReference/function/cases/booleanNotIntrinsic.kt @@ -2,7 +2,7 @@ package foo fun box(): String { - if (true.(Boolean::not)() != false) return "Fail 1" - if (false.(Boolean::not)() != true) return "Fail 2" + if ((Boolean::not)(true) != false) return "Fail 1" + if ((Boolean::not)(false) != true) return "Fail 2" return "OK" } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberAndExtension.kt b/js/js.translator/testData/callableReference/function/cases/classMemberAndExtension.kt index e3297fc6d7e..bcf27dd2b3c 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberAndExtension.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberAndExtension.kt @@ -12,14 +12,14 @@ fun box():String { val a = A() - var r = a.(A::memBar)("!!") + var r = (A::memBar)(a, "!!") if (r != "sA:memBar:!!") return r - r = a.(A::extBar)("!!") + r = (A::extBar)(a, "!!") if (r != "sA:extBar:!!") return r - r = a.(A::locExtBar)("!!") + r = (A::locExtBar)(a, "!!") if (r != "sA:locExtBar:!!") return r return "OK" -} \ No newline at end of file +} diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberAndExtensionCompatibility.kt b/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt similarity index 75% rename from js/js.translator/testData/callableReference/function/cases/classMemberAndExtensionCompatibility.kt rename to js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt index da9091f4f2d..9bb628371d3 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberAndExtensionCompatibility.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberAndNonExtensionCompatibility.kt @@ -1,7 +1,7 @@ package foo -fun run(a: A, arg: String, funRef:A.(String) -> String): String { - return a.(funRef)(arg) +fun run(a: A, arg: String, funRef:(A, String) -> String): String { + return funRef(a, arg) } class A { @@ -25,8 +25,8 @@ fun box():String { r = run(a, "!!", A::locExtBar) if (r != "sA:locExtBar:!!") return r - r = run(a, "!!") {A.(other:String):String -> s + ":literal:" + other } + r = run(a, "!!") {(a: A, other: String): String -> a.s + ":literal:" + other } if (r != "sA:literal:!!") return r return "OK" -} \ No newline at end of file +} diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt index 437d60f1b74..6ccd9aba4f6 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromClass.kt @@ -4,7 +4,7 @@ package foo class A { fun bar(k: Int) = k - fun result() = this.(::bar)(111) + fun result() = (::bar)(this, 111) } fun box(): String { diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt index 3320e69657e..4355161af61 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromExtension.kt @@ -6,7 +6,7 @@ class A { fun k(k: Int) = k } -fun A.bar() = this.(::o)() + this.(A::k)(222) +fun A.bar() = (::o)(this) + (A::k)(this, 222) fun box(): String { val result = A().bar() diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringNoArgs.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringNoArgs.kt index 88c380b34e3..324b957b0af 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringNoArgs.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringNoArgs.kt @@ -1,22 +1,12 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, funRef:A.() -> String): String { - return arg1.funRef() -} - class A { fun foo() = "OK" } fun box(): String { val x = A::foo - var r = A().x() - if (r != "OK") return r - - r = run(A(), A::foo) - if (r != "OK") return r - - return "OK" + var r = x(A()) + return r } - diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringOneStringArg.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringOneStringArg.kt index d38f4139e12..23c5409bd29 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringOneStringArg.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelStringOneStringArg.kt @@ -1,21 +1,13 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, arg2: String, funRef:A.(String) -> String): String { - return arg1.funRef(arg2) -} - class A { fun foo(result: String):String = result } fun box(): String { val x = A::foo - var r = A().x("OK") + var r = x(A(), "OK") - if (r != "OK") return r - - r = run(A(), "OK", A::foo) - if (r != "OK") return r - return "OK" + return r } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitNoArgs.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitNoArgs.kt index b9305e91102..a10c1899391 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitNoArgs.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitNoArgs.kt @@ -1,10 +1,6 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, funRef:A.() -> Unit): Unit { - return arg1.funRef() -} - class A { var result = "Fail" @@ -16,14 +12,6 @@ class A { fun box(): String { val a = A() val x = A::foo - a.x() - var r = a.result - if (r != "OK") return r - - val a1 = A() - run(a1, A::foo) - r = a.result - if (r != "OK") return r - - return "OK" + x(a) + return a.result } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitOneStringArg.kt b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitOneStringArg.kt index 4b5bbcc85dd..88c55e2be28 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitOneStringArg.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberFromTopLevelUnitOneStringArg.kt @@ -1,10 +1,6 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, arg2: String, funRef:A.(String) -> Unit): Unit { - return arg1.funRef(arg2) -} - class A { var result = "Fail" @@ -16,14 +12,6 @@ class A { fun box(): String { val a = A() val x = A::foo - a.x("OK") - var r = a.result - if (r != "OK") return r - - val a1 = A() - run(a1, "OK", A::foo) - r = a1.result - if (r != "OK") return r - - return "OK" + x(a, "OK") + return a.result } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberOverridden.kt b/js/js.translator/testData/callableReference/function/cases/classMemberOverridden.kt index b5084c182dd..00fac713bef 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberOverridden.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberOverridden.kt @@ -11,6 +11,6 @@ class B : A() { fun box(): String { val b = B() var ref = A::foo - val result = b.(ref)("1", "2") + val result = ref(b, "1", "2") return (if (result == "fooB:12") "OK" else result) } diff --git a/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt b/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt index ac2a4f3716f..0ad39d5ad91 100644 --- a/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt +++ b/js/js.translator/testData/callableReference/function/cases/classMemberOverriddenInObject.kt @@ -10,6 +10,6 @@ object B : A() { fun box(): String { var ref = B::foo - val result = B.(ref)("1", "2") + val result = ref(B, "1", "2") return (if (result == "fooB:12") "OK" else result) } diff --git a/js/js.translator/testData/callableReference/function/cases/extension.kt b/js/js.translator/testData/callableReference/function/cases/extension.kt index 704a1f0b8c4..ad6c89fab9d 100644 --- a/js/js.translator/testData/callableReference/function/cases/extension.kt +++ b/js/js.translator/testData/callableReference/function/cases/extension.kt @@ -5,5 +5,5 @@ class A fun box(): String { fun A.foo() = "OK" - return A().(A::foo)() + return (A::foo)(A()) } diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt index 03d12c89dc1..80806ebd149 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromClass.kt @@ -2,7 +2,7 @@ package foo class A { - fun result() = this.(::bar)("OK") + fun result() = (::bar)(this, "OK") } fun A.bar(x: String) = x diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromExtension.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromExtension.kt index 39f76b5b8a6..17fab022176 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromExtension.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromExtension.kt @@ -3,7 +3,7 @@ package foo class A -fun A.foo() = this.(A::bar)("OK") +fun A.foo() = (A::bar)(this, "OK") fun A.bar(x: String) = x diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevel.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevel.kt index 01468e38276..797f52eda1d 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevel.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevel.kt @@ -1,8 +1,8 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, arg2: T, funRef:A.(T) -> T): T { - return arg1.funRef(arg2) +fun run(arg1: A, arg2: T, funRef:(A, T) -> T): T { + return funRef(arg1, arg2) } class A { @@ -17,9 +17,9 @@ fun A.bar(x: Int): Int { fun box(): Boolean { val funRef = A::bar val obj = A() - var result = obj.(funRef)(25) + var result = funRef(obj, 25) if (result != 25 || obj.xx != 200) return false result = run(A(), 25, funRef) return result == 25 && obj.xx == 200 -} \ No newline at end of file +} diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringNoArgs.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringNoArgs.kt index 26a597855d3..8b5bcd4e06e 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringNoArgs.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringNoArgs.kt @@ -11,7 +11,7 @@ fun A.foo() = "OK" fun box(): String { val x = A::foo - var r = A().x() + var r = x(A()) if (r != "OK") return r r = run(A(), A::foo) diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringOneStringArg.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringOneStringArg.kt index 3c4d6976e6f..cdcb5d09a0a 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringOneStringArg.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelStringOneStringArg.kt @@ -11,7 +11,7 @@ fun A.foo(result: String) = result fun box(): String { val x = A::foo - var r = A().x("OK") + var r = x(A(), "OK") if (r != "OK") return r r = run(A(), "OK", A::foo) diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitNoArgs.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitNoArgs.kt index 4ca7aa999f6..5feb3ac7d12 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitNoArgs.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitNoArgs.kt @@ -1,10 +1,6 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/function/. package foo -fun run(arg1: A, funRef:A.() -> Unit): Unit { - return arg1.funRef() -} - class A { var result = "Fail" } @@ -16,11 +12,7 @@ fun A.foo() { fun box(): String { val a = A() val x = A::foo - a.x() + x(a) - if (a.result != "OK") return a.result - - val a1 = A() - run(a1, A::foo) return a.result } diff --git a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitOneStringArg.kt b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitOneStringArg.kt index 303595bd7fd..025c997a3db 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitOneStringArg.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionFromTopLevelUnitOneStringArg.kt @@ -16,7 +16,7 @@ fun A.foo(newResult: String) { fun box(): String { val a = A() val x = A::foo - a.x("OK") + x(a, "OK") if (a.result != "OK") return a.result diff --git a/js/js.translator/testData/callableReference/function/cases/extensionToPrimitive.kt b/js/js.translator/testData/callableReference/function/cases/extensionToPrimitive.kt index f4d9ebc8410..d47f70664cf 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionToPrimitive.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionToPrimitive.kt @@ -3,5 +3,5 @@ package foo fun box(): String { fun Int.is42With(that: Int) = this + 2 * that == 42 - return if (16.(Int::is42With)(13)) "OK" else "Fail" + return if ((Int::is42With)(16, 13)) "OK" else "Fail" } diff --git a/js/js.translator/testData/callableReference/function/cases/extensionWithClosure.kt b/js/js.translator/testData/callableReference/function/cases/extensionWithClosure.kt index 03db48e36ae..dc0bf4868f9 100644 --- a/js/js.translator/testData/callableReference/function/cases/extensionWithClosure.kt +++ b/js/js.translator/testData/callableReference/function/cases/extensionWithClosure.kt @@ -9,6 +9,6 @@ fun box(): String { fun A.ext() { result = "OK" } val f = A::ext - A().f() + f(A()) return result } diff --git a/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt b/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt index 49b58d9439d..9ccfd7ef4e1 100644 --- a/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt +++ b/js/js.translator/testData/callableReference/function/cases/localAndTopLevelExtensions.kt @@ -1,6 +1,6 @@ package foo -fun Int.sum0(other: Int): Int = this + other; +fun Int.sum0(other: Int): Int = this + other fun box(): String { fun Int.sum1(other: Int): Int = this + other @@ -13,8 +13,8 @@ fun box(): String { x = x.sum2(5) var y = 10 - y = y.(Int::sum0)(5) - y = y.(Int::sum1)(5) + y = (Int::sum0)(y, 5) + y = (Int::sum1)(y, 5) y = y.sum2(5) var result:String = (if (x == y && x == 25) "OK" else "x=${x} y=${y}") diff --git a/js/js.translator/testData/callableReference/function/cases/stringNativeExtension.kt b/js/js.translator/testData/callableReference/function/cases/stringNativeExtension.kt index 52a1655a976..8153191281f 100644 --- a/js/js.translator/testData/callableReference/function/cases/stringNativeExtension.kt +++ b/js/js.translator/testData/callableReference/function/cases/stringNativeExtension.kt @@ -2,7 +2,7 @@ package foo fun box(): String { var s = "abc" - assertEquals("ABC", s.(String::toUpperCase)()) + assertEquals("ABC", (String::toUpperCase)(s)) return "OK" } diff --git a/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt b/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt index d0f0c2b23ba..5c32ed9f60b 100644 --- a/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt +++ b/js/js.translator/testData/expression/invoke/cases/invokeWithImplicitDispatchReceiverAndExtensionReceiver.kt @@ -3,10 +3,10 @@ package foo fun A.f(s: String) = value + s class A(val value: String) { - fun bar(s: String) = (::f)(s) + fun bar(s: String) = (::f)(this, s) } -fun A.baz(s: String) = (::f)(s) +fun A.baz(s: String) = (::f)(this, s) fun box(): String { val a = A("aaa") diff --git a/js/js.translator/testData/kotlin_lib_ecma5.js b/js/js.translator/testData/kotlin_lib_ecma5.js index fb93b455480..e0c62d82ba2 100644 --- a/js/js.translator/testData/kotlin_lib_ecma5.js +++ b/js/js.translator/testData/kotlin_lib_ecma5.js @@ -337,7 +337,9 @@ var Kotlin = {}; // TODO Store callable references for members in class Kotlin.getCallableRefForMemberFunction = function (klass, memberName) { return function () { - return this[memberName].apply(this, arguments); + var args = [].slice.call(arguments); + var instance = args.shift(); + return instance[memberName].apply(instance, args); }; }; @@ -345,9 +347,15 @@ var Kotlin = {}; // extFun expected receiver as the first argument Kotlin.getCallableRefForExtensionFunction = function (extFun) { return function () { - var args = [this]; - Array.prototype.push.apply(args, arguments); - return extFun.apply(null, args); + return extFun.apply(null, arguments); + }; + }; + + Kotlin.getCallableRefForLocalExtensionFunction = function (extFun) { + return function () { + var args = [].slice.call(arguments); + var instance = args.shift(); + return extFun.apply(instance, args); }; }; diff --git a/js/js.translator/testData/multiPackage/cases/reflectionFromOtherPackage/b.kt b/js/js.translator/testData/multiPackage/cases/reflectionFromOtherPackage/b.kt index cbc31257a28..625ccbd9772 100644 --- a/js/js.translator/testData/multiPackage/cases/reflectionFromOtherPackage/b.kt +++ b/js/js.translator/testData/multiPackage/cases/reflectionFromOtherPackage/b.kt @@ -7,9 +7,9 @@ fun A.ext2(s: String): String = "A.ext2: ${this.v} ${s}" fun box(): Boolean { assertEquals("topLevelFun: A", (::topLevelFun)("A")) - assertEquals("A.ext1: test B", A("test").(A::ext1)("B")) - assertEquals("A.ext2: test B", A("test").(A::ext2)("B")) - assertEquals("memA: test C", A("test").(A::memA)("C")) + assertEquals("A.ext1: test B", (A::ext1)(A("test"), "B")) + assertEquals("A.ext2: test B", (A::ext2)(A("test"), "B")) + assertEquals("memA: test C", (A::memA)(A("test"), "C")) assertEquals(100, ::topLevelVar.get()) ::topLevelVar.set(500) @@ -25,5 +25,5 @@ fun box(): Boolean { (A::extProp).set(a, "new text") assertEquals("new text", (A::extProp).get(a)) - return true; -} \ No newline at end of file + return true +} diff --git a/js/js.translator/testData/native/cases/nativeExtensionLikeMember.kt b/js/js.translator/testData/native/cases/nativeExtensionLikeMember.kt index d088358614c..956da932d1f 100644 --- a/js/js.translator/testData/native/cases/nativeExtensionLikeMember.kt +++ b/js/js.translator/testData/native/cases/nativeExtensionLikeMember.kt @@ -22,8 +22,8 @@ fun box(): String { assertEquals("A.bar A", a.bar()) assertEquals("B.bar B", b.bar()) - assertEquals("A.bar A", a.(A::bar)()) - assertEquals("B.bar B", b.(A::bar)()) + assertEquals("A.bar A", (A::bar)(a)) + assertEquals("B.bar B", (A::bar)(b)) a.prop = "prop" assertEquals("prop", a.prop) @@ -31,10 +31,10 @@ fun box(): String { a = b assertEquals("B.bar B", a.bar()) - assertEquals("B.bar B", a.(A::bar)()) + assertEquals("B.bar B", (A::bar)(a)) assertEquals("B prop", a.prop) assertEquals("B prop", (A::prop).get(a)) - return "OK"; + return "OK" } diff --git a/js/js.translator/testData/native/cases/passMemberOrExtFromNative.kt b/js/js.translator/testData/native/cases/passMemberOrExtFromNative.kt index 8cca0493769..fb70ffbc1b2 100644 --- a/js/js.translator/testData/native/cases/passMemberOrExtFromNative.kt +++ b/js/js.translator/testData/native/cases/passMemberOrExtFromNative.kt @@ -16,13 +16,13 @@ fun box(): String { val a = A("test") assertEquals("A.m test 4 boo", a.m(4, "boo")) - assertEquals("A.m test 4 boo", bar(a, A::m)) + assertEquals("A.m test 4 boo", bar(a, fun A.(i, s) = (A::m)(this, i, s))) assertEquals("nativeExt test 4 boo", a.nativeExt(4, "boo")) - assertEquals("nativeExt test 4 boo", bar(a, A::nativeExt)) + assertEquals("nativeExt test 4 boo", bar(a, fun A.(i, s) = (A::nativeExt)(this, i, s))) assertEquals("nativeExt2 test 4 boo", a.nativeExt2(4, "boo")) - assertEquals("nativeExt2 test 4 boo", bar(a, A::nativeExt2)) + assertEquals("nativeExt2 test 4 boo", bar(a, fun A.(i, s) = (A::nativeExt2)(this, i, s))) return "OK" } diff --git a/js/js.translator/testData/native/cases/passMemberOrExtToNative.kt b/js/js.translator/testData/native/cases/passMemberOrExtToNative.kt index 125a2c5eeed..57c1f0e0e5d 100644 --- a/js/js.translator/testData/native/cases/passMemberOrExtToNative.kt +++ b/js/js.translator/testData/native/cases/passMemberOrExtToNative.kt @@ -21,18 +21,18 @@ fun box(): String { fun A.LocalExt(i:Int, s:String): String = "A::LocalExt ${this.v} $i $s" - r = bar(a, A::topLevelExt) + r = bar(a, fun A.(i, s) = (A::topLevelExt)(this, i, s)) if (r != "A::topLevelExt test 4 boo") return r - r = bar(a, A::LocalExt) + r = bar(a, fun A.(i, s) = (A::LocalExt)(this, i, s)) if (r != "A::LocalExt test 4 boo") return r - r = bar(a, A::m) + r = bar(a, fun A.(i, s) = (A::m)(this, i, s)) if (r != "A.m test 4 boo") return r val b = B("test") - r = bar(b, A::m) + r = bar(b, fun A.(i, s) = (A::m)(this, i, s)) if (r != "B.m test 4 boo") return r return "OK" -} \ No newline at end of file +} From 30794060a91d4f6dac1d16ccc441ca56ea096de2 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 26 Jun 2015 16:40:39 +0300 Subject: [PATCH 224/450] Simplify property hierarchy in reflection Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their mutable analogs, depending on the number of receivers a property takes --- .../kotlin/codegen/ExpressionCodegen.java | 12 +-- .../kotlin/resolve/jvm/AsmTypes.java | 10 +- .../BasicExpressionTypingVisitor.java | 21 ++--- .../reflection/mapping/javaFields.kt | 8 +- .../kotlinPropertyInheritedInJava/K.kt | 8 +- .../property/genericProperty.kt | 8 +- .../kClassInstanceIsInitializedFirst.kt | 4 +- .../property/privateClassVal.kt | 4 +- .../property/privateClassVar.kt | 4 +- .../platformStatic/callableRef.kt | 4 +- .../extensionPropertyReceiverToString.kt | 4 +- .../callPrivatePropertyFromGetProperties.kt | 2 +- ...nericClassLiteralPropertyReceiverIsStar.kt | 5 +- ...getExtensionPropertiesMutableVsReadonly.kt | 8 +- .../getPropertiesMutableVsReadonly.kt | 8 +- .../memberAndMemberExtensionWithSameName.kt | 10 +- .../property/abstractPropertyViaSubclasses.kt | 8 +- .../property/accessViaSubclass.kt | 4 +- .../property/classFromClass.kt | 4 +- .../property/extensionFromClass.kt | 4 +- .../property/extensionFromTopLevel.kt | 10 +- .../property/genericClass.kt | 8 +- .../property/javaInstanceField.kt | 12 +-- .../property/javaStaticFieldViaImport.kt | 5 +- .../callableReference/property/kt7564.kt | 6 +- .../property/kt7945_unrelatedClass.kt | 4 +- .../property/kt7945_unrelatedClass.txt | 2 +- .../property/memberFromExtension.kt | 6 +- .../property/memberFromTopLevel.kt | 8 +- .../samePriorityForFunctionsAndProperties.kt | 6 +- .../property/topLevelFromTopLevel.kt | 11 +-- core/builtins/src/kotlin/reflect/KClass.kt | 4 +- .../src/kotlin/reflect/KExtensionProperty.kt | 47 ---------- .../reflect/KMemberExtensionProperty.kt | 51 ---------- .../src/kotlin/reflect/KMemberProperty.kt | 46 --------- core/builtins/src/kotlin/reflect/KProperty.kt | 94 +++++++++++++++++++ .../reflect/KTopLevelExtensionProperty.kt | 27 ------ .../src/kotlin/reflect/KTopLevelProperty.kt | 27 ------ .../src/kotlin/reflect/KTopLevelVariable.kt | 27 ------ core/builtins/src/kotlin/reflect/KVariable.kt | 41 -------- .../kotlin/builtins/ReflectionTypes.kt | 39 ++++---- .../src/kotlin/reflect/KClassExtensions.kt | 4 +- .../reflect/jvm/internal/KCallableImpl.kt | 2 +- .../kotlin/reflect/jvm/internal/KClassImpl.kt | 24 ++--- .../jvm/internal/KMemberPropertyImpl.kt | 58 ------------ .../reflect/jvm/internal/KPackageImpl.kt | 16 ++-- ...LevelVariableImpl.kt => KProperty0Impl.kt} | 10 +- .../reflect/jvm/internal/KProperty1Impl.kt | 88 +++++++++++++++++ ...nsionPropertyImpl.kt => KProperty2Impl.kt} | 21 ++--- .../reflect/jvm/internal/KPropertyImpl.kt | 4 +- .../KTopLevelExtensionPropertyImpl.kt | 58 ------------ .../reflect/jvm/internal/KVariableImpl.kt | 23 ----- .../jvm/internal/ReflectionFactoryImpl.java | 12 +-- .../src/kotlin/reflect/jvm/mapping.kt | 46 ++------- .../src/kotlin/reflect/jvm/properties.kt | 12 +-- .../src/kotlin/jvm/internal/Reflection.java | 12 +-- .../jvm/internal/ReflectionFactory.java | 12 +-- .../cases/kClassInstanceIsInitializedFirst.kt | 4 +- 58 files changed, 374 insertions(+), 653 deletions(-) delete mode 100644 core/builtins/src/kotlin/reflect/KExtensionProperty.kt delete mode 100644 core/builtins/src/kotlin/reflect/KMemberExtensionProperty.kt delete mode 100644 core/builtins/src/kotlin/reflect/KMemberProperty.kt delete mode 100644 core/builtins/src/kotlin/reflect/KTopLevelExtensionProperty.kt delete mode 100644 core/builtins/src/kotlin/reflect/KTopLevelProperty.kt delete mode 100644 core/builtins/src/kotlin/reflect/KTopLevelVariable.kt delete mode 100644 core/builtins/src/kotlin/reflect/KVariable.kt delete mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberPropertyImpl.kt rename core/reflection.jvm/src/kotlin/reflect/jvm/internal/{KTopLevelVariableImpl.kt => KProperty0Impl.kt} (79%) create mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt rename core/reflection.jvm/src/kotlin/reflect/jvm/internal/{KMemberExtensionPropertyImpl.kt => KProperty2Impl.kt} (70%) delete mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt delete mode 100644 core/reflection.jvm/src/kotlin/reflect/jvm/internal/KVariableImpl.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 1c1806566ba..591f878d981 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2796,14 +2796,14 @@ public class ExpressionCodegen extends JetVisitor implem if (receiverParameter != null) { Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE, getType(Class.class)}; factoryMethod = descriptor.isVar() - ? method("mutableTopLevelExtensionProperty", K_MUTABLE_TOP_LEVEL_EXTENSION_PROPERTY_TYPE, parameterTypes) - : method("topLevelExtensionProperty", K_TOP_LEVEL_EXTENSION_PROPERTY_TYPE, parameterTypes); + ? method("mutableTopLevelExtensionProperty", K_MUTABLE_PROPERTY1_TYPE, parameterTypes) + : method("topLevelExtensionProperty", K_PROPERTY1_TYPE, parameterTypes); } else { Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE}; factoryMethod = descriptor.isVar() - ? method("mutableTopLevelVariable", K_MUTABLE_TOP_LEVEL_VARIABLE_TYPE, parameterTypes) - : method("topLevelVariable", K_TOP_LEVEL_VARIABLE_TYPE, parameterTypes); + ? method("mutableTopLevelVariable", K_MUTABLE_PROPERTY0_TYPE, parameterTypes) + : method("topLevelVariable", K_PROPERTY0_TYPE, parameterTypes); } return StackValue.operation(factoryMethod.getReturnType(), new Function1() { @@ -2828,8 +2828,8 @@ public class ExpressionCodegen extends JetVisitor implem @NotNull final ClassDescriptor containingClass ) { final Method factoryMethod = descriptor.isVar() - ? method("mutableMemberProperty", K_MUTABLE_MEMBER_PROPERTY_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE) - : method("memberProperty", K_MEMBER_PROPERTY_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE); + ? method("mutableMemberProperty", K_MUTABLE_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE) + : method("memberProperty", K_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE); return StackValue.operation(factoryMethod.getReturnType(), new Function1() { @Override diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index fc1cdc5a981..853ec58a853 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -44,12 +44,10 @@ public class AsmTypes { public static final Type K_FUNCTION = reflect("KFunction"); - public static final Type K_MEMBER_PROPERTY_TYPE = reflect("KMemberProperty"); - public static final Type K_MUTABLE_MEMBER_PROPERTY_TYPE = reflect("KMutableMemberProperty"); - public static final Type K_TOP_LEVEL_VARIABLE_TYPE = reflect("KTopLevelVariable"); - public static final Type K_MUTABLE_TOP_LEVEL_VARIABLE_TYPE = reflect("KMutableTopLevelVariable"); - public static final Type K_TOP_LEVEL_EXTENSION_PROPERTY_TYPE = reflect("KTopLevelExtensionProperty"); - public static final Type K_MUTABLE_TOP_LEVEL_EXTENSION_PROPERTY_TYPE = reflect("KMutableTopLevelExtensionProperty"); + public static final Type K_PROPERTY0_TYPE = reflect("KProperty0"); + public static final Type K_PROPERTY1_TYPE = reflect("KProperty1"); + public static final Type K_MUTABLE_PROPERTY0_TYPE = reflect("KMutableProperty0"); + public static final Type K_MUTABLE_PROPERTY1_TYPE = reflect("KMutableProperty1"); public static final String REFLECTION = "kotlin/jvm/internal/Reflection"; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index dce191599b6..7e6679e91b2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -694,20 +694,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { return null; } - JetType receiverType = null; - if (extensionReceiver != null) { - receiverType = extensionReceiver.getType(); - } - else if (dispatchReceiver != null) { - receiverType = dispatchReceiver.getType(); - } - boolean isExtension = extensionReceiver != null; + JetType receiverType = extensionReceiver != null ? extensionReceiver.getType() : + dispatchReceiver != null ? dispatchReceiver.getType() : + null; if (descriptor instanceof FunctionDescriptor) { return createFunctionReferenceType(expression, context, (FunctionDescriptor) descriptor, receiverType); } else if (descriptor instanceof PropertyDescriptor) { - return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType, isExtension); + return createPropertyReferenceType(expression, context, (PropertyDescriptor) descriptor, receiverType); } else if (descriptor instanceof VariableDescriptor) { context.trace.report(UNSUPPORTED.on(reference, "References to variables aren't supported yet")); @@ -751,11 +746,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @NotNull JetCallableReferenceExpression expression, @NotNull ExpressionTypingContext context, @NotNull PropertyDescriptor descriptor, - @Nullable JetType receiverType, - boolean isExtension + @Nullable JetType receiverType ) { - JetType type = components.reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.getType(), isExtension, - descriptor.isVar()); + JetType type = components.reflectionTypes.getKPropertyType( + Annotations.EMPTY, receiverType, descriptor.getType(), descriptor.isVar() + ); LocalVariableDescriptor localVariable = new LocalVariableDescriptor(context.scope.getContainingDeclaration(), Annotations.EMPTY, Name.special(""), diff --git a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt index bb2102216e9..8d89bd89451 100644 --- a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt +++ b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt @@ -10,8 +10,8 @@ fun box(): String { val s = J::s // Check that correct reflection objects are created - assert(i.javaClass.getSimpleName() == "KMemberPropertyImpl", "Fail i class") - assert(s.javaClass.getSimpleName() == "KMutableMemberPropertyImpl", "Fail s class") + assert(i.javaClass.getSimpleName() == "KProperty1Impl", "Fail i class") + assert(s.javaClass.getSimpleName() == "KMutableProperty1Impl", "Fail s class") // Check that no Method objects are created for such properties assert(i.javaGetter == null, "Fail i getter") @@ -33,8 +33,8 @@ fun box(): String { assert(a.s == "def", "Fail js access") // Check that valid Kotlin reflection objects are created by those Field objects - val ki = ji.kotlin as KMemberProperty - val ks = js.kotlin as KMutableMemberProperty + val ki = ji.kotlin as KProperty1 + val ks = js.kotlin as KMutableProperty1 assert(ki.get(a) == 42, "Fail ki get") assert(ks.get(a) == "def", "Fail ks get") ks.set(a, "ghi") diff --git a/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt b/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt index 7cb9078f898..71c941f1bca 100644 --- a/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt +++ b/compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/K.kt @@ -11,7 +11,7 @@ fun box(): String { val j = J() val prop = J::prop - if (prop !is KMutableMemberProperty<*, *>) return "Fail instanceof" + if (prop !is KMutableProperty1<*, *>) return "Fail instanceof" if (prop.name != "prop") return "Fail name: ${prop.name}" if (prop.get(j) != ":(") return "Fail get before: ${prop[j]}" prop[j] = ":)" @@ -27,13 +27,13 @@ fun box(): String { val prop2 = klass.properties.firstOrNull { it.name == "prop" } ?: "Fail: no 'prop' property in properties" if (prop != prop2) return "Fail: property references from :: and from properties differ: $prop != $prop2" - if (prop2 !is KMutableMemberProperty<*, *>) return "Fail instanceof 2" - (prop2 as KMutableMemberProperty).set(j, "::)") + if (prop2 !is KMutableProperty1<*, *>) return "Fail instanceof 2" + (prop2 as KMutableProperty1).set(j, "::)") if (prop.get(j) != "::)") return "Fail get after 2: ${prop[j]}" val ext = klass.extensionProperties.firstOrNull { it.name == "ext" } ?: "Fail: no 'ext' property in extensionProperties" - ext as KMemberExtensionProperty + ext as KProperty2 val fortyTwo = ext.get(j, 42) if (fortyTwo != 42) return "Fail ext get: $fortyTwo" diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt index d5e2dd8f1d2..fae016e0a82 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt @@ -1,6 +1,6 @@ //For KT-6020 -import kotlin.reflect.KMemberProperty -import kotlin.reflect.KMutableMemberProperty +import kotlin.reflect.KProperty1 +import kotlin.reflect.KMutableProperty1 class Value(var value: T = null as T, var text: String? = null) @@ -8,7 +8,7 @@ val Value.additionalText by DVal(Value::text) //works val Value.additionalValue by DVal(Value::value) //not work -class DVal>(val kmember: P) { +class DVal>(val kmember: P) { fun get(t: T, p: PropertyMetadata): R { return kmember.get(t) } @@ -17,4 +17,4 @@ class DVal>(val kmember: P) { fun box(): String { val p = Value("O", "K") return p.additionalValue + p.additionalText -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/kClassInstanceIsInitializedFirst.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kClassInstanceIsInitializedFirst.kt index db87afa64e7..5ce636926d5 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/kClassInstanceIsInitializedFirst.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kClassInstanceIsInitializedFirst.kt @@ -1,8 +1,8 @@ -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class A { companion object { - val ref: KMemberProperty = A::foo + val ref: KProperty1 = A::foo } val foo: String = "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt index c6ed7d44c65..99f6d3ee6d9 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt @@ -1,11 +1,11 @@ import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 import kotlin.reflect.jvm.accessible class Result { private val value = "OK" - fun ref(): KMemberProperty = ::value + fun ref(): KProperty1 = ::value } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt index f8f4d8226ca..0d5ea464a93 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt @@ -1,11 +1,11 @@ import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMutableMemberProperty +import kotlin.reflect.KMutableProperty1 import kotlin.reflect.jvm.accessible class A { private var value = 0 - fun ref(): KMutableMemberProperty = ::value + fun ref(): KMutableProperty1 = ::value } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt b/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt index a02509760fb..346de4cd500 100644 --- a/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt +++ b/compiler/testData/codegen/boxWithStdlib/platformStatic/callableRef.kt @@ -4,7 +4,7 @@ object A { val b: String = "OK" - platformStatic val c: String = "OK" + platformStatic var c: String = "Fail" platformStatic fun test1() : String { return b @@ -36,6 +36,8 @@ fun box(): String { if ((A::test4)(A) != "1OK") return "fail 4" + (A::c).set(A, "OK") + if (((A::c).get(A)) != "OK") return "fail 5" return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt index bb1915fb389..5f4f70ce558 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt @@ -1,7 +1,7 @@ -import kotlin.reflect.KExtensionProperty +import kotlin.reflect.KProperty1 import kotlin.test.assertEquals -fun check(expected: String, p: KExtensionProperty<*, *>) { +fun check(expected: String, p: KProperty1<*, *>) { var s = p.toString() // Strip "val" or "var" diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/callPrivatePropertyFromGetProperties.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/callPrivatePropertyFromGetProperties.kt index 59589294b1c..b11fc5e5dd8 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/callPrivatePropertyFromGetProperties.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/callPrivatePropertyFromGetProperties.kt @@ -4,7 +4,7 @@ import kotlin.reflect.jvm.* class K(private val value: String) fun box(): String { - val p = javaClass().kotlin.properties.single() as KMemberProperty + val p = javaClass().kotlin.properties.single() as KProperty1 try { return p.get(K("Fail: private property should not be accessible by default")) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/genericClassLiteralPropertyReceiverIsStar.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/genericClassLiteralPropertyReceiverIsStar.kt index c87de4331d0..e97248ae99b 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/genericClassLiteralPropertyReceiverIsStar.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/genericClassLiteralPropertyReceiverIsStar.kt @@ -1,11 +1,10 @@ -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class A { val result = "OK" } fun box(): String { - val k = A::class.properties.single() - k : KMemberProperty, *> + val k : KProperty1, *> = A::class.properties.single() return k.get(A()) as String } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt index 76b17b83f51..2ebf098af3c 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getExtensionPropertiesMutableVsReadonly.kt @@ -1,5 +1,5 @@ import kotlin.reflect.jvm.kotlin -import kotlin.reflect.KMutableMemberExtensionProperty +import kotlin.reflect.KMutableProperty2 var storage = "before" @@ -15,12 +15,12 @@ class A { fun box(): String { val props = javaClass().kotlin.extensionProperties val readonly = props.single { it.name == "readonly" } - assert(readonly !is KMutableMemberExtensionProperty) { "Fail 1: $readonly" } + assert(readonly !is KMutableProperty2) { "Fail 1: $readonly" } val mutable = props.single { it.name == "mutable" } - assert(mutable is KMutableMemberExtensionProperty) { "Fail 2: $mutable" } + assert(mutable is KMutableProperty2) { "Fail 2: $mutable" } val a = A() - mutable as KMutableMemberExtensionProperty + mutable as KMutableProperty2 assert(mutable[a, ""] == "before") { "Fail 3: ${mutable.get(a, "")}" } mutable[a, ""] = "OK" return mutable.get(a, "") diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt index 435243a6938..fb764361b30 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/getPropertiesMutableVsReadonly.kt @@ -1,5 +1,5 @@ import kotlin.reflect.jvm.kotlin -import kotlin.reflect.KMutableMemberProperty +import kotlin.reflect.KMutableProperty1 class A(val readonly: String) { var mutable: String = "before" @@ -8,12 +8,12 @@ class A(val readonly: String) { fun box(): String { val props = javaClass().kotlin.properties val readonly = props.single { it.name == "readonly" } - assert(readonly !is KMutableMemberProperty) { "Fail 1: $readonly" } + assert(readonly !is KMutableProperty1) { "Fail 1: $readonly" } val mutable = props.single { it.name == "mutable" } - assert(mutable is KMutableMemberProperty) { "Fail 2: $mutable" } + assert(mutable is KMutableProperty1) { "Fail 2: $mutable" } val a = A("") - mutable as KMutableMemberProperty + mutable as KMutableProperty1 assert(mutable[a] == "before") { "Fail 3: ${mutable.get(a)}" } mutable[a] = "OK" return mutable.get(a) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt index b194d12e01c..a60072738bd 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/memberAndMemberExtensionWithSameName.kt @@ -1,6 +1,6 @@ import kotlin.reflect.jvm.kotlin -import kotlin.reflect.KMemberProperty -import kotlin.reflect.KMemberExtensionProperty +import kotlin.reflect.KProperty1 +import kotlin.reflect.KProperty2 class A { val foo: String = "member" @@ -9,15 +9,15 @@ class A { fun box(): String { run { - val foo: KMemberProperty = javaClass().kotlin.properties.single() + val foo: KProperty1 = javaClass().kotlin.properties.single() assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" } assert(foo.get(A()) == "member") { "Fail value: ${foo[A()]}" } } run { - val foo: KMemberExtensionProperty = javaClass().kotlin.extensionProperties.single() + val foo: KProperty2 = javaClass().kotlin.extensionProperties.single() assert(foo.name == "foo") { "Fail name: $foo (${foo.name})" } - foo as KMemberExtensionProperty + foo as KProperty2 assert(foo.get(A(), Unit) == "extension") { "Fail value: ${foo[A(), Unit]}" } } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/abstractPropertyViaSubclasses.kt b/compiler/testData/diagnostics/tests/callableReference/property/abstractPropertyViaSubclasses.kt index 0f5adfb8e4b..36ec672d567 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/abstractPropertyViaSubclasses.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/abstractPropertyViaSubclasses.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 interface Base { val x: Any @@ -20,17 +20,17 @@ class C : B() { fun test() { val base = Base::x - checkSubtype>(base) + checkSubtype>(base) checkSubtype(base.get(A())) checkSubtype(base.get(B())) checkSubtype(base.get(C())) val a = A::x - checkSubtype>(a) + checkSubtype>(a) checkSubtype(a.get(A())) checkSubtype(a.get(B())) val b = B::x - checkSubtype>(b) + checkSubtype>(b) checkSubtype(b.get(C())) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/accessViaSubclass.kt b/compiler/testData/diagnostics/tests/callableReference/property/accessViaSubclass.kt index 44bba28e333..ec5c86975b4 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/accessViaSubclass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/accessViaSubclass.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 open class Base { val foo: Int = 42 @@ -10,6 +10,6 @@ open class Derived : Base() fun test() { val o = Base::foo - checkSubtype>(o) + checkSubtype>(o) checkSubtype(o.get(Derived())) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt index 65ef1ee9ca2..b5d3570a170 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/classFromClass.kt @@ -6,7 +6,7 @@ class A(var g: A) { val f: Int = 0 fun test() { - val fRef: KMemberProperty = ::f - val gRef: KMutableMemberProperty = ::g + val fRef: KProperty1 = ::f + val gRef: KMutableProperty1 = ::g } } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt index ac92c4a0dbc..e28b2c4c6d2 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromClass.kt @@ -4,8 +4,8 @@ import kotlin.reflect.* class A { fun test() { - val fooRef: KExtensionProperty = ::foo - val barRef: KMutableExtensionProperty = ::bar + val fooRef: KProperty1 = ::foo + val barRef: KMutableProperty1 = ::bar } } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt index afb67c72591..6da7eaec881 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/extensionFromTopLevel.kt @@ -12,18 +12,14 @@ var Int.meaning: Long fun test() { val f = String::countCharacters - checkSubtype>(f) - checkSubtype>(f) - checkSubtype>(f) + checkSubtype>(f) + checkSubtype>(f) checkSubtype(f.get("abc")) f.set("abc", 0) val g = Int::meaning - checkSubtype>(g) - checkSubtype>(g) - checkSubtype>(g) - checkSubtype>(g) + checkSubtype>(g) checkSubtype(g.get(0)) g.set(1, 0L) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt index a741e69b357..3c1181248c1 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class A(val t: T) { val foo: T = t @@ -8,9 +8,9 @@ class A(val t: T) { fun bar() { val x = A::foo - checkSubtype, String>>(x) - checkSubtype, Any?>>(x) + checkSubtype, String>>(x) + checkSubtype, Any?>>(x) val y = A<*>::foo - checkSubtype, Any?>>(y) + checkSubtype, Any?>>(y) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/javaInstanceField.kt b/compiler/testData/diagnostics/tests/callableReference/property/javaInstanceField.kt index 7304ad21fdf..901c2f1d084 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/javaInstanceField.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/javaInstanceField.kt @@ -17,10 +17,10 @@ public class JavaClass { import kotlin.reflect.* fun test() { - val pubFinRef: KMemberProperty = JavaClass::publicFinal - val pubMutRef: KMutableMemberProperty = JavaClass::publicMutable - val protFinRef: KMemberProperty = JavaClass::protectedFinal - val protMutRef: KMutableMemberProperty = JavaClass::protectedMutable - val privFinRef: KMemberProperty = JavaClass::privateFinal - val privMutRef: KMutableMemberProperty = JavaClass::privateMutable + val pubFinRef: KProperty1 = JavaClass::publicFinal + val pubMutRef: KMutableProperty1 = JavaClass::publicMutable + val protFinRef: KProperty1 = JavaClass::protectedFinal + val protMutRef: KMutableProperty1 = JavaClass::protectedMutable + val privFinRef: KProperty1 = JavaClass::privateFinal + val privMutRef: KMutableProperty1 = JavaClass::privateMutable } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/javaStaticFieldViaImport.kt b/compiler/testData/diagnostics/tests/callableReference/property/javaStaticFieldViaImport.kt index 1d3017e8e4a..6109457f932 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/javaStaticFieldViaImport.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/javaStaticFieldViaImport.kt @@ -1,4 +1,3 @@ -// !CHECK_TYPE // !DIAGNOSTICS:-UNUSED_VARIABLE // FILE: JavaClass.java @@ -20,8 +19,8 @@ import JavaClass.* import kotlin.reflect.* fun test() { - val pubFinRef: KTopLevelProperty = ::publicFinal - val pubMutRef: KMutableTopLevelProperty = ::publicMutable + val pubFinRef: KProperty0 = ::publicFinal + val pubMutRef: KMutableProperty0 = ::publicMutable val protFinRef: KProperty = ::protectedFinal val protMutRef: KMutableProperty = ::protectedMutable val privFinRef: KProperty = ::privateFinal diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt b/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt index acbf68eb5d4..26295d99f72 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/kt7564.kt @@ -6,7 +6,7 @@ class A(var g: A) { val f: Int = 0 fun test() { - checkSubtype>(::f) - checkSubtype>(::g) + checkSubtype>(::f) + checkSubtype>(::g) } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt index f9c917d5be8..2354ecf0ba7 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.kt @@ -1,10 +1,10 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class TestClass(var prop: Int) open class OtherClass -fun OtherClass.test(prop: KMemberProperty): Unit = throw Exception() +fun OtherClass.test(prop: KProperty1): Unit = throw Exception() class OtherClass2: OtherClass() { val result = test(TestClass::result) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.txt b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.txt index d99d7aa2d2c..013fce270d6 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.txt +++ b/compiler/testData/diagnostics/tests/callableReference/property/kt7945_unrelatedClass.txt @@ -1,6 +1,6 @@ package -internal fun OtherClass.test(/*0*/ prop: kotlin.reflect.KMemberProperty): kotlin.Unit +internal fun OtherClass.test(/*0*/ prop: kotlin.reflect.KProperty1): kotlin.Unit internal open class OtherClass { public constructor OtherClass() diff --git a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt b/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt index 24b84678ee1..32958ec26ab 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/memberFromExtension.kt @@ -15,9 +15,9 @@ fun A.test() { val y = ::bar val z = ::self - checkSubtype>(x) - checkSubtype>(y) - checkSubtype>(z) + checkSubtype>(x) + checkSubtype>(y) + checkSubtype>(z) y.set(z.get(A()), x.get(A()).toString()) } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt index 14be337f739..0afa68cc50a 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/memberFromTopLevel.kt @@ -10,16 +10,16 @@ class A { fun test() { val p = A::foo - checkSubtype>(p) - checkSubtype>(p) + checkSubtype>(p) + checkSubtype>(p) checkSubtype(p.get(A())) p.get() p.set(A(), 239) val q = A::bar - checkSubtype>(q) - checkSubtype>(q) + checkSubtype>(q) + checkSubtype>(q) checkSubtype(q.get(A())) q.set(A(), "q") } diff --git a/compiler/testData/diagnostics/tests/callableReference/property/samePriorityForFunctionsAndProperties.kt b/compiler/testData/diagnostics/tests/callableReference/property/samePriorityForFunctionsAndProperties.kt index 2065b87f8d4..6bedc84c041 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/samePriorityForFunctionsAndProperties.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/samePriorityForFunctionsAndProperties.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class C { val baz: Int = 12 @@ -9,5 +9,5 @@ class C { fun Int.baz() {} fun test() { - C::baz checkType { _>() } -} \ No newline at end of file + C::baz checkType { _>() } +} diff --git a/compiler/testData/diagnostics/tests/callableReference/property/topLevelFromTopLevel.kt b/compiler/testData/diagnostics/tests/callableReference/property/topLevelFromTopLevel.kt index d9fcb90c7ff..ce7ccf72c9d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/property/topLevelFromTopLevel.kt +++ b/compiler/testData/diagnostics/tests/callableReference/property/topLevelFromTopLevel.kt @@ -7,12 +7,9 @@ val y: String get() = "y" fun testX() { val xx = ::x - checkSubtype>(xx) - checkSubtype>(xx) - checkSubtype>(xx) - checkSubtype>(xx) + checkSubtype>(xx) + checkSubtype>(xx) checkSubtype>(xx) - checkSubtype>(xx) checkSubtype>(xx) checkSubtype>(xx) @@ -23,8 +20,8 @@ fun testX() { fun testY() { val yy = ::y - checkSubtype>(yy) - checkSubtype>(yy) + checkSubtype>(yy) + checkSubtype>(yy) checkSubtype>(yy) checkSubtype>(yy) checkSubtype>(yy) diff --git a/core/builtins/src/kotlin/reflect/KClass.kt b/core/builtins/src/kotlin/reflect/KClass.kt index a12536a465a..965a5470f47 100644 --- a/core/builtins/src/kotlin/reflect/KClass.kt +++ b/core/builtins/src/kotlin/reflect/KClass.kt @@ -41,10 +41,10 @@ public interface KClass : KDeclarationContainer { /** * Returns non-extension properties declared in this class and all of its superclasses. */ - public val properties: Collection> + public val properties: Collection> /** * Returns extension properties declared in this class and all of its superclasses. */ - public val extensionProperties: Collection> + public val extensionProperties: Collection> } diff --git a/core/builtins/src/kotlin/reflect/KExtensionProperty.kt b/core/builtins/src/kotlin/reflect/KExtensionProperty.kt deleted file mode 100644 index 817e1c3c216..00000000000 --- a/core/builtins/src/kotlin/reflect/KExtensionProperty.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents an extension property. - * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/extensions.html#extension-properties) - * for more information. - * - * @param E the type of the extension receiver. - * @param R the type of the property. - */ -public interface KExtensionProperty : KProperty { - /** - * Returns the current value of the property. - * - * @param receiver the instance of the extension receiver. - */ - public fun get(receiver: E): R -} - -/** - * Represents an extension property declared as a `var`. - */ -public interface KMutableExtensionProperty : KExtensionProperty, KMutableProperty { - /** - * Modifies the value of the property. - * - * @param receiver the instance of the extension receiver. - * @param value the new value to be assigned to this property. - */ - public fun set(receiver: E, value: R) -} diff --git a/core/builtins/src/kotlin/reflect/KMemberExtensionProperty.kt b/core/builtins/src/kotlin/reflect/KMemberExtensionProperty.kt deleted file mode 100644 index a99c19a4f9f..00000000000 --- a/core/builtins/src/kotlin/reflect/KMemberExtensionProperty.kt +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents an extension property declared in a class. - * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/extensions.html#extension-properties) - * for more information. - * - * @param T the type of the instance which should be used to obtain the value of the property. - * Must be derived either from a class declaring this property, or any subclass of that class. - * @param E the type of the extension receiver. - * @param R the type of the property. - */ -public interface KMemberExtensionProperty : KProperty { - /** - * Returns the current value of the property. - * - * @param instance the instance to obtain the value of the property from. - * @param extensionReceiver the instance of the extension receiver. - */ - public fun get(instance: T, extensionReceiver: E): R -} - -/** - * Represents a `var` extension property declared in a class. - */ -public interface KMutableMemberExtensionProperty : KMemberExtensionProperty, KMutableProperty { - /** - * Modifies the value of the property. - * - * @param instance the instance to obtain the value of the property from. - * @param extensionReceiver the instance of the extension receiver. - * @param value the new value to be assigned to this property. - */ - public fun set(instance: T, extensionReceiver: E, value: R) -} diff --git a/core/builtins/src/kotlin/reflect/KMemberProperty.kt b/core/builtins/src/kotlin/reflect/KMemberProperty.kt deleted file mode 100644 index 58c4d9f2ab1..00000000000 --- a/core/builtins/src/kotlin/reflect/KMemberProperty.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a property declared in a class. - * - * @param T the type of the instance which should be used to obtain the value of the property. - * Must be derived either from a class declaring this property, or any subclass of that class. - * @param R the type of the property. - */ -public interface KMemberProperty : KProperty { - /** - * Returns the current value of the property. - * - * @param instance the instance to obtain the value of the property from. - */ - public fun get(instance: T): R -} - -/** - * Represents a `var` property declared in a class. - */ -public interface KMutableMemberProperty : KMemberProperty, KMutableProperty { - /** - * Modifies the value of the property. - * - * @param instance the instance to obtain the value of the property from. - * @param value the new value to be assigned to this property. - */ - public fun set(instance: T, value: R) -} diff --git a/core/builtins/src/kotlin/reflect/KProperty.kt b/core/builtins/src/kotlin/reflect/KProperty.kt index 10f4a3508a2..b068eff3f55 100644 --- a/core/builtins/src/kotlin/reflect/KProperty.kt +++ b/core/builtins/src/kotlin/reflect/KProperty.kt @@ -30,3 +30,97 @@ public interface KProperty : KCallable * Represents a property declared as a `var`. */ public interface KMutableProperty : KProperty + + +/** + * Represents a property without any kind of receiver. + * Such property is either originally declared in a receiverless context such as a package, + * or has the receiver bound to it. + */ +public interface KProperty0 : KProperty { + /** + * Returns the current value of the property. + */ + public fun get(): R +} + +/** + * Represents a `var`-property without any kind of receiver. + */ +public interface KMutableProperty0 : KProperty0, KMutableProperty { + /** + * Modifies the value of the property. + * + * @param value the new value to be assigned to this property. + */ + public fun set(value: R) +} + + +/** + * Represents a property, operations on which take one receiver as a parameter. + * + * @param T the type of the receiver which should be used to obtain the value of the property. + * @param R the type of the property. + */ +public interface KProperty1 : KProperty { + /** + * Returns the current value of the property. + * + * @param receiver the receiver which is used to obtain the value of the property. + * For example, it should be a class instance if this is a member property of that class, + * or an extension receiver if this is a top level extension property. + */ + public fun get(receiver: T): R +} + +/** + * Represents a `var`-property, operations on which take one receiver as a parameter. + */ +public interface KMutableProperty1 : KProperty1, KMutableProperty { + /** + * Modifies the value of the property. + * + * @param receiver the receiver which is used to modify the value of the property. + * For example, it should be a class instance if this is a member property of that class, + * or an extension receiver if this is a top level extension property. + * @param value the new value to be assigned to this property. + */ + public fun set(receiver: T, value: R) +} + + +/** + * Represents a property, operations on which take two receivers as parameters, + * such as an extension property declared in a class. + * + * @param D the type of the first receiver. In case of the extension property in a class this is + * the type of the declaring class of the property, or any subclass of that class. + * @param E the type of the second receiver. In case of the extension property in a class this is + * the type of the extension receiver. + * @param R the type of the property. + */ +public interface KProperty2 : KProperty { + /** + * Returns the current value of the property. In case of the extension property in a class, + * the instance of the class should be passed first and the instance of the extension receiver second. + * + * @param receiver1 the instance of the first receiver. + * @param receiver2 the instance of the second receiver. + */ + public fun get(receiver1: D, receiver2: E): R +} + +/** + * Represents a `var`-property, operations on which take two receivers as parameters. + */ +public interface KMutableProperty2 : KProperty2, KMutableProperty { + /** + * Modifies the value of the property. + * + * @param receiver1 the instance of the first receiver. + * @param receiver2 the instance of the second receiver. + * @param value the new value to be assigned to this property. + */ + public fun set(receiver1: D, receiver2: E, value: R) +} diff --git a/core/builtins/src/kotlin/reflect/KTopLevelExtensionProperty.kt b/core/builtins/src/kotlin/reflect/KTopLevelExtensionProperty.kt deleted file mode 100644 index 3381b037182..00000000000 --- a/core/builtins/src/kotlin/reflect/KTopLevelExtensionProperty.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents an extension property declared in a package. - */ -public interface KTopLevelExtensionProperty : KExtensionProperty, KTopLevelProperty - -/** - * Represents a package extension property declared as a `var`. - */ -public interface KMutableTopLevelExtensionProperty : KTopLevelExtensionProperty, KMutableExtensionProperty, KMutableTopLevelProperty diff --git a/core/builtins/src/kotlin/reflect/KTopLevelProperty.kt b/core/builtins/src/kotlin/reflect/KTopLevelProperty.kt deleted file mode 100644 index 597e831325f..00000000000 --- a/core/builtins/src/kotlin/reflect/KTopLevelProperty.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a property declared in a package. - */ -public interface KTopLevelProperty : KProperty - -/** - * Represents a package property declared as a `var`. - */ -public interface KMutableTopLevelProperty : KTopLevelProperty, KMutableProperty diff --git a/core/builtins/src/kotlin/reflect/KTopLevelVariable.kt b/core/builtins/src/kotlin/reflect/KTopLevelVariable.kt deleted file mode 100644 index 39b8856ac66..00000000000 --- a/core/builtins/src/kotlin/reflect/KTopLevelVariable.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a variable declared in a package. - */ -public interface KTopLevelVariable : KVariable, KTopLevelProperty - -/** - * Represents a package variable declared as a `var`. - */ -public interface KMutableTopLevelVariable : KTopLevelVariable, KMutableVariable, KMutableTopLevelProperty diff --git a/core/builtins/src/kotlin/reflect/KVariable.kt b/core/builtins/src/kotlin/reflect/KVariable.kt deleted file mode 100644 index 100e149a5c0..00000000000 --- a/core/builtins/src/kotlin/reflect/KVariable.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect - -/** - * Represents a property without any kind of receiver. - * Such property is either originally declared in a receiverless context such as a package, - * or has the receiver bound to it. - */ -public interface KVariable : KProperty { - /** - * Returns the current value of the variable. - */ - public fun get(): R -} - -/** - * Represents a variable declared as a `var`. - */ -public interface KMutableVariable : KVariable, KMutableProperty { - /** - * Modifies the value of the variable. - * - * @param value the new value to be assigned to this variable. - */ - public fun set(value: R) -} diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 71539e305b8..5b02b53cd56 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -50,12 +50,10 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { public fun getKFunction(n: Int): ClassDescriptor = find("KFunction$n") public val kClass: ClassDescriptor by ClassLookup - public val kTopLevelVariable: ClassDescriptor by ClassLookup - public val kMutableTopLevelVariable: ClassDescriptor by ClassLookup - public val kMemberProperty: ClassDescriptor by ClassLookup - public val kMutableMemberProperty: ClassDescriptor by ClassLookup - public val kTopLevelExtensionProperty: ClassDescriptor by ClassLookup - public val kMutableTopLevelExtensionProperty: ClassDescriptor by ClassLookup + public val kProperty0: ClassDescriptor by ClassLookup + public val kProperty1: ClassDescriptor by ClassLookup + public val kMutableProperty0: ClassDescriptor by ClassLookup + public val kMutableProperty1: ClassDescriptor by ClassLookup public fun getKClassType(annotations: Annotations, type: JetType): JetType { val descriptor = kClass @@ -84,23 +82,18 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { return JetTypeImpl(annotations, classDescriptor.getTypeConstructor(), false, arguments, classDescriptor.getMemberScope(arguments)) } - public fun getKPropertyType( - annotations: Annotations, - receiverType: JetType?, - returnType: JetType, - extensionProperty: Boolean, - mutable: Boolean - ): JetType { - val classDescriptor = if (mutable) when { - extensionProperty -> kMutableTopLevelExtensionProperty - receiverType != null -> kMutableMemberProperty - else -> kMutableTopLevelVariable - } - else when { - extensionProperty -> kTopLevelExtensionProperty - receiverType != null -> kMemberProperty - else -> kTopLevelVariable - } + public fun getKPropertyType(annotations: Annotations, receiverType: JetType?, returnType: JetType, mutable: Boolean): JetType { + val classDescriptor = + when { + receiverType != null -> when { + mutable -> kMutableProperty1 + else -> kProperty1 + } + else -> when { + mutable -> kMutableProperty0 + else -> kProperty0 + } + } if (ErrorUtils.isError(classDescriptor)) { return classDescriptor.getDefaultType() diff --git a/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt b/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt index 30d73543926..ddddc04a511 100644 --- a/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt +++ b/core/reflection.jvm/src/kotlin/reflect/KClassExtensions.kt @@ -21,11 +21,11 @@ import kotlin.reflect.jvm.internal.KClassImpl /** * Returns non-extension properties declared in this class. */ -public val KClass.declaredProperties: Collection> +public val KClass.declaredProperties: Collection> get() = (this as KClassImpl).getProperties(declared = true) /** * Returns extension properties declared in this class. */ -public val KClass.declaredExtensionProperties: Collection> +public val KClass.declaredExtensionProperties: Collection> get() = (this as KClassImpl).getExtensionProperties(declared = true) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableImpl.kt index eb4460b5f53..d98e816c3d7 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableImpl.kt @@ -18,4 +18,4 @@ package kotlin.reflect.jvm.internal import kotlin.reflect.KCallable -trait KCallableImpl : KCallable +interface KCallableImpl : KCallable diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index 5c534a70b9c..73c98ce0a1a 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -75,22 +75,22 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K } } - override val properties: Collection> + override val properties: Collection> get() = getProperties(declared = false) - override val extensionProperties: Collection> + override val extensionProperties: Collection> get() = getExtensionProperties(declared = false) - fun getProperties(declared: Boolean): Collection> = + fun getProperties(declared: Boolean): Collection> = getProperties(extension = false, declared = declared) { descriptor -> - if (descriptor.isVar()) KMutableMemberPropertyImpl(this, descriptor) - else KMemberPropertyImpl(this, descriptor) + if (descriptor.isVar()) KMutableProperty1Impl(this, descriptor) + else KProperty1Impl(this, descriptor) } - fun getExtensionProperties(declared: Boolean): Collection> = + fun getExtensionProperties(declared: Boolean): Collection> = getProperties(extension = true, declared = declared) { descriptor -> - if (descriptor.isVar()) KMutableMemberExtensionPropertyImpl(this, descriptor) - else KMemberExtensionPropertyImpl(this, descriptor) + if (descriptor.isVar()) KMutableProperty2Impl(this, descriptor) + else KProperty2Impl(this, descriptor) } private fun

> getProperties(extension: Boolean, declared: Boolean, create: (PropertyDescriptor) -> P): Collection

= @@ -104,11 +104,11 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K .map(create) .toList() - fun memberProperty(name: String): KMemberProperty = - KMemberPropertyImpl(this, name) + fun memberProperty(name: String): KProperty1 = + KProperty1Impl(this, name, null) - fun mutableMemberProperty(name: String): KMutableMemberProperty = - KMutableMemberPropertyImpl(this, name) + fun mutableMemberProperty(name: String): KMutableProperty1 = + KMutableProperty1Impl(this, name, null) override fun equals(other: Any?): Boolean = other is KClassImpl<*> && jClass == other.jClass diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberPropertyImpl.kt deleted file mode 100644 index 5a2522d63f5..00000000000 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberPropertyImpl.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect.jvm.internal - -import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMemberProperty -import kotlin.reflect.KMutableMemberProperty - -open class KMemberPropertyImpl : DescriptorBasedProperty, KMemberProperty, KPropertyImpl { - constructor(container: KClassImpl, name: String) : super(container, name, null) - - constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) - - override val name: String get() = descriptor.getName().asString() - - override fun get(instance: T): R { - try { - val getter = getter - @suppress("UNCHECKED_CAST") - return if (getter != null) getter(instance) as R else field!!.get(instance) as R - } - catch (e: IllegalAccessException) { - throw IllegalPropertyAccessException(e) - } - } -} - - -class KMutableMemberPropertyImpl : KMemberPropertyImpl, KMutableMemberProperty, KMutablePropertyImpl { - constructor(container: KClassImpl, name: String) : super(container, name) - - constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) - - override fun set(instance: T, value: R) { - try { - val setter = setter - if (setter != null) setter(instance, value) else field!!.set(instance, value) - } - catch (e: IllegalAccessException) { - throw IllegalPropertyAccessException(e) - } - } -} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt index 28a9a48a9ca..22c389274ab 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt @@ -31,17 +31,17 @@ class KPackageImpl(override val jClass: Class<*>) : KCallableContainerImpl(), KP override val scope: JetScope get() = descriptor.memberScope - fun topLevelVariable(name: String): KTopLevelVariable<*> = - KTopLevelVariableImpl(this, name) + fun topLevelVariable(name: String): KProperty0<*> = + KProperty0Impl(this, name) - fun mutableTopLevelVariable(name: String): KMutableTopLevelVariable<*> = - KMutableTopLevelVariableImpl(this, name) + fun mutableTopLevelVariable(name: String): KMutableProperty0<*> = + KMutableProperty0Impl(this, name) - fun topLevelExtensionProperty(name: String, receiver: Class): KTopLevelExtensionProperty = - KTopLevelExtensionPropertyImpl(this, name, receiver) + fun topLevelExtensionProperty(name: String, receiver: Class): KProperty1 = + KProperty1Impl(this, name, receiver) - fun mutableTopLevelExtensionProperty(name: String, receiver: Class): KMutableTopLevelExtensionProperty = - KMutableTopLevelExtensionPropertyImpl(this, name, receiver) + fun mutableTopLevelExtensionProperty(name: String, receiver: Class): KMutableProperty1 = + KMutableProperty1Impl(this, name, receiver) override fun equals(other: Any?): Boolean = other is KPackageImpl && jClass == other.jClass diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelVariableImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt similarity index 79% rename from core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelVariableImpl.kt rename to core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt index b1758677721..0fa44d92f64 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelVariableImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt @@ -18,10 +18,10 @@ package kotlin.reflect.jvm.internal import java.lang.reflect.Method import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMutableTopLevelVariable -import kotlin.reflect.KTopLevelVariable +import kotlin.reflect.KMutableProperty0 +import kotlin.reflect.KProperty0 -open class KTopLevelVariableImpl : DescriptorBasedProperty, KTopLevelVariable, KVariableImpl { +open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KPropertyImpl { constructor(container: KPackageImpl, name: String) : super(container, name, null) override val name: String get() = descriptor.getName().asString() @@ -39,10 +39,10 @@ open class KTopLevelVariableImpl : DescriptorBasedProperty, KTopLevelVari } } -class KMutableTopLevelVariableImpl : KTopLevelVariableImpl, KMutableTopLevelVariable, KMutableVariableImpl { +class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutablePropertyImpl { constructor(container: KPackageImpl, name: String) : super(container, name) - override val setter: Method get() = super.setter!! + override val setter: Method get() = super.setter!! override fun set(value: R) { try { diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt new file mode 100644 index 00000000000..e575e316192 --- /dev/null +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt @@ -0,0 +1,88 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect.jvm.internal + +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import java.lang.reflect.Modifier +import kotlin.reflect.IllegalPropertyAccessException +import kotlin.reflect.KMutableProperty1 +import kotlin.reflect.KProperty1 + +open class KProperty1Impl : DescriptorBasedProperty, KProperty1, KPropertyImpl { + constructor(container: KCallableContainerImpl, name: String, receiverParameterClass: Class<*>?) : super( + container, name, receiverParameterClass + ) + + constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) + + override val name: String get() = descriptor.getName().asString() + + // TODO: consider optimizing this, not to do complex checks on every access + @suppress("UNCHECKED_CAST") + override fun get(receiver: T): R { + try { + val getter = getter ?: + return field!!.get(receiver) as R + + if (Modifier.isStatic(getter.getModifiers())) { + // Workaround the case of platformStatic property in object, getter of which doesn't take a receiver + if (getter.getParameterTypes().isEmpty()) { + return getter.invoke(null) as R + } + + return getter.invoke(null, receiver) as R + } + + return getter.invoke(receiver) as R + } + catch (e: IllegalAccessException) { + throw IllegalPropertyAccessException(e) + } + } +} + + +class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1, KMutablePropertyImpl { + constructor(container: KCallableContainerImpl, name: String, receiverParameterClass: Class<*>?) : super( + container, name, receiverParameterClass + ) + + constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) + + override fun set(receiver: T, value: R) { + try { + val setter = setter ?: + return field!!.set(receiver, value) + + if (Modifier.isStatic(setter.getModifiers())) { + // Workaround the case of platformStatic property in object, setter of which doesn't take a receiver + if (setter.getParameterTypes().size() == 1) { + setter.invoke(null, value) + } + else { + setter.invoke(null, receiver, value) + } + } + else { + setter.invoke(receiver, value) + } + } + catch (e: IllegalAccessException) { + throw IllegalPropertyAccessException(e) + } + } +} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberExtensionPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt similarity index 70% rename from core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberExtensionPropertyImpl.kt rename to core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt index 5777671ca62..9a65d8e8e88 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KMemberExtensionPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt @@ -20,10 +20,10 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor import java.lang.reflect.Field import java.lang.reflect.Method import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMemberExtensionProperty -import kotlin.reflect.KMutableMemberExtensionProperty +import kotlin.reflect.KMutableProperty2 +import kotlin.reflect.KProperty2 -open class KMemberExtensionPropertyImpl : DescriptorBasedProperty, KMemberExtensionProperty, KPropertyImpl { +open class KProperty2Impl : DescriptorBasedProperty, KProperty2, KPropertyImpl { constructor(container: KClassImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) @@ -34,10 +34,10 @@ open class KMemberExtensionPropertyImpl : DescriptorBasedProp override val field: Field? get() = null - override fun get(instance: D, extensionReceiver: E): R { + override fun get(receiver1: D, receiver2: E): R { try { @suppress("UNCHECKED_CAST") - return getter.invoke(instance, extensionReceiver) as R + return getter.invoke(receiver1, receiver2) as R } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) @@ -46,19 +46,16 @@ open class KMemberExtensionPropertyImpl : DescriptorBasedProp } -class KMutableMemberExtensionPropertyImpl : - KMemberExtensionPropertyImpl, - KMutableMemberExtensionProperty, - KMutablePropertyImpl { +class KMutableProperty2Impl : KProperty2Impl, KMutableProperty2, KMutablePropertyImpl { constructor(container: KClassImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) - override val setter: Method get() = super.setter!! + override val setter: Method get() = super.setter!! - override fun set(instance: D, extensionReceiver: E, value: R) { + override fun set(receiver1: D, receiver2: E, value: R) { try { - setter.invoke(instance, extensionReceiver, value) + setter.invoke(receiver1, receiver2, value) } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt index 42843629643..d6e9f6e87a4 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt @@ -19,13 +19,13 @@ package kotlin.reflect.jvm.internal import java.lang.reflect.* import kotlin.reflect.* -trait KPropertyImpl : KProperty, KCallableImpl { +interface KPropertyImpl : KProperty, KCallableImpl { val field: Field? val getter: Method? } -trait KMutablePropertyImpl : KMutableProperty, KPropertyImpl { +interface KMutablePropertyImpl : KMutableProperty, KPropertyImpl { val setter: Method? } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt deleted file mode 100644 index bae24330fce..00000000000 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KTopLevelExtensionPropertyImpl.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect.jvm.internal - -import java.lang.reflect.Method -import kotlin.reflect.IllegalPropertyAccessException -import kotlin.reflect.KMutableTopLevelExtensionProperty -import kotlin.reflect.KTopLevelExtensionProperty - -open class KTopLevelExtensionPropertyImpl : DescriptorBasedProperty, KTopLevelExtensionProperty, KPropertyImpl { - constructor(container: KPackageImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) - - override val name: String get() = descriptor.getName().asString() - - override val getter: Method get() = super.getter!! - - override fun get(receiver: T): R { - try { - @suppress("UNCHECKED_CAST") - return getter.invoke(null, receiver) as R - } - catch (e: IllegalAccessException) { - throw IllegalPropertyAccessException(e) - } - } -} - -class KMutableTopLevelExtensionPropertyImpl : - KTopLevelExtensionPropertyImpl, - KMutableTopLevelExtensionProperty, - KMutablePropertyImpl { - constructor(container: KPackageImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) - - override val setter: Method get() = super.setter!! - - override fun set(receiver: T, value: R) { - try { - setter.invoke(null, receiver, value) - } - catch (e: IllegalAccessException) { - throw IllegalPropertyAccessException(e) - } - } -} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KVariableImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KVariableImpl.kt deleted file mode 100644 index 45c7c09d564..00000000000 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KVariableImpl.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package kotlin.reflect.jvm.internal - -import kotlin.reflect.* - -trait KVariableImpl : KVariable, KPropertyImpl - -trait KMutableVariableImpl : KMutableVariable, KVariableImpl, KMutablePropertyImpl diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java index 239a77fa24e..8d7ef554cba 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java @@ -50,32 +50,32 @@ public class ReflectionFactoryImpl extends ReflectionFactory { // Properties @Override - public KMemberProperty memberProperty(String name, KClass owner) { + public KProperty1 memberProperty(String name, KClass owner) { return ((KClassImpl) owner).memberProperty(name); } @Override - public KMutableMemberProperty mutableMemberProperty(String name, KClass owner) { + public KMutableProperty1 mutableMemberProperty(String name, KClass owner) { return ((KClassImpl) owner).mutableMemberProperty(name); } @Override - public KTopLevelVariable topLevelVariable(String name, KPackage owner) { + public KProperty0 topLevelVariable(String name, KPackage owner) { return ((KPackageImpl) owner).topLevelVariable(name); } @Override - public KMutableTopLevelVariable mutableTopLevelVariable(String name, KPackage owner) { + public KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { return ((KPackageImpl) owner).mutableTopLevelVariable(name); } @Override - public KTopLevelExtensionProperty topLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { return ((KPackageImpl) owner).topLevelExtensionProperty(name, receiver); } @Override - public KMutableTopLevelExtensionProperty mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { return ((KPackageImpl) owner).mutableTopLevelExtensionProperty(name, receiver); } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt index e29e44245e5..34f8ef44fb5 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt @@ -41,6 +41,13 @@ public val KPackage.javaFacade: Class<*> get() = (this as KPackageImpl).jClass +/** + * Returns a Java [Field] instance corresponding to the backing field of the given property, + * or `null` if the property has no backing field. + */ +public val KProperty<*>.javaField: Field? + get() = (this as KPropertyImpl<*>).field + /** * Returns a Java [Method] instance corresponding to the getter of the given property, * or `null` if the property has no getter, for example in case of a simple private `val` in a class. @@ -56,45 +63,6 @@ public val KMutableProperty<*>.javaSetter: Method? get() = (this as? KMutablePropertyImpl<*>)?.setter -/** - * Returns a Java [Field] instance corresponding to the backing field of the given top level property, - * or `null` if the property has no backing field. - */ -public val KTopLevelVariable<*>.javaField: Field? - get() = (this as KPropertyImpl<*>).field - -/** - * Returns a Java [Method] instance corresponding to the getter of the given top level property. - */ -public val KTopLevelVariable<*>.javaGetter: Method - get() = (this as KTopLevelVariableImpl<*>).getter - -/** - * Returns a Java [Method] instance corresponding to the setter of the given top level property. - */ -public val KMutableTopLevelVariable<*>.javaSetter: Method - get() = (this as KMutableTopLevelVariableImpl<*>).setter - - -/** - * Returns a Java [Method] instance corresponding to the getter of the given top level extension property. - */ -public val KTopLevelExtensionProperty<*, *>.javaGetter: Method - get() = (this as KTopLevelExtensionPropertyImpl<*, *>).getter - -/** - * Returns a Java [Method] instance corresponding to the setter of the given top level extension property. - */ -public val KMutableTopLevelExtensionProperty<*, *>.javaSetter: Method - get() = (this as KMutableTopLevelExtensionPropertyImpl<*, *>).setter - - -/** - * Returns a Java [Field] instance corresponding to the backing field of the given member property, - * or `null` if the property has no backing field. - */ -public val KMemberProperty<*, *>.javaField: Field? - get() = (this as KPropertyImpl<*>).field // Java reflection -> Kotlin reflection diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt index 093aa963fa4..a98e358f949 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt @@ -17,8 +17,8 @@ package kotlin.reflect.jvm import kotlin.reflect.KProperty -import kotlin.reflect.jvm.internal.KMemberPropertyImpl -import kotlin.reflect.jvm.internal.KMutableMemberPropertyImpl +import kotlin.reflect.jvm.internal.KProperty1Impl +import kotlin.reflect.jvm.internal.KMutableProperty1Impl /** * Provides a way to suppress JVM access checks for a property. @@ -34,11 +34,11 @@ import kotlin.reflect.jvm.internal.KMutableMemberPropertyImpl public var KProperty.accessible: Boolean get() { return when (this) { - is KMutableMemberPropertyImpl<*, R> -> + is KMutableProperty1Impl<*, R> -> field?.isAccessible() ?: true && getter?.isAccessible() ?: true && setter?.isAccessible() ?: true - is KMemberPropertyImpl<*, R> -> + is KProperty1Impl<*, R> -> field?.isAccessible() ?: true && getter?.isAccessible() ?: true else -> { @@ -49,12 +49,12 @@ public var KProperty.accessible: Boolean } set(value) { when (this) { - is KMutableMemberPropertyImpl<*, R> -> { + is KMutableProperty1Impl<*, R> -> { field?.setAccessible(value) getter?.setAccessible(value) setter?.setAccessible(value) } - is KMemberPropertyImpl<*, R> -> { + is KProperty1Impl<*, R> -> { field?.setAccessible(value) getter?.setAccessible(value) } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java b/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java index 6c48b3d55da..e839eeb1196 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java @@ -67,27 +67,27 @@ public class Reflection { // Properties - public static KMemberProperty memberProperty(String name, KClass owner) { + public static KProperty1 memberProperty(String name, KClass owner) { return factory.memberProperty(name, owner); } - public static KMutableMemberProperty mutableMemberProperty(String name, KClass owner) { + public static KMutableProperty1 mutableMemberProperty(String name, KClass owner) { return factory.mutableMemberProperty(name, owner); } - public static KTopLevelVariable topLevelVariable(String name, KPackage owner) { + public static KProperty0 topLevelVariable(String name, KPackage owner) { return factory.topLevelVariable(name, owner); } - public static KMutableTopLevelVariable mutableTopLevelVariable(String name, KPackage owner) { + public static KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { return factory.mutableTopLevelVariable(name, owner); } - public static KTopLevelExtensionProperty topLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public static KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { return factory.topLevelExtensionProperty(name, owner, receiver); } - public static KMutableTopLevelExtensionProperty mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public static KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { return factory.mutableTopLevelExtensionProperty(name, owner, receiver); } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java b/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java index 431863234fa..13b310e76fa 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java @@ -40,27 +40,27 @@ public class ReflectionFactory { // Properties - public KMemberProperty memberProperty(String name, KClass owner) { + public KProperty1 memberProperty(String name, KClass owner) { throw error(); } - public KMutableMemberProperty mutableMemberProperty(String name, KClass owner) { + public KMutableProperty1 mutableMemberProperty(String name, KClass owner) { throw error(); } - public KTopLevelVariable topLevelVariable(String name, KPackage owner) { + public KProperty0 topLevelVariable(String name, KPackage owner) { throw error(); } - public KMutableTopLevelVariable mutableTopLevelVariable(String name, KPackage owner) { + public KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { throw error(); } - public KTopLevelExtensionProperty topLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { throw error(); } - public KMutableTopLevelExtensionProperty mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { + public KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { throw error(); } diff --git a/js/js.translator/testData/callableReference/property/cases/kClassInstanceIsInitializedFirst.kt b/js/js.translator/testData/callableReference/property/cases/kClassInstanceIsInitializedFirst.kt index de0f3d9157b..6682058120e 100644 --- a/js/js.translator/testData/callableReference/property/cases/kClassInstanceIsInitializedFirst.kt +++ b/js/js.translator/testData/callableReference/property/cases/kClassInstanceIsInitializedFirst.kt @@ -1,11 +1,11 @@ // This test was adapted from compiler/testData/codegen/boxWithStdlib/callableReference/property/. package foo -import kotlin.reflect.KMemberProperty +import kotlin.reflect.KProperty1 class A { companion object { - val ref: KMemberProperty = A::foo + val ref: KProperty1 = A::foo } val foo: String = "OK" From 048a9b686e51c3265d3b3b6d221840ab715c3347 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 30 Jun 2015 16:07:51 +0300 Subject: [PATCH 225/450] Generate separate anonymous class for each property reference Each property reference obtained by the '::' operator now causes back-end to generate an anonymous subclass of the corresponding KProperty class, with the customized behavior. This fixes a number of issues: - get/set/name of property references now works without kotlin-reflect.jar in the classpath - get/set/name methods are now overridden with statically-generated property access instead of the default KPropertyImpl's behavior of using Java reflection, which should be a lot faster - references to private/protected properties now work without the need to set 'accessible' flag, because corresponding synthetic accessors are generated at compile-time near the target property #KT-6870 Fixed #KT-6873 Fixed #KT-7033 Fixed --- .../kotlin/codegen/ClosureCodegen.java | 31 +-- .../kotlin/codegen/ExpressionCodegen.java | 109 +++------- .../kotlin/codegen/JvmRuntimeTypes.java | 20 +- .../kotlin/codegen/MemberCodegen.java | 12 ++ .../codegen/PropertyReferenceCodegen.kt | 201 ++++++++++++++++++ .../binding/CodegenAnnotatingVisitor.java | 42 ++-- .../codegen/binding/CodegenBinding.java | 33 +-- .../codegen/context/ClosureContext.java | 4 +- .../kotlin/codegen/context/LocalLookup.java | 2 +- .../codegen/inline/InlineCodegenUtil.java | 2 +- .../kotlin/codegen/inline/LambdaInfo.java | 2 +- .../kotlin/resolve/jvm/AsmTypes.java | 4 + .../reflection/mapping/javaFields.kt | 4 +- .../kt6870_privatePropertyReference.kt | 22 ++ .../properties}/privateClassVal.kt | 2 +- .../properties}/privateClassVar.kt | 2 +- .../properties}/protectedClassVar.kt | 3 +- ...lackBoxWithStdlibCodegenTestGenerated.java | 42 ++-- .../jvm/internal/DescriptorBasedProperty.kt | 10 +- .../jvm/internal/KCallableContainerImpl.kt | 10 +- .../kotlin/reflect/jvm/internal/KClassImpl.kt | 6 - .../reflect/jvm/internal/KPackageImpl.kt | 12 -- .../reflect/jvm/internal/KProperty0Impl.kt | 38 +++- .../reflect/jvm/internal/KProperty1Impl.kt | 42 +++- .../reflect/jvm/internal/KProperty2Impl.kt | 4 +- .../jvm/internal/ReflectionFactoryImpl.java | 29 +-- .../reflect/jvm/internal/RuntimeTypeMapper.kt | 88 ++++---- .../src/kotlin/reflect/jvm/mapping.kt | 17 +- .../jvm/internal/CallableReference.java | 68 ++++++ .../jvm/internal/FunctionReference.java | 13 +- .../internal/MutablePropertyReference.java | 22 ++ .../internal/MutablePropertyReference0.java | 31 +++ .../internal/MutablePropertyReference1.java | 31 +++ .../internal/MutablePropertyReference2.java | 31 +++ .../jvm/internal/PropertyReference.java | 22 ++ .../jvm/internal/PropertyReference0.java | 26 +++ .../jvm/internal/PropertyReference1.java | 26 +++ .../jvm/internal/PropertyReference2.java | 26 +++ .../src/kotlin/jvm/internal/Reflection.java | 24 +-- .../jvm/internal/ReflectionFactory.java | 24 +-- 40 files changed, 833 insertions(+), 304 deletions(-) create mode 100644 compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt rename compiler/testData/codegen/boxWithStdlib/{callableReference/property => reflection/properties}/privateClassVal.kt (88%) rename compiler/testData/codegen/boxWithStdlib/{callableReference/property => reflection/properties}/privateClassVar.kt (89%) rename compiler/testData/codegen/boxWithStdlib/{callableReference/property => reflection/properties}/protectedClassVar.kt (84%) create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/CallableReference.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java create mode 100644 core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index b9f6c7a80d9..e8c1415888d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -202,7 +202,7 @@ public class ClosureCodegen extends MemberCodegen { this.constructor = generateConstructor(); if (isConst(closure)) { - generateConstInstance(); + generateConstInstance(asmType); } genClosureFields(closure, v, typeMapper); @@ -251,30 +251,12 @@ public class ClosureCodegen extends MemberCodegen { ); } - private void generateConstInstance() { - MethodVisitor mv = v.newMethod(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_SYNTHETIC, "", "()V", null, - ArrayUtil.EMPTY_STRING_ARRAY); - InstructionAdapter iv = new InstructionAdapter(mv); - - v.newField(OtherOrigin(element, funDescriptor), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, asmType.getDescriptor(), - null, null); - - if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { - mv.visitCode(); - iv.anew(asmType); - iv.dup(); - iv.invokespecial(asmType.getInternalName(), "", "()V", false); - iv.putstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); - mv.visitInsn(RETURN); - FunctionCodegen.endVisit(mv, "", element); - } - } - private void generateBridge(@NotNull Method bridge, @NotNull Method delegate) { if (bridge.equals(delegate)) return; MethodVisitor mv = - v.newMethod(OtherOrigin(element, funDescriptor), ACC_PUBLIC | ACC_BRIDGE, bridge.getName(), bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY); + v.newMethod(OtherOrigin(element, funDescriptor), ACC_PUBLIC | ACC_BRIDGE, + bridge.getName(), bridge.getDescriptor(), null, ArrayUtil.EMPTY_STRING_ARRAY); if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return; @@ -306,6 +288,7 @@ public class ClosureCodegen extends MemberCodegen { FunctionCodegen.endVisit(mv, "bridge", element); } + // TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction? private void generateFunctionReferenceMethods(@NotNull FunctionDescriptor descriptor) { int flags = ACC_PUBLIC | ACC_FINAL; boolean generateBody = state.getClassBuilderMode() == ClassBuilderMode.FULL; @@ -316,7 +299,7 @@ public class ClosureCodegen extends MemberCodegen { if (generateBody) { mv.visitCode(); InstructionAdapter iv = new InstructionAdapter(mv); - generateFunctionReferenceDeclarationContainer(iv, descriptor, typeMapper); + generateCallableReferenceDeclarationContainer(iv, descriptor, typeMapper); iv.areturn(K_DECLARATION_CONTAINER_TYPE); FunctionCodegen.endVisit(iv, "function reference getOwner", element); } @@ -347,9 +330,9 @@ public class ClosureCodegen extends MemberCodegen { } } - private static void generateFunctionReferenceDeclarationContainer( + public static void generateCallableReferenceDeclarationContainer( @NotNull InstructionAdapter iv, - @NotNull FunctionDescriptor descriptor, + @NotNull CallableDescriptor descriptor, @NotNull JetTypeMapper typeMapper ) { DeclarationDescriptor container = descriptor.getContainingDeclaration(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 591f878d981..4efc5b90c7e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.backend.common.CodegenUtil; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.binding.CalculatedClosure; +import org.jetbrains.kotlin.codegen.binding.CodegenBinding; import org.jetbrains.kotlin.codegen.context.*; import org.jetbrains.kotlin.codegen.extensions.ExpressionCodegenExtension; import org.jetbrains.kotlin.codegen.inline.*; @@ -51,7 +52,6 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor; -import org.jetbrains.kotlin.load.kotlin.PackageClassUtils; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.renderer.DescriptorRenderer; @@ -85,7 +85,6 @@ import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Opcodes; import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; -import org.jetbrains.org.objectweb.asm.commons.Method; import java.util.*; @@ -2755,29 +2754,39 @@ public class ExpressionCodegen extends JetVisitor implem (FunctionDescriptor) resolvedCall.getResultingDescriptor()); } - VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression); - if (variableDescriptor == null) { - throw new UnsupportedOperationException("Unsupported callable reference expression: " + expression.getText()); - } - // TODO: this diagnostic should also be reported on function references once they obtain reflection checkReflectionIsAvailable(expression); - VariableDescriptor descriptor = (VariableDescriptor) resolvedCall.getResultingDescriptor(); + VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression); + if (variableDescriptor != null) { + return generatePropertyReference(expression, variableDescriptor, resolvedCall); + } - DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration(); - if (containingDeclaration instanceof PackageFragmentDescriptor) { - return generateTopLevelPropertyReference(descriptor); - } - else if (containingDeclaration instanceof ClassDescriptor) { - return generateMemberPropertyReference(descriptor, (ClassDescriptor) containingDeclaration); - } - else if (containingDeclaration instanceof ScriptDescriptor) { - return generateMemberPropertyReference(descriptor, ((ScriptDescriptor) containingDeclaration).getClassDescriptor()); - } - else { - throw new UnsupportedOperationException("Unsupported callable reference container: " + containingDeclaration); - } + throw new UnsupportedOperationException("Unsupported callable reference expression: " + expression.getText()); + } + + @NotNull + private StackValue generatePropertyReference( + @NotNull JetCallableReferenceExpression expression, + @NotNull VariableDescriptor variableDescriptor, + @NotNull ResolvedCall resolvedCall + ) { + ClassDescriptor classDescriptor = CodegenBinding.anonymousClassForCallable(bindingContext, variableDescriptor); + + ClassBuilder classBuilder = state.getFactory().newVisitor( + OtherOrigin(expression), + typeMapper.mapClass(classDescriptor), + expression.getContainingFile() + ); + + @SuppressWarnings("unchecked") + PropertyReferenceCodegen codegen = new PropertyReferenceCodegen( + state, parentCodegen, context.intoAnonymousClass(classDescriptor, this, OwnerKind.IMPLEMENTATION), + expression, classBuilder, classDescriptor, (ResolvedCall) resolvedCall + ); + codegen.generate(); + + return codegen.putInstanceOnStack(); } private void checkReflectionIsAvailable(@NotNull JetExpression expression) { @@ -2786,64 +2795,6 @@ public class ExpressionCodegen extends JetVisitor implem } } - @NotNull - private StackValue generateTopLevelPropertyReference(@NotNull final VariableDescriptor descriptor) { - PackageFragmentDescriptor containingPackage = (PackageFragmentDescriptor) descriptor.getContainingDeclaration(); - final String packageClassInternalName = PackageClassUtils.getPackageClassInternalName(containingPackage.getFqName()); - - final ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter(); - final Method factoryMethod; - if (receiverParameter != null) { - Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE, getType(Class.class)}; - factoryMethod = descriptor.isVar() - ? method("mutableTopLevelExtensionProperty", K_MUTABLE_PROPERTY1_TYPE, parameterTypes) - : method("topLevelExtensionProperty", K_PROPERTY1_TYPE, parameterTypes); - } - else { - Type[] parameterTypes = new Type[] {JAVA_STRING_TYPE, K_PACKAGE_TYPE}; - factoryMethod = descriptor.isVar() - ? method("mutableTopLevelVariable", K_MUTABLE_PROPERTY0_TYPE, parameterTypes) - : method("topLevelVariable", K_PROPERTY0_TYPE, parameterTypes); - } - - return StackValue.operation(factoryMethod.getReturnType(), new Function1() { - @Override - public Unit invoke(InstructionAdapter v) { - v.visitLdcInsn(descriptor.getName().asString()); - v.getstatic(packageClassInternalName, JvmAbi.KOTLIN_PACKAGE_FIELD_NAME, K_PACKAGE_TYPE.getDescriptor()); - - if (receiverParameter != null) { - putJavaLangClassInstance(v, typeMapper.mapType(receiverParameter)); - } - - v.invokestatic(REFLECTION, factoryMethod.getName(), factoryMethod.getDescriptor(), false); - return Unit.INSTANCE$; - } - }); - } - - @NotNull - private StackValue generateMemberPropertyReference( - @NotNull final VariableDescriptor descriptor, - @NotNull final ClassDescriptor containingClass - ) { - final Method factoryMethod = descriptor.isVar() - ? method("mutableMemberProperty", K_MUTABLE_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE) - : method("memberProperty", K_PROPERTY1_TYPE, JAVA_STRING_TYPE, K_CLASS_TYPE); - - return StackValue.operation(factoryMethod.getReturnType(), new Function1() { - @Override - public Unit invoke(InstructionAdapter v) { - v.visitLdcInsn(descriptor.getName().asString()); - StackValue receiverClass = generateClassLiteralReference(typeMapper, containingClass.getDefaultType()); - receiverClass.put(receiverClass.type, v); - v.invokestatic(REFLECTION, factoryMethod.getName(), factoryMethod.getDescriptor(), false); - - return Unit.INSTANCE$; - } - }); - } - @NotNull public static StackValue generateClassLiteralReference(@NotNull final JetTypeMapper typeMapper, @NotNull final JetType type) { return StackValue.operation(K_CLASS_TYPE, new Function1() { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java index 5db8904a904..492048c5675 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.java @@ -29,15 +29,15 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; +import java.util.*; import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns; public class JvmRuntimeTypes { private final ClassDescriptor lambda; private final ClassDescriptor functionReference; + private final List propertyReferences; + private final List mutablePropertyReferences; public JvmRuntimeTypes() { ModuleDescriptorImpl module = new ModuleDescriptorImpl( @@ -49,6 +49,13 @@ public class JvmRuntimeTypes { this.lambda = createClass(kotlinJvmInternal, "Lambda"); this.functionReference = createClass(kotlinJvmInternal, "FunctionReference"); + this.propertyReferences = new ArrayList(3); + this.mutablePropertyReferences = new ArrayList(3); + + for (int i = 0; i <= 2; i++) { + propertyReferences.add(createClass(kotlinJvmInternal, "PropertyReference" + i)); + mutablePropertyReferences.add(createClass(kotlinJvmInternal, "MutablePropertyReference" + i)); + } } @NotNull @@ -98,4 +105,11 @@ public class JvmRuntimeTypes { return Arrays.asList(functionReference.getDefaultType(), functionType); } + + @NotNull + public JetType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) { + int arity = (descriptor.getExtensionReceiverParameter() != null ? 1 : 0) + + (descriptor.getDispatchReceiverParameter() != null ? 1 : 0); + return (descriptor.isVar() ? mutablePropertyReferences : propertyReferences).get(arity).getDefaultType(); + } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index 6e0108e2d50..97724959a7b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -532,4 +532,16 @@ public abstract class MemberCodegen", "()V", false); + iv.putstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); + } + } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt new file mode 100644 index 00000000000..c7918316638 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -0,0 +1,201 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen + +import org.jetbrains.kotlin.codegen.AsmUtil.method +import org.jetbrains.kotlin.codegen.AsmUtil.writeKotlinSyntheticClassAnnotation +import org.jetbrains.kotlin.codegen.context.ClassContext +import org.jetbrains.kotlin.codegen.state.GenerationState +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KotlinSyntheticClass +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.JetCallableReferenceExpression +import org.jetbrains.kotlin.resolve.DescriptorFactory +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny +import org.jetbrains.kotlin.resolve.jvm.AsmTypes.* +import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin +import org.jetbrains.kotlin.resolve.scopes.receivers.ScriptReceiver +import org.jetbrains.kotlin.utils.sure +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_FINAL +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_SUPER +import org.jetbrains.org.objectweb.asm.Opcodes.V1_6 +import org.jetbrains.org.objectweb.asm.Type +import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter +import org.jetbrains.org.objectweb.asm.commons.Method + +public class PropertyReferenceCodegen( + state: GenerationState, + parentCodegen: MemberCodegen<*>, + context: ClassContext, + expression: JetCallableReferenceExpression, + classBuilder: ClassBuilder, + private val classDescriptor: ClassDescriptor, + private val resolvedCall: ResolvedCall +) : MemberCodegen(state, parentCodegen, context, expression, classBuilder) { + private val target = resolvedCall.getResultingDescriptor() + private val asmType = typeMapper.mapClass(classDescriptor) + private val superAsmType: Type + + init { + val superClass = classDescriptor.getSuperClassNotAny().sure { "No super class for $classDescriptor" } + superAsmType = typeMapper.mapClass(superClass) + } + + override fun generateDeclaration() { + v.defineClass( + element, + V1_6, + ACC_FINAL or ACC_SUPER or AsmUtil.getVisibilityAccessFlagForAnonymous(classDescriptor), // TODO: test inline + asmType.getInternalName(), + null, + superAsmType.getInternalName(), + emptyArray() + ) + + v.visitSource(element.getContainingFile().getName(), null) + } + + // TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction? + override fun generateBody() { + // TODO: instance should be already wrapped by Reflection + generateConstInstance(asmType) + + generateMethod("property reference init", 0, method("", Type.VOID_TYPE)) { + load(0, OBJECT_TYPE) + invokespecial(superAsmType.getInternalName(), "", "()V", false) + } + + generateMethod("property reference getOwner", ACC_PUBLIC, method("getOwner", K_DECLARATION_CONTAINER_TYPE)) { + ClosureCodegen.generateCallableReferenceDeclarationContainer(this, target, typeMapper) + } + + generateMethod("property reference getName", ACC_PUBLIC, method("getName", JAVA_STRING_TYPE)) { + aconst(target.getName().asString()) + } + + generateMethod("property reference getSignature", ACC_PUBLIC, method("getSignature", JAVA_STRING_TYPE)) { + target as PropertyDescriptor + + val getter = target.getGetter() ?: run { + val defaultGetter = DescriptorFactory.createDefaultGetter(target) + defaultGetter.initialize(target.getType()) + defaultGetter + } + + val method = typeMapper.mapSignature(getter.sure { "No getter: $target" }).getAsmMethod() + aconst(method.getName() + method.getDescriptor()) + } + + generateAccessors() + } + + private fun generateAccessors() { + val dispatchReceiver = resolvedCall.getDispatchReceiver() + val extensionReceiver = resolvedCall.getExtensionReceiver() + val receiverType = + when { + dispatchReceiver is ScriptReceiver -> { + // TODO: fix receiver for scripts, see ScriptReceiver#getType + dispatchReceiver.getDeclarationDescriptor().getClassDescriptor().getDefaultType() + } + dispatchReceiver.exists() -> dispatchReceiver.getType() + extensionReceiver.exists() -> extensionReceiver.getType() + else -> null + } + + fun generateAccessor(method: Method, accessorBody: InstructionAdapter.(StackValue) -> Unit) { + generateMethod("property reference $method", ACC_PUBLIC, method) { + // Note: this descriptor is an inaccurate representation of the get/set method. In particular, it has incorrect + // return type and value parameter types. However, it's created only to be able to use + // ExpressionCodegen#intermediateValueForProperty, which is poorly coupled with everything else. + val fakeDescriptor = SimpleFunctionDescriptorImpl.create( + classDescriptor, Annotations.EMPTY, Name.identifier(method.getName()), CallableMemberDescriptor.Kind.DECLARATION, + SourceElement.NO_SOURCE + ) + fakeDescriptor.initialize(null, classDescriptor.getThisAsReceiverParameter(), emptyList(), emptyList(), + classDescriptor.builtIns.getAnyType(), Modality.OPEN, Visibilities.PUBLIC) + + val fakeCodegen = ExpressionCodegen( + this, FrameMap(), OBJECT_TYPE, context.intoFunction(fakeDescriptor), state, this@PropertyReferenceCodegen + ) + + val receiver = + if (receiverType != null) StackValue.coercion(StackValue.local(1, OBJECT_TYPE), typeMapper.mapType(receiverType)) + else StackValue.none() + val value = fakeCodegen.intermediateValueForProperty(target as PropertyDescriptor, false, null, receiver) + + accessorBody(value) + } + } + + val getterParameters = if (receiverType != null) arrayOf(OBJECT_TYPE) else emptyArray() + generateAccessor(method("get", OBJECT_TYPE, *getterParameters)) { value -> + value.put(OBJECT_TYPE, this) + } + + if (!target.isVar()) return + + val setterParameters = (getterParameters + arrayOf(OBJECT_TYPE)).toTypedArray() + generateAccessor(method("set", Type.VOID_TYPE, *setterParameters)) { value -> + // Hard-coded 1 or 2 is safe here because there's only java/lang/Object in the signature, no double/long parameters + value.store(StackValue.local(if (receiverType != null) 2 else 1, OBJECT_TYPE), this) + } + } + + private fun generateMethod(debugString: String, access: Int, method: Method, generate: InstructionAdapter.() -> Unit) { + val mv = v.newMethod(JvmDeclarationOrigin.NO_ORIGIN, access, method.getName(), method.getDescriptor(), null, null) + + if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { + val iv = InstructionAdapter(mv) + iv.visitCode() + iv.generate() + iv.areturn(method.getReturnType()) + FunctionCodegen.endVisit(mv, debugString, element) + } + } + + override fun generateKotlinAnnotation() { + writeKotlinSyntheticClassAnnotation(v, KotlinSyntheticClass.Kind.CALLABLE_REFERENCE_WRAPPER) + } + + public fun putInstanceOnStack(): StackValue { + val hasReceiver = target.getDispatchReceiverParameter() != null || target.getExtensionReceiverParameter() != null + + val method = + when { + hasReceiver -> when { + target.isVar() -> method("mutableProperty1", K_MUTABLE_PROPERTY1_TYPE, MUTABLE_PROPERTY_REFERENCE1) + else -> method("property1", K_PROPERTY1_TYPE, PROPERTY_REFERENCE1) + } + else -> when { + target.isVar() -> method("mutableProperty0", K_MUTABLE_PROPERTY0_TYPE, MUTABLE_PROPERTY_REFERENCE0) + else -> method("property0", K_PROPERTY0_TYPE, PROPERTY_REFERENCE0) + } + } + + return StackValue.operation(method.getReturnType()) { iv -> + iv.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()) + iv.invokestatic(REFLECTION, method.getName(), method.getDescriptor(), false) + } + } +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index c93832eaec0..69855dca290 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -84,15 +84,15 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { } @NotNull - private ClassDescriptor recordClassForFunction( + private ClassDescriptor recordClassForCallable( @NotNull JetElement element, - @NotNull FunctionDescriptor funDescriptor, + @NotNull CallableDescriptor callableDescriptor, @NotNull Collection supertypes, @NotNull String name ) { String simpleName = name.substring(name.lastIndexOf('/') + 1); ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl( - correctContainerForLambda(funDescriptor, element), + correctContainerForLambda(callableDescriptor, element), Name.special(""), Modality.FINAL, supertypes, @@ -100,13 +100,13 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { ); classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.emptySet(), null); - bindingTrace.record(CLASS_FOR_FUNCTION, funDescriptor, classDescriptor); + bindingTrace.record(CLASS_FOR_CALLABLE, callableDescriptor, classDescriptor); return classDescriptor; } @NotNull @SuppressWarnings("ConstantConditions") - private DeclarationDescriptor correctContainerForLambda(@NotNull FunctionDescriptor descriptor, @NotNull JetElement function) { + private DeclarationDescriptor correctContainerForLambda(@NotNull CallableDescriptor descriptor, @NotNull JetElement function) { DeclarationDescriptor container = descriptor.getContainingDeclaration(); // In almost all cases the function's direct container is the correct container to consider in JVM back-end @@ -286,7 +286,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { String name = inventAnonymousClassName(expression); Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); - ClassDescriptor classDescriptor = recordClassForFunction(functionLiteral, functionDescriptor, supertypes, name); + ClassDescriptor classDescriptor = recordClassForCallable(functionLiteral, functionDescriptor, supertypes, name); recordClosure(classDescriptor, name); classStack.push(classDescriptor); @@ -298,17 +298,31 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { @Override public void visitCallableReferenceExpression(@NotNull JetCallableReferenceExpression expression) { - FunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression); - // working around a problem with shallow analysis - if (functionDescriptor == null) return; - ResolvedCall referencedFunction = CallUtilPackage.getResolvedCall(expression.getCallableReference(), bindingContext); if (referencedFunction == null) return; - Collection supertypes = - runtimeTypes.getSupertypesForFunctionReference((FunctionDescriptor) referencedFunction.getResultingDescriptor()); + CallableDescriptor target = referencedFunction.getResultingDescriptor(); + + CallableDescriptor callableDescriptor; + Collection supertypes; + + if (target instanceof FunctionDescriptor) { + callableDescriptor = bindingContext.get(FUNCTION, expression); + if (callableDescriptor == null) return; + + supertypes = runtimeTypes.getSupertypesForFunctionReference((FunctionDescriptor) target); + } + else if (target instanceof PropertyDescriptor) { + callableDescriptor = bindingContext.get(VARIABLE, expression); + if (callableDescriptor == null) return; + + supertypes = Collections.singleton(runtimeTypes.getSupertypeForPropertyReference((PropertyDescriptor) target)); + } + else { + return; + } String name = inventAnonymousClassName(expression); - ClassDescriptor classDescriptor = recordClassForFunction(expression, functionDescriptor, supertypes, name); + ClassDescriptor classDescriptor = recordClassForCallable(expression, callableDescriptor, supertypes, name); recordClosure(classDescriptor, name); classStack.push(classDescriptor); @@ -354,7 +368,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { else { String name = inventAnonymousClassName(function); Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); - ClassDescriptor classDescriptor = recordClassForFunction(function, functionDescriptor, supertypes, name); + ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name); recordClosure(classDescriptor, name); classStack.push(classDescriptor); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java index e5e9355c4af..bfbcb51e979 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java @@ -40,16 +40,14 @@ import org.jetbrains.org.objectweb.asm.Type; import java.util.*; -import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isInterface; import static org.jetbrains.kotlin.resolve.BindingContext.*; import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration; -import static org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage.getResolvedCall; import static org.jetbrains.kotlin.resolve.source.SourcePackage.toSourceElement; public class CodegenBinding { public static final WritableSlice CLOSURE = Slices.createSimpleSlice(); - public static final WritableSlice CLASS_FOR_FUNCTION = Slices.createSimpleSlice(); + public static final WritableSlice CLASS_FOR_CALLABLE = Slices.createSimpleSlice(); public static final WritableSlice CLASS_FOR_SCRIPT = Slices.createSimpleSlice(); @@ -110,34 +108,41 @@ public class CodegenBinding { } @NotNull - public static ClassDescriptor anonymousClassForFunction( + public static ClassDescriptor anonymousClassForCallable( @NotNull BindingContext bindingContext, - @NotNull FunctionDescriptor descriptor + @NotNull CallableDescriptor descriptor ) { //noinspection ConstantConditions - return bindingContext.get(CLASS_FOR_FUNCTION, descriptor); + return bindingContext.get(CLASS_FOR_CALLABLE, descriptor); } @NotNull public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull JetElement expression) { if (expression instanceof JetObjectLiteralExpression) { - JetObjectLiteralExpression jetObjectLiteralExpression = (JetObjectLiteralExpression) expression; - expression = jetObjectLiteralExpression.getObjectDeclaration(); + expression = ((JetObjectLiteralExpression) expression).getObjectDeclaration(); } ClassDescriptor descriptor = bindingContext.get(CLASS, expression); - if (descriptor == null) { - SimpleFunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression); - assert functionDescriptor != null : "Couldn't find function descriptor for " + PsiUtilPackage.getElementTextWithContext(expression); + if (descriptor != null) { + return getAsmType(bindingContext, descriptor); + } + + SimpleFunctionDescriptor functionDescriptor = bindingContext.get(FUNCTION, expression); + if (functionDescriptor != null) { return asmTypeForAnonymousClass(bindingContext, functionDescriptor); } - return getAsmType(bindingContext, descriptor); + VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression); + if (variableDescriptor != null) { + return asmTypeForAnonymousClass(bindingContext, variableDescriptor); + } + + throw new IllegalStateException("Couldn't compute ASM type for " + PsiUtilPackage.getElementTextWithContext(expression)); } @NotNull - public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull FunctionDescriptor descriptor) { - return getAsmType(bindingContext, anonymousClassForFunction(bindingContext, descriptor)); + public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull CallableDescriptor descriptor) { + return getAsmType(bindingContext, anonymousClassForCallable(bindingContext, descriptor)); } public static boolean canHaveOuter(@NotNull BindingContext bindingContext, @NotNull ClassDescriptor classDescriptor) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ClosureContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ClosureContext.java index 96a2f541028..e51bc7ced13 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ClosureContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/ClosureContext.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.codegen.OwnerKind; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.anonymousClassForFunction; +import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.anonymousClassForCallable; public class ClosureContext extends ClassContext { private final FunctionDescriptor functionDescriptor; @@ -33,7 +33,7 @@ public class ClosureContext extends ClassContext { @Nullable CodegenContext parentContext, @NotNull LocalLookup localLookup ) { - super(typeMapper, anonymousClassForFunction(typeMapper.getBindingContext(), functionDescriptor), + super(typeMapper, anonymousClassForCallable(typeMapper.getBindingContext(), functionDescriptor), OwnerKind.IMPLEMENTATION, parentContext, localLookup); this.functionDescriptor = functionDescriptor; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java index 401a7314ebd..8f1413c69c4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/LocalLookup.java @@ -103,7 +103,7 @@ public interface LocalLookup { BindingContext bindingContext = state.getBindingContext(); Type localType = asmTypeForAnonymousClass(bindingContext, vd); - MutableClosure localFunClosure = bindingContext.get(CLOSURE, bindingContext.get(CLASS_FOR_FUNCTION, vd)); + MutableClosure localFunClosure = bindingContext.get(CLOSURE, bindingContext.get(CLASS_FOR_CALLABLE, vd)); if (localFunClosure != null && JvmCodegenUtil.isConst(localFunClosure)) { // This is an optimization: we can obtain an instance of a const closure simply by GETSTATIC ...$instance // (instead of passing this instance to the constructor and storing as a field) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java index d5f142da4e1..d35b9448bca 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegenUtil.java @@ -234,7 +234,7 @@ public class InlineCodegenUtil { return type.getInternalName(); } else if (currentDescriptor instanceof FunctionDescriptor) { ClassDescriptor descriptor = - typeMapper.getBindingContext().get(CodegenBinding.CLASS_FOR_FUNCTION, (FunctionDescriptor) currentDescriptor); + typeMapper.getBindingContext().get(CodegenBinding.CLASS_FOR_CALLABLE, (FunctionDescriptor) currentDescriptor); if (descriptor != null) { Type type = typeMapper.mapType(descriptor); return type.getInternalName(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.java index e8e6656557c..c3782e78277 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/LambdaInfo.java @@ -70,7 +70,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner { functionDescriptor = bindingContext.get(BindingContext.FUNCTION, expression); assert functionDescriptor != null : "Function is not resolved to descriptor: " + expression.getText(); - classDescriptor = anonymousClassForFunction(bindingContext, functionDescriptor); + classDescriptor = anonymousClassForCallable(bindingContext, functionDescriptor); closureClassType = asmTypeForAnonymousClass(bindingContext, functionDescriptor); closure = bindingContext.get(CLOSURE, classDescriptor); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java index 853ec58a853..ea288900c2c 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/AsmTypes.java @@ -36,6 +36,10 @@ public class AsmTypes { public static final Type LAMBDA = Type.getObjectType("kotlin/jvm/internal/Lambda"); public static final Type FUNCTION_REFERENCE = Type.getObjectType("kotlin/jvm/internal/FunctionReference"); + public static final Type PROPERTY_REFERENCE0 = Type.getObjectType("kotlin/jvm/internal/PropertyReference0"); + public static final Type PROPERTY_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/PropertyReference1"); + public static final Type MUTABLE_PROPERTY_REFERENCE0 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference0"); + public static final Type MUTABLE_PROPERTY_REFERENCE1 = Type.getObjectType("kotlin/jvm/internal/MutablePropertyReference1"); public static final Type K_CLASS_TYPE = reflect("KClass"); public static final Type K_CLASS_ARRAY_TYPE = Type.getObjectType("[" + K_CLASS_TYPE.getDescriptor()); diff --git a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt index 8d89bd89451..bd5f9a4fc71 100644 --- a/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt +++ b/compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaFields.kt @@ -10,8 +10,8 @@ fun box(): String { val s = J::s // Check that correct reflection objects are created - assert(i.javaClass.getSimpleName() == "KProperty1Impl", "Fail i class") - assert(s.javaClass.getSimpleName() == "KMutableProperty1Impl", "Fail s class") + assert(i !is KMutableProperty<*>, "Fail i class: ${i.javaClass}") + assert(s is KMutableProperty<*>, "Fail s class: ${s.javaClass}") // Check that no Method objects are created for such properties assert(i.javaGetter == null, "Fail i getter") diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt new file mode 100644 index 00000000000..3bfa39df049 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt @@ -0,0 +1,22 @@ +class Test { + private var iv = 1 + + public fun exec() { + val t = object : Thread() { + override fun run() { + ::iv.get(this@Test) + ::iv.set(this@Test, 2) + } + } + t.start() + t.join(1000) + } + + fun result() = if (iv == 2) "OK" else "Fail $iv" +} + +fun box(): String { + val t = Test() + t.exec() + return t.result() +} diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVal.kt similarity index 88% rename from compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVal.kt index 99f6d3ee6d9..6a0d84da88d 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVal.kt @@ -5,7 +5,7 @@ import kotlin.reflect.jvm.accessible class Result { private val value = "OK" - fun ref(): KProperty1 = ::value + fun ref() = Result::class.properties.single() as KProperty1 } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVar.kt similarity index 89% rename from compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVar.kt index 0d5ea464a93..81f336e698f 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVar.kt @@ -5,7 +5,7 @@ import kotlin.reflect.jvm.accessible class A { private var value = 0 - fun ref(): KMutableProperty1 = ::value + fun ref() = A::class.properties.single() as KMutableProperty1 } fun box(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/callableReference/property/protectedClassVar.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt similarity index 84% rename from compiler/testData/codegen/boxWithStdlib/callableReference/property/protectedClassVar.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt index 9263a9b188f..578b45f3e2e 100644 --- a/compiler/testData/codegen/boxWithStdlib/callableReference/property/protectedClassVar.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt @@ -1,10 +1,11 @@ import kotlin.reflect.IllegalPropertyAccessException import kotlin.reflect.jvm.accessible +import kotlin.reflect.KMutableProperty1 class A(param: String) { protected var v: String = param - fun ref() = ::v + fun ref() = A::class.properties.single() as KMutableProperty1 } fun box(): String { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index a02c2e6c25e..561b9c1c6ea 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -795,6 +795,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("kt6870_privatePropertyReference.kt") + public void testKt6870_privatePropertyReference() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/kt6870_privatePropertyReference.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("localClassVar.kt") public void testLocalClassVar() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/localClassVar.kt"); @@ -813,24 +819,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("privateClassVal.kt") - public void testPrivateClassVal() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVal.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("privateClassVar.kt") - public void testPrivateClassVar() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/privateClassVar.kt"); - doTestWithStdlib(fileName); - } - - @TestMetadata("protectedClassVar.kt") - public void testProtectedClassVar() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/protectedClassVar.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("publicClassValAccessible.kt") public void testPublicClassValAccessible() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/property/publicClassValAccessible.kt"); @@ -3222,6 +3210,18 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("privateClassVal.kt") + public void testPrivateClassVal() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVal.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("privateClassVar.kt") + public void testPrivateClassVar() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/privateClassVar.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("privateFakeOverrideFromSuperclass.kt") public void testPrivateFakeOverrideFromSuperclass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/privateFakeOverrideFromSuperclass.kt"); @@ -3240,6 +3240,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("protectedClassVar.kt") + public void testProtectedClassVar() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/protectedClassVar.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("simpleGetProperties.kt") public void testSimpleGetProperties() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/simpleGetProperties.kt"); diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt index c281e039e43..a0646108cb5 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt @@ -30,17 +30,17 @@ import java.lang.reflect.Method abstract class DescriptorBasedProperty protected constructor( container: KCallableContainerImpl, name: String, - receiverParameterDesc: String?, + signature: String, descriptorInitialValue: PropertyDescriptor? ) { - constructor(container: KCallableContainerImpl, name: String, receiverParameterClass: Class<*>?) : this( - container, name, receiverParameterClass?.desc, null + constructor(container: KCallableContainerImpl, name: String, signature: String) : this( + container, name, signature, null ) constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : this( container, descriptor.getName().asString(), - descriptor.getExtensionReceiverParameter()?.getType()?.let { type -> RuntimeTypeMapper.mapTypeToJvmDesc(type) }, + RuntimeTypeMapper.mapPropertySignature(descriptor), descriptor ) @@ -51,7 +51,7 @@ abstract class DescriptorBasedProperty protected constructor( ) protected val descriptor: PropertyDescriptor by ReflectProperties.lazySoft(descriptorInitialValue) { - container.findPropertyDescriptor(name, receiverParameterDesc) + container.findPropertyDescriptor(name, signature) } // null if this is a property declared in a foreign (Java) class diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt index bedc410dd47..08141bae80b 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KCallableContainerImpl.kt @@ -43,20 +43,16 @@ abstract class KCallableContainerImpl : KDeclarationContainer { abstract val scope: JetScope - fun findPropertyDescriptor(name: String, receiverDesc: String? = null): PropertyDescriptor { + fun findPropertyDescriptor(name: String, signature: String): PropertyDescriptor { val properties = scope .getProperties(Name.guess(name)) .filter { descriptor -> descriptor is PropertyDescriptor && - descriptor.getName().asString() == name && - with(descriptor.getExtensionReceiverParameter()) { - (this == null && receiverDesc == null) || - (this != null && RuntimeTypeMapper.mapTypeToJvmDesc(getType()) == receiverDesc) - } + RuntimeTypeMapper.mapPropertySignature(descriptor) == signature } if (properties.size() != 1) { - val debugText = if (receiverDesc == null) name else "'$receiverDesc.$name'" + val debugText = "'$name' (JVM signature: $signature)" throw KotlinReflectionInternalError( if (properties.isEmpty()) "Property $debugText not resolved in $this" else "${properties.size()} properties $debugText resolved in $this: $properties" diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt index 73c98ce0a1a..903648d59cf 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.kt @@ -104,12 +104,6 @@ class KClassImpl(override val jClass: Class) : KCallableContainerImpl(), K .map(create) .toList() - fun memberProperty(name: String): KProperty1 = - KProperty1Impl(this, name, null) - - fun mutableMemberProperty(name: String): KMutableProperty1 = - KMutableProperty1Impl(this, name, null) - override fun equals(other: Any?): Boolean = other is KClassImpl<*> && jClass == other.jClass diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt index 22c389274ab..22d236f0b45 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.kt @@ -31,18 +31,6 @@ class KPackageImpl(override val jClass: Class<*>) : KCallableContainerImpl(), KP override val scope: JetScope get() = descriptor.memberScope - fun topLevelVariable(name: String): KProperty0<*> = - KProperty0Impl(this, name) - - fun mutableTopLevelVariable(name: String): KMutableProperty0<*> = - KMutableProperty0Impl(this, name) - - fun topLevelExtensionProperty(name: String, receiver: Class): KProperty1 = - KProperty1Impl(this, name, receiver) - - fun mutableTopLevelExtensionProperty(name: String, receiver: Class): KMutableProperty1 = - KMutableProperty1Impl(this, name, receiver) - override fun equals(other: Any?): Boolean = other is KPackageImpl && jClass == other.jClass diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt index 0fa44d92f64..fcbfd7c12aa 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt @@ -17,12 +17,14 @@ package kotlin.reflect.jvm.internal import java.lang.reflect.Method +import kotlin.jvm.internal.MutablePropertyReference0 +import kotlin.jvm.internal.PropertyReference0 import kotlin.reflect.IllegalPropertyAccessException import kotlin.reflect.KMutableProperty0 import kotlin.reflect.KProperty0 open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KPropertyImpl { - constructor(container: KPackageImpl, name: String) : super(container, name, null) + constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) override val name: String get() = descriptor.getName().asString() @@ -39,8 +41,8 @@ open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KProp } } -class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutablePropertyImpl { - constructor(container: KPackageImpl, name: String) : super(container, name) +open class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutablePropertyImpl { + constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) override val setter: Method get() = super.setter!! @@ -53,3 +55,33 @@ class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutab } } } + + +class KProperty0FromReferenceImpl( + val reference: PropertyReference0 +) : KProperty0Impl( + reference.getOwner() as KCallableContainerImpl, + reference.getName(), + reference.getSignature() +) { + override val name: String get() = reference.getName() + + override fun get(): Any? = reference.get() +} + + +class KMutableProperty0FromReferenceImpl( + val reference: MutablePropertyReference0 +) : KMutableProperty0Impl( + reference.getOwner() as KCallableContainerImpl, + reference.getName(), + reference.getSignature() +) { + override val name: String get() = reference.getName() + + override fun get(): Any? = reference.get() + + override fun set(value: Any?) { + reference.set(value) + } +} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt index e575e316192..d9d249442b6 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt @@ -21,11 +21,11 @@ import java.lang.reflect.Modifier import kotlin.reflect.IllegalPropertyAccessException import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty1 +import kotlin.jvm.internal.MutablePropertyReference1 +import kotlin.jvm.internal.PropertyReference1 open class KProperty1Impl : DescriptorBasedProperty, KProperty1, KPropertyImpl { - constructor(container: KCallableContainerImpl, name: String, receiverParameterClass: Class<*>?) : super( - container, name, receiverParameterClass - ) + constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) @@ -56,10 +56,8 @@ open class KProperty1Impl : DescriptorBasedProperty, KProperty1, } -class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1, KMutablePropertyImpl { - constructor(container: KCallableContainerImpl, name: String, receiverParameterClass: Class<*>?) : super( - container, name, receiverParameterClass - ) +open class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1, KMutablePropertyImpl { + constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) @@ -86,3 +84,33 @@ class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1( + reference.getOwner() as KCallableContainerImpl, + reference.getName(), + reference.getSignature() +) { + override val name: String get() = reference.getName() + + override fun get(receiver: Any?): Any? = reference.get(receiver) +} + + +class KMutableProperty1FromReferenceImpl( + val reference: MutablePropertyReference1 +) : KMutableProperty1Impl( + reference.getOwner() as KCallableContainerImpl, + reference.getName(), + reference.getSignature() +) { + override val name: String get() = reference.getName() + + override fun get(receiver: Any?): Any? = reference.get(receiver) + + override fun set(receiver: Any?, value: Any?) { + reference.set(receiver, value) + } +} diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt index 9a65d8e8e88..d67def0ccd2 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt @@ -24,7 +24,7 @@ import kotlin.reflect.KMutableProperty2 import kotlin.reflect.KProperty2 open class KProperty2Impl : DescriptorBasedProperty, KProperty2, KPropertyImpl { - constructor(container: KClassImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) + constructor(container: KClassImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) @@ -47,7 +47,7 @@ open class KProperty2Impl : DescriptorBasedProperty, KProperty2 : KProperty2Impl, KMutableProperty2, KMutablePropertyImpl { - constructor(container: KClassImpl, name: String, receiverParameterClass: Class) : super(container, name, receiverParameterClass) + constructor(container: KClassImpl, name: String, signature: String) : super(container, name, signature) constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java index 8d7ef554cba..6f86ff69d36 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java @@ -16,8 +16,7 @@ package kotlin.reflect.jvm.internal; -import kotlin.jvm.internal.FunctionReference; -import kotlin.jvm.internal.ReflectionFactory; +import kotlin.jvm.internal.*; import kotlin.reflect.*; /** @@ -50,32 +49,34 @@ public class ReflectionFactoryImpl extends ReflectionFactory { // Properties @Override - public KProperty1 memberProperty(String name, KClass owner) { - return ((KClassImpl) owner).memberProperty(name); + public KProperty0 property0(PropertyReference0 p) { + return new KProperty0FromReferenceImpl(p); } @Override - public KMutableProperty1 mutableMemberProperty(String name, KClass owner) { - return ((KClassImpl) owner).mutableMemberProperty(name); + public KMutableProperty0 mutableProperty0(MutablePropertyReference0 p) { + return new KMutableProperty0FromReferenceImpl(p); } @Override - public KProperty0 topLevelVariable(String name, KPackage owner) { - return ((KPackageImpl) owner).topLevelVariable(name); + public KProperty1 property1(PropertyReference1 p) { + return new KProperty1FromReferenceImpl(p); } @Override - public KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { - return ((KPackageImpl) owner).mutableTopLevelVariable(name); + public KMutableProperty1 mutableProperty1(MutablePropertyReference1 p) { + return new KMutableProperty1FromReferenceImpl(p); } @Override - public KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { - return ((KPackageImpl) owner).topLevelExtensionProperty(name, receiver); + public KProperty2 property2(PropertyReference2 p) { + // TODO: support member extension property references + return p; } @Override - public KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { - return ((KPackageImpl) owner).mutableTopLevelExtensionProperty(name, receiver); + public KMutableProperty2 mutableProperty2(MutablePropertyReference2 p) { + // TODO: support member extension property references + return p; } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt index 529f085bf47..934fd724c47 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt @@ -18,58 +18,25 @@ package kotlin.reflect.jvm.internal import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.PrimitiveType -import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor import org.jetbrains.kotlin.load.java.sources.JavaSourceElement import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.load.java.structure.reflect.* import org.jetbrains.kotlin.load.kotlin.SignatureDeserializer import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.platform.JavaToKotlinClassMap -import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.classId -import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeUtils import kotlin.reflect.KotlinReflectionInternalError object RuntimeTypeMapper { - // TODO: this logic must be shared with JetTypeMapper - fun mapTypeToJvmDesc(type: JetType): String { - val classifier = type.getConstructor().getDeclarationDescriptor() - if (classifier is TypeParameterDescriptor) { - return mapTypeToJvmDesc(classifier.getUpperBounds().first()) - } - - if (KotlinBuiltIns.isArray(type)) { - val elementType = KotlinBuiltIns.getInstance().getArrayElementType(type) - // makeNullable is called here to map primitive types to the corresponding wrappers, - // because the given type is Array, not SomethingArray - return "[" + mapTypeToJvmDesc(TypeUtils.makeNullable(elementType)) - } - - val classDescriptor = classifier as ClassDescriptor - val fqName = DescriptorUtils.getFqName(classDescriptor) - - KotlinBuiltIns.getPrimitiveTypeByFqName(fqName)?.let { primitiveType -> - val jvmType = JvmPrimitiveType.get(primitiveType) - return if (TypeUtils.isNullableType(type)) ClassId.topLevel(jvmType.getWrapperFqName()).desc else jvmType.getDesc() - } - - KotlinBuiltIns.getPrimitiveTypeByArrayClassFqName(fqName)?.let { primitiveType -> - return "[" + JvmPrimitiveType.get(primitiveType).getDesc() - } - - JavaToKotlinClassMap.INSTANCE.mapKotlinToJava(fqName)?.let { return it.desc } - - return classDescriptor.classId.desc - } - fun mapSignature(function: FunctionDescriptor): String { if (function is DeserializedSimpleFunctionDescriptor) { val proto = function.getProto() @@ -125,6 +92,50 @@ object RuntimeTypeMapper { } } + fun mapPropertySignature(property: PropertyDescriptor): String { + if (property is DeserializedPropertyDescriptor) { + val proto = property.proto + val nameResolver = property.nameResolver + if (!proto.hasExtension(JvmProtoBuf.propertySignature)) { + throw KotlinReflectionInternalError("No metadata found for $property") + } + val signature = proto.getExtension(JvmProtoBuf.propertySignature) + val deserializer = SignatureDeserializer(nameResolver) + + if (signature.hasGetter()) { + return deserializer.methodSignatureString(signature.getGetter()) + } + + // In case the property doesn't have a getter, construct the signature of its imaginary default getter. + // See PropertyReference#getSignature + val field = signature.getField() + + // TODO: some kind of test on the Java Bean convention? + return getterName(nameResolver.getString(field.getName())) + + "()" + + deserializer.typeDescriptor(field.getType()) + } + else if (property is JavaPropertyDescriptor) { + val method = (property.getSource() as? JavaSourceElement)?.javaElement as? JavaField ?: + throw KotlinReflectionInternalError("Incorrect resolution sequence for Java field $property") + + return StringBuilder { + append(getterName(method.getName().asString())) + append("()") + appendJavaType(method.getType()) + }.toString() + } + else throw KotlinReflectionInternalError("Unknown origin of $property (${property.javaClass})") + } + + private fun getterName(propertyName: String): String { + return JvmAbi.GETTER_PREFIX + propertyName.capitalizeWithJavaBeanConvention() + } + + private fun String.capitalizeWithJavaBeanConvention(): String { + return if (length() > 1 && this[1].isUpperCase()) this else capitalize() + } + fun mapJvmClassToKotlinClassId(klass: Class<*>): ClassId { if (klass.isArray()) { klass.getComponentType().primitiveType?.let { @@ -147,7 +158,4 @@ object RuntimeTypeMapper { private val Class<*>.primitiveType: PrimitiveType? get() = if (isPrimitive()) JvmPrimitiveType.get(getSimpleName()).getPrimitiveType() else null - - private val ClassId.desc: String - get() = "L${JvmClassName.byClassId(this).getInternalName()};" } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt index 34f8ef44fb5..be860b2dc80 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt @@ -95,17 +95,10 @@ public val Field.kotlin: KProperty<*>? get() { if (isSynthetic()) return null - val clazz = getDeclaringClass() - val name = getName() - val modifiers = getModifiers() - val static = Modifier.isStatic(modifiers) - val final = Modifier.isFinal(modifiers) - if (static) { - val kPackage = clazz.kotlinPackage - return if (final) Reflection.topLevelVariable(name, kPackage) else Reflection.mutableTopLevelVariable(name, kPackage) - } - else { - val kClass = clazz.kotlin - return if (final) Reflection.memberProperty(name, kClass) else Reflection.mutableMemberProperty(name, kClass) + val clazz = getDeclaringClass().kotlin as KClassImpl + + // TODO: optimize (search by name) + return clazz.properties.firstOrNull { p: KProperty<*> -> + (p as KPropertyImpl<*>).field == this } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/CallableReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/CallableReference.java new file mode 100644 index 00000000000..d0bb16a299b --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/CallableReference.java @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.jvm.KotlinReflectionNotSupportedError; +import kotlin.reflect.KCallable; +import kotlin.reflect.KDeclarationContainer; + +/** + * A superclass for all classes generated by Kotlin compiler for callable references. + * + * All methods from reflection API should be implemented here to throw informative exceptions (see KotlinReflectionNotSupportedError) + */ +public abstract class CallableReference implements KCallable { + + // The following methods provide the information identifying this callable, which is used by the reflection implementation. + // They are supposed to be overridden in each subclass (each anonymous class generated for a callable reference). + + /** + * @return the class or package where the callable should be located, usually specified on the LHS of the '::' operator + */ + public KDeclarationContainer getOwner() { + throw error(); + } + + /** + * @return Kotlin name of the callable, the one which was declared in the source code (@platformName doesn't change it) + */ + @Override + public String getName() { + throw error(); + } + + /** + * @return JVM signature of the callable, e.g. "println(Ljava/lang/Object;)V". If this is a property reference, + * returns the JVM signature of its getter, e.g. "getFoo(Ljava/lang/String;)I". If the property has no getter in the bytecode + * (e.g. private property in a class), it's still the signature of the imaginary default getter that would be generated otherwise. + * + * Note that technically the signature itself is not even used as a signature per se in reflection implementation, + * but only as a unique and unambiguous way to map a function/property descriptor to a string. + */ + public String getSignature() { + throw error(); + } + + // The following methods are the stub implementations of reflection functions. + // They are called when you're using reflection on a property reference without the reflection implementation in the classpath. + + // (nothing here yet) + + protected static Error error() { + throw new KotlinReflectionNotSupportedError(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java index 8b7511305d7..6aff6021d97 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java @@ -37,29 +37,22 @@ public class FunctionReference extends FunctionImpl implements KFunction { return arity; } - // The following methods provide the information identifying this function, which is used by the reflection implementation. - // They are supposed to be overridden in each subclass (each anonymous class generated for a function reference). + // Most of the following methods are copies from CallableReference, since this class cannot inherit from it public KDeclarationContainer getOwner() { throw error(); } - // Kotlin name of the function, the one which was declared in the source code (@platformName can't change it) + @Override public String getName() { throw error(); } - // JVM signature of the function, e.g. "println(Ljava/lang/Object;)V" public String getSignature() { throw error(); } - // The following methods are the stub implementations of reflection functions. - // They are called when you're using reflection on a function reference without the reflection implementation in the classpath. - - // (nothing here yet) - - private static Error error() { + protected static Error error() { throw new KotlinReflectionNotSupportedError(); } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference.java new file mode 100644 index 00000000000..b5c4b6b7771 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KMutableProperty; + +public abstract class MutablePropertyReference extends PropertyReference implements KMutableProperty { +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java new file mode 100644 index 00000000000..6b19fdcac72 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KMutableProperty0; + +public class MutablePropertyReference0 extends MutablePropertyReference implements KMutableProperty0 { + @Override + public Object get() { + throw error(); + } + + @Override + public void set(Object value) { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java new file mode 100644 index 00000000000..44bd0b747db --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KMutableProperty1; + +public class MutablePropertyReference1 extends MutablePropertyReference implements KMutableProperty1 { + @Override + public Object get(Object receiver) { + throw error(); + } + + @Override + public void set(Object receiver, Object value) { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java new file mode 100644 index 00000000000..eb6688fb5c1 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KMutableProperty2; + +public class MutablePropertyReference2 extends MutablePropertyReference implements KMutableProperty2 { + @Override + public Object get(Object receiver1, Object receiver2) { + throw error(); + } + + @Override + public void set(Object receiver1, Object receiver2, Object value) { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference.java new file mode 100644 index 00000000000..822d9fc9af2 --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KProperty; + +public abstract class PropertyReference extends CallableReference implements KProperty { +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java new file mode 100644 index 00000000000..0c07baf59ff --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KProperty0; + +public class PropertyReference0 extends PropertyReference implements KProperty0 { + @Override + public Object get() { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java new file mode 100644 index 00000000000..3a5df99f07d --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KProperty1; + +public class PropertyReference1 extends PropertyReference implements KProperty1 { + @Override + public Object get(Object receiver) { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java new file mode 100644 index 00000000000..b04fe85ebaa --- /dev/null +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.jvm.internal; + +import kotlin.reflect.KProperty2; + +public class PropertyReference2 extends PropertyReference implements KProperty2 { + @Override + public Object get(Object receiver1, Object receiver2) { + throw error(); + } +} diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java b/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java index e839eeb1196..26bfe9fa704 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Reflection.java @@ -67,27 +67,27 @@ public class Reflection { // Properties - public static KProperty1 memberProperty(String name, KClass owner) { - return factory.memberProperty(name, owner); + public static KProperty0 property0(PropertyReference0 p) { + return factory.property0(p); } - public static KMutableProperty1 mutableMemberProperty(String name, KClass owner) { - return factory.mutableMemberProperty(name, owner); + public static KMutableProperty0 mutableProperty0(MutablePropertyReference0 p) { + return factory.mutableProperty0(p); } - public static KProperty0 topLevelVariable(String name, KPackage owner) { - return factory.topLevelVariable(name, owner); + public static KProperty1 property1(PropertyReference1 p) { + return factory.property1(p); } - public static KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { - return factory.mutableTopLevelVariable(name, owner); + public static KMutableProperty1 mutableProperty1(MutablePropertyReference1 p) { + return factory.mutableProperty1(p); } - public static KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { - return factory.topLevelExtensionProperty(name, owner, receiver); + public static KProperty2 property2(PropertyReference2 p) { + return factory.property2(p); } - public static KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { - return factory.mutableTopLevelExtensionProperty(name, owner, receiver); + public static KMutableProperty2 mutableProperty2(MutablePropertyReference2 p) { + return factory.mutableProperty2(p); } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java b/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java index 13b310e76fa..05adf0b59b7 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/ReflectionFactory.java @@ -40,28 +40,28 @@ public class ReflectionFactory { // Properties - public KProperty1 memberProperty(String name, KClass owner) { - throw error(); + public KProperty0 property0(PropertyReference0 p) { + return p; } - public KMutableProperty1 mutableMemberProperty(String name, KClass owner) { - throw error(); + public KMutableProperty0 mutableProperty0(MutablePropertyReference0 p) { + return p; } - public KProperty0 topLevelVariable(String name, KPackage owner) { - throw error(); + public KProperty1 property1(PropertyReference1 p) { + return p; } - public KMutableProperty0 mutableTopLevelVariable(String name, KPackage owner) { - throw error(); + public KMutableProperty1 mutableProperty1(MutablePropertyReference1 p) { + return p; } - public KProperty1 topLevelExtensionProperty(String name, KPackage owner, Class receiver) { - throw error(); + public KProperty2 property2(PropertyReference2 p) { + return p; } - public KMutableProperty1 mutableTopLevelExtensionProperty(String name, KPackage owner, Class receiver) { - throw error(); + public KMutableProperty2 mutableProperty2(MutablePropertyReference2 p) { + return p; } private Error error() { From fd198accf64f4f12b2e8875e6c3ae6aee6de1863 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 16:24:31 +0300 Subject: [PATCH 226/450] Rename internal field/getter/setter properties in KPropertyImpl To avoid clash with getter/setter which will appear soon in KProperty interface --- .../jvm/internal/DescriptorBasedProperty.kt | 6 +++--- .../reflect/jvm/internal/KProperty0Impl.kt | 8 ++++---- .../reflect/jvm/internal/KProperty1Impl.kt | 8 ++++---- .../reflect/jvm/internal/KProperty2Impl.kt | 10 +++++----- .../reflect/jvm/internal/KPropertyImpl.kt | 6 +++--- .../src/kotlin/reflect/jvm/mapping.kt | 8 ++++---- .../src/kotlin/reflect/jvm/properties.kt | 20 +++++++++---------- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt index a0646108cb5..87ebafd26a1 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/DescriptorBasedProperty.kt @@ -66,21 +66,21 @@ abstract class DescriptorBasedProperty protected constructor( null } - open val field: Field? by ReflectProperties.lazySoft { + open val javaField: Field? by ReflectProperties.lazySoft { val proto = protoData if (proto == null) container.jClass.getField(name) else if (!proto.signature.hasField()) null else container.findFieldBySignature(proto.proto, proto.signature.getField(), proto.nameResolver) } - open val getter: Method? by ReflectProperties.lazySoft { + open val javaGetter: Method? by ReflectProperties.lazySoft { val proto = protoData if (proto == null || !proto.signature.hasGetter()) null else container.findMethodBySignature(proto.signature.getGetter(), proto.nameResolver, descriptor.getGetter()?.getVisibility()?.let { Visibilities.isPrivate(it) } ?: false) } - open val setter: Method? by ReflectProperties.lazySoft { + open val javaSetter: Method? by ReflectProperties.lazySoft { val proto = protoData if (proto == null || !proto.signature.hasSetter()) null else container.findMethodBySignature(proto.signature.getSetter(), proto.nameResolver, diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt index fcbfd7c12aa..f67e5b5c04e 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt @@ -28,12 +28,12 @@ open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KProp override val name: String get() = descriptor.getName().asString() - override val getter: Method get() = super.getter!! + override val javaGetter: Method get() = super.javaGetter!! override fun get(): R { try { @suppress("UNCHECKED_CAST") - return getter.invoke(null) as R + return javaGetter.invoke(null) as R } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) @@ -44,11 +44,11 @@ open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KProp open class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutablePropertyImpl { constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) - override val setter: Method get() = super.setter!! + override val javaSetter: Method get() = super.javaSetter!! override fun set(value: R) { try { - setter.invoke(null, value) + javaSetter.invoke(null, value) } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt index d9d249442b6..b42441dc27f 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt @@ -35,8 +35,8 @@ open class KProperty1Impl : DescriptorBasedProperty, KProperty1, @suppress("UNCHECKED_CAST") override fun get(receiver: T): R { try { - val getter = getter ?: - return field!!.get(receiver) as R + val getter = javaGetter ?: + return javaField!!.get(receiver) as R if (Modifier.isStatic(getter.getModifiers())) { // Workaround the case of platformStatic property in object, getter of which doesn't take a receiver @@ -63,8 +63,8 @@ open class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1 override fun set(receiver: T, value: R) { try { - val setter = setter ?: - return field!!.set(receiver, value) + val setter = javaSetter ?: + return javaField!!.set(receiver, value) if (Modifier.isStatic(setter.getModifiers())) { // Workaround the case of platformStatic property in object, setter of which doesn't take a receiver diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt index d67def0ccd2..e1fd983f1c5 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt @@ -30,14 +30,14 @@ open class KProperty2Impl : DescriptorBasedProperty, KProperty2.getter!! + override val javaGetter: Method get() = super.javaGetter!! - override val field: Field? get() = null + override val javaField: Field? get() = null override fun get(receiver1: D, receiver2: E): R { try { @suppress("UNCHECKED_CAST") - return getter.invoke(receiver1, receiver2) as R + return javaGetter.invoke(receiver1, receiver2) as R } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) @@ -51,11 +51,11 @@ class KMutableProperty2Impl : KProperty2Impl, KMutableProperty constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) - override val setter: Method get() = super.setter!! + override val javaSetter: Method get() = super.javaSetter!! override fun set(receiver1: D, receiver2: E, value: R) { try { - setter.invoke(receiver1, receiver2, value) + javaSetter.invoke(receiver1, receiver2, value) } catch (e: IllegalAccessException) { throw IllegalPropertyAccessException(e) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt index d6e9f6e87a4..c19511af775 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt @@ -20,12 +20,12 @@ import java.lang.reflect.* import kotlin.reflect.* interface KPropertyImpl : KProperty, KCallableImpl { - val field: Field? + val javaField: Field? - val getter: Method? + val javaGetter: Method? } interface KMutablePropertyImpl : KMutableProperty, KPropertyImpl { - val setter: Method? + val javaSetter: Method? } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt index be860b2dc80..9ba00c2bb24 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/mapping.kt @@ -46,21 +46,21 @@ public val KPackage.javaFacade: Class<*> * or `null` if the property has no backing field. */ public val KProperty<*>.javaField: Field? - get() = (this as KPropertyImpl<*>).field + get() = (this as KPropertyImpl<*>).javaField /** * Returns a Java [Method] instance corresponding to the getter of the given property, * or `null` if the property has no getter, for example in case of a simple private `val` in a class. */ public val KProperty<*>.javaGetter: Method? - get() = (this as? KPropertyImpl<*>)?.getter + get() = (this as? KPropertyImpl<*>)?.javaGetter /** * Returns a Java [Method] instance corresponding to the setter of the given mutable property, * or `null` if the property has no setter, for example in case of a simple private `var` in a class. */ public val KMutableProperty<*>.javaSetter: Method? - get() = (this as? KMutablePropertyImpl<*>)?.setter + get() = (this as? KMutablePropertyImpl<*>)?.javaSetter @@ -99,6 +99,6 @@ public val Field.kotlin: KProperty<*>? // TODO: optimize (search by name) return clazz.properties.firstOrNull { p: KProperty<*> -> - (p as KPropertyImpl<*>).field == this + (p as KPropertyImpl<*>).javaField == this } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt index a98e358f949..0996cabb747 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt @@ -35,12 +35,12 @@ public var KProperty.accessible: Boolean get() { return when (this) { is KMutableProperty1Impl<*, R> -> - field?.isAccessible() ?: true && - getter?.isAccessible() ?: true && - setter?.isAccessible() ?: true + javaField?.isAccessible() ?: true && + javaGetter?.isAccessible() ?: true && + javaSetter?.isAccessible() ?: true is KProperty1Impl<*, R> -> - field?.isAccessible() ?: true && - getter?.isAccessible() ?: true + javaField?.isAccessible() ?: true && + javaGetter?.isAccessible() ?: true else -> { // Non-member properties always have public visibility on JVM, thus accessible has no effect on them true @@ -50,13 +50,13 @@ public var KProperty.accessible: Boolean set(value) { when (this) { is KMutableProperty1Impl<*, R> -> { - field?.setAccessible(value) - getter?.setAccessible(value) - setter?.setAccessible(value) + javaField?.setAccessible(value) + javaGetter?.setAccessible(value) + javaSetter?.setAccessible(value) } is KProperty1Impl<*, R> -> { - field?.setAccessible(value) - getter?.setAccessible(value) + javaField?.setAccessible(value) + javaGetter?.setAccessible(value) } } } From 749d0c4a52ae04d2856f2a04c4e9a4c7fbd577e1 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 6 Jul 2015 14:44:56 +0300 Subject: [PATCH 227/450] Minor, simplify KProperty.accessible --- .../src/kotlin/reflect/jvm/properties.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt index 0996cabb747..d3b40bc1b31 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/properties.kt @@ -17,8 +17,8 @@ package kotlin.reflect.jvm import kotlin.reflect.KProperty -import kotlin.reflect.jvm.internal.KProperty1Impl -import kotlin.reflect.jvm.internal.KMutableProperty1Impl +import kotlin.reflect.jvm.internal.KMutablePropertyImpl +import kotlin.reflect.jvm.internal.KPropertyImpl /** * Provides a way to suppress JVM access checks for a property. @@ -34,29 +34,27 @@ import kotlin.reflect.jvm.internal.KMutableProperty1Impl public var KProperty.accessible: Boolean get() { return when (this) { - is KMutableProperty1Impl<*, R> -> + is KMutablePropertyImpl -> javaField?.isAccessible() ?: true && javaGetter?.isAccessible() ?: true && javaSetter?.isAccessible() ?: true - is KProperty1Impl<*, R> -> + is KPropertyImpl -> javaField?.isAccessible() ?: true && javaGetter?.isAccessible() ?: true - else -> { - // Non-member properties always have public visibility on JVM, thus accessible has no effect on them - true - } + else -> throw UnsupportedOperationException("Unknown property: $this ($javaClass)") } } set(value) { when (this) { - is KMutableProperty1Impl<*, R> -> { + is KMutablePropertyImpl -> { javaField?.setAccessible(value) javaGetter?.setAccessible(value) javaSetter?.setAccessible(value) } - is KProperty1Impl<*, R> -> { + is KPropertyImpl -> { javaField?.setAccessible(value) javaGetter?.setAccessible(value) } + else -> throw UnsupportedOperationException("Unknown property: $this ($javaClass)") } } From 4f1247f03ff7b32b9d26215e97b07f7a157c1c80 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 1 Jul 2015 19:08:31 +0300 Subject: [PATCH 228/450] Support property getters/setters in reflection --- .../properties/accessors/accessorNames.kt | 30 ++++++++++ .../accessors/extensionPropertyAccessors.kt | 18 ++++++ .../properties/accessors/memberExtensions.kt | 20 +++++++ .../accessors/memberPropertyAccessors.kt | 15 +++++ .../accessors/topLevelPropertyAccessors.kt | 14 +++++ ...lackBoxWithStdlibCodegenTestGenerated.java | 39 +++++++++++++ core/builtins/src/kotlin/reflect/KCallable.kt | 5 ++ core/builtins/src/kotlin/reflect/KProperty.kt | 56 ++++++++++++++++++- .../reflect/jvm/internal/KProperty0Impl.kt | 12 ++++ .../reflect/jvm/internal/KProperty1Impl.kt | 16 +++++- .../reflect/jvm/internal/KProperty2Impl.kt | 12 ++++ .../reflect/jvm/internal/KPropertyImpl.kt | 16 ++++++ .../internal/MutablePropertyReference0.java | 11 ++++ .../internal/MutablePropertyReference1.java | 11 ++++ .../internal/MutablePropertyReference2.java | 11 ++++ .../jvm/internal/PropertyReference0.java | 5 ++ .../jvm/internal/PropertyReference1.java | 5 ++ .../jvm/internal/PropertyReference2.java | 5 ++ 18 files changed, 297 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/accessorNames.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/extensionPropertyAccessors.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberExtensions.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberPropertyAccessors.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/topLevelPropertyAccessors.kt diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/accessorNames.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/accessorNames.kt new file mode 100644 index 00000000000..fdb3103603b --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/accessorNames.kt @@ -0,0 +1,30 @@ +import kotlin.reflect.* +import kotlin.test.assertEquals + +var foo = "" +var String.bar: String + get() = this + set(value) {} + +class A(var baz: Int) { + var String.quux: String + get() = this + set(value) {} +} + +fun box(): String { + assertEquals("", ::foo.getter.name) + assertEquals("", ::foo.setter.name) + + assertEquals("", String::bar.getter.name) + assertEquals("", String::bar.setter.name) + + assertEquals("", A::baz.getter.name) + assertEquals("", A::baz.setter.name) + + val me = A::class.extensionProperties.single() as KMutableProperty2 + assertEquals("", me.getter.name) + assertEquals("", me.setter.name) + + return "OK" +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/extensionPropertyAccessors.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/extensionPropertyAccessors.kt new file mode 100644 index 00000000000..42cbcc74e80 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/extensionPropertyAccessors.kt @@ -0,0 +1,18 @@ +import kotlin.test.assertEquals + +var state: String = "" + +var String.prop: String + get() = length().toString() + set(value) { state = this + value } + +fun box(): String { + val prop = String::prop + + assertEquals("3", prop.getter.invoke("abc")) + assertEquals("5", prop.getter("defgh")) + + prop.setter("O", "K") + + return state +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberExtensions.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberExtensions.kt new file mode 100644 index 00000000000..fcd53d24ef5 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberExtensions.kt @@ -0,0 +1,20 @@ +import kotlin.reflect.KMutableProperty2 +import kotlin.test.assertEquals + +class C(var state: String) { + var String.prop: String + get() = length().toString() + set(value) { state = this + value } +} + +fun box(): String { + val prop = C::class.extensionProperties.single() as KMutableProperty2 + + val c = C("") + assertEquals("3", prop.getter.invoke(c, "abc")) + assertEquals("1", prop.getter(c, "d")) + + prop.setter(c, "O", "K") + + return c.state +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberPropertyAccessors.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberPropertyAccessors.kt new file mode 100644 index 00000000000..dcf3c560b42 --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberPropertyAccessors.kt @@ -0,0 +1,15 @@ +import kotlin.test.assertEquals + +class C(var state: String) + +fun box(): String { + val prop = C::state + + val c = C("1") + assertEquals("1", prop.getter.invoke(c)) + assertEquals("1", prop.getter(c)) + + prop.setter(c, "OK") + + return prop.get(c) +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/topLevelPropertyAccessors.kt b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/topLevelPropertyAccessors.kt new file mode 100644 index 00000000000..49ab1f5ef8e --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/topLevelPropertyAccessors.kt @@ -0,0 +1,14 @@ +import kotlin.test.assertEquals + +var state: String = "" + +fun box(): String { + val prop = ::state + + assertEquals("", prop.getter.invoke()) + assertEquals("", prop.getter()) + + prop.setter("OK") + + return prop.get() +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 561b9c1c6ea..455bd514b20 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -3251,6 +3251,45 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/simpleGetProperties.kt"); doTestWithStdlib(fileName); } + + @TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Accessors extends AbstractBlackBoxCodegenTest { + @TestMetadata("accessorNames.kt") + public void testAccessorNames() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/accessorNames.kt"); + doTestWithStdlib(fileName); + } + + public void testAllFilesPresentInAccessors() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("extensionPropertyAccessors.kt") + public void testExtensionPropertyAccessors() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/extensionPropertyAccessors.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("memberExtensions.kt") + public void testMemberExtensions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberExtensions.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("memberPropertyAccessors.kt") + public void testMemberPropertyAccessors() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/memberPropertyAccessors.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("topLevelPropertyAccessors.kt") + public void testTopLevelPropertyAccessors() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/properties/accessors/topLevelPropertyAccessors.kt"); + doTestWithStdlib(fileName); + } + } } } diff --git a/core/builtins/src/kotlin/reflect/KCallable.kt b/core/builtins/src/kotlin/reflect/KCallable.kt index 554d3d46fbb..b5e23954ab4 100644 --- a/core/builtins/src/kotlin/reflect/KCallable.kt +++ b/core/builtins/src/kotlin/reflect/KCallable.kt @@ -24,6 +24,11 @@ package kotlin.reflect public interface KCallable { /** * The name of this callable as it was declared in the source code. + * If the callable has no name, a special invented name is created. + * Nameless callables include: + * - constructors have the name "", + * - property accessors: the getter for a property named "foo" will have the name "", + * the setter, similarly, will have the name "". */ public val name: String } diff --git a/core/builtins/src/kotlin/reflect/KProperty.kt b/core/builtins/src/kotlin/reflect/KProperty.kt index b068eff3f55..32cca5e069d 100644 --- a/core/builtins/src/kotlin/reflect/KProperty.kt +++ b/core/builtins/src/kotlin/reflect/KProperty.kt @@ -24,12 +24,40 @@ package kotlin.reflect * * @param R the type of the property. */ -public interface KProperty : KCallable +public interface KProperty : KCallable { + /** The getter of this property, used to obtain the value of the property. */ + public val getter: Getter + + /** + * Represents a property accessor, which is a `get` or `set` method declared alongside the property. + * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/properties.html#getters-and-setters) + * for more information. + * + * @param R the type of the property, which it is an accessor of. + */ + public interface Accessor { + /** The property which this accessor is originated from. */ + public val property: KProperty + } + + /** + * Getter of the property is a `get` method declared alongside the property. + */ + public interface Getter : Accessor, KFunction +} /** * Represents a property declared as a `var`. */ -public interface KMutableProperty : KProperty +public interface KMutableProperty : KProperty { + /** The setter of this mutable property, used to change the value of the property. */ + public val setter: Setter + + /** + * Setter of the property is a `set` method declared alongside the property. + */ + public interface Setter : KProperty.Accessor, KFunction +} /** @@ -42,6 +70,10 @@ public interface KProperty0 : KProperty { * Returns the current value of the property. */ public fun get(): R + + override val getter: Getter + + public interface Getter : KProperty.Getter, () -> R } /** @@ -54,6 +86,10 @@ public interface KMutableProperty0 : KProperty0, KMutableProperty { * @param value the new value to be assigned to this property. */ public fun set(value: R) + + override val setter: Setter + + public interface Setter : KMutableProperty.Setter, (R) -> Unit } @@ -72,6 +108,10 @@ public interface KProperty1 : KProperty { * or an extension receiver if this is a top level extension property. */ public fun get(receiver: T): R + + override val getter: Getter + + public interface Getter : KProperty.Getter, (T) -> R } /** @@ -87,6 +127,10 @@ public interface KMutableProperty1 : KProperty1, KMutableProperty * @param value the new value to be assigned to this property. */ public fun set(receiver: T, value: R) + + override val setter: Setter + + public interface Setter : KMutableProperty.Setter, (T, R) -> Unit } @@ -109,6 +153,10 @@ public interface KProperty2 : KProperty { * @param receiver2 the instance of the second receiver. */ public fun get(receiver1: D, receiver2: E): R + + override val getter: Getter + + public interface Getter : KProperty.Getter, (D, E) -> R } /** @@ -123,4 +171,8 @@ public interface KMutableProperty2 : KProperty2, KMutablePrope * @param value the new value to be assigned to this property. */ public fun set(receiver1: D, receiver2: E, value: R) + + override val setter: Setter + + public interface Setter : KMutableProperty.Setter, (D, E, R) -> Unit } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt index f67e5b5c04e..2877a9111ed 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty0Impl.kt @@ -28,6 +28,8 @@ open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KProp override val name: String get() = descriptor.getName().asString() + override val getter by ReflectProperties.lazy { Getter(this) } + override val javaGetter: Method get() = super.javaGetter!! override fun get(): R { @@ -39,11 +41,17 @@ open class KProperty0Impl : DescriptorBasedProperty, KProperty0, KProp throw IllegalPropertyAccessException(e) } } + + class Getter(override val property: KProperty0Impl) : KPropertyImpl.Getter, KProperty0.Getter { + override fun invoke(): R = property.get() + } } open class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, KMutablePropertyImpl { constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) + override val setter by ReflectProperties.lazy { Setter(this) } + override val javaSetter: Method get() = super.javaSetter!! override fun set(value: R) { @@ -54,6 +62,10 @@ open class KMutableProperty0Impl : KProperty0Impl, KMutableProperty0, K throw IllegalPropertyAccessException(e) } } + + class Setter(override val property: KMutableProperty0Impl) : KMutablePropertyImpl.Setter, KMutableProperty0.Setter { + override fun invoke(value: R): Unit = property.set(value) + } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt index b42441dc27f..a4bde8fcfd9 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty1Impl.kt @@ -18,11 +18,11 @@ package kotlin.reflect.jvm.internal import org.jetbrains.kotlin.descriptors.PropertyDescriptor import java.lang.reflect.Modifier +import kotlin.jvm.internal.MutablePropertyReference1 +import kotlin.jvm.internal.PropertyReference1 import kotlin.reflect.IllegalPropertyAccessException import kotlin.reflect.KMutableProperty1 import kotlin.reflect.KProperty1 -import kotlin.jvm.internal.MutablePropertyReference1 -import kotlin.jvm.internal.PropertyReference1 open class KProperty1Impl : DescriptorBasedProperty, KProperty1, KPropertyImpl { constructor(container: KCallableContainerImpl, name: String, signature: String) : super(container, name, signature) @@ -31,6 +31,8 @@ open class KProperty1Impl : DescriptorBasedProperty, KProperty1, override val name: String get() = descriptor.getName().asString() + override val getter by ReflectProperties.lazy { Getter(this) } + // TODO: consider optimizing this, not to do complex checks on every access @suppress("UNCHECKED_CAST") override fun get(receiver: T): R { @@ -53,6 +55,10 @@ open class KProperty1Impl : DescriptorBasedProperty, KProperty1, throw IllegalPropertyAccessException(e) } } + + class Getter(override val property: KProperty1Impl) : KPropertyImpl.Getter, KProperty1.Getter { + override fun invoke(receiver: T): R = property.get(receiver) + } } @@ -61,6 +67,8 @@ open class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1 constructor(container: KCallableContainerImpl, descriptor: PropertyDescriptor) : super(container, descriptor) + override val setter by ReflectProperties.lazy { Setter(this) } + override fun set(receiver: T, value: R) { try { val setter = javaSetter ?: @@ -83,6 +91,10 @@ open class KMutableProperty1Impl : KProperty1Impl, KMutableProperty1 throw IllegalPropertyAccessException(e) } } + + class Setter(override val property: KMutableProperty1Impl) : KMutablePropertyImpl.Setter, KMutableProperty1.Setter { + override fun invoke(receiver: T, value: R): Unit = property.set(receiver, value) + } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt index e1fd983f1c5..02de0088c96 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KProperty2Impl.kt @@ -30,6 +30,8 @@ open class KProperty2Impl : DescriptorBasedProperty, KProperty2 : DescriptorBasedProperty, KProperty2(override val property: KProperty2Impl) : KPropertyImpl.Getter, KProperty2.Getter { + override fun invoke(receiver1: D, receiver2: E): R = property.get(receiver1, receiver2) + } } @@ -51,6 +57,8 @@ class KMutableProperty2Impl : KProperty2Impl, KMutableProperty constructor(container: KClassImpl, descriptor: PropertyDescriptor) : super(container, descriptor) + override val setter by ReflectProperties.lazy { Setter(this) } + override val javaSetter: Method get() = super.javaSetter!! override fun set(receiver1: D, receiver2: E, value: R) { @@ -61,4 +69,8 @@ class KMutableProperty2Impl : KProperty2Impl, KMutableProperty throw IllegalPropertyAccessException(e) } } + + class Setter(override val property: KMutableProperty2Impl) : KMutablePropertyImpl.Setter, KMutableProperty2.Setter { + override fun invoke(receiver1: D, receiver2: E, value: R): Unit = property.set(receiver1, receiver2, value) + } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt index c19511af775..cca0803d778 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KPropertyImpl.kt @@ -23,9 +23,25 @@ interface KPropertyImpl : KProperty, KCallableImpl { val javaField: Field? val javaGetter: Method? + + override val getter: Getter + + interface Accessor : KProperty.Accessor { + override val property: KPropertyImpl + } + + interface Getter : KProperty.Getter, KCallableImpl { + override val name: String get() = "" + } } interface KMutablePropertyImpl : KMutableProperty, KPropertyImpl { val javaSetter: Method? + + override val setter: Setter + + interface Setter : KMutableProperty.Setter, KPropertyImpl.Accessor, KCallableImpl { + override val name: String get() = "" + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java index 6b19fdcac72..0e8840ee65f 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference0.java @@ -17,6 +17,7 @@ package kotlin.jvm.internal; import kotlin.reflect.KMutableProperty0; +import kotlin.reflect.KProperty0; public class MutablePropertyReference0 extends MutablePropertyReference implements KMutableProperty0 { @Override @@ -28,4 +29,14 @@ public class MutablePropertyReference0 extends MutablePropertyReference implemen public void set(Object value) { throw error(); } + + @Override + public KProperty0.Getter getGetter() { + throw error(); + } + + @Override + public KMutableProperty0.Setter getSetter() { + throw error(); + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java index 44bd0b747db..ec5dcb604fc 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference1.java @@ -17,6 +17,7 @@ package kotlin.jvm.internal; import kotlin.reflect.KMutableProperty1; +import kotlin.reflect.KProperty1; public class MutablePropertyReference1 extends MutablePropertyReference implements KMutableProperty1 { @Override @@ -28,4 +29,14 @@ public class MutablePropertyReference1 extends MutablePropertyReference implemen public void set(Object receiver, Object value) { throw error(); } + + @Override + public KProperty1.Getter getGetter() { + throw error(); + } + + @Override + public KMutableProperty1.Setter getSetter() { + throw error(); + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java index eb6688fb5c1..b4c53be92a1 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/MutablePropertyReference2.java @@ -17,6 +17,7 @@ package kotlin.jvm.internal; import kotlin.reflect.KMutableProperty2; +import kotlin.reflect.KProperty2; public class MutablePropertyReference2 extends MutablePropertyReference implements KMutableProperty2 { @Override @@ -28,4 +29,14 @@ public class MutablePropertyReference2 extends MutablePropertyReference implemen public void set(Object receiver1, Object receiver2, Object value) { throw error(); } + + @Override + public KProperty2.Getter getGetter() { + throw error(); + } + + @Override + public KMutableProperty2.Setter getSetter() { + throw error(); + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java index 0c07baf59ff..027d3fb2dec 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference0.java @@ -23,4 +23,9 @@ public class PropertyReference0 extends PropertyReference implements KProperty0 public Object get() { throw error(); } + + @Override + public KProperty0.Getter getGetter() { + throw error(); + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java index 3a5df99f07d..ab45224ef95 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference1.java @@ -23,4 +23,9 @@ public class PropertyReference1 extends PropertyReference implements KProperty1 public Object get(Object receiver) { throw error(); } + + @Override + public KProperty1.Getter getGetter() { + throw error(); + } } diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java index b04fe85ebaa..f6404e32c2c 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/PropertyReference2.java @@ -23,4 +23,9 @@ public class PropertyReference2 extends PropertyReference implements KProperty2 public Object get(Object receiver1, Object receiver2) { throw error(); } + + @Override + public KProperty2.Getter getGetter() { + throw error(); + } } From 636b63a8c59ef42890b1247def58b4021b8e3237 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 2 Jul 2015 17:39:16 +0300 Subject: [PATCH 229/450] Make "reflection not found" a warning, provide a quick fix Reporting the warning on each "::", as ReflectionNotFoundInspection did, is not correct anymore, because for example name/get/set on properties works perfectly without kotlin-reflect.jar in the classpath. So instead we report the warning on calls to functions from reflection interfaces. This is not perfect either because it's wrong in projects with custom implementations of reflection interfaces, but this case is so rare that the users can suppress the warning there anyway #KT-7176 Fixed --- .../kotlin/codegen/ExpressionCodegen.java | 13 -- .../load/kotlin/KotlinJvmCheckerProvider.kt | 4 +- .../checkers/ReflectionAPICallChecker.kt | 70 +++++++++ .../diagnostics/DefaultErrorMessagesJvm.java | 4 +- .../resolve/jvm/diagnostics/ErrorsJvm.java | 3 +- .../cli/jvm/noReflectionInClasspath.args | 3 - .../cli/jvm/noReflectionInClasspath.kt | 4 - .../cli/jvm/noReflectionInClasspath.out | 7 - .../reflection/noReflectionInClassPath.kt | 21 +++ .../reflection/noReflectionInClassPath.txt | 25 ++++ .../checkers/JetDiagnosticsTestGenerated.java | 15 ++ .../cli/KotlincExecutableTestGenerated.java | 6 - .../resolve/JetExpectedResolveDataUtil.java | 5 +- .../kotlin/types/JetTypeCheckerTest.java | 7 +- .../kotlin/builtins/ReflectionTypes.kt | 13 +- idea/src/META-INF/plugin.xml | 7 - .../idea/inspections/AddReflectionQuickFix.kt | 79 ++++++++++ .../ReflectionNotFoundInspection.kt | 137 ------------------ .../kotlin/idea/quickfix/QuickFixRegistrar.kt | 12 +- .../reflectionNotFound/functionReference.kt | 18 --- .../inspectionData/expected.xml | 26 ---- .../inspectionData/inspections.test | 1 - .../withinAnnotationEntry.kt | 15 -- .../JetInspectionTestGenerated.java | 6 - 24 files changed, 240 insertions(+), 261 deletions(-) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt delete mode 100644 compiler/testData/cli/jvm/noReflectionInClasspath.args delete mode 100644 compiler/testData/cli/jvm/noReflectionInClasspath.kt delete mode 100644 compiler/testData/cli/jvm/noReflectionInClasspath.out create mode 100644 compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt create mode 100644 compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.txt create mode 100644 idea/src/org/jetbrains/kotlin/idea/inspections/AddReflectionQuickFix.kt delete mode 100644 idea/src/org/jetbrains/kotlin/idea/inspections/ReflectionNotFoundInspection.kt delete mode 100644 idea/testData/inspections/reflectionNotFound/functionReference.kt delete mode 100644 idea/testData/inspections/reflectionNotFound/inspectionData/expected.xml delete mode 100644 idea/testData/inspections/reflectionNotFound/inspectionData/inspections.test delete mode 100644 idea/testData/inspections/reflectionNotFound/withinAnnotationEntry.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 4efc5b90c7e..ad8442d37fb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -70,7 +70,6 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat import org.jetbrains.kotlin.resolve.constants.evaluate.EvaluatePackage; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; import org.jetbrains.kotlin.resolve.inline.InlineUtil; -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; @@ -103,7 +102,6 @@ import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage. import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.TraitImpl; -import static org.jetbrains.kotlin.serialization.deserialization.DeserializationPackage.findClassAcrossModuleDependencies; import static org.jetbrains.org.objectweb.asm.Opcodes.*; public class ExpressionCodegen extends JetVisitor implements LocalLookup { @@ -2733,8 +2731,6 @@ public class ExpressionCodegen extends JetVisitor implem @Override public StackValue visitClassLiteralExpression(@NotNull JetClassLiteralExpression expression, StackValue data) { - checkReflectionIsAvailable(expression); - JetType type = bindingContext.getType(expression); assert type != null; @@ -2754,9 +2750,6 @@ public class ExpressionCodegen extends JetVisitor implem (FunctionDescriptor) resolvedCall.getResultingDescriptor()); } - // TODO: this diagnostic should also be reported on function references once they obtain reflection - checkReflectionIsAvailable(expression); - VariableDescriptor variableDescriptor = bindingContext.get(VARIABLE, expression); if (variableDescriptor != null) { return generatePropertyReference(expression, variableDescriptor, resolvedCall); @@ -2789,12 +2782,6 @@ public class ExpressionCodegen extends JetVisitor implem return codegen.putInstanceOnStack(); } - private void checkReflectionIsAvailable(@NotNull JetExpression expression) { - if (findClassAcrossModuleDependencies(state.getModule(), JvmAbi.REFLECTION_FACTORY_IMPL) == null) { - state.getDiagnostics().report(ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH.on(expression, expression)); - } - } - @NotNull public static StackValue generateClassLiteralReference(@NotNull final JetTypeMapper typeMapper, @NotNull final JetType type) { return StackValue.operation(K_CLASS_TYPE, new Function1() { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index 9f0c1a1838b..a8b0f8f4625 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability import org.jetbrains.kotlin.resolve.jvm.calls.checkers.NeedSyntheticChecker +import org.jetbrains.kotlin.resolve.jvm.calls.checkers.ReflectionAPICallChecker import org.jetbrains.kotlin.resolve.jvm.calls.checkers.TraitDefaultMethodCallChecker import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.NullabilityInformationSource @@ -59,7 +60,8 @@ public class KotlinJvmCheckerProvider(private val module: ModuleDescriptor) : Ad PublicFieldAnnotationChecker()), additionalCallCheckers = listOf(NeedSyntheticChecker(), JavaAnnotationCallChecker(), - JavaAnnotationMethodCallChecker(), TraitDefaultMethodCallChecker()), + JavaAnnotationMethodCallChecker(), TraitDefaultMethodCallChecker(), + ReflectionAPICallChecker(module)), additionalTypeCheckers = listOf(JavaNullabilityWarningsChecker()), additionalSymbolUsageValidators = listOf() diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt new file mode 100644 index 00000000000..ad12ca997b4 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/calls/checkers/ReflectionAPICallChecker.kt @@ -0,0 +1,70 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.jvm.calls.checkers + +import org.jetbrains.kotlin.builtins.KOTLIN_REFLECT_FQ_NAME +import org.jetbrains.kotlin.builtins.ReflectionTypes +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker +import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH +import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies +import org.jetbrains.kotlin.types.expressions.OperatorConventions +import kotlin.reflect.jvm.java + +/** + * If there's no Kotlin reflection implementation found in the classpath, checks that there are no usages + * of reflection API which will fail at runtime. + */ +class ReflectionAPICallChecker(private val module: ModuleDescriptor) : CallChecker { + private val isReflectionAvailable by lazy { + module.findClassAcrossModuleDependencies(JvmAbi.REFLECTION_FACTORY_IMPL) != null + } + + private val kPropertyClasses by lazy { + val reflectionTypes = ReflectionTypes(module) + setOf(reflectionTypes.kProperty0, reflectionTypes.kProperty1, reflectionTypes.kProperty2) + } + + override fun check(resolvedCall: ResolvedCall, context: BasicCallResolutionContext) { + if (isReflectionAvailable) return + + val descriptor = resolvedCall.getResultingDescriptor() + val containingClass = descriptor.getContainingDeclaration() as? ClassDescriptor ?: return + if (!ReflectionTypes.isReflectionClass(containingClass)) return + + // Skip some symbols which are supposed to work fine without kotlin-reflect.jar: + // - 'name' on anything + // - 'invoke' on functions (or on anything else for that matter) + // - 'get'/'set' on properties + val name = descriptor.getName() + when { + name == OperatorConventions.INVOKE -> return + name.asString() == "name" -> return + (name.asString() == "get" || name.asString() == "set") && + kPropertyClasses.any { kProperty -> DescriptorUtils.isSubclass(containingClass, kProperty) } -> return + } + + context.trace.report(NO_REFLECTION_IN_CLASS_PATH.on(resolvedCall.getCall().getCallElement())) + } +} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 3f3c39dd126..c5c2d84881e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -59,8 +59,8 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION, "Only named arguments are available for Java annotations"); MAP.put(ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL, "Annotation methods are deprecated. Use property instead"); - MAP.put(ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH, "Expression ''{0}'' uses reflection which is not found in compilation classpath. " + - "Make sure you have kotlin-reflect.jar in the classpath", Renderers.ELEMENT_TEXT); + MAP.put(ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH, "Call uses reflection API which is not found in compilation classpath. " + + "Make sure you have kotlin-reflect.jar in the classpath"); MAP.put(ErrorsJvm.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS, "Expected type does not accept nulls in {0}, but the value may be null in {1}", Renderers.TO_STRING, Renderers.TO_STRING); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 9fddc2d9a71..1c59989e593 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -58,8 +58,7 @@ public interface ErrorsJvm { DiagnosticFactory0 INAPPLICABLE_PUBLIC_FIELD = DiagnosticFactory0.create(ERROR); - // TODO: make this a warning - DiagnosticFactory1 NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory1.create(ERROR); + DiagnosticFactory0 NO_REFLECTION_IN_CLASS_PATH = DiagnosticFactory0.create(WARNING); enum NullabilityInformationSource { KOTLIN { diff --git a/compiler/testData/cli/jvm/noReflectionInClasspath.args b/compiler/testData/cli/jvm/noReflectionInClasspath.args deleted file mode 100644 index 6c45450a152..00000000000 --- a/compiler/testData/cli/jvm/noReflectionInClasspath.args +++ /dev/null @@ -1,3 +0,0 @@ -$TESTDATA_DIR$/noReflectionInClasspath.kt --d -$TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/noReflectionInClasspath.kt b/compiler/testData/cli/jvm/noReflectionInClasspath.kt deleted file mode 100644 index aea00a248ca..00000000000 --- a/compiler/testData/cli/jvm/noReflectionInClasspath.kt +++ /dev/null @@ -1,4 +0,0 @@ -class Foo(val prop: Any) - -fun t1() = Foo::prop -fun t2() = Foo::class diff --git a/compiler/testData/cli/jvm/noReflectionInClasspath.out b/compiler/testData/cli/jvm/noReflectionInClasspath.out deleted file mode 100644 index 77b22ce279d..00000000000 --- a/compiler/testData/cli/jvm/noReflectionInClasspath.out +++ /dev/null @@ -1,7 +0,0 @@ -compiler/testData/cli/jvm/noReflectionInClasspath.kt:3:12: error: expression 'Foo::prop' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath -fun t1() = Foo::prop - ^ -compiler/testData/cli/jvm/noReflectionInClasspath.kt:4:12: error: expression 'Foo::class' uses reflection which is not found in compilation classpath. Make sure you have kotlin-reflect.jar in the classpath -fun t2() = Foo::class - ^ -COMPILATION_ERROR diff --git a/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt b/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt new file mode 100644 index 00000000000..2e37aa21352 --- /dev/null +++ b/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt @@ -0,0 +1,21 @@ +import kotlin.reflect.* + +class Foo(val prop: Any) { + fun func() {} +} + +fun n01() = Foo::prop +fun n02() = Foo::func +fun n03() = Foo::class +fun n04(p: KProperty0) = p.get() +fun n05(p: KMutableProperty0) = p.set("") +fun n06(p: KProperty0) = p.get() +fun n07(p: KFunction) = p.name +fun n08(p: KProperty1) = p[""] +fun n09(p: KProperty2) = p["", ""] +fun n10() = (Foo::func).invoke(Foo("")) +fun n11() = (Foo::func)(Foo("")) + +fun y01() = Foo::prop.getter +fun y02() = Foo::class.properties +fun y03() = Foo::class.simpleName diff --git a/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.txt b/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.txt new file mode 100644 index 00000000000..6b6d957333b --- /dev/null +++ b/compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.txt @@ -0,0 +1,25 @@ +package + +internal fun n01(): kotlin.reflect.KProperty1 +internal fun n02(): kotlin.reflect.KFunction1 +internal fun n03(): kotlin.reflect.KClass +internal fun n04(/*0*/ p: kotlin.reflect.KProperty0): kotlin.Int +internal fun n05(/*0*/ p: kotlin.reflect.KMutableProperty0): kotlin.Unit +internal fun n06(/*0*/ p: kotlin.reflect.KProperty0): kotlin.Int +internal fun n07(/*0*/ p: kotlin.reflect.KFunction): kotlin.String +internal fun n08(/*0*/ p: kotlin.reflect.KProperty1): kotlin.Int +internal fun n09(/*0*/ p: kotlin.reflect.KProperty2): kotlin.Int +internal fun n10(): kotlin.Unit +internal fun n11(): kotlin.Unit +internal fun y01(): kotlin.reflect.KProperty1.Getter +internal fun y02(): kotlin.Collection> +internal fun y03(): kotlin.String? + +internal final class Foo { + public constructor Foo(/*0*/ prop: kotlin.Any) + internal final val prop: kotlin.Any + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index f636caee210..075a993b04f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10435,6 +10435,21 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { } } + @TestMetadata("compiler/testData/diagnostics/tests/reflection") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Reflection extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInReflection() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/reflection"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("noReflectionInClassPath.kt") + public void testNoReflectionInClassPath() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/reflection/noReflectionInClassPath.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/regressions") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java index 23ad7e546e4..0495cffe9fa 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java @@ -97,12 +97,6 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes doJvmTest(fileName); } - @TestMetadata("noReflectionInClasspath.args") - public void testNoReflectionInClasspath() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/noReflectionInClasspath.args"); - doJvmTest(fileName); - } - @TestMetadata("nonExistingClassPathAndAnnotationsPath.args") public void testNonExistingClassPathAndAnnotationsPath() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args"); diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java b/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java index 9d5af24634e..179bcf2d4d1 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/JetExpectedResolveDataUtil.java @@ -21,6 +21,7 @@ import com.intellij.psi.*; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; +import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; @@ -126,8 +127,10 @@ public class JetExpectedResolveDataUtil { Project project, JetType... parameterTypes ) { - ModuleDescriptor emptyModule = JetTestUtils.createEmptyModule(); + ModuleDescriptorImpl emptyModule = JetTestUtils.createEmptyModule(); ContainerForTests container = DiPackage.createContainerForTests(project, emptyModule); + emptyModule.setDependencies(emptyModule); + emptyModule.initialize(PackageFragmentProvider.Empty.INSTANCE$); ExpressionTypingContext context = ExpressionTypingContext.newContext( container.getAdditionalCheckerProvider(), new BindingTraceContext(), classDescriptor.getDefaultType().getMemberScope(), diff --git a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java index 0beede9467d..608c06c003b 100644 --- a/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/kotlin/types/JetTypeCheckerTest.java @@ -23,8 +23,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.descriptors.ModuleDescriptor; +import org.jetbrains.kotlin.descriptors.PackageFragmentProvider; import org.jetbrains.kotlin.descriptors.PackageViewDescriptor; import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor; +import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl; import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; @@ -73,7 +75,10 @@ public class JetTypeCheckerTest extends JetLiteFixture { builtIns = KotlinBuiltIns.getInstance(); - ContainerForTests container = DiPackage.createContainerForTests(getProject(), JetTestUtils.createEmptyModule()); + ModuleDescriptorImpl module = JetTestUtils.createEmptyModule(); + ContainerForTests container = DiPackage.createContainerForTests(getProject(), module); + module.setDependencies(Collections.singletonList(module)); + module.initialize(PackageFragmentProvider.Empty.INSTANCE$); typeResolver = container.getTypeResolver(); expressionTypingServices = container.getExpressionTypingServices(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt index 5b02b53cd56..787d7a775da 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/ReflectionTypes.kt @@ -18,20 +18,19 @@ package org.jetbrains.kotlin.builtins import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.name.isSubpackageOf import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* import java.util.ArrayList -import kotlin.properties.Delegates val KOTLIN_REFLECT_FQ_NAME = FqName("kotlin.reflect") public class ReflectionTypes(private val module: ModuleDescriptor) { - private val kotlinReflectScope: JetScope by Delegates.lazy { + private val kotlinReflectScope: JetScope by lazy { module.getPackage(KOTLIN_REFLECT_FQ_NAME).memberScope } @@ -52,6 +51,7 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { public val kClass: ClassDescriptor by ClassLookup public val kProperty0: ClassDescriptor by ClassLookup public val kProperty1: ClassDescriptor by ClassLookup + public val kProperty2: ClassDescriptor by ClassLookup public val kMutableProperty0: ClassDescriptor by ClassLookup public val kMutableProperty1: ClassDescriptor by ClassLookup @@ -108,10 +108,9 @@ public class ReflectionTypes(private val module: ModuleDescriptor) { } companion object { - public fun isReflectionType(type: JetType): Boolean { - val descriptor = type.getConstructor().getDeclarationDescriptor() ?: return false - val fqName = DescriptorUtils.getFqName(descriptor) - return fqName.isSafe() && fqName.toSafe().isSubpackageOf(KOTLIN_REFLECT_FQ_NAME) + public fun isReflectionClass(descriptor: ClassDescriptor): Boolean { + val containingPackage = DescriptorUtils.getParentOfType(descriptor, javaClass()) + return containingPackage != null && containingPackage.fqName == KOTLIN_REFLECT_FQ_NAME } } } diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 513efab7734..cc30188b4b7 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -1047,13 +1047,6 @@ level="WARNING" /> - - (element) { + override fun getText() = JetBundle.message("add.reflection.to.classpath") + override fun getFamilyName() = getText() + + override fun invoke(project: Project, editor: Editor?, file: JetFile) { + val pluginReflectJar = PathUtil.getKotlinPathsForIdeaPlugin().getReflectPath() + if (!pluginReflectJar.exists()) return + + val configurator = Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME) + .firstIsInstanceOrNull() ?: return + + for (library in KotlinRuntimeLibraryUtil.findKotlinLibraries(project)) { + val runtimeJar = JavaRuntimePresentationProvider.getRuntimeJar(library) ?: continue + if (JavaRuntimePresentationProvider.getReflectJar(library) != null) continue + + val model = library.getModifiableModel() + + val libFilesDir = VfsUtilCore.virtualToIoFile(runtimeJar).getParent() + val reflectIoFile = File(libFilesDir, PathUtil.KOTLIN_JAVA_REFLECT_JAR) + if (reflectIoFile.exists()) { + model.addRoot(VfsUtil.getUrlForLibraryRoot(reflectIoFile), OrderRootType.CLASSES) + } + else { + val copied = configurator.copyFileToDir(pluginReflectJar, libFilesDir)!! + model.addRoot(VfsUtil.getUrlForLibraryRoot(copied), OrderRootType.CLASSES) + } + + model.commit() + + ConfigureKotlinInProjectUtils.showInfoNotification( + "${PathUtil.KOTLIN_JAVA_REFLECT_JAR} was added to the library ${library.getName()}" + ) + } + } + + companion object : JetSingleIntentionActionFactory() { + override fun createAction(diagnostic: Diagnostic) = diagnostic.createIntentionForFirstParentOfType(::AddReflectionQuickFix) + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ReflectionNotFoundInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ReflectionNotFoundInspection.kt deleted file mode 100644 index 53e9ec236b7..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ReflectionNotFoundInspection.kt +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.inspections - -import com.intellij.codeInspection.LocalQuickFix -import com.intellij.codeInspection.ProblemDescriptor -import com.intellij.codeInspection.ProblemHighlightType -import com.intellij.codeInspection.ProblemsHolder -import com.intellij.openapi.extensions.Extensions -import com.intellij.openapi.module.ModuleUtilCore -import com.intellij.openapi.project.Project -import com.intellij.openapi.roots.OrderRootType -import com.intellij.openapi.vfs.VfsUtil -import com.intellij.openapi.vfs.VfsUtilCore -import com.intellij.psi.PsiElementVisitor -import com.intellij.psi.PsiFile -import org.jetbrains.kotlin.idea.JetBundle -import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor -import org.jetbrains.kotlin.idea.configuration.ConfigureKotlinInProjectUtils -import org.jetbrains.kotlin.idea.configuration.KotlinJavaModuleConfigurator -import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator -import org.jetbrains.kotlin.idea.framework.JavaRuntimePresentationProvider -import org.jetbrains.kotlin.idea.project.ProjectStructureUtil -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil -import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtil -import org.jetbrains.kotlin.load.java.JvmAbi -import org.jetbrains.kotlin.psi.JetDoubleColonExpression -import org.jetbrains.kotlin.psi.JetFile -import org.jetbrains.kotlin.psi.JetVisitorVoid -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.serialization.deserialization.findClassAcrossModuleDependencies -import org.jetbrains.kotlin.builtins.ReflectionTypes -import org.jetbrains.kotlin.psi.JetAnnotationEntry -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.utils.PathUtil -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -import org.jetbrains.kotlin.utils.singletonOrEmptyList -import java.io.File - -public class ReflectionNotFoundInspection : AbstractKotlinInspection() { - override fun runForWholeFile() = true - - override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { - if (!shouldReportInFile(holder.getFile())) return PsiElementVisitor.EMPTY_VISITOR - - return object : JetVisitorVoid() { - private fun createQuickFix(): LocalQuickFix? { - val pluginReflectJar = PathUtil.getKotlinPathsForIdeaPlugin().getReflectPath() - if (pluginReflectJar.exists()) { - val configurator = - Extensions.getExtensions(KotlinProjectConfigurator.EP_NAME).firstIsInstanceOrNull() - - if (configurator != null) { - return AddReflectJarQuickFix(configurator, pluginReflectJar) - } - } - - return null - } - - override fun visitDoubleColonExpression(expression: JetDoubleColonExpression) { - val expectedType = expression.analyze().get(BindingContext.EXPECTED_EXPRESSION_TYPE, expression) - if (expectedType != null && !ReflectionTypes.isReflectionType(expectedType)) return - - if (expression.getStrictParentOfType() != null) return - - // If a callable reference is used where a KFunction/KProperty/... expected, we should report that usage as dangerous - // because reflection features will fail without kotlin-reflect.jar in the classpath. - // If it's only used as a Function however (for example, "list.map(::function)"), we should not report anything - holder.registerProblem( - expression.getDoubleColonTokenReference(), - JetBundle.message("reflection.not.found"), - ProblemHighlightType.GENERIC_ERROR_OR_WARNING, - *(createQuickFix().singletonOrEmptyList().toTypedArray()) - ) - } - } - } - - private fun shouldReportInFile(file: PsiFile): Boolean { - if (file !is JetFile || !ProjectRootsUtil.isInProjectSource(file)) return false - - val module = ModuleUtilCore.findModuleForPsiElement(file) - if (module == null || !ProjectStructureUtil.isJavaKotlinModule(module)) return false - - return file.findModuleDescriptor().findClassAcrossModuleDependencies(JvmAbi.REFLECTION_FACTORY_IMPL) == null - } - - class AddReflectJarQuickFix( - val configurator: KotlinJavaModuleConfigurator, - val pluginReflectJar: File - ) : LocalQuickFix { - override fun getName() = JetBundle.message("add.reflection.to.classpath") - - override fun getFamilyName() = getName() - - override fun applyFix(project: Project, descriptor: ProblemDescriptor?) { - for (library in KotlinRuntimeLibraryUtil.findKotlinLibraries(project)) { - val runtimeJar = JavaRuntimePresentationProvider.getRuntimeJar(library) ?: continue - if (JavaRuntimePresentationProvider.getReflectJar(library) != null) continue - - val model = library.getModifiableModel() - - val libFilesDir = VfsUtilCore.virtualToIoFile(runtimeJar).getParent() - val reflectIoFile = File(libFilesDir, PathUtil.KOTLIN_JAVA_REFLECT_JAR) - if (reflectIoFile.exists()) { - model.addRoot(VfsUtil.getUrlForLibraryRoot(reflectIoFile), OrderRootType.CLASSES) - } - else { - val copied = configurator.copyFileToDir(pluginReflectJar, libFilesDir)!! - model.addRoot(VfsUtil.getUrlForLibraryRoot(copied), OrderRootType.CLASSES) - } - - model.commit() - - ConfigureKotlinInProjectUtils.showInfoNotification( - "${PathUtil.KOTLIN_JAVA_REFLECT_JAR} was added to the library ${library.getName()}" - ) - } - } - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt index 256dbe1aaae..c23ea011a44 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixRegistrar.kt @@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.IntentionAction import org.jetbrains.kotlin.diagnostics.DiagnosticFactory import org.jetbrains.kotlin.diagnostics.Errors.* import org.jetbrains.kotlin.idea.core.codeInsight.ImplementMethodsHandler +import org.jetbrains.kotlin.idea.inspections.AddReflectionQuickFix import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createCallable.* import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromCallWithConstructorCalleeActionFactory import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.CreateClassFromConstructorCallActionFactory @@ -30,7 +31,9 @@ import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateP import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createVariable.CreateParameterByNamedArgumentActionFactory import org.jetbrains.kotlin.lexer.JetTokens.* import org.jetbrains.kotlin.psi.JetClass -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.NO_REFLECTION_IN_CLASS_PATH +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION public class QuickFixRegistrar : QuickFixContributor { public override fun registerQuickFixes(quickFixes: QuickFixes) { @@ -306,8 +309,7 @@ public class QuickFixRegistrar : QuickFixContributor { EXPLICIT_DELEGATION_CALL_REQUIRED.registerFactory(InsertDelegationCallQuickfix.InsertThisDelegationCallFactory) EXPLICIT_DELEGATION_CALL_REQUIRED.registerFactory(InsertDelegationCallQuickfix.InsertSuperDelegationCallFactory) - ErrorsJvm.DEPRECATED_ANNOTATION_METHOD_CALL.registerFactory(MigrateAnnotationMethodCallFix, - MigrateAnnotationMethodCallInWholeFile) + DEPRECATED_ANNOTATION_METHOD_CALL.registerFactory(MigrateAnnotationMethodCallFix, MigrateAnnotationMethodCallInWholeFile) ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR.registerFactory(DeprecatedEnumEntrySuperConstructorSyntaxFix, DeprecatedEnumEntrySuperConstructorSyntaxFix.createWholeProjectFixFactory()) @@ -327,6 +329,8 @@ public class QuickFixRegistrar : QuickFixContributor { DEPRECATED_SYMBOL_WITH_MESSAGE.registerFactory(DeprecatedSymbolUsageFix, DeprecatedSymbolUsageInWholeProjectFix) - ErrorsJvm.POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix) + POSITIONED_VALUE_ARGUMENT_FOR_JAVA_ANNOTATION.registerFactory(ReplaceJavaAnnotationPositionedArgumentsFix) + + NO_REFLECTION_IN_CLASS_PATH.registerFactory(AddReflectionQuickFix) } } diff --git a/idea/testData/inspections/reflectionNotFound/functionReference.kt b/idea/testData/inspections/reflectionNotFound/functionReference.kt deleted file mode 100644 index 289cd4ecda9..00000000000 --- a/idea/testData/inspections/reflectionNotFound/functionReference.kt +++ /dev/null @@ -1,18 +0,0 @@ -package test - -// WITH_RUNTIME - -import kotlin.reflect.KFunction0 - -fun foo() {} - -fun bar(f: () -> Unit) = f() - -// Inspection should be reported here because '::foo' may be used as a reflection object -val p1 = ::foo // the type is KFunction0 by default -val p2: KFunction0 = ::foo // the expected type is KFunction0 - -// But shouldn't be reported here -val p3 = bar(::foo) // the expected type is Function0, '::foo' is used as an ordinary function -val p4: Any = ::foo // the expected type is Any -val p5: UnresolvedClass = ::foo // an error, another warning would be useless diff --git a/idea/testData/inspections/reflectionNotFound/inspectionData/expected.xml b/idea/testData/inspections/reflectionNotFound/inspectionData/expected.xml deleted file mode 100644 index fed4c656629..00000000000 --- a/idea/testData/inspections/reflectionNotFound/inspectionData/expected.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - functionReference.kt - 12 - light_idea_test_case - - Reflection not found - Reflection not found in the classpath - - - functionReference.kt - 13 - light_idea_test_case - - Reflection not found - Reflection not found in the classpath - - - withinAnnotationEntry.kt - 13 - light_idea_test_case - - Reflection not found - Reflection not found in the classpath - - diff --git a/idea/testData/inspections/reflectionNotFound/inspectionData/inspections.test b/idea/testData/inspections/reflectionNotFound/inspectionData/inspections.test deleted file mode 100644 index e5639d6dfe9..00000000000 --- a/idea/testData/inspections/reflectionNotFound/inspectionData/inspections.test +++ /dev/null @@ -1 +0,0 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.ReflectionNotFoundInspection diff --git a/idea/testData/inspections/reflectionNotFound/withinAnnotationEntry.kt b/idea/testData/inspections/reflectionNotFound/withinAnnotationEntry.kt deleted file mode 100644 index 3e75d6bc3e8..00000000000 --- a/idea/testData/inspections/reflectionNotFound/withinAnnotationEntry.kt +++ /dev/null @@ -1,15 +0,0 @@ -package test - -// WITH_RUNTIME - -import kotlin.reflect.KClass - -annotation class A(val arg: KClass<*>, val args: Array>, vararg val other: KClass<*>) - -A(Int::class, array(String::class), Double::class, Char::class) -class MyClass { - throws(Exception::class) - fun foo() { - Exception::class - } -} diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/JetInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/JetInspectionTestGenerated.java index 2ebab0d6aca..70dafa1ab80 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/JetInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/JetInspectionTestGenerated.java @@ -88,12 +88,6 @@ public class JetInspectionTestGenerated extends AbstractJetInspectionTest { JetTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/inspections"), Pattern.compile("^(inspections\\.test)$")); } - @TestMetadata("reflectionNotFound/inspectionData/inspections.test") - public void testReflectionNotFound_inspectionData_Inspections_test() throws Exception { - String fileName = JetTestUtils.navigationMetadata("idea/testData/inspections/reflectionNotFound/inspectionData/inspections.test"); - doTest(fileName); - } - @TestMetadata("spelling/inspectionData/inspections.test") public void testSpelling_inspectionData_Inspections_test() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/inspections/spelling/inspectionData/inspections.test"); From 9b832d4b87ec592793d4aca42c9eade454c879ea Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 7 Jul 2015 16:31:56 +0300 Subject: [PATCH 230/450] Container of value parameter is always a callable --- .../kotlin/codegen/ExpressionCodegen.java | 8 ++++++-- .../kotlin/resolve/DescriptorResolver.java | 17 +++-------------- .../resolve/ScriptParameterResolver.java | 18 ++++++------------ .../kotlin/resolve/calls/tasks/dynamicCalls.kt | 3 +-- .../lazy/descriptors/LazyScriptDescriptor.kt | 2 +- .../kotlin/load/java/descriptors/util.kt | 5 ++--- .../descriptors/ValueParameterDescriptor.java | 6 +++++- .../impl/ValueParameterDescriptorImpl.java | 15 ++++++++++++--- .../deserialization/MemberDeserializer.kt | 5 +++-- 9 files changed, 39 insertions(+), 40 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index ad8442d37fb..2e698b7203e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -46,6 +46,7 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.codegen.when.SwitchCodegen; import org.jetbrains.kotlin.codegen.when.SwitchCodegenUtil; import org.jetbrains.kotlin.descriptors.*; +import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor; import org.jetbrains.kotlin.diagnostics.DiagnosticUtils; import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.lexer.JetTokens; @@ -2036,11 +2037,14 @@ public class ExpressionCodegen extends JetVisitor implem return localOrCaptured; } - if (descriptor instanceof ValueParameterDescriptor && descriptor.getContainingDeclaration() instanceof ScriptDescriptor) { - ScriptDescriptor scriptDescriptor = (ScriptDescriptor) descriptor.getContainingDeclaration(); + DeclarationDescriptor container = descriptor.getContainingDeclaration(); + if (descriptor instanceof ValueParameterDescriptor && container instanceof ScriptCodeDescriptor) { + ScriptCodeDescriptor scriptCodeDescriptor = (ScriptCodeDescriptor) container; + ScriptDescriptor scriptDescriptor = (ScriptDescriptor) scriptCodeDescriptor.getContainingDeclaration(); Type scriptClassType = asmTypeForScriptDescriptor(bindingContext, scriptDescriptor); ValueParameterDescriptor valueParameterDescriptor = (ValueParameterDescriptor) descriptor; ClassDescriptor scriptClass = bindingContext.get(CLASS_FOR_SCRIPT, scriptDescriptor); + //noinspection ConstantConditions StackValue script = StackValue.thisOrOuter(this, scriptClass, false, false); Type fieldType = typeMapper.mapType(valueParameterDescriptor); return StackValue.field(fieldType, scriptClassType, valueParameterDescriptor.getName().getIdentifier(), false, script, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 94d6f0bcb33..6dbac5fab2d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -345,18 +345,7 @@ public class DescriptorResolver { @NotNull public ValueParameterDescriptorImpl resolveValueParameterDescriptor( - JetScope scope, DeclarationDescriptor declarationDescriptor, - JetParameter valueParameter, int index, JetType type, BindingTrace trace - ) { - return resolveValueParameterDescriptor(declarationDescriptor, valueParameter, index, type, trace, - annotationResolver.resolveAnnotationsWithoutArguments(scope, valueParameter.getModifierList(), trace)); - } - - @NotNull - private ValueParameterDescriptorImpl resolveValueParameterDescriptor( - DeclarationDescriptor declarationDescriptor, - JetParameter valueParameter, int index, JetType type, BindingTrace trace, - Annotations annotations + JetScope scope, FunctionDescriptor owner, JetParameter valueParameter, int index, JetType type, BindingTrace trace ) { JetType varargElementType = null; JetType variableType = type; @@ -365,10 +354,10 @@ public class DescriptorResolver { variableType = getVarargParameterType(type); } ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl( - declarationDescriptor, + owner, null, index, - annotations, + annotationResolver.resolveAnnotationsWithoutArguments(scope, valueParameter.getModifierList(), trace), JetPsiUtil.safeName(valueParameter.getName()), variableType, valueParameter.hasDefaultValue(), diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java index f666db45388..d8e88ce1105 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.ScriptDescriptor; import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.descriptors.annotations.Annotations; +import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor; import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.kotlin.parsing.JetScriptDefinition; import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider; @@ -35,7 +36,7 @@ public final class ScriptParameterResolver { @NotNull public static List resolveScriptParameters( @NotNull JetScript declaration, - @NotNull ScriptDescriptor scriptDescriptor + @NotNull ScriptCodeDescriptor scriptCodeDescriptor ) { List valueParameters = Lists.newArrayList(); @@ -44,23 +45,16 @@ public final class ScriptParameterResolver { int index = 0; for (AnalyzerScriptParameter scriptParameter : scriptDefinition.getScriptParameters()) { - ValueParameterDescriptor parameter = resolveScriptParameter(scriptParameter, index, scriptDescriptor); + ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl( + scriptCodeDescriptor, null, index, Annotations.EMPTY, scriptParameter.getName(), + scriptParameter.getType(), false, null, SourceElement.NO_SOURCE + ); valueParameters.add(parameter); ++index; } return valueParameters; } - @NotNull - private static ValueParameterDescriptor resolveScriptParameter( - @NotNull AnalyzerScriptParameter scriptParameter, - int index, - @NotNull ScriptDescriptor script - ) { - return new ValueParameterDescriptorImpl(script, null, index, Annotations.EMPTY, scriptParameter.getName(), - scriptParameter.getType(), false, null, SourceElement.NO_SOURCE); - } - private ScriptParameterResolver() { } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index 696cda75774..0142950ccc8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -148,8 +148,7 @@ object DynamicCallableDescriptors { ) } - private fun createValueParameters(owner: DeclarationDescriptor, call: Call): List { - + private fun createValueParameters(owner: FunctionDescriptor, call: Call): List { val parameters = ArrayList() fun addParameter(arg : ValueArgument, outType: JetType, varargElementType: JetType?) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt index bd1d1bb6fec..9effaedda56 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt @@ -69,7 +69,7 @@ public class LazyScriptDescriptor( val result = ScriptCodeDescriptor(this) result.initialize( implicitReceiver, - ScriptParameterResolver.resolveScriptParameters(jetScript, this), + ScriptParameterResolver.resolveScriptParameters(jetScript, result), DeferredType.create(resolveSession.getStorageManager(), resolveSession.getTrace()) { scriptBodyResolver.resolveScriptReturnType(jetScript, this, resolveSession.getTrace()) } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt index 5d11301f7ef..870c29cc493 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/util.kt @@ -16,8 +16,7 @@ package org.jetbrains.kotlin.load.java.descriptors -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.resolve.descriptorUtil.module @@ -26,7 +25,7 @@ import org.jetbrains.kotlin.types.JetType fun createEnhancedValueParameters( enhancedTypes: Collection, oldValueParameters: Collection, - newOwner: DeclarationDescriptor + newOwner: CallableDescriptor ): List { assert(enhancedTypes.size() == oldValueParameters.size()) { "Different value parameters sizes: Enhanced = ${enhancedTypes.size()}, Old = ${oldValueParameters.size()}" diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java index ff5b4515c9e..d50adb66272 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ValueParameterDescriptor.java @@ -24,6 +24,10 @@ import org.jetbrains.kotlin.types.JetType; import java.util.Set; public interface ValueParameterDescriptor extends VariableDescriptor, ParameterDescriptor { + @NotNull + @Override + CallableDescriptor getContainingDeclaration(); + /** * Returns the 0-based index of the value parameter in the parameter list of its containing function. * @@ -53,7 +57,7 @@ public interface ValueParameterDescriptor extends VariableDescriptor, ParameterD ValueParameterDescriptor getOriginal(); @NotNull - ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName); + ValueParameterDescriptor copy(@NotNull CallableDescriptor newOwner, @NotNull Name newName); /** * Parameter p1 overrides p2 iff diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java index 9d2b2909f1f..af4f31cc1d8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ValueParameterDescriptorImpl.java @@ -39,7 +39,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme private final Set readOnlyOverriddenDescriptors = Collections.unmodifiableSet(overriddenDescriptors); public ValueParameterDescriptorImpl( - @NotNull DeclarationDescriptor containingDeclaration, + @NotNull CallableDescriptor containingDeclaration, @Nullable ValueParameterDescriptor original, int index, @NotNull Annotations annotations, @@ -56,6 +56,12 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme this.varargElementType = varargElementType; } + @NotNull + @Override + public CallableDescriptor getContainingDeclaration() { + return (CallableDescriptor) super.getContainingDeclaration(); + } + public void setType(@NotNull JetType type) { setOutType(type); } @@ -124,8 +130,11 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme @NotNull @Override - public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName) { - return new ValueParameterDescriptorImpl(newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType, SourceElement.NO_SOURCE); + public ValueParameterDescriptor copy(@NotNull CallableDescriptor newOwner, @NotNull Name newName) { + return new ValueParameterDescriptorImpl( + newOwner, null, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType, + SourceElement.NO_SOURCE + ); } @NotNull diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index cc2e0cf7223..532075e94b4 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -170,11 +170,12 @@ public class MemberDeserializer(private val c: DeserializationContext) { } private fun valueParameters(callable: Callable, kind: AnnotatedCallableKind): List { - val containerOfCallable = c.containingDeclaration.getContainingDeclaration()!!.asProtoContainer() + val callableDescriptor = c.containingDeclaration as CallableDescriptor + val containerOfCallable = callableDescriptor.getContainingDeclaration().asProtoContainer() return callable.getValueParameterList().mapIndexed { i, proto -> ValueParameterDescriptorImpl( - c.containingDeclaration, null, i, + callableDescriptor, null, i, getParameterAnnotations(containerOfCallable, callable, kind, proto), c.nameResolver.getName(proto.getName()), c.typeDeserializer.type(proto.getType()), From 64d8e35d264aff9512db01f877a3a6a8a41ab0b6 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 7 Jul 2015 21:32:13 +0300 Subject: [PATCH 231/450] Remove ScriptParameterResolver, inline its single method --- .../resolve/ScriptParameterResolver.java | 60 ------------------- .../lazy/descriptors/LazyScriptDescriptor.kt | 15 ++++- 2 files changed, 13 insertions(+), 62 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java deleted file mode 100644 index d8e88ce1105..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptParameterResolver.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve; - -import com.google.common.collect.Lists; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.descriptors.ScriptDescriptor; -import org.jetbrains.kotlin.descriptors.SourceElement; -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; -import org.jetbrains.kotlin.descriptors.annotations.Annotations; -import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor; -import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl; -import org.jetbrains.kotlin.parsing.JetScriptDefinition; -import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider; -import org.jetbrains.kotlin.psi.JetFile; -import org.jetbrains.kotlin.psi.JetScript; - -import java.util.List; - -// SCRIPT: Resolve script parameters -public final class ScriptParameterResolver { - @NotNull - public static List resolveScriptParameters( - @NotNull JetScript declaration, - @NotNull ScriptCodeDescriptor scriptCodeDescriptor - ) { - List valueParameters = Lists.newArrayList(); - - JetFile file = declaration.getContainingJetFile(); - JetScriptDefinition scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file); - - int index = 0; - for (AnalyzerScriptParameter scriptParameter : scriptDefinition.getScriptParameters()) { - ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl( - scriptCodeDescriptor, null, index, Annotations.EMPTY, scriptParameter.getName(), - scriptParameter.getType(), false, null, SourceElement.NO_SOURCE - ); - valueParameters.add(parameter); - ++index; - } - return valueParameters; - } - - private ScriptParameterResolver() { - } -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt index 9effaedda56..75693de7bc1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt @@ -19,14 +19,16 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ScriptDescriptor +import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorNonRootImpl import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor +import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl +import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider import org.jetbrains.kotlin.psi.JetScript import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.ScriptBodyResolver -import org.jetbrains.kotlin.resolve.ScriptParameterResolver import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.lazy.LazyEntity import org.jetbrains.kotlin.resolve.lazy.ResolveSession @@ -67,9 +69,18 @@ public class LazyScriptDescriptor( private val scriptCodeDescriptor = resolveSession.getStorageManager().createLazyValue { val result = ScriptCodeDescriptor(this) + + val file = jetScript.getContainingJetFile() + val scriptDefinition = JetScriptDefinitionProvider.getInstance(file.getProject()).findScriptDefinition(file) + result.initialize( implicitReceiver, - ScriptParameterResolver.resolveScriptParameters(jetScript, result), + scriptDefinition.getScriptParameters().mapIndexed { index, scriptParameter -> + ValueParameterDescriptorImpl( + result, null, index, Annotations.EMPTY, scriptParameter.getName(), scriptParameter.getType(), + false, null, SourceElement.NO_SOURCE + ) + }, DeferredType.create(resolveSession.getStorageManager(), resolveSession.getTrace()) { scriptBodyResolver.resolveScriptReturnType(jetScript, this, resolveSession.getTrace()) } From c62f19ee8242efef572253456e214f65a2e1f304 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 9 Jul 2015 20:05:44 +0300 Subject: [PATCH 232/450] Move getterName/setterName to JvmAbi Reuse in RuntimeTypeMapper in reflection --- .../kotlin/codegen/PropertyCodegen.java | 12 ----- .../kotlin/codegen/state/JetTypeMapper.java | 15 +++--- .../kotlin/asJava/LightClassUtil.java | 3 +- .../jetbrains/kotlin/load/java/JvmAbi.java | 18 +++++-- .../reflect/jvm/internal/RuntimeTypeMapper.kt | 12 +---- .../kotlin/idea/search/usagesSearch/utils.kt | 24 ++++----- .../breakpoints/KotlinFieldBreakpoint.kt | 14 +++-- .../DelegatedPropertyFieldDescriptor.kt | 5 +- .../ConvertFunctionToPropertyIntention.kt | 4 +- .../ConvertPropertyToFunctionIntention.kt | 4 +- .../changeSignature/JetChangeInfo.kt | 8 ++- .../usages/JetFunctionCallUsage.java | 4 +- .../rename/RenameKotlinPropertyProcessor.kt | 53 +++++++++---------- 13 files changed, 82 insertions(+), 94 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java index 94acfe9cb26..5454cff725c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.codegen; import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,7 +25,6 @@ import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.load.java.JvmAbi; -import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.resolve.BindingContext; @@ -491,16 +489,6 @@ public class PropertyCodegen { } } - @NotNull - public static String getterName(Name propertyName) { - return JvmAbi.GETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString()); - } - - @NotNull - public static String setterName(Name propertyName) { - return JvmAbi.SETTER_PREFIX + StringUtil.capitalizeWithJavaBeanConvention(propertyName.asString()); - } - public void genDelegate(@NotNull PropertyDescriptor delegate, @NotNull PropertyDescriptor delegateTo, @NotNull StackValue field) { ClassDescriptor toClass = (ClassDescriptor) delegateTo.getContainingDeclaration(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java index 832e249f77c..db4519777cb 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java @@ -38,7 +38,10 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.load.kotlin.PackageClassUtils; import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils; import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage; -import org.jetbrains.kotlin.name.*; +import org.jetbrains.kotlin.name.ClassId; +import org.jetbrains.kotlin.name.FqName; +import org.jetbrains.kotlin.name.FqNameUnsafe; +import org.jetbrains.kotlin.name.SpecialNames; import org.jetbrains.kotlin.platform.JavaToKotlinClassMap; import org.jetbrains.kotlin.psi.JetExpression; import org.jetbrains.kotlin.psi.JetFile; @@ -681,13 +684,13 @@ public class JetTypeMapper { } boolean isAccessor = property instanceof AccessorForPropertyDescriptor; - Name propertyName = isAccessor - ? Name.identifier(((AccessorForPropertyDescriptor) property).getIndexedAccessorSuffix()) - : property.getName(); + String propertyName = isAccessor + ? ((AccessorForPropertyDescriptor) property).getIndexedAccessorSuffix() + : property.getName().asString(); String accessorName = descriptor instanceof PropertyGetterDescriptor - ? PropertyCodegen.getterName(propertyName) - : PropertyCodegen.setterName(propertyName); + ? JvmAbi.getterName(propertyName) + : JvmAbi.setterName(propertyName); return isAccessor ? "access$" + accessorName : accessorName; } diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java index e9951862f26..a20d1b07061 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.java @@ -290,7 +290,8 @@ public class LightClassUtil { new Function1() { @Override public Boolean invoke(PsiMethod method) { - return JvmAbi.isAccessorName(method.getName()); + String name = method.getName(); + return name.startsWith(JvmAbi.GETTER_PREFIX) || name.startsWith(JvmAbi.SETTER_PREFIX); } } ); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java index a0f89706774..b0afee8d1dc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAbi.java @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.load.java; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.ClassId; import org.jetbrains.kotlin.name.FqName; @@ -55,10 +56,21 @@ public final class JvmAbi { return isDelegated ? propertyName.asString() + DELEGATED_PROPERTY_NAME_SUFFIX : propertyName.asString(); } - public static boolean isAccessorName(String name) { - return name.startsWith(GETTER_PREFIX) || name.startsWith(SETTER_PREFIX); + @NotNull + public static String getterName(@NotNull String propertyName) { + return GETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName); } - private JvmAbi() { + @NotNull + public static String setterName(@NotNull String propertyName) { + return SETTER_PREFIX + capitalizeWithJavaBeanConvention(propertyName); + } + + /** + * @see com.intellij.openapi.util.text.StringUtil#capitalizeWithJavaBeanConvention(String) + */ + @NotNull + private static String capitalizeWithJavaBeanConvention(@NotNull String s) { + return s.length() > 1 && Character.isUpperCase(s.charAt(1)) ? s : KotlinPackage.capitalize(s); } } diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt index 934fd724c47..4a960067e1e 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/RuntimeTypeMapper.kt @@ -111,7 +111,7 @@ object RuntimeTypeMapper { val field = signature.getField() // TODO: some kind of test on the Java Bean convention? - return getterName(nameResolver.getString(field.getName())) + + return JvmAbi.getterName(nameResolver.getString(field.getName())) + "()" + deserializer.typeDescriptor(field.getType()) } @@ -120,7 +120,7 @@ object RuntimeTypeMapper { throw KotlinReflectionInternalError("Incorrect resolution sequence for Java field $property") return StringBuilder { - append(getterName(method.getName().asString())) + append(JvmAbi.getterName(method.getName().asString())) append("()") appendJavaType(method.getType()) }.toString() @@ -128,14 +128,6 @@ object RuntimeTypeMapper { else throw KotlinReflectionInternalError("Unknown origin of $property (${property.javaClass})") } - private fun getterName(propertyName: String): String { - return JvmAbi.GETTER_PREFIX + propertyName.capitalizeWithJavaBeanConvention() - } - - private fun String.capitalizeWithJavaBeanConvention(): String { - return if (length() > 1 && this[1].isUpperCase()) this else capitalize() - } - fun mapJvmClassToKotlinClassId(klass: Class<*>): ClassId { if (klass.isArray()) { klass.getComponentType().primitiveType?.let { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt index 348c47b96f8..29d488b3c77 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/utils.kt @@ -19,27 +19,27 @@ package org.jetbrains.kotlin.idea.search.usagesSearch import com.intellij.psi.PsiConstructorCall import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.* -import org.jetbrains.kotlin.resolve.BindingContext import com.intellij.psi.PsiReference import com.intellij.psi.search.SearchScope import org.jetbrains.kotlin.asJava.KotlinLightElement -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.asJava.KotlinLightMethod import org.jetbrains.kotlin.asJava.KotlinNoOriginLightMethod import org.jetbrains.kotlin.asJava.unwrapped -import org.jetbrains.kotlin.resolve.OverrideResolver -import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -import org.jetbrains.kotlin.idea.references.* -import org.jetbrains.kotlin.idea.findUsages.UsageTypeUtils -import org.jetbrains.kotlin.idea.findUsages.UsageTypeEnum +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor +import org.jetbrains.kotlin.idea.findUsages.UsageTypeEnum +import org.jetbrains.kotlin.idea.findUsages.UsageTypeUtils +import org.jetbrains.kotlin.idea.references.unwrappedTargets import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest import org.jetbrains.kotlin.idea.search.declarationsSearch.searchInheritors +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.OverrideResolver val JetDeclaration.descriptor: DeclarationDescriptor? get() = this.analyze().get(BindingContext.DECLARATION_TO_DESCRIPTOR, this) @@ -221,7 +221,7 @@ fun PsiReference.isPropertyReadOnlyUsage(): Boolean { is JetProperty, is JetParameter -> origin as JetNamedDeclaration else -> null } - return declaration != null && refTarget.getName() == PropertyCodegen.getterName(declaration.getNameAsName()) + return declaration != null && refTarget.getName() == JvmAbi.getterName(declaration.getName()!!) } return false diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt index d6ba2fde21d..a0e4bee5ec5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/breakpoints/KotlinFieldBreakpoint.kt @@ -41,13 +41,12 @@ import com.sun.jdi.event.* import com.sun.jdi.request.EventRequest import com.sun.jdi.request.MethodEntryRequest import org.jetbrains.annotations.TestOnly -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyzeAndGetResult import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.load.kotlin.PackageClassUtils -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.JetCallableDeclaration import org.jetbrains.kotlin.psi.JetClassOrObject import org.jetbrains.kotlin.psi.JetParameter @@ -165,17 +164,17 @@ class KotlinFieldBreakpoint( } } BreakpointType.METHOD -> { - val propertyName = Name.identifier(getFieldName()) + val fieldName = getFieldName() if (getProperties().WATCH_ACCESS) { - val getter = refType.methodsByName(PropertyCodegen.getterName(propertyName)).firstOrNull() + val getter = refType.methodsByName(JvmAbi.getterName(fieldName)).firstOrNull() if (getter != null) { createMethodBreakpoint(debugProcess, refType, getter) } } if (getProperties().WATCH_MODIFICATION) { - val setter = refType.methodsByName(PropertyCodegen.setterName(propertyName)).firstOrNull() + val setter = refType.methodsByName(JvmAbi.setterName(fieldName)).firstOrNull() if (setter != null) { createMethodBreakpoint(debugProcess, refType, setter) } @@ -255,9 +254,8 @@ class KotlinFieldBreakpoint( } private fun getMethodsName(): List { - val propertyName = Name.identifier(getFieldName()) - return arrayListOf(PropertyCodegen.getterName(propertyName), PropertyCodegen.setterName(propertyName)) - + val fieldName = getFieldName() + return listOf(JvmAbi.getterName(fieldName), JvmAbi.setterName(fieldName)) } override fun getEventMessage(event: LocatableEvent): String { diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/render/DelegatedPropertyFieldDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/render/DelegatedPropertyFieldDescriptor.kt index 2495757e664..3ce3d947600 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/render/DelegatedPropertyFieldDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/render/DelegatedPropertyFieldDescriptor.kt @@ -27,7 +27,6 @@ import com.sun.jdi.Field import com.sun.jdi.Method import com.sun.jdi.ObjectReference import com.sun.jdi.Value -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name @@ -86,8 +85,6 @@ class DelegatedPropertyFieldDescriptor( val fieldName = getName() if (!Name.isValidIdentifier(fieldName)) return null - val getterName = PropertyCodegen.getterName(Name.identifier(fieldName)) - return getObject().referenceType().methodsByName(getterName)?.firstOrNull() + return getObject().referenceType().methodsByName(JvmAbi.getterName(fieldName))?.firstOrNull() } } - diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt index cb0082e01ce..71ab68953cc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt @@ -25,7 +25,6 @@ import com.intellij.psi.* import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.asJava.namedUnwrappedElement import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze @@ -44,6 +43,7 @@ import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.idea.util.application.executeWriteCommand import org.jetbrains.kotlin.idea.util.supertypes +import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch @@ -91,7 +91,7 @@ public class ConvertFunctionToPropertyIntention : JetSelfTargetingIntention) { val conflicts = MultiMap() - val getterName = PropertyCodegen.getterName(callableDescriptor.getName()) + val getterName = JvmAbi.getterName(callableDescriptor.getName().asString()) val callables = getAffectedCallables(project, descriptorsForChange) val kotlinCalls = ArrayList() val foreignRefs = ArrayList() diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt index 6a10c55f324..c533ba50d4d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertPropertyToFunctionIntention.kt @@ -24,7 +24,6 @@ import com.intellij.psi.* import com.intellij.refactoring.util.RefactoringUIUtil import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.asJava.namedUnwrappedElement -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde @@ -39,6 +38,7 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget import org.jetbrains.kotlin.idea.search.usagesSearch.search import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.load.java.JvmAbi import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.siblings @@ -80,7 +80,7 @@ public class ConvertPropertyToFunctionIntention : JetSelfTargetingIntention) { val propertyName = callableDescriptor.getName().asString() - val getterName = PropertyCodegen.getterName(callableDescriptor.getName()) + val getterName = JvmAbi.getterName(callableDescriptor.getName().asString()) val conflicts = MultiMap() val callables = getAffectedCallables(project, descriptorsForChange) val kotlinRefs = ArrayList() diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index d0fd4378a7d..0f049551a01 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -28,7 +28,6 @@ import org.jetbrains.kotlin.asJava.getRepresentativeLightMethod import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.codegen.PropertyCodegen import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility @@ -42,7 +41,6 @@ import org.jetbrains.kotlin.idea.refactoring.changeSignature.usages.KotlinCaller import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.load.java.JvmAbi -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.types.JetType @@ -328,7 +326,7 @@ public class JetChangeInfo( ): JavaChangeInfo? { val newParameterList = receiverParameterInfo.singletonOrEmptyList() + getNonReceiverParameters() val newJavaParameters = getJavaParameterInfos(currentPsiMethod, newParameterList).toTypedArray() - val newName = if (isGetter) PropertyCodegen.getterName(Name.identifier(getNewName())) else getNewName() + val newName = if (isGetter) JvmAbi.getterName(getNewName()) else getNewName() return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, currentPsiMethod.getReturnType(), newJavaParameters) } @@ -344,7 +342,7 @@ public class JetChangeInfo( newJavaParameters.add(ParameterInfoImpl(oldIndex, "receiver", PsiType.VOID)) } - val newName = PropertyCodegen.setterName(Name.identifier(getNewName())) + val newName = JvmAbi.setterName(getNewName()) return createJavaChangeInfo(originalPsiMethod, currentPsiMethod, newName, PsiType.VOID, newJavaParameters.toTypedArray()) } @@ -434,4 +432,4 @@ public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMeth newParameters, null, method) -} \ No newline at end of file +} diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java index 7d24b78320a..dc53ba1645c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/usages/JetFunctionCallUsage.java @@ -149,8 +149,8 @@ public class JetFunctionCallUsage extends JetUsageInfo { String newName = changeInfo.getNewName(); if (isPropertyJavaUsage()) { String currentName = ((JetSimpleNameExpression) callee).getReferencedName(); - if (currentName.startsWith(JvmAbi.GETTER_PREFIX)) newName = PropertyCodegen.getterName(Name.identifier(newName)); - else if (currentName.startsWith(JvmAbi.SETTER_PREFIX)) newName = PropertyCodegen.setterName(Name.identifier(newName)); + if (currentName.startsWith(JvmAbi.GETTER_PREFIX)) newName = JvmAbi.getterName(newName); + else if (currentName.startsWith(JvmAbi.SETTER_PREFIX)) newName = JvmAbi.setterName(newName); } callee.replace(JetPsiFactory(getProject()).createSimpleName(newName)); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt index 356272f33d3..dbbd26b2b1a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/rename/RenameKotlinPropertyProcessor.kt @@ -16,32 +16,32 @@ package org.jetbrains.kotlin.idea.refactoring.rename -import com.intellij.refactoring.rename.RenamePsiElementProcessor -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.psi.JetProperty -import com.intellij.psi.search.SearchScope import com.intellij.openapi.application.ApplicationManager -import org.jetbrains.kotlin.asJava.LightClassUtil -import com.intellij.psi.search.searches.OverridingMethodsSearch +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.ui.Messages +import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.intellij.psi.SyntheticElement -import com.intellij.refactoring.util.RefactoringUtil -import com.intellij.refactoring.rename.RenameProcessor -import org.jetbrains.kotlin.codegen.PropertyCodegen -import org.jetbrains.kotlin.name.Name -import com.intellij.usageView.UsageInfo +import com.intellij.psi.search.SearchScope +import com.intellij.psi.search.searches.OverridingMethodsSearch import com.intellij.refactoring.listeners.RefactoringElementListener -import com.intellij.openapi.editor.Editor -import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.psi.JetClassOrObject -import com.intellij.openapi.ui.Messages -import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import com.intellij.refactoring.rename.RenameProcessor +import com.intellij.refactoring.rename.RenamePsiElementProcessor +import com.intellij.refactoring.util.RefactoringUtil +import com.intellij.usageView.UsageInfo +import org.jetbrains.kotlin.asJava.LightClassUtil import org.jetbrains.kotlin.asJava.namedUnwrappedElement -import org.jetbrains.kotlin.resolve.OverrideResolver -import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils -import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.util.application.runReadAction +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.JetClassOrObject +import org.jetbrains.kotlin.psi.JetProperty +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils +import org.jetbrains.kotlin.resolve.OverrideResolver public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { override fun canProcessElement(element: PsiElement): Boolean = element.namedUnwrappedElement is JetProperty @@ -102,8 +102,9 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { return } - val oldGetterName = PropertyCodegen.getterName(element.getNameAsName()) - val oldSetterName = PropertyCodegen.setterName(element.getNameAsName()) + val name = element.getName()!! + val oldGetterName = JvmAbi.getterName(name) + val oldSetterName = JvmAbi.setterName(name) val refKindUsages = usages.toList().groupBy { usage: UsageInfo -> val refElement = usage.getReference()?.resolve() @@ -119,11 +120,11 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { } } - super.renameElement(element, PropertyCodegen.setterName(Name.identifier(newName!!)), + super.renameElement(element, JvmAbi.setterName(newName!!), refKindUsages[UsageKind.SETTER_USAGE]?.toTypedArray() ?: arrayOf(), null) - super.renameElement(element, PropertyCodegen.getterName(Name.identifier(newName)), + super.renameElement(element, JvmAbi.getterName(newName), refKindUsages[UsageKind.GETTER_USAGE]?.toTypedArray() ?: arrayOf(), null) @@ -151,9 +152,7 @@ public class RenameKotlinPropertyProcessor : RenamePsiElementProcessor() { if (overriderElement is PsiMethod) { if (newName != null && Name.isValidIdentifier(newName)) { val isGetter = overriderElement.getParameterList().getParametersCount() == 0 - val name = Name.identifier(newName) - - allRenames[overriderElement] = if (isGetter) PropertyCodegen.getterName(name) else PropertyCodegen.setterName(name) + allRenames[overriderElement] = if (isGetter) JvmAbi.getterName(newName) else JvmAbi.setterName(newName) } } else { From 3b2be6212d86eb7b54dd5cdc33baf63a732ac9ca Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 15:50:33 +0300 Subject: [PATCH 233/450] Add some tests on Java property references --- .../reflection/javaStaticField/J.java | 3 +++ .../reflection/javaStaticField/K.kt | 12 ++++++++++ .../J.java | 3 +++ .../noConflictOnKotlinGetterAndJavaField/K.kt | 23 +++++++++++++++++++ .../BlackBoxWithJavaCodegenTestGenerated.java | 12 ++++++++++ 5 files changed, 53 insertions(+) create mode 100644 compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java create mode 100644 compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt create mode 100644 compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java create mode 100644 compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt diff --git a/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java new file mode 100644 index 00000000000..00317c601f4 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/J.java @@ -0,0 +1,3 @@ +public class J { + static String x; +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt new file mode 100644 index 00000000000..869e71619f0 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/javaStaticField/K.kt @@ -0,0 +1,12 @@ +import kotlin.test.assertEquals + +fun box(): String { + val f = J::x + assertEquals("x", f.name) + + f.set("OK") + assertEquals("OK", J.x) + assertEquals("OK", f.getter()) + + return f.get() +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java new file mode 100644 index 00000000000..c081e6d25cf --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/J.java @@ -0,0 +1,3 @@ +public class J { + public String foo = ""; +} diff --git a/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt new file mode 100644 index 00000000000..d78c60c8661 --- /dev/null +++ b/compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/K.kt @@ -0,0 +1,23 @@ +import kotlin.test.* + +class K : J() { + fun getFoo(): String = "K" +} + +fun box(): String { + val j = J() + val x = J::foo + x.set(j, "J") + assertEquals("J", x.get(j)) + + val k = K() + val y = K::foo + y.set(k, "K") + assertEquals("K", y.get(k)) + assertEquals("K", x.get(k)) + + val z = K::getFoo + assertEquals("K", z.invoke(k)) + + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 590575d2c01..d3e078cf43e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -285,12 +285,24 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege doTestWithJava(fileName); } + @TestMetadata("javaStaticField") + public void testJavaStaticField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/javaStaticField/"); + doTestWithJava(fileName); + } + @TestMetadata("kotlinPropertyInheritedInJava") public void testKotlinPropertyInheritedInJava() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/kotlinPropertyInheritedInJava/"); doTestWithJava(fileName); } + @TestMetadata("noConflictOnKotlinGetterAndJavaField") + public void testNoConflictOnKotlinGetterAndJavaField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/noConflictOnKotlinGetterAndJavaField/"); + doTestWithJava(fileName); + } + } @TestMetadata("compiler/testData/codegen/boxWithJava/secondaryConstructors") From f8815d9450b34a1967b892a1f7c4e072871efd13 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 16:04:13 +0300 Subject: [PATCH 234/450] Test visibility of anonymous classes for callable references --- .../codegen/PropertyReferenceCodegen.kt | 2 +- .../visibility/functionReference.kt | 9 ++++ .../functionReferenceInInlineFunction.kt | 9 ++++ .../visibility/propertyReference.kt | 9 ++++ .../propertyReferenceInInlineFunction.kt | 9 ++++ .../flags/WriteFlagsTestGenerated.java | 42 +++++++++++++++++++ 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/writeFlags/callableReference/visibility/functionReference.kt create mode 100644 compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt create mode 100644 compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt create mode 100644 compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index c7918316638..be819795dc8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -65,7 +65,7 @@ public class PropertyReferenceCodegen( v.defineClass( element, V1_6, - ACC_FINAL or ACC_SUPER or AsmUtil.getVisibilityAccessFlagForAnonymous(classDescriptor), // TODO: test inline + ACC_FINAL or ACC_SUPER or AsmUtil.getVisibilityAccessFlagForAnonymous(classDescriptor), asmType.getInternalName(), null, superAsmType.getInternalName(), diff --git a/compiler/testData/writeFlags/callableReference/visibility/functionReference.kt b/compiler/testData/writeFlags/callableReference/visibility/functionReference.kt new file mode 100644 index 00000000000..6ff451d264e --- /dev/null +++ b/compiler/testData/writeFlags/callableReference/visibility/functionReference.kt @@ -0,0 +1,9 @@ +class A { + fun foo() {} + + val bar = A::foo +} + +// TESTED_OBJECT_KIND: class +// TESTED_OBJECTS: A$bar$1 +// FLAGS: ACC_FINAL, ACC_SUPER diff --git a/compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt b/compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt new file mode 100644 index 00000000000..ac3186c0552 --- /dev/null +++ b/compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt @@ -0,0 +1,9 @@ +class A { + fun foo() {} + + inline fun bar() = A::foo +} + +// TESTED_OBJECT_KIND: class +// TESTED_OBJECTS: A$bar$1 +// FLAGS: ACC_FINAL, ACC_PUBLIC, ACC_SUPER diff --git a/compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt b/compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt new file mode 100644 index 00000000000..8f737e2a173 --- /dev/null +++ b/compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt @@ -0,0 +1,9 @@ +class A { + val foo = "" + + val bar = A::foo +} + +// TESTED_OBJECT_KIND: class +// TESTED_OBJECTS: A$bar$1 +// FLAGS: ACC_FINAL, ACC_SUPER diff --git a/compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt b/compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt new file mode 100644 index 00000000000..261fa973e3e --- /dev/null +++ b/compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt @@ -0,0 +1,9 @@ +class A { + val foo = "" + + inline fun bar() = A::foo +} + +// TESTED_OBJECT_KIND: class +// TESTED_OBJECTS: A$bar$1 +// FLAGS: ACC_FINAL, ACC_PUBLIC, ACC_SUPER diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/flags/WriteFlagsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/flags/WriteFlagsTestGenerated.java index e94cfa19831..41638666d1d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/flags/WriteFlagsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/flags/WriteFlagsTestGenerated.java @@ -35,6 +35,48 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("compiler/testData/writeFlags/callableReference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class CallableReference extends AbstractWriteFlagsTest { + public void testAllFilesPresentInCallableReference() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/writeFlags/callableReference/visibility") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Visibility extends AbstractWriteFlagsTest { + public void testAllFilesPresentInVisibility() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/callableReference/visibility"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("functionReference.kt") + public void testFunctionReference() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/callableReference/visibility/functionReference.kt"); + doTest(fileName); + } + + @TestMetadata("functionReferenceInInlineFunction.kt") + public void testFunctionReferenceInInlineFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/callableReference/visibility/functionReferenceInInlineFunction.kt"); + doTest(fileName); + } + + @TestMetadata("propertyReference.kt") + public void testPropertyReference() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/callableReference/visibility/propertyReference.kt"); + doTest(fileName); + } + + @TestMetadata("propertyReferenceInInlineFunction.kt") + public void testPropertyReferenceInInlineFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/callableReference/visibility/propertyReferenceInInlineFunction.kt"); + doTest(fileName); + } + } + } + @TestMetadata("compiler/testData/writeFlags/class") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 16b5b95556635a144d8faf931bdf188e12690dc6 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 16:27:11 +0300 Subject: [PATCH 235/450] Test equals/hashCode/toString for function references --- .../methodsFromAny/functionEqualsHashCode.kt | 31 +++++++++++++++++++ .../methodsFromAny/functionToString.kt | 24 ++++++++++++++ ...sHashCode.kt => propertyEqualsHashCode.kt} | 0 ...lackBoxWithStdlibCodegenTestGenerated.java | 24 ++++++++++---- .../jvm/internal/ReflectionObjectRenderer.kt | 1 - 5 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionEqualsHashCode.kt create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionToString.kt rename compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/{equalsHashCode.kt => propertyEqualsHashCode.kt} (100%) diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionEqualsHashCode.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionEqualsHashCode.kt new file mode 100644 index 00000000000..bc313072f2e --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionEqualsHashCode.kt @@ -0,0 +1,31 @@ +import kotlin.test.* + +fun top() = 42 + +fun Int.intExt(): Int = this + +class A { + fun mem() {} +} + +class B { + fun mem() {} +} + + +fun checkEqual(x: Any, y: Any) { + assertEquals(x, y) + assertEquals(x.hashCode(), y.hashCode(), "Elements are equal but their hash codes are not: ${x.hashCode()} != ${y.hashCode()}") +} + +fun box(): String { + checkEqual(::top, ::top) + checkEqual(Int::intExt, Int::intExt) + checkEqual(A::mem, A::mem) + + assertFalse(::top == Int::intExt) + assertFalse(::top == A::mem) + assertFalse(A::mem == B::mem) + + return "OK" +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionToString.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionToString.kt new file mode 100644 index 00000000000..c0d912c985b --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionToString.kt @@ -0,0 +1,24 @@ +package test + +import kotlin.test.assertEquals + +fun top() = 42 + +fun String.ext(): Int = 0 +fun IntRange?.ext2(): Array = arrayOfNulls(0) + +class A { + fun mem(): String = "" +} + +fun assertToString(s: String, x: Any) { + assertEquals(s, x.toString()) +} + +fun box(): String { + assertToString("fun top(): kotlin.Int", ::top) + assertToString("fun kotlin.String.ext(): kotlin.Int", String::ext) + assertToString("fun kotlin.IntRange?.ext2(): kotlin.Array", IntRange::ext2) + assertToString("fun test.A.mem(): kotlin.String", A::mem) + return "OK" +} diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/equalsHashCode.kt b/compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyEqualsHashCode.kt similarity index 100% rename from compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/equalsHashCode.kt rename to compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyEqualsHashCode.kt diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index 455bd514b20..cc474679aff 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -3123,18 +3123,24 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("equalsHashCode.kt") - public void testEqualsHashCode() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/equalsHashCode.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("extensionPropertyReceiverToString.kt") public void testExtensionPropertyReceiverToString() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/extensionPropertyReceiverToString.kt"); doTestWithStdlib(fileName); } + @TestMetadata("functionEqualsHashCode.kt") + public void testFunctionEqualsHashCode() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionEqualsHashCode.kt"); + doTestWithStdlib(fileName); + } + + @TestMetadata("functionToString.kt") + public void testFunctionToString() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/functionToString.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("memberExtensionToString.kt") public void testMemberExtensionToString() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/memberExtensionToString.kt"); @@ -3153,6 +3159,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } + @TestMetadata("propertyEqualsHashCode.kt") + public void testPropertyEqualsHashCode() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyEqualsHashCode.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("propertyToString.kt") public void testPropertyToString() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/methodsFromAny/propertyToString.kt"); diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt index ad55d9aa085..ea104dfeb8d 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionObjectRenderer.kt @@ -55,7 +55,6 @@ object ReflectionObjectRenderer { } fun renderFunction(descriptor: FunctionDescriptor): String { - // TODO: add tests return StringBuilder { append("fun ") appendReceiversAndName(descriptor) From 670565b251a8f5ddee673a6f7bb3c88c78710bf6 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 17:11:49 +0300 Subject: [PATCH 236/450] Wrap property reference instance before storing to static field --- .../kotlin/codegen/ClosureCodegen.java | 3 +- .../kotlin/codegen/MemberCodegen.java | 18 +++++-- .../codegen/PropertyReferenceCodegen.kt | 53 ++++++++++--------- .../org/jetbrains/kotlin/utils/functions.kt | 13 +++-- 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index e8c1415888d..f5375b206fd 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.expressions.OperatorConventions; +import org.jetbrains.kotlin.utils.UtilsPackage; import org.jetbrains.org.objectweb.asm.MethodVisitor; import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; @@ -202,7 +203,7 @@ public class ClosureCodegen extends MemberCodegen { this.constructor = generateConstructor(); if (isConst(closure)) { - generateConstInstance(asmType); + generateConstInstance(asmType, asmType, UtilsPackage.doNothing()); } genClosureFields(closure, v, typeMapper); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index 97724959a7b..c4a779ffd2d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -17,7 +17,9 @@ package org.jetbrains.kotlin.codegen; import com.intellij.openapi.progress.ProcessCanceledException; +import kotlin.Unit; import kotlin.jvm.functions.Function0; +import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.codegen.context.*; @@ -533,15 +535,21 @@ public abstract class MemberCodegen initialization + ) { + v.newField(OtherOrigin(element), ACC_STATIC | ACC_FINAL | ACC_PUBLIC, JvmAbi.INSTANCE_FIELD, fieldAsmType.getDescriptor(), + null, null); if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { InstructionAdapter iv = createOrGetClInitCodegen().v; - iv.anew(asmType); + iv.anew(thisAsmType); iv.dup(); - iv.invokespecial(asmType.getInternalName(), "", "()V", false); - iv.putstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()); + iv.invokespecial(thisAsmType.getInternalName(), "", "()V", false); + initialization.invoke(iv); + iv.putstatic(thisAsmType.getInternalName(), JvmAbi.INSTANCE_FIELD, fieldAsmType.getDescriptor()); } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index be819795dc8..16f054df8d2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -54,11 +54,27 @@ public class PropertyReferenceCodegen( ) : MemberCodegen(state, parentCodegen, context, expression, classBuilder) { private val target = resolvedCall.getResultingDescriptor() private val asmType = typeMapper.mapClass(classDescriptor) - private val superAsmType: Type + + // e.g. MutablePropertyReference0 + private val superAsmType = typeMapper.mapClass(classDescriptor.getSuperClassNotAny().sure { "No super class for $classDescriptor" }) + + // e.g. mutableProperty0(Lkotlin/jvm/internal/MutablePropertyReference0;)Lkotlin/reflect/KMutableProperty0; + private val wrapperMethod: Method init { - val superClass = classDescriptor.getSuperClassNotAny().sure { "No super class for $classDescriptor" } - superAsmType = typeMapper.mapClass(superClass) + val hasReceiver = target.getDispatchReceiverParameter() != null || target.getExtensionReceiverParameter() != null + val isMutable = target.isVar() + + wrapperMethod = when { + hasReceiver -> when { + isMutable -> method("mutableProperty1", K_MUTABLE_PROPERTY1_TYPE, MUTABLE_PROPERTY_REFERENCE1) + else -> method("property1", K_PROPERTY1_TYPE, PROPERTY_REFERENCE1) + } + else -> when { + isMutable -> method("mutableProperty0", K_MUTABLE_PROPERTY0_TYPE, MUTABLE_PROPERTY_REFERENCE0) + else -> method("property0", K_PROPERTY0_TYPE, PROPERTY_REFERENCE0) + } + } } override fun generateDeclaration() { @@ -77,8 +93,9 @@ public class PropertyReferenceCodegen( // TODO: ImplementationBodyCodegen.markLineNumberForSyntheticFunction? override fun generateBody() { - // TODO: instance should be already wrapped by Reflection - generateConstInstance(asmType) + generateConstInstance(asmType, wrapperMethod.getReturnType()) { iv -> + iv.invokestatic(REFLECTION, wrapperMethod.getName(), wrapperMethod.getDescriptor(), false) + } generateMethod("property reference init", 0, method("", Type.VOID_TYPE)) { load(0, OBJECT_TYPE) @@ -102,7 +119,7 @@ public class PropertyReferenceCodegen( defaultGetter } - val method = typeMapper.mapSignature(getter.sure { "No getter: $target" }).getAsmMethod() + val method = typeMapper.mapSignature(getter).getAsmMethod() aconst(method.getName() + method.getDescriptor()) } @@ -178,24 +195,8 @@ public class PropertyReferenceCodegen( writeKotlinSyntheticClassAnnotation(v, KotlinSyntheticClass.Kind.CALLABLE_REFERENCE_WRAPPER) } - public fun putInstanceOnStack(): StackValue { - val hasReceiver = target.getDispatchReceiverParameter() != null || target.getExtensionReceiverParameter() != null - - val method = - when { - hasReceiver -> when { - target.isVar() -> method("mutableProperty1", K_MUTABLE_PROPERTY1_TYPE, MUTABLE_PROPERTY_REFERENCE1) - else -> method("property1", K_PROPERTY1_TYPE, PROPERTY_REFERENCE1) - } - else -> when { - target.isVar() -> method("mutableProperty0", K_MUTABLE_PROPERTY0_TYPE, MUTABLE_PROPERTY_REFERENCE0) - else -> method("property0", K_PROPERTY0_TYPE, PROPERTY_REFERENCE0) - } - } - - return StackValue.operation(method.getReturnType()) { iv -> - iv.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor()) - iv.invokestatic(REFLECTION, method.getName(), method.getDescriptor(), false) - } - } + public fun putInstanceOnStack(): StackValue = + StackValue.operation(wrapperMethod.getReturnType()) { iv -> + iv.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, wrapperMethod.getReturnType().getDescriptor()) + } } diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt index 1b538942cd6..5414a37327f 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/functions.kt @@ -16,12 +16,17 @@ package org.jetbrains.kotlin.utils -private val IDENTITY: Function1 = { it } +private val IDENTITY: (Any?) -> Any? = { it } suppress("UNCHECKED_CAST") -public fun identity(): Function1 = IDENTITY as Function1 +public fun identity(): (T) -> T = IDENTITY as (T) -> T -private val ALWAYS_TRUE: Function1 = { true } +private val ALWAYS_TRUE: (Any?) -> Boolean = { true } -public fun alwaysTrue(): Function1 = ALWAYS_TRUE +public fun alwaysTrue(): (T) -> Boolean = ALWAYS_TRUE + + +public val DO_NOTHING: (Any?) -> Unit = { } + +public fun doNothing(): (T) -> Unit = DO_NOTHING From 95f5d24988a43d62c0da1ebc0eeb396dc5b321b4 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 18:39:15 +0300 Subject: [PATCH 237/450] Use a built-in marker class for Configure Kotlin action This helps to get rid of the balloon which was shown in Kotlin project itself because of the recent change where a source root was added to the module 'builtins', which doesn't have the class kotlin.jvm.internal.Intrinsics (the 'runtime.jvm' module does) --- .../kotlin/idea/versions/KotlinRuntimeLibraryCoreUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryCoreUtil.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryCoreUtil.java index e3389f3c152..f4e7472e19e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryCoreUtil.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryCoreUtil.java @@ -28,7 +28,7 @@ import org.jetbrains.annotations.Nullable; public class KotlinRuntimeLibraryCoreUtil { private static final ImmutableList CANDIDATE_CLASSES = ImmutableList.of( - "kotlin.jvm.internal.Intrinsics", + "kotlin.Unit", // For older versions "jet.runtime.Intrinsics" From d540ff8890b540703d3cbdfd662f35a722b1d0d1 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 9 Jul 2015 10:41:47 +0300 Subject: [PATCH 238/450] KT-8206 java.lang.NoSuchFieldError: $kotlinClass for deprecated::class Instantiate class literals for annotation classes as foreign. --- .../org/jetbrains/kotlin/codegen/ExpressionCodegen.java | 5 ++++- .../reflection/classLiterals/annotationClassLiteral.kt | 7 +++++++ .../generated/BlackBoxWithStdlibCodegenTestGenerated.java | 6 ++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 2e698b7203e..f9466586266 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2795,7 +2795,10 @@ public class ExpressionCodegen extends JetVisitor implem ClassifierDescriptor descriptor = type.getConstructor().getDeclarationDescriptor(); //noinspection ConstantConditions ModuleDescriptor module = DescriptorUtils.getContainingModule(descriptor); - if (descriptor instanceof JavaClassDescriptor || module == module.getBuiltIns().getBuiltInsModule()) { + // Instantiate annotation classes as foreign due to bug in JDK 6 and 7: + // http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6857918 + if (descriptor instanceof JavaClassDescriptor || module == module.getBuiltIns().getBuiltInsModule() || + DescriptorUtils.isAnnotationClass(descriptor)) { putJavaLangClassInstance(v, classAsmType); wrapJavaClassIntoKClass(v); } diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt b/compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt new file mode 100644 index 00000000000..a567b7f80af --- /dev/null +++ b/compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt @@ -0,0 +1,7 @@ +import kotlin.test.assertEquals + +fun box(): String { + assertEquals("deprecated", deprecated::class.simpleName) + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index cc474679aff..2407669c3b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2751,6 +2751,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("annotationClassLiteral.kt") + public void testAnnotationClassLiteral() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/annotationClassLiteral.kt"); + doTestWithStdlib(fileName); + } + @TestMetadata("arrays.kt") public void testArrays() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classLiterals/arrays.kt"); From 5dc28f1313be0804c20588c00c26851a8afa8883 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 9 Jul 2015 15:18:53 +0300 Subject: [PATCH 239/450] KT-7507 Check expected type for class literal expression --- .../BasicExpressionTypingVisitor.java | 4 +++- .../tests/classLiteral/classLiteralType.kt | 9 +++++++++ .../tests/classLiteral/classLiteralType.txt | 20 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/classLiteral/classLiteralType.kt create mode 100644 compiler/testData/diagnostics/tests/classLiteral/classLiteralType.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 7e6679e91b2..f7c0eb0bcda 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -517,7 +517,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { public JetTypeInfo visitClassLiteralExpression(@NotNull JetClassLiteralExpression expression, ExpressionTypingContext c) { JetType type = resolveClassLiteral(expression, c); if (type != null && !type.isError()) { - return TypeInfoFactoryPackage.createTypeInfo(components.reflectionTypes.getKClassType(Annotations.EMPTY, type), c); + return TypeInfoFactoryPackage.createCheckedTypeInfo( + components.reflectionTypes.getKClassType(Annotations.EMPTY, type), c, expression + ); } return TypeInfoFactoryPackage.createTypeInfo(ErrorUtils.createErrorType("Unresolved class"), c); diff --git a/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.kt b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.kt new file mode 100644 index 00000000000..1ca87eac20c --- /dev/null +++ b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.kt @@ -0,0 +1,9 @@ +import kotlin.reflect.KClass + +class A +class B + +val a1 : KClass<*> = A::class +val a2 : KClass = A::class +val a3 : KClass = A::class +val a4 : B = A::class diff --git a/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.txt b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.txt new file mode 100644 index 00000000000..642f545fe46 --- /dev/null +++ b/compiler/testData/diagnostics/tests/classLiteral/classLiteralType.txt @@ -0,0 +1,20 @@ +package + +internal val a1: kotlin.reflect.KClass<*> +internal val a2: kotlin.reflect.KClass +internal val a3: kotlin.reflect.KClass +internal val a4: B + +internal final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class B { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 075a993b04f..1558a70e534 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -2031,6 +2031,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("classLiteralType.kt") + public void testClassLiteralType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classLiteral/classLiteralType.kt"); + doTest(fileName); + } + @TestMetadata("genericClasses.kt") public void testGenericClasses() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/classLiteral/genericClasses.kt"); From 290983687d64a4efae95eef4447756ed9fe74010 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 19:19:37 +0300 Subject: [PATCH 240/450] Fix generation of bridges for lambdas #KT-8447 Fixed --- .../kotlin/codegen/ClosureCodegen.java | 22 ++++++++++--------- .../sam/adapters/doubleLongParameters.java | 3 +++ .../sam/adapters/doubleLongParameters.kt | 9 ++++++++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 6 +++++ 4 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.java create mode 100644 compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index f5375b206fd..852620a056b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.codegen; import com.google.common.collect.Lists; import com.intellij.util.ArrayUtil; +import kotlin.KotlinPackage; import kotlin.Unit; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; @@ -268,17 +269,18 @@ public class ClosureCodegen extends MemberCodegen { iv.load(0, asmType); - ReceiverParameterDescriptor receiver = funDescriptor.getExtensionReceiverParameter(); - int count = 1; - if (receiver != null) { - StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(receiver.getType()), iv); - count++; - } + Type[] myParameterTypes = bridge.getArgumentTypes(); - List params = funDescriptor.getValueParameters(); - for (ValueParameterDescriptor param : params) { - StackValue.local(count, bridge.getArgumentTypes()[count - 1]).put(typeMapper.mapType(param.getType()), iv); - count++; + List calleeParameters = KotlinPackage.plus( + UtilsPackage.singletonOrEmptyList(funDescriptor.getExtensionReceiverParameter()), + funDescriptor.getValueParameters() + ); + + int slot = 1; + for (int i = 0; i < calleeParameters.size(); i++) { + Type type = myParameterTypes[i]; + StackValue.local(slot, type).put(typeMapper.mapType(calleeParameters.get(i)), iv); + slot += type.getSize(); } iv.invokevirtual(asmType.getInternalName(), delegate.getName(), delegate.getDescriptor(), false); diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.java new file mode 100644 index 00000000000..66fd53063de --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.java @@ -0,0 +1,3 @@ +interface GenericInterface { + public T foo(double d, int i, long j, short s); +} diff --git a/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt new file mode 100644 index 00000000000..2f350b4dbad --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt @@ -0,0 +1,9 @@ +fun getInterface(): GenericInterface { + return GenericInterface { d, i, j, s -> + "OK" + } +} + +fun box(): String { + return getInterface().foo(0.0, 0, 0, 0) +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java index e1eb33ee306..91cad226b8d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -597,6 +597,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod doTestAgainstJava(fileName); } + @TestMetadata("doubleLongParameters.kt") + public void testDoubleLongParameters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/doubleLongParameters.kt"); + doTestAgainstJava(fileName); + } + @TestMetadata("fileFilter.kt") public void testFileFilter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt"); From 34cd2e0ac3a3da7f407e8d34c0956355e4f599aa Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 10 Jul 2015 03:18:01 +0300 Subject: [PATCH 241/450] Refactoring: Replace factory functions with constructors --- .../JetControlFlowInstructionsGenerator.java | 8 +-- .../instructions/eval/accessInstructions.kt | 33 ++++----- .../eval/operationInstructions.kt | 67 +++++++++---------- 3 files changed, 48 insertions(+), 60 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java index 49dca299a67..3e54da8759d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java @@ -446,7 +446,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull Map expectedTypes, @NotNull MagicKind kind ) { - MagicInstruction instruction = MagicInstruction.Factory.create( + MagicInstruction instruction = new MagicInstruction( instructionElement, valueElement, getCurrentScope(), inputValues, expectedTypes, kind, valueFactory ); add(instruction); @@ -456,7 +456,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull @Override public MergeInstruction merge(@NotNull JetExpression expression, @NotNull List inputValues) { - MergeInstruction instruction = MergeInstruction.Factory.create(expression, getCurrentScope(), inputValues, valueFactory); + MergeInstruction instruction = new MergeInstruction(expression, getCurrentScope(), inputValues, valueFactory); add(instruction); return instruction; } @@ -480,7 +480,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull Map arguments ) { JetType returnType = resolvedCall.getResultingDescriptor().getReturnType(); - CallInstruction instruction = CallInstruction.Factory.create( + CallInstruction instruction = new CallInstruction( valueElement, getCurrentScope(), resolvedCall, @@ -537,7 +537,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull Map receiverValues ) { AccessTarget accessTarget = resolvedCall != null ? new AccessTarget.Call(resolvedCall) : AccessTarget.BlackBox.INSTANCE$; - ReadValueInstruction instruction = ReadValueInstruction.Factory.create( + ReadValueInstruction instruction = new ReadValueInstruction( expression, getCurrentScope(), accessTarget, receiverValues, valueFactory ); add(instruction); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt index db5d57a1c1b..fe8d1c2422f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/accessInstructions.kt @@ -29,10 +29,10 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionVisitorWithRe import org.jetbrains.kotlin.cfg.pseudocode.instructions.InstructionImpl import org.jetbrains.kotlin.psi.JetNamedDeclaration -public trait AccessTarget { - public data class Declaration(val descriptor: VariableDescriptor): AccessTarget - public data class Call(val resolvedCall: ResolvedCall<*>): AccessTarget - public object BlackBox: AccessTarget +public sealed class AccessTarget { + public data class Declaration(val descriptor: VariableDescriptor): AccessTarget() + public data class Call(val resolvedCall: ResolvedCall<*>): AccessTarget() + public object BlackBox: AccessTarget() } public abstract class AccessValueInstruction protected constructor( @@ -49,8 +49,14 @@ public class ReadValueInstruction private constructor( receiverValues: Map, private var _outputValue: PseudoValue? ) : AccessValueInstruction(element, lexicalScope, target, receiverValues), InstructionWithValue { - private fun newResultValue(factory: PseudoValueFactory, valueElement: JetElement) { - _outputValue = factory.newValue(valueElement, this) + public constructor( + element: JetElement, + lexicalScope: LexicalScope, + target: AccessTarget, + receiverValues: Map, + factory: PseudoValueFactory + ): this(element, lexicalScope, target, receiverValues, null) { + _outputValue = factory.newValue(element, this) } override val inputValues: List @@ -82,21 +88,6 @@ public class ReadValueInstruction private constructor( override fun createCopy(): InstructionImpl = ReadValueInstruction(element, lexicalScope, target, receiverValues, outputValue) - - companion object Factory { - public fun create ( - element: JetElement, - lexicalScope: LexicalScope, - target: AccessTarget, - receiverValues: Map, - factory: PseudoValueFactory - ): ReadValueInstruction { - return ReadValueInstruction(element, lexicalScope, target, receiverValues, null).let { instruction -> - instruction.newResultValue(factory, element) - instruction - } - } - } } public class WriteValueInstruction( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt index 672f8172017..4547fc2d7aa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt @@ -60,6 +60,17 @@ public class CallInstruction private constructor( override val receiverValues: Map, public val arguments: Map ) : OperationInstruction(element, lexicalScope, receiverValues.keySet() + arguments.keySet()), InstructionWithReceivers { + public constructor ( + element: JetElement, + lexicalScope: LexicalScope, + resolvedCall: ResolvedCall<*>, + receiverValues: Map, + arguments: Map, + factory: PseudoValueFactory? + ): this(element, lexicalScope, resolvedCall, receiverValues, arguments) { + setResult(factory) + } + override fun accept(visitor: InstructionVisitor) { visitor.visitCallInstruction(this) } @@ -73,18 +84,6 @@ public class CallInstruction private constructor( override fun toString() = renderInstruction("call", "${render(element)}, ${resolvedCall.getResultingDescriptor()!!.getName()}") - - companion object Factory { - fun create ( - element: JetElement, - lexicalScope: LexicalScope, - resolvedCall: ResolvedCall<*>, - receiverValues: Map, - arguments: Map, - factory: PseudoValueFactory? - ): CallInstruction = - CallInstruction(element, lexicalScope, resolvedCall, receiverValues, arguments).setResult(factory, element) as CallInstruction - } } // Introduces black-box operation @@ -99,6 +98,18 @@ public class MagicInstruction( val expectedTypes: Map, val kind: MagicKind ) : OperationInstruction(element, lexicalScope, inputValues) { + public constructor ( + element: JetElement, + valueElement: JetElement?, + lexicalScope: LexicalScope, + inputValues: List, + expectedTypes: Map, + kind: MagicKind, + factory: PseudoValueFactory + ): this(element, lexicalScope, inputValues, expectedTypes, kind) { + setResult(factory, valueElement) + } + public val synthetic: Boolean get() = outputValue.element == null override val outputValue: PseudoValue @@ -112,20 +123,6 @@ public class MagicInstruction( MagicInstruction(element, lexicalScope, inputValues, expectedTypes, kind).setResult(resultValue) override fun toString() = renderInstruction("magic[$kind]", render(element)) - - companion object Factory { - fun create( - element: JetElement, - valueElement: JetElement?, - lexicalScope: LexicalScope, - inputValues: List, - expectedTypes: Map, - kind: MagicKind, - factory: PseudoValueFactory - ): MagicInstruction = MagicInstruction( - element, lexicalScope, inputValues, expectedTypes, kind - ).setResult(factory, valueElement) as MagicInstruction - } } public enum class MagicKind(val sideEffectFree: Boolean = false) { @@ -155,6 +152,15 @@ class MergeInstruction private constructor( lexicalScope: LexicalScope, inputValues: List ): OperationInstruction(element, lexicalScope, inputValues) { + public constructor ( + element: JetElement, + lexicalScope: LexicalScope, + inputValues: List, + factory: PseudoValueFactory + ): this(element, lexicalScope, inputValues) { + setResult(factory) + } + override val outputValue: PseudoValue get() = resultValue!! @@ -165,13 +171,4 @@ class MergeInstruction private constructor( override fun createCopy() = MergeInstruction(element, lexicalScope, inputValues).setResult(resultValue) override fun toString() = renderInstruction("merge", render(element)) - - companion object Factory { - fun create( - element: JetElement, - lexicalScope: LexicalScope, - inputValues: List, - factory: PseudoValueFactory - ): MergeInstruction = MergeInstruction(element, lexicalScope, inputValues).setResult(factory) as MergeInstruction - } } From 969183fbf3b59242425e473d4d0f519545aa6962 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Thu, 28 May 2015 16:26:46 +0300 Subject: [PATCH 242/450] Control-Flow: Move type predicate computation out of control-flow analysis --- .../kotlin/cfg/JetControlFlowBuilder.java | 2 - .../cfg/JetControlFlowBuilderAdapter.java | 4 +- .../kotlin/cfg/JetControlFlowProcessor.java | 216 +++--------------- .../JetControlFlowInstructionsGenerator.java | 23 +- .../eval/operationInstructions.kt | 6 +- .../kotlin/cfg/pseudocode/pseudocodeUtil.kt | 131 +++++++++-- .../kotlin/resolve/calls/resolvedCallUtil.kt | 9 + 7 files changed, 158 insertions(+), 233 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilder.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilder.java index d7e63e1a982..4035bfba69c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilder.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilder.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue; import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode; -import org.jetbrains.kotlin.cfg.pseudocode.TypePredicate; import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.*; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.psi.*; @@ -120,7 +119,6 @@ public interface JetControlFlowBuilder { @NotNull JetElement instructionElement, @Nullable JetElement valueElement, @NotNull List inputValues, - @NotNull Map expectedTypes, @NotNull MagicKind kind ); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilderAdapter.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilderAdapter.java index b3d81011e37..a5ac8a404a0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilderAdapter.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowBuilderAdapter.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue; import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode; -import org.jetbrains.kotlin.cfg.pseudocode.TypePredicate; import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.*; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.psi.*; @@ -71,10 +70,9 @@ public abstract class JetControlFlowBuilderAdapter implements JetControlFlowBuil @NotNull JetElement instructionElement, @Nullable JetElement valueElement, @NotNull List inputValues, - @NotNull Map expectedTypes, @NotNull MagicKind kind ) { - return getDelegateBuilder().magic(instructionElement, valueElement, inputValues, expectedTypes, kind); + return getDelegateBuilder().magic(instructionElement, valueElement, inputValues, kind); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java index 8d34e1869e0..009380aa147 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetControlFlowProcessor.java @@ -17,20 +17,21 @@ package org.jetbrains.kotlin.cfg; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.SmartFMap; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.MultiMap; import kotlin.KotlinPackage; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.cfg.pseudocode.*; +import org.jetbrains.kotlin.cfg.pseudocode.JetControlFlowInstructionsGenerator; +import org.jetbrains.kotlin.cfg.pseudocode.PseudoValue; +import org.jetbrains.kotlin.cfg.pseudocode.Pseudocode; +import org.jetbrains.kotlin.cfg.pseudocode.PseudocodeImpl; import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.AccessTarget; import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.InstructionWithValue; import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicKind; @@ -41,15 +42,12 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; -import org.jetbrains.kotlin.renderer.DescriptorRenderer; -import org.jetbrains.kotlin.resolve.*; -import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilPackage; -import org.jetbrains.kotlin.resolve.calls.ValueArgumentsToParametersMapper; -import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; +import org.jetbrains.kotlin.resolve.BindingContext; +import org.jetbrains.kotlin.resolve.BindingContextUtils; +import org.jetbrains.kotlin.resolve.BindingTrace; +import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils; import org.jetbrains.kotlin.resolve.calls.model.*; import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; -import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate; -import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; @@ -142,7 +140,7 @@ public class JetControlFlowProcessor { if (!generateCall(condition.getOperationReference())) { JetExpression rangeExpression = condition.getRangeExpression(); generateInstructions(rangeExpression); - createUnresolvedCall(condition, rangeExpression); + createNonSyntheticValue(condition, MagicKind.UNRESOLVED_CALL, rangeExpression); } } @@ -209,7 +207,7 @@ public class JetControlFlowProcessor { @NotNull private PseudoValue createSyntheticValue(@NotNull JetElement instructionElement, @NotNull MagicKind kind, JetElement... from) { List values = elementsToValues(from.length > 0 ? Arrays.asList(from) : Collections.emptyList()); - return builder.magic(instructionElement, null, values, defaultTypeMap(values), kind).getOutputValue(); + return builder.magic(instructionElement, null, values, kind).getOutputValue(); } @NotNull @@ -217,7 +215,7 @@ public class JetControlFlowProcessor { @NotNull JetElement to, @NotNull List from, @NotNull MagicKind kind ) { List values = elementsToValues(from); - return builder.magic(to, to, values, defaultTypeMap(values), kind).getOutputValue(); + return builder.magic(to, to, values, kind).getOutputValue(); } @NotNull @@ -225,114 +223,6 @@ public class JetControlFlowProcessor { return createNonSyntheticValue(to, Arrays.asList(from), kind); } - @Nullable - private Map getTypeMapForUnresolvedCall(@NotNull JetElement to, List arguments) { - Call call = CallUtilPackage.getCall(to, trace.getBindingContext()); - if (call == null) return null; - - JetExpression callee = call.getCalleeExpression(); - if (callee == null) return null; - - Collection candidates = KotlinPackage.sortBy( - KotlinPackage.filterIsInstance( - BindingContextUtilPackage.getReferenceTargets(callee, trace.getBindingContext()), - FunctionDescriptor.class - ), - new Function1() { - @Override - public Comparable invoke(FunctionDescriptor descriptor) { - return DescriptorRenderer.DEBUG_TEXT.render(descriptor); - } - } - ); - if (candidates.isEmpty()) return null; - - ReceiverValue explicitReceiver = call.getExplicitReceiver(); - int argValueOffset = explicitReceiver.exists() ? 1 : 0; - - MultiMap valuesToPredicates = new MultiMap(arguments.size(), 1); - - candidateLoop: - for (FunctionDescriptor candidate : candidates) { - ResolvedCallImpl candidateCall = ResolvedCallImpl.create( - ResolutionCandidate.create(call, - candidate, - call.getDispatchReceiver(), - explicitReceiver, - ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, - null), - new DelegatingBindingTrace(trace.getBindingContext(), "Compute type predicates for unresolved call arguments"), - TracingStrategy.EMPTY, - new DataFlowInfoForArgumentsImpl(call) - ); - ValueArgumentsToParametersMapper.Status status = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters( - call, - TracingStrategy.EMPTY, - candidateCall, - Sets.newLinkedHashSet() - ); - if (!status.isSuccess()) continue; - - if ((candidate.getExtensionReceiverParameter() == null) == candidateCall.getExtensionReceiver().exists()) continue; - - Map candidateArgumentMap = candidateCall.getValueArguments(); - List callArguments = call.getValueArguments(); - for (int i = 0; i < callArguments.size(); i++) { - int valueIndex = i + argValueOffset; - if (valueIndex >= arguments.size()) continue candidateLoop; - PseudoValue argumentValue = arguments.get(valueIndex); - - ArgumentMapping mapping = candidateCall.getArgumentMapping(callArguments.get(i)); - if (!(mapping instanceof ArgumentMatch)) continue candidateLoop; - - ValueParameterDescriptor candidateParameter = ((ArgumentMatch) mapping).getValueParameter(); - ResolvedValueArgument resolvedArgument = candidateArgumentMap.get(candidateParameter); - JetType expectedType = resolvedArgument instanceof VarargValueArgument - ? candidateParameter.getVarargElementType() - : candidateParameter.getType(); - - valuesToPredicates.putValue(argumentValue, expectedType != null ? new AllSubtypes(expectedType) : AllTypes.INSTANCE$); - } - } - - SmartFMap result = SmartFMap.emptyMap(); - for (Map.Entry> entry : valuesToPredicates.entrySet()) { - result = result.plus(entry.getKey(), PseudocodePackage.or(entry.getValue())); - } - - return result; - } - - @NotNull - private PseudoValue createUnresolvedCallByValues(@NotNull JetElement to, @Nullable JetElement valueElement, List arguments) { - Map typeMap = getTypeMapForUnresolvedCall(to, arguments); - if (typeMap == null) { - typeMap = defaultTypeMap(arguments); - } - - return builder.magic(to, valueElement, arguments, typeMap, MagicKind.UNRESOLVED_CALL).getOutputValue(); - } - - @NotNull - private PseudoValue createUnresolvedCallByValues(@NotNull JetElement to, List arguments) { - return createUnresolvedCallByValues(to, to, arguments); - } - - @NotNull - private PseudoValue createUnresolvedCall(@NotNull JetElement to, List from) { - return createUnresolvedCallByValues(to, elementsToValues(from)); - } - - @NotNull - private PseudoValue createUnresolvedCall(@NotNull JetElement to, JetElement... from) { - return createUnresolvedCall(to, Arrays.asList(from)); - } - - @NotNull - private Map defaultTypeMap(List values) { - return PseudocodePackage.expectedTypeFor(AllTypes.INSTANCE$, values); - } - private void mergeValues(@NotNull List from, @NotNull JetExpression to) { builder.merge(to, elementsToValues(from)); } @@ -414,7 +304,7 @@ public class JetControlFlowProcessor { public void visitThisExpression(@NotNull JetThisExpression expression) { ResolvedCall resolvedCall = getResolvedCall(expression, trace.getBindingContext()); if (resolvedCall == null) { - createUnresolvedCall(expression); + createNonSyntheticValue(expression, MagicKind.UNRESOLVED_CALL); return; } @@ -440,7 +330,7 @@ public class JetControlFlowProcessor { generateCall(variableAsFunctionResolvedCall.getVariableCall()); } else if (!generateCall(expression) && !(expression.getParent() instanceof JetCallExpression)) { - createUnresolvedCall(expression, generateAndGetReceiverIfAny(expression)); + createNonSyntheticValue(expression, MagicKind.UNRESOLVED_CALL, generateAndGetReceiverIfAny(expression)); } } @@ -553,7 +443,7 @@ public class JetControlFlowProcessor { generateInstructions(right); } mark(expression); - createUnresolvedCall(expression, left, right); + createNonSyntheticValue(expression, MagicKind.UNRESOLVED_CALL, left, right); } private void visitAssignment( @@ -564,7 +454,7 @@ public class JetControlFlowProcessor { JetExpression left = JetPsiUtil.deparenthesize(lhs); if (left == null) { List arguments = Collections.singletonList(rhsDeferredValue.invoke()); - builder.magic(parentExpression, parentExpression, arguments, defaultTypeMap(arguments), MagicKind.UNSUPPORTED_ELEMENT); + builder.magic(parentExpression, parentExpression, arguments, MagicKind.UNSUPPORTED_ELEMENT); return; } @@ -609,7 +499,7 @@ public class JetControlFlowProcessor { List arguments = KotlinPackage.filterNotNull( Arrays.asList(getBoundOrUnreachableValue(lhs), rhsDeferredValue.invoke()) ); - createUnresolvedCallByValues(parentExpression, arguments); + builder.magic(parentExpression, parentExpression, arguments, MagicKind.UNRESOLVED_CALL); return; } @@ -680,7 +570,7 @@ public class JetControlFlowProcessor { } private void generateArrayAccessWithoutCall(JetArrayAccessExpression arrayAccessExpression) { - createUnresolvedCall(arrayAccessExpression, generateArrayAccessArguments(arrayAccessExpression)); + createNonSyntheticValue(arrayAccessExpression, generateArrayAccessArguments(arrayAccessExpression), MagicKind.UNRESOLVED_CALL); } private List generateArrayAccessArguments(JetArrayAccessExpression arrayAccessExpression) { @@ -719,7 +609,7 @@ public class JetControlFlowProcessor { } else { generateInstructions(baseExpression); - rhsValue = createUnresolvedCall(expression, baseExpression); + rhsValue = createNonSyntheticValue(expression, MagicKind.UNRESOLVED_CALL, baseExpression); } if (incrementOrDecrement) { @@ -917,10 +807,7 @@ public class JetControlFlowProcessor { } else { assert condition != null : "Invalid while condition: " + expression.getText(); - List values = ContainerUtil.createMaybeSingletonList(builder.getBoundValue(condition)); - Map typePredicates = - PseudocodePackage.expectedTypeFor(new SingleType(KotlinBuiltIns.getInstance().getBooleanType()), values); - builder.magic(condition, null, values, typePredicates, MagicKind.VALUE_CONSUMER); + createSyntheticValue(condition, MagicKind.VALUE_CONSUMER, condition); } builder.enterLoopBody(expression); @@ -1006,17 +893,10 @@ public class JetControlFlowProcessor { JetMultiDeclaration multiDeclaration = expression.getMultiParameter(); JetExpression loopRange = expression.getLoopRange(); - TypePredicate loopRangeTypePredicate = - getTypePredicateByReceiverValue(trace.get(BindingContext.LOOP_RANGE_ITERATOR_RESOLVED_CALL, loopRange)); - - PseudoValue loopRangeValue = builder.getBoundValue(loopRange); PseudoValue value = builder.magic( loopRange != null ? loopRange : expression, null, - ContainerUtil.createMaybeSingletonList(loopRangeValue), - loopRangeValue != null - ? Collections.singletonMap(loopRangeValue, loopRangeTypePredicate) - : Collections.emptyMap(), + ContainerUtil.createMaybeSingletonList(builder.getBoundValue(loopRange)), MagicKind.LOOP_RANGE_ITERATION ).getOutputValue(); @@ -1030,17 +910,6 @@ public class JetControlFlowProcessor { } } - private ReceiverValue getExplicitReceiverValue(ResolvedCall resolvedCall) { - switch(resolvedCall.getExplicitReceiverKind()) { - case DISPATCH_RECEIVER: - return resolvedCall.getDispatchReceiver(); - case EXTENSION_RECEIVER: - return resolvedCall.getExtensionReceiver(); - default: - return ReceiverValue.NO_RECEIVER; - } - } - @Override public void visitBreakExpression(@NotNull JetBreakExpression expression) { JetElement loop = getCorrespondingLoop(expression); @@ -1250,7 +1119,7 @@ public class JetControlFlowProcessor { inputExpressions.add(generateAndGetReceiverIfAny(expression)); mark(expression); - createUnresolvedCall(expression, inputExpressions); + createNonSyntheticValue(expression, inputExpressions, MagicKind.UNRESOLVED_CALL); } } @@ -1292,33 +1161,9 @@ public class JetControlFlowProcessor { DeclarationDescriptor descriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, property); if (!(descriptor instanceof PropertyDescriptor)) return; - PseudoValue delegateValue = builder.getBoundValue(delegate); - if (delegateValue == null) return; + if (builder.getBoundValue(delegate) == null) return; - List typePredicates = KotlinPackage.map( - ((PropertyDescriptor) descriptor).getAccessors(), - new Function1() { - @Override - public TypePredicate invoke(PropertyAccessorDescriptor descriptor) { - return getTypePredicateByReceiverValue(trace.get(BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, descriptor)); - } - } - ); - Map valuesToTypePredicates = SmartFMap - .emptyMap() - .plus(delegateValue, PseudocodePackage.and(KotlinPackage.filterNotNull(typePredicates))); - builder.magic(property, null, Collections.singletonList(delegateValue), valuesToTypePredicates, MagicKind.VALUE_CONSUMER); - } - - private TypePredicate getTypePredicateByReceiverValue(@Nullable ResolvedCall resolvedCall) { - if (resolvedCall == null) return AllTypes.INSTANCE$; - - ReceiverValue receiverValue = getExplicitReceiverValue(resolvedCall); - if (receiverValue.exists()) { - return PseudocodePackage.getReceiverTypePredicate(resolvedCall, receiverValue); - } - - return AllTypes.INSTANCE$; + createSyntheticValue(property, MagicKind.VALUE_CONSUMER, delegate); } @Override @@ -1344,8 +1189,7 @@ public class JetControlFlowProcessor { ).getOutputValue(); } else { - List arguments = ContainerUtil.createMaybeSingletonList(getBoundOrUnreachableValue(initializer)); - writtenValue = createUnresolvedCallByValues(entry, null, arguments); + writtenValue = createSyntheticValue(entry, MagicKind.UNRESOLVED_CALL, initializer); } if (generateWriteForEntries) { @@ -1591,19 +1435,15 @@ public class JetControlFlowProcessor { for (JetExpression argument : arguments) { generateInstructions(argument); } - createUnresolvedCall(call, arguments); + createNonSyntheticValue(call, arguments, MagicKind.UNRESOLVED_CALL); } } @Override public void visitDelegationByExpressionSpecifier(@NotNull JetDelegatorByExpressionSpecifier specifier) { - generateInstructions(specifier.getDelegateExpression()); - - List arguments = ContainerUtil.createMaybeSingletonList(builder.getBoundValue(specifier.getDelegateExpression())); - JetType jetType = trace.get(BindingContext.TYPE, specifier.getTypeReference()); - TypePredicate expectedTypePredicate = jetType != null ? PseudocodePackage.getSubtypesPredicate(jetType) : AllTypes.INSTANCE$; - builder.magic(specifier, null, arguments, PseudocodePackage.expectedTypeFor(expectedTypePredicate, arguments), - MagicKind.VALUE_CONSUMER); + JetExpression delegateExpression = specifier.getDelegateExpression(); + generateInstructions(delegateExpression); + createSyntheticValue(specifier, MagicKind.VALUE_CONSUMER, delegateExpression); } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java index 3e54da8759d..c4c87faaa32 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/JetControlFlowInstructionsGenerator.java @@ -432,9 +432,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull @Override public InstructionWithValue loadStringTemplate(@NotNull JetStringTemplateExpression expression, @NotNull List inputValues) { - if (inputValues.isEmpty()) return read(expression); - Map predicate = PseudocodePackage.expectedTypeFor(AllTypes.INSTANCE$, inputValues); - return magic(expression, expression, inputValues, predicate, MagicKind.STRING_TEMPLATE); + return inputValues.isEmpty() ? read(expression) : magic(expression, expression, inputValues, MagicKind.STRING_TEMPLATE); } @NotNull @@ -443,11 +441,10 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull JetElement instructionElement, @Nullable JetElement valueElement, @NotNull List inputValues, - @NotNull Map expectedTypes, @NotNull MagicKind kind ) { MagicInstruction instruction = new MagicInstruction( - instructionElement, valueElement, getCurrentScope(), inputValues, expectedTypes, kind, valueFactory + instructionElement, valueElement, getCurrentScope(), inputValues, kind, valueFactory ); add(instruction); return instruction; @@ -499,21 +496,7 @@ public class JetControlFlowInstructionsGenerator extends JetControlFlowBuilderAd @NotNull PredefinedOperation operation, @NotNull List inputValues ) { - Map expectedTypes; - switch(operation) { - case AND: - case OR: - SingleType onlyBoolean = new SingleType(KotlinBuiltIns.getInstance().getBooleanType()); - expectedTypes = PseudocodePackage.expectedTypeFor(onlyBoolean, inputValues); - break; - case NOT_NULL_ASSERTION: - expectedTypes = PseudocodePackage.expectedTypeFor(AllTypes.INSTANCE$, inputValues); - break; - default: - throw new IllegalArgumentException("Invalid operation: " + operation); - } - - return magic(expression, expression, inputValues, expectedTypes, getMagicKind(operation)); + return magic(expression, expression, inputValues, getMagicKind(operation)); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt index 4547fc2d7aa..2daa3ef0394 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/eval/operationInstructions.kt @@ -95,7 +95,6 @@ public class MagicInstruction( element: JetElement, lexicalScope: LexicalScope, inputValues: List, - val expectedTypes: Map, val kind: MagicKind ) : OperationInstruction(element, lexicalScope, inputValues) { public constructor ( @@ -103,10 +102,9 @@ public class MagicInstruction( valueElement: JetElement?, lexicalScope: LexicalScope, inputValues: List, - expectedTypes: Map, kind: MagicKind, factory: PseudoValueFactory - ): this(element, lexicalScope, inputValues, expectedTypes, kind) { + ): this(element, lexicalScope, inputValues, kind) { setResult(factory, valueElement) } @@ -120,7 +118,7 @@ public class MagicInstruction( override fun accept(visitor: InstructionVisitorWithResult): R = visitor.visitMagic(this) override fun createCopy() = - MagicInstruction(element, lexicalScope, inputValues, expectedTypes, kind).setResult(resultValue) + MagicInstruction(element, lexicalScope, inputValues, kind).setResult(resultValue) override fun toString() = renderInstruction("magic[$kind]", render(element)) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtil.kt index b40fbd43d58..2649798f09f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/pseudocodeUtil.kt @@ -16,8 +16,12 @@ package org.jetbrains.kotlin.cfg.pseudocode +import com.google.common.collect.Sets import com.intellij.psi.util.PsiTreeUtil +import com.intellij.util.SmartFMap +import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.MagicKind.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.Instruction import org.jetbrains.kotlin.cfg.pseudocode.instructions.eval.* import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.ConditionalJumpInstruction @@ -26,23 +30,28 @@ import org.jetbrains.kotlin.cfg.pseudocode.instructions.jumps.ThrowExceptionInst import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext -import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType -import org.jetbrains.kotlin.psi.psiUtil.parents +import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.BindingContext.* +import org.jetbrains.kotlin.resolve.DelegatingBindingTrace import org.jetbrains.kotlin.resolve.OverridingUtil +import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets import org.jetbrains.kotlin.resolve.bindingContextUtil.getTargetFunctionDescriptor -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument +import org.jetbrains.kotlin.resolve.calls.ValueArgumentsToParametersMapper +import org.jetbrains.kotlin.resolve.calls.callUtil.getCall +import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind +import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate +import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils -import java.util.ArrayList -import java.util.LinkedHashSet +import java.util.* fun getReceiverTypePredicate(resolvedCall: ResolvedCall<*>, receiverValue: ReceiverValue): TypePredicate? { - val callableDescriptor = resolvedCall.getResultingDescriptor() - if (callableDescriptor == null) return null + val callableDescriptor = resolvedCall.getResultingDescriptor() ?: return null when (receiverValue) { resolvedCall.getExtensionReceiver() -> { @@ -61,13 +70,75 @@ fun getReceiverTypePredicate(resolvedCall: ResolvedCall<*>, receiverValue: Recei } public fun getExpectedTypePredicate(value: PseudoValue, bindingContext: BindingContext): TypePredicate { - val pseudocode = value.createdAt?.owner - if (pseudocode == null) return AllTypes + val pseudocode = value.createdAt?.owner ?: return AllTypes + val builtIns = KotlinBuiltIns.getInstance() val typePredicates = LinkedHashSet() fun addSubtypesOf(jetType: JetType?) = typePredicates.add(jetType?.getSubtypesPredicate()) + fun addByExplicitReceiver(resolvedCall: ResolvedCall<*>?) { + val receiverValue = (resolvedCall ?: return).getExplicitReceiverValue() + if (receiverValue.exists()) typePredicates.add(getReceiverTypePredicate(resolvedCall, receiverValue)) + } + + fun getTypePredicateForUnresolvedCallArgument(to: JetElement, inputValueIndex: Int): TypePredicate? { + if (inputValueIndex < 0) return null + val call = to.getCall(bindingContext) ?: return null + val callee = call.getCalleeExpression() ?: return null + + val candidates = callee.getReferenceTargets(bindingContext) + .filterIsInstance() + .sortBy { DescriptorRenderer.DEBUG_TEXT.render(it) } + if (candidates.isEmpty()) return null + + val explicitReceiver = call.getExplicitReceiver() + val argValueOffset = if (explicitReceiver.exists()) 1 else 0 + + val predicates = ArrayList() + + for (candidate in candidates) { + val resolutionCandidate = ResolutionCandidate.create( + call, + candidate, + call.getDispatchReceiver(), + explicitReceiver, + ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, + null + ) + val candidateCall = ResolvedCallImpl.create( + resolutionCandidate, + DelegatingBindingTrace(bindingContext, "Compute type predicates for unresolved call arguments"), + TracingStrategy.EMPTY, + DataFlowInfoForArgumentsImpl(call) + ) + val status = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters(call, + TracingStrategy.EMPTY, + candidateCall, + LinkedHashSet()) + if (!status.isSuccess()) continue + + val candidateArgumentMap = candidateCall.getValueArguments() + val callArguments = call.getValueArguments() + val i = inputValueIndex - argValueOffset + if (i < 0 || i >= callArguments.size()) continue + + val mapping = candidateCall.getArgumentMapping(callArguments.get(i)) + if (mapping !is ArgumentMatch) continue + + val candidateParameter = mapping.valueParameter + val resolvedArgument = candidateArgumentMap.get(candidateParameter) + val expectedType = if (resolvedArgument is VarargValueArgument) + candidateParameter.getVarargElementType() + else + candidateParameter.getType() + + predicates.add(if (expectedType != null) AllSubtypes(expectedType) else AllTypes) + } + + return or(predicates) + } + fun addTypePredicates(value: PseudoValue) { pseudocode.getUsages(value).forEach { when (it) { @@ -75,16 +146,16 @@ public fun getExpectedTypePredicate(value: PseudoValue, bindingContext: BindingC val returnElement = it.element val functionDescriptor = when(returnElement) { is JetReturnExpression -> returnElement.getTargetFunctionDescriptor(bindingContext) - else -> bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, pseudocode.getCorrespondingElement()] + else -> bindingContext[DECLARATION_TO_DESCRIPTOR, pseudocode.getCorrespondingElement()] } addSubtypesOf((functionDescriptor as? CallableDescriptor)?.getReturnType()) } is ConditionalJumpInstruction -> - addSubtypesOf(KotlinBuiltIns.getInstance().getBooleanType()) + addSubtypesOf(builtIns.getBooleanType()) is ThrowExceptionInstruction -> - addSubtypesOf(KotlinBuiltIns.getInstance().getThrowable().getDefaultType()) + addSubtypesOf(builtIns.getThrowable().getDefaultType()) is MergeInstruction -> addTypePredicates(it.outputValue) @@ -126,8 +197,36 @@ public fun getExpectedTypePredicate(value: PseudoValue, bindingContext: BindingC } } - is MagicInstruction -> - typePredicates.add(it.expectedTypes[value]) + is MagicInstruction -> @suppress("NON_EXHAUSTIVE_WHEN") when (it.kind) { + AND, OR -> + addSubtypesOf(builtIns.getBooleanType()) + + LOOP_RANGE_ITERATION -> + addByExplicitReceiver(bindingContext[LOOP_RANGE_ITERATOR_RESOLVED_CALL, value.element as? JetExpression]) + + VALUE_CONSUMER -> { + val element = it.element + when { + element.getStrictParentOfType()?.getCondition() == element -> + addSubtypesOf(builtIns.getBooleanType()) + + element is JetProperty -> { + val propertyDescriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, element] as? PropertyDescriptor + propertyDescriptor?.getAccessors()?.map { + addByExplicitReceiver(bindingContext[DELEGATED_PROPERTY_RESOLVED_CALL, it]) + } + } + + element is JetDelegatorByExpressionSpecifier -> + addSubtypesOf(bindingContext[TYPE, element.getTypeReference()]) + } + } + + UNRESOLVED_CALL -> { + val typePredicate = getTypePredicateForUnresolvedCallArgument(it.element, it.inputValues.indexOf(value)) + typePredicates.add(typePredicate) + } + } } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt index da03a928a6b..44bca5ea909 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/resolvedCallUtil.kt @@ -26,8 +26,10 @@ import org.jetbrains.kotlin.psi.JetThisExpression import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.descriptorUtil.getOwnerForEffectiveDispatchReceiverParameter import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver // it returns true if call has no dispatch receiver (e.g. resulting descriptor is top-level function or local variable) @@ -66,3 +68,10 @@ private fun ResolvedCall<*>.hasThisOrNoDispatchReceiver( return dispatchReceiverDescriptor == getResultingDescriptor().getOwnerForEffectiveDispatchReceiverParameter() } +public fun ResolvedCall<*>.getExplicitReceiverValue(): ReceiverValue { + return when (getExplicitReceiverKind()) { + ExplicitReceiverKind.DISPATCH_RECEIVER -> getDispatchReceiver() + ExplicitReceiverKind.EXTENSION_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> getExtensionReceiver() + else -> ReceiverValue.NO_RECEIVER + } +} \ No newline at end of file From 064b03ca3fca927332a52e25fc0ff266bff829c5 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Sat, 11 Jul 2015 14:08:51 +0300 Subject: [PATCH 243/450] Minor: Suppress error message to fix compilation against Java 8 --- .../refactoring/changeSignature/ui/JetChangeSignatureDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt index 949259ab460..9cb68759f8f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/JetChangeSignatureDialog.kt @@ -250,7 +250,7 @@ public class JetChangeSignatureDialog( val columnInfo = parametersTableModel.getColumnInfos()[column] if (JetPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo)) - return (components.get(column) as JComboBox).getSelectedItem() + return (components.get(column) as @suppress("NO_TYPE_ARGUMENTS_ON_RHS") JComboBox).getSelectedItem() else if (JetCallableParameterTableModel.isTypeColumn(columnInfo)) return item.typeCodeFragment else if (JetCallableParameterTableModel.isNameColumn(columnInfo)) From 4de2c5a5c84cc0e096c72587941e021d9490ca3a Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 10 Jul 2015 21:01:57 +0300 Subject: [PATCH 244/450] Don't generate default no-args constructor for enums #KT-8438 Fixed --- .../kotlin/codegen/DefaultParameterValueSubstitutor.kt | 1 + .../codegen/box/enum/publicConstructorWithDefault.kt | 9 +++++++++ .../codegen/generated/BlackBoxCodegenTestGenerated.java | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt index bd036f7e545..fb19e4c7287 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt @@ -206,6 +206,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) { private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: JetClassOrObject): Boolean { val classDescriptor = constructorDescriptor.getContainingDeclaration() + if (classDescriptor.getKind() != ClassKind.CLASS) return false if (classOrObject.isLocal()) return false diff --git a/compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt b/compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt new file mode 100644 index 00000000000..be8a43b12b5 --- /dev/null +++ b/compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt @@ -0,0 +1,9 @@ +// KT-8438 org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 4: Cannot pop operand off an empty stack + +enum class E public constructor(x: String = "OK") { + ENTRY(); + + val result = x +} + +fun box(): String = E.ENTRY.result diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index fe9d48e3f7d..875ede44b80 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -3475,6 +3475,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("publicConstructorWithDefault.kt") + public void testPublicConstructorWithDefault() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/publicConstructorWithDefault.kt"); + doTest(fileName); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/enum/simple.kt"); From f7ccb3819ed4fa07da89c4d7a5154eeb774868e3 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 13 Jul 2015 00:27:51 +0300 Subject: [PATCH 245/450] JS: don't pollute object with `$metadata$` #KT-8126 Fixed --- .../kotlin/js/test/semantics/ObjectTest.java | 4 ++ js/js.translator/testData/kotlin_lib_ecma5.js | 4 +- .../object/cases/dontPolluteObject.kt | 45 +++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 js/js.translator/testData/object/cases/dontPolluteObject.kt diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ObjectTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ObjectTest.java index f1a2f0d9cc8..2b5e4b88d6f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ObjectTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/ObjectTest.java @@ -59,4 +59,8 @@ public final class ObjectTest extends SingleFileTranslationTest { public void testLambdaInObjectInsideObject() throws Exception { checkFooBoxIsOk(); } + + public void testDontPolluteObject() throws Exception { + checkFooBoxIsOk(); + } } diff --git a/js/js.translator/testData/kotlin_lib_ecma5.js b/js/js.translator/testData/kotlin_lib_ecma5.js index e0c62d82ba2..fd799ac5cd8 100644 --- a/js/js.translator/testData/kotlin_lib_ecma5.js +++ b/js/js.translator/testData/kotlin_lib_ecma5.js @@ -175,9 +175,7 @@ var Kotlin = {}; Kotlin.createObjectNow = function (bases, constructor, functions) { var noNameClass = Kotlin.createClassNow(bases, constructor, functions); var obj = new noNameClass(); - obj.$metadata$ = { - type: Kotlin.TYPE.OBJECT - }; + noNameClass.$metadata$.type = Kotlin.TYPE.OBJECT; return obj; }; diff --git a/js/js.translator/testData/object/cases/dontPolluteObject.kt b/js/js.translator/testData/object/cases/dontPolluteObject.kt new file mode 100644 index 00000000000..9349125a2b6 --- /dev/null +++ b/js/js.translator/testData/object/cases/dontPolluteObject.kt @@ -0,0 +1,45 @@ +package foo + +object EmptyObject {} + +object SomeObject { + val foo = 1 + var bar = "t" + fun baz() {} +} + +val emptyObjectExpr = object {} + +val someObjectExpr = object { + val foo = 1 + var bar = "t" + fun baz() {} +} + +val o = js("Object") + +fun keys(a: Any): List { + val arr: Array = o.keys(a) + return arr.toList() +} + +fun getOwnPropertyNames(a: Any): List { + val arr: Array = o.getOwnPropertyNames(a) + return arr.toList() +} + +fun box(): String { + assertEquals(listOf(), getOwnPropertyNames(EmptyObject)) + assertEquals(listOf(), keys(EmptyObject)) + + assertEquals(listOf("foo", "bar"), getOwnPropertyNames(SomeObject)) + assertEquals(listOf("foo", "bar"), keys(SomeObject)) + + assertEquals(listOf(), getOwnPropertyNames(emptyObjectExpr)) + assertEquals(listOf(), keys(emptyObjectExpr)) + + assertEquals(listOf("foo", "bar"), getOwnPropertyNames(someObjectExpr)) + assertEquals(listOf("foo", "bar"), keys(someObjectExpr)) + + return "OK" +} From 4ad6a8e30156d2451ad2a4b6e5d602672f3334a8 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sat, 11 Jul 2015 16:09:22 +0300 Subject: [PATCH 246/450] Ensure type of a stack value is coerced to the expected return type after the binary operation instruction with the different return type. --- .../kotlin/codegen/intrinsics/BinaryOp.kt | 6 +++++- .../codegen/box/binaryOp/longOverflow.kt | 5 ----- .../codegen/box/binaryOp/overflowChar.kt | 10 ++++++++++ .../codegen/box/binaryOp/overflowInt.kt | 11 +++++++++++ .../codegen/box/binaryOp/overflowLong.kt | 14 ++++++++++++++ .../BlackBoxCodegenTestGenerated.java | 18 +++++++++++++++--- 6 files changed, 55 insertions(+), 9 deletions(-) delete mode 100644 compiler/testData/codegen/box/binaryOp/longOverflow.kt create mode 100644 compiler/testData/codegen/box/binaryOp/overflowChar.kt create mode 100644 compiler/testData/codegen/box/binaryOp/overflowInt.kt create mode 100644 compiler/testData/codegen/box/binaryOp/overflowLong.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt index 8806c6cad2c..8a3a576387e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics import org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType import org.jetbrains.kotlin.codegen.Callable import org.jetbrains.kotlin.codegen.CallableMethod +import org.jetbrains.kotlin.codegen.StackValue import org.jetbrains.org.objectweb.asm.Opcodes.ISHL import org.jetbrains.org.objectweb.asm.Opcodes.ISHR import org.jetbrains.org.objectweb.asm.Opcodes.IUSHR @@ -35,7 +36,10 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() { val paramType = if (shift()) Type.INT_TYPE else operandType return createBinaryIntrinsicCallable(returnType, paramType, operandType) { - v -> v.visitInsn(returnType.getOpcode(opcode)) + v -> + v.visitInsn(returnType.getOpcode(opcode)); + if (operandType != returnType) + StackValue.coerce(operandType, returnType, v) } } } diff --git a/compiler/testData/codegen/box/binaryOp/longOverflow.kt b/compiler/testData/codegen/box/binaryOp/longOverflow.kt deleted file mode 100644 index 9f7a9f6bd4d..00000000000 --- a/compiler/testData/codegen/box/binaryOp/longOverflow.kt +++ /dev/null @@ -1,5 +0,0 @@ -fun box(): String { - val a: Long = 2147483647 + 1 - if (a != -2147483648L) return "fail: in this case we should add to ints and than cast the result to long - overflow expected" - return "OK" -} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/overflowChar.kt b/compiler/testData/codegen/box/binaryOp/overflowChar.kt new file mode 100644 index 00000000000..0f06f4969fd --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/overflowChar.kt @@ -0,0 +1,10 @@ +fun box(): String { + val c1: Char = 0.toChar() + val c2 = c1 - 1 + if (c2 < c1) return "fail: 0.toChar() - 1 should overflow to positive." + + val c3 = c2 + 1 + if (c3 > c2) return "fail: FFFF.toChar() + 1 should overflow to zero." + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/overflowInt.kt b/compiler/testData/codegen/box/binaryOp/overflowInt.kt new file mode 100644 index 00000000000..4d5b899987f --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/overflowInt.kt @@ -0,0 +1,11 @@ +fun box(): String { + val i1: Int = Int.MAX_VALUE + val i2 = i1 + 1 + if (i2 > i1) return "fail: Int.MAX_VALUE + 1 should overflow to negative." + + val i3: Int = Int.MIN_VALUE + val i4 = i3 - 1 + if (i4 < i3) return "fail: Int.MIN_VALUE - 1 should overflow to positive." + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/overflowLong.kt b/compiler/testData/codegen/box/binaryOp/overflowLong.kt new file mode 100644 index 00000000000..28d37ab1c12 --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/overflowLong.kt @@ -0,0 +1,14 @@ +fun box(): String { + val a: Long = 2147483647 + 1 + if (a != -2147483648L) return "fail: in this case we should add to ints and than cast the result to long - overflow expected" + + val l1 = Long.MAX_VALUE + val l2 = l1 + 1 + if (l2 > l1) return "fail: Long.MAX_VALUE + 1 should overflow to negative." + + val l3 = Long.MIN_VALUE + val l4 = l3 - 1 + if (l4 < l3) return "fail: Long.MIN_VALUE - 1 should overflow to positive." + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index 875ede44b80..e3921f3bf3f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -322,9 +322,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("longOverflow.kt") - public void testLongOverflow() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/longOverflow.kt"); + @TestMetadata("overflowChar.kt") + public void testOverflowChar() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/overflowChar.kt"); + doTest(fileName); + } + + @TestMetadata("overflowInt.kt") + public void testOverflowInt() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/overflowInt.kt"); + doTest(fileName); + } + + @TestMetadata("overflowLong.kt") + public void testOverflowLong() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/overflowLong.kt"); doTest(fileName); } } From 31f6405e07e6164c56b9770db88cd9d70f3d403f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 18:11:44 +0200 Subject: [PATCH 247/450] don't use "whatever" as implementation of getFamilyName(), provide correct implementation instead --- .../idea/inspections/UnusedReceiverParameterInspection.kt | 2 +- .../jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt index 3d2231f09a6..69655659bf0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt @@ -99,6 +99,6 @@ public class UnusedReceiverParameterInspection : AbstractKotlinInspection() { declaration.setReceiverTypeReference(null) } - override fun getFamilyName(): String = "whatever" + override fun getFamilyName(): String = getName() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 57a72dd8c97..73670008380 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -110,7 +110,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { return object : LocalQuickFix { override fun getName() = QuickFixBundle.message("safe.delete.text", declaration.getName()) - override fun getFamilyName() = "whatever" + override fun getFamilyName() = "Safe delete" override fun applyFix(project: Project, descriptor: ProblemDescriptor?) { if (!FileModificationService.getInstance().prepareFileForWrite(declaration.getContainingFile())) return From d32ba08cb7456dcd9b5a0323daab6afe23b8ac79 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 21:53:02 +0300 Subject: [PATCH 248/450] KT-8394 ReplaceWith for Delegates.lazy fails outside of stdlib #KT-8394 Fixed --- .../ClassDescriptorWithResolutionScopes.java | 3 - .../impl/MutableClassDescriptor.java | 8 +-- .../kotlin/resolve/DeclarationResolver.kt | 2 +- .../ClassResolutionScopesSupport.kt | 68 ++++++++++++++++++ .../lazy/descriptors/LazyClassDescriptor.java | 71 +++++-------------- .../LazyScriptClassDescriptor.java | 4 +- .../lazy/descriptors/LazyScriptDescriptor.kt | 2 +- .../descriptors/LazyJavaClassDescriptor.kt | 10 +-- .../functions/FunctionClassDescriptor.kt | 2 +- .../kotlin/descriptors/ClassDescriptor.java | 3 + .../impl/AbstractClassDescriptor.java | 11 ++- .../descriptors/impl/ClassDescriptorImpl.java | 10 +-- .../EnumEntrySyntheticClassDescriptor.java | 2 +- .../impl/LazySubstitutingClassDescriptor.java | 10 +++ .../DeserializedClassDescriptor.kt | 2 +- .../textBuilder/missingDependencies.kt | 2 +- .../quickfix/ReplaceWithAnnotationAnalyzer.kt | 11 ++- .../deprecatedMemberInCompiledClass.kt | 7 ++ .../deprecatedMemberInCompiledClass.kt.after | 7 ++ .../quickfix/DeprecatedInCompiledClassTest.kt | 54 ++++++++++++++ 20 files changed, 199 insertions(+), 90 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt create mode 100644 idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt create mode 100644 idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt.after create mode 100644 idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedInCompiledClassTest.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/ClassDescriptorWithResolutionScopes.java b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/ClassDescriptorWithResolutionScopes.java index 07d1e710ccb..b8c9e4d3ec4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/ClassDescriptorWithResolutionScopes.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/ClassDescriptorWithResolutionScopes.java @@ -33,9 +33,6 @@ public interface ClassDescriptorWithResolutionScopes extends ClassDescriptor { @NotNull JetScope getScopeForInitializerResolution(); - @NotNull - JetScope getScopeForMemberLookup(); - @Nullable @Override ClassDescriptorWithResolutionScopes getCompanionObjectDescriptor(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java index 785f195b879..700b51a6a35 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java @@ -51,7 +51,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class // This scope contains type parameters but does not contain inner classes private final WritableScope scopeForSupertypeResolution; private JetScope scopeForInitializers; //contains members + primary constructor value parameters + map for backing fields - private final JetScope scopeForMemberLookup; + private final JetScope unsubstitutedMemberScope; private final JetScope staticScope = new StaticScopeForKotlinClass(this); public MutableClassDescriptor( @@ -70,7 +70,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING; - this.scopeForMemberLookup = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, redeclarationHandler, "MemberLookup", null, this) + this.unsubstitutedMemberScope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, redeclarationHandler, "MemberLookup", null, this) .changeLockLevel(WritableScope.LockLevel.BOTH); this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler, "SupertypeResolution") .changeLockLevel(WritableScope.LockLevel.BOTH); @@ -256,8 +256,8 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class @Override @NotNull - public JetScope getScopeForMemberLookup() { - return scopeForMemberLookup; + public JetScope getUnsubstitutedMemberScope() { + return unsubstitutedMemberScope; } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt index 880909bc1f5..b03e082fb3b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt @@ -61,7 +61,7 @@ public class DeclarationResolver { public fun checkRedeclarations(c: TopDownAnalysisContext) { for (classDescriptor in c.getDeclaredClasses().values()) { val descriptorMap = HashMultimap.create() - for (desc in classDescriptor.getScopeForMemberLookup().getOwnDeclaredDescriptors()) { + for (desc in classDescriptor.getUnsubstitutedMemberScope().getOwnDeclaredDescriptors()) { if (desc is ClassDescriptor || desc is PropertyDescriptor) { descriptorMap.put(desc.getName(), desc) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt new file mode 100644 index 00000000000..6a0ea715837 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.lazy.descriptors + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.resolve.scopes.* +import org.jetbrains.kotlin.storage.StorageManager + +class ClassResolutionScopesSupport( + private val classDescriptor: ClassDescriptor, + storageManager: StorageManager, + private val getOuterScope: () -> JetScope +) { + private val staticScope = StaticScopeForKotlinClass(classDescriptor) + + private val scopeForClassHeaderResolution = storageManager.createLazyValue { computeScopeForClassHeaderResolution() } + private val scopeForMemberDeclarationResolution = storageManager.createLazyValue { computeScopeForMemberDeclarationResolution() } + + fun getStaticScope(): JetScope = staticScope + + fun getScopeForClassHeaderResolution(): JetScope = scopeForClassHeaderResolution() + + fun getScopeForMemberDeclarationResolution(): JetScope = scopeForMemberDeclarationResolution() + + private fun computeScopeForClassHeaderResolution(): JetScope { + val scope = WritableScopeImpl(JetScope.Empty, classDescriptor, RedeclarationHandler.DO_NOTHING, "Scope with type parameters for " + classDescriptor.getName()) + for (typeParameterDescriptor in classDescriptor.getTypeConstructor().getParameters()) { + scope.addClassifierDescriptor(typeParameterDescriptor) + } + scope.changeLockLevel(WritableScope.LockLevel.READING) + + return ChainedScope(classDescriptor, "ScopeForClassHeaderResolution: " + classDescriptor.getName(), scope, getOuterScope()) + } + + private fun computeScopeForMemberDeclarationResolution(): JetScope { + val thisScope = WritableScopeImpl(JetScope.Empty, classDescriptor, RedeclarationHandler.DO_NOTHING, + "Scope with 'this' for " + classDescriptor.getName(), classDescriptor.getThisAsReceiverParameter(), classDescriptor) + thisScope.changeLockLevel(WritableScope.LockLevel.READING) + + return ChainedScope( + classDescriptor, + "ScopeForMemberDeclarationResolution: " + classDescriptor.getName(), + thisScope, + classDescriptor.getUnsubstitutedMemberScope(), + getScopeForClassHeaderResolution(), + getCompanionObjectScope(), + classDescriptor.getStaticScope()) + } + + private fun getCompanionObjectScope(): JetScope { + val companionObjectDescriptor = classDescriptor.getCompanionObjectDescriptor() + return if ((companionObjectDescriptor != null)) CompanionObjectMixinScope(companionObjectDescriptor) else JetScope.Empty + } +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index c6d1f72fd60..7426c82f89a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -87,15 +87,14 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private final MemoizedFunctionToNotNull extraCompanionObjectDescriptors; private final LazyClassMemberScope unsubstitutedMemberScope; - private final JetScope staticScope = new StaticScopeForKotlinClass(this); - private final NotNullLazyValue scopeForClassHeaderResolution; - private final NotNullLazyValue scopeForMemberDeclarationResolution; private final NotNullLazyValue scopeForPropertyInitializerResolution; private final NullableLazyValue forceResolveAllContents; private final boolean isCompanionObject; + private final ClassResolutionScopesSupport resolutionScopesSupport; + public LazyClassDescriptor( @NotNull LazyClassContext c, @NotNull DeclarationDescriptor containingDeclaration, @@ -193,18 +192,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return computeCompanionObjectDescriptor(companionObject); } }); - this.scopeForClassHeaderResolution = storageManager.createLazyValue(new Function0() { - @Override - public JetScope invoke() { - return computeScopeForClassHeaderResolution(); - } - }); - this.scopeForMemberDeclarationResolution = storageManager.createLazyValue(new Function0() { - @Override - public JetScope invoke() { - return computeScopeForMemberDeclarationResolution(); - } - }); this.scopeForPropertyInitializerResolution = storageManager.createLazyValue(new Function0() { @Override public JetScope invoke() { @@ -218,6 +205,13 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return null; } }, null); + + this.resolutionScopesSupport = new ClassResolutionScopesSupport(this, storageManager, new Function0() { + @Override + public JetScope invoke() { + return getOuterScope(); + } + }); } // NOTE: Called from constructor! @@ -231,25 +225,14 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @NotNull @Override - public JetScope getScopeForMemberLookup() { + public JetScope getUnsubstitutedMemberScope() { return unsubstitutedMemberScope; } @Override @NotNull public JetScope getScopeForClassHeaderResolution() { - return scopeForClassHeaderResolution.invoke(); - } - - @NotNull - private JetScope computeScopeForClassHeaderResolution() { - WritableScopeImpl scope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING, "Scope with type parameters for " + getName()); - for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) { - scope.addClassifierDescriptor(typeParameterDescriptor); - } - scope.changeLockLevel(WritableScope.LockLevel.READING); - - return new ChainedScope(this, "ScopeForClassHeaderResolution: " + getName(), scope, getOuterScope()); + return resolutionScopesSupport.getScopeForClassHeaderResolution(); } @NotNull @@ -260,29 +243,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @Override @NotNull public JetScope getScopeForMemberDeclarationResolution() { - return scopeForMemberDeclarationResolution.invoke(); - } - - @NotNull - private JetScope computeScopeForMemberDeclarationResolution() { - WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING, - "Scope with 'this' for " + getName(), this.getThisAsReceiverParameter(), this); - thisScope.changeLockLevel(WritableScope.LockLevel.READING); - - return new ChainedScope( - this, - "ScopeForMemberDeclarationResolution: " + getName(), - thisScope, - getScopeForMemberLookup(), - getScopeForClassHeaderResolution(), - getCompanionObjectScope(), - getStaticScope() - ); - } - - private JetScope getCompanionObjectScope() { - ClassDescriptor companionObjectDescriptor = getCompanionObjectDescriptor(); - return (companionObjectDescriptor != null) ? new CompanionObjectMixinScope(companionObjectDescriptor) : JetScope.Empty.INSTANCE$; + return resolutionScopesSupport.getScopeForMemberDeclarationResolution(); } @Override @@ -331,7 +292,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @NotNull @Override public JetScope getStaticScope() { - return staticScope; + return resolutionScopesSupport.getStaticScope(); } @NotNull @@ -388,7 +349,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes } Name name = ((JetClassOrObjectInfo) companionObjectInfo).getName(); assert name != null; - getScopeForMemberLookup().getClassifier(name); + getUnsubstitutedMemberScope().getClassifier(name); ClassDescriptor companionObjectDescriptor = c.getTrace().get(BindingContext.CLASS, companionObject); if (companionObjectDescriptor instanceof LazyClassDescriptor) { assert DescriptorUtils.isCompanionObject(companionObjectDescriptor) : "Not a companion object: " + companionObjectDescriptor; @@ -481,7 +442,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes ForceResolveUtil.forceResolveAllContents(getConstructors()); ForceResolveUtil.forceResolveAllContents(getDescriptorsForExtraCompanionObjects()); - ForceResolveUtil.forceResolveAllContents(getScopeForMemberLookup()); + ForceResolveUtil.forceResolveAllContents(getUnsubstitutedMemberScope()); ForceResolveUtil.forceResolveAllContents(getTypeConstructor()); } @@ -503,7 +464,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes getOriginal(); getScopeForClassHeaderResolution(); getScopeForMemberDeclarationResolution(); - getScopeForMemberLookup().getAllDescriptors(); + getUnsubstitutedMemberScope().getAllDescriptors(); getScopeForInitializerResolution(); getUnsubstitutedInnerClassesScope(); getTypeConstructor().getSupertypes(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassDescriptor.java index 1a81b679724..996e919fd50 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptClassDescriptor.java @@ -54,8 +54,8 @@ public class LazyScriptClassDescriptor extends LazyClassDescriptor { @NotNull @Override - public LazyScriptClassMemberScope getScopeForMemberLookup() { - return (LazyScriptClassMemberScope) super.getScopeForMemberLookup(); + public LazyScriptClassMemberScope getUnsubstitutedMemberScope() { + return (LazyScriptClassMemberScope) super.getUnsubstitutedMemberScope(); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt index 75693de7bc1..fb05f3d224f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyScriptDescriptor.kt @@ -65,7 +65,7 @@ public class LazyScriptDescriptor( override fun getClassDescriptor() = resolveSession.getClassDescriptorForScript(jetScript) as LazyScriptClassDescriptor - override fun getScriptResultProperty(): PropertyDescriptor = getClassDescriptor().getScopeForMemberLookup().getScriptResultProperty() + override fun getScriptResultProperty(): PropertyDescriptor = getClassDescriptor().getUnsubstitutedMemberScope().getScriptResultProperty() private val scriptCodeDescriptor = resolveSession.getStorageManager().createLazyValue { val result = ScriptCodeDescriptor(this) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index b80311bb371..8dab34fbd9c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -77,10 +77,10 @@ class LazyJavaClassDescriptor( private val typeConstructor = c.storageManager.createLazyValue { LazyJavaClassTypeConstructor() } override fun getTypeConstructor(): TypeConstructor = typeConstructor() - private val scopeForMemberLookup = LazyJavaClassMemberScope(c, this, jClass) - override fun getScopeForMemberLookup() = scopeForMemberLookup + private val unsubstitutedMemberScope = LazyJavaClassMemberScope(c, this, jClass) + override fun getUnsubstitutedMemberScope() = unsubstitutedMemberScope - private val innerClassesScope = InnerClassesScopeWrapper(getScopeForMemberLookup()) + private val innerClassesScope = InnerClassesScopeWrapper(getUnsubstitutedMemberScope()) override fun getUnsubstitutedInnerClassesScope(): JetScope = innerClassesScope private val staticScope = LazyJavaStaticClassScope(c, jClass, this) @@ -90,14 +90,14 @@ class LazyJavaClassDescriptor( override fun getCompanionObjectDescriptor(): ClassDescriptor? = null - override fun getConstructors() = scopeForMemberLookup.constructors() + override fun getConstructors() = unsubstitutedMemberScope.constructors() private val annotations = c.storageManager.createLazyValue { c.resolveAnnotations(jClass) } override fun getAnnotations() = annotations() private val functionTypeForSamInterface = c.storageManager.createNullableLazyValue { c.samConversionResolver.resolveFunctionTypeIfSamInterface(this) { method -> - scopeForMemberLookup.resolveMethodToFunctionDescriptor(method, false) + unsubstitutedMemberScope.resolveMethodToFunctionDescriptor(method, false) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 9ca51bc7e48..5b013d923de 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -71,7 +71,7 @@ public class FunctionClassDescriptor( override fun getTypeConstructor(): TypeConstructor = typeConstructor - override fun getScopeForMemberLookup() = memberScope + override fun getUnsubstitutedMemberScope() = memberScope override fun getCompanionObjectDescriptor() = null override fun getConstructors() = emptyList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java index 8a5b89a5d8a..7d5c79af2c8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java @@ -31,6 +31,9 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor, @NotNull JetScope getMemberScope(@NotNull List typeArguments); + @NotNull + JetScope getUnsubstitutedMemberScope(); + @NotNull JetScope getUnsubstitutedInnerClassesScope(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java index 21c4b60d743..5ed6bfc0e36 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractClassDescriptor.java @@ -41,13 +41,13 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { this.defaultType = storageManager.createLazyValue(new Function0() { @Override public JetType invoke() { - return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getScopeForMemberLookup()); + return TypeUtils.makeUnsubstitutedType(AbstractClassDescriptor.this, getUnsubstitutedMemberScope()); } }); this.unsubstitutedInnerClassesScope = storageManager.createLazyValue(new Function0() { @Override public JetScope invoke() { - return new InnerClassesScopeWrapper(getScopeForMemberLookup()); + return new InnerClassesScopeWrapper(getUnsubstitutedMemberScope()); } }); this.thisAsReceiverParameter = storageManager.createLazyValue(new Function0() { @@ -70,9 +70,6 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { return this; } - @NotNull - protected abstract JetScope getScopeForMemberLookup(); - @NotNull @Override public JetScope getUnsubstitutedInnerClassesScope() { @@ -91,13 +88,13 @@ public abstract class AbstractClassDescriptor implements ClassDescriptor { assert typeArguments.size() == getTypeConstructor().getParameters().size() : "Illegal number of type arguments: expected " + getTypeConstructor().getParameters().size() + " but was " + typeArguments.size() + " for " + getTypeConstructor() + " " + getTypeConstructor().getParameters(); - if (typeArguments.isEmpty()) return getScopeForMemberLookup(); + if (typeArguments.isEmpty()) return getUnsubstitutedMemberScope(); List typeParameters = getTypeConstructor().getParameters(); Map substitutionContext = TypeSubstitutor.buildSubstitutionContext(typeParameters, typeArguments); TypeSubstitutor substitutor = TypeSubstitutor.create(substitutionContext); - return new SubstitutingScope(getScopeForMemberLookup(), substitutor); + return new SubstitutingScope(getUnsubstitutedMemberScope(), substitutor); } @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java index 430f05928eb..f67ab43650a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java @@ -37,7 +37,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { private final TypeConstructor typeConstructor; private final JetScope staticScope = new StaticScopeForKotlinClass(this); - private JetScope scopeForMemberLookup; + private JetScope unsubstitutedMemberScope; private Set constructors; private ConstructorDescriptor primaryConstructor; @@ -56,11 +56,11 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { } public final void initialize( - @NotNull JetScope scopeForMemberLookup, + @NotNull JetScope unsubstitutedMemberScope, @NotNull Set constructors, @Nullable ConstructorDescriptor primaryConstructor ) { - this.scopeForMemberLookup = scopeForMemberLookup; + this.unsubstitutedMemberScope = unsubstitutedMemberScope; this.constructors = constructors; this.primaryConstructor = primaryConstructor; } @@ -89,8 +89,8 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { @NotNull @Override - protected JetScope getScopeForMemberLookup() { - return scopeForMemberLookup; + public JetScope getUnsubstitutedMemberScope() { + return unsubstitutedMemberScope; } @NotNull diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index d8090db79f1..7fe50931fc8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -91,7 +91,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull @Override - protected JetScope getScopeForMemberLookup() { + public JetScope getUnsubstitutedMemberScope() { return scope; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index 224498d01e7..6783de5f75e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -97,6 +97,16 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { return new SubstitutingScope(memberScope, getSubstitutor()); } + @NotNull + @Override + public JetScope getUnsubstitutedMemberScope() { + JetScope memberScope = original.getUnsubstitutedMemberScope(); + if (originalSubstitutor.isEmpty()) { + return memberScope; + } + return new SubstitutingScope(memberScope, getSubstitutor()); + } + @NotNull @Override public JetScope getStaticScope() { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index f9bb831697b..bbbf6233675 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -91,7 +91,7 @@ public class DeserializedClassDescriptor( override fun getAnnotations() = annotations - override fun getScopeForMemberLookup() = memberScope + override fun getUnsubstitutedMemberScope() = memberScope override fun getStaticScope() = staticScope diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt index cef52d9312f..dbfd26ea74f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/missingDependencies.kt @@ -77,7 +77,7 @@ private class MissingDependencyErrorClassDescriptor( override fun substitute(substitutor: TypeSubstitutor) = this - override fun getScopeForMemberLookup() = scope + override fun getUnsubstitutedMemberScope() = scope override fun getMemberScope(typeArguments: List) = scope } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt index 9b3abd6a43b..33eeed65747 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ReplaceWithAnnotationAnalyzer.kt @@ -42,11 +42,11 @@ import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.descriptorUtil.module +import org.jetbrains.kotlin.resolve.lazy.descriptors.ClassResolutionScopesSupport import org.jetbrains.kotlin.resolve.scopes.* import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver -import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.storage.LockBasedStorageManager import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import java.util.ArrayList import java.util.LinkedHashSet @@ -172,13 +172,18 @@ object ReplaceWithAnnotationAnalyzer { is ClassDescriptorWithResolutionScopes -> descriptor.getScopeForMemberDeclarationResolution() + is ClassDescriptor -> { + val outerScope = getResolutionScope(descriptor.getContainingDeclaration()) + ClassResolutionScopesSupport(descriptor, LockBasedStorageManager.NO_LOCKS, { outerScope }).getScopeForMemberDeclarationResolution() + } + is FunctionDescriptor -> FunctionDescriptorUtil.getFunctionInnerScope(getResolutionScope(descriptor.getContainingDeclaration()), descriptor, RedeclarationHandler.DO_NOTHING) is PropertyDescriptor -> JetScopeUtils.getPropertyDeclarationInnerScope(descriptor, - getResolutionScope(descriptor.getContainingDeclaration()!!), + getResolutionScope(descriptor.getContainingDeclaration()), RedeclarationHandler.DO_NOTHING) is LocalVariableDescriptor -> { val declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor) as JetDeclaration diff --git a/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt b/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt new file mode 100644 index 00000000000..110af59ade9 --- /dev/null +++ b/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt @@ -0,0 +1,7 @@ +// "Replace with 'matches(input)'" "true" + +import kotlin.text.Regex + +fun foo(regex: Regex) { + regex.hasMatch("") +} \ No newline at end of file diff --git a/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt.after b/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt.after new file mode 100644 index 00000000000..14508d63305 --- /dev/null +++ b/idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt.after @@ -0,0 +1,7 @@ +// "Replace with 'matches(input)'" "true" + +import kotlin.text.Regex + +fun foo(regex: Regex) { + regex.matches("") +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedInCompiledClassTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedInCompiledClassTest.kt new file mode 100644 index 00000000000..d6272ee856f --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/DeprecatedInCompiledClassTest.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.quickfix; + +import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.TestDataPath +import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor +import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.idea.util.application.runWriteAction +import org.jetbrains.kotlin.psi.JetSimpleNameExpression +import org.jetbrains.kotlin.psi.psiUtil.parents +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners +import org.jetbrains.kotlin.test.JetTestUtils +import org.jetbrains.kotlin.test.TestMetadata +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance +import org.junit.runner.RunWith + +TestMetadata("idea/testData/quickfix.special") +TestDataPath("\$PROJECT_ROOT") +RunWith(JUnit3RunnerWithInners::class) +public class QuickFixSpecialTest : JetLightCodeInsightFixtureTestCase() { + override fun getTestDataPath() = JetTestUtils.getHomeDirectory() + override fun getProjectDescriptor() = JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE + + TestMetadata("deprecatedMemberInCompiledClass.kt") + public fun testDeprecatedMemberInCompiledClass() { + val testPath = JetTestUtils.navigationMetadata("idea/testData/quickfix.special/deprecatedMemberInCompiledClass.kt") + myFixture.configureByFile(testPath) + + val offset = getEditor().getCaretModel().getOffset() + val element = getFile().findElementAt(offset) + val nameExpression = element!!.parents.firstIsInstance() + getProject().executeWriteCommand("") { + DeprecatedSymbolUsageFix(nameExpression, ReplaceWith("matches(input)")).invoke(getProject(), getEditor(), getFile()) + } + + myFixture.checkResultByFile("$testPath.after") + } +} From b162a65e855a13df8668cea3ad58eca06b56dbfe Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 13 Jul 2015 20:36:24 +0300 Subject: [PATCH 249/450] Changed the way the constraints are written in tests SUBTYPE T Int -> T <: Int --- .../checkStatus/conflictingConstraints.bounds | 4 +- .../conflictingConstraints.constraints | 4 +- .../checkStatus/successful.bounds | 4 +- .../checkStatus/successful.constraints | 4 +- .../typeConstructorMismatch.bounds | 2 +- .../typeConstructorMismatch.constraints | 2 +- .../checkStatus/unknownParameters.bounds | 2 +- .../checkStatus/unknownParameters.constraints | 2 +- .../checkStatus/violatedUpperBound.bounds | 21 ----- .../violatedUpperBound.constraints | 4 - .../computeValues/contradiction.bounds | 4 +- .../computeValues/contradiction.constraints | 4 +- .../computeValues/subTypeOfUpperBounds.bounds | 4 +- .../subTypeOfUpperBounds.constraints | 4 +- .../superTypeOfLowerBounds1.bounds | 4 +- .../superTypeOfLowerBounds1.constraints | 4 +- .../superTypeOfLowerBounds2.bounds | 6 +- .../superTypeOfLowerBounds2.constraints | 6 +- .../{declarations => }/declarations.kt | 0 .../integerValueTypes/byteOverflow.bounds | 4 +- .../byteOverflow.constraints | 4 +- .../integerValueTypes/defaultLong.bounds | 4 +- .../integerValueTypes/defaultLong.constraints | 4 +- .../integerValueTypes/numberAndAny.bounds | 4 +- .../numberAndAny.constraints | 4 +- .../integerValueTypes/numberAndString.bounds | 4 +- .../numberAndString.constraints | 4 +- .../integerValueTypes/severalNumbers.bounds | 4 +- .../severalNumbers.constraints | 4 +- .../integerValueTypes/simpleByte.bounds | 4 +- .../integerValueTypes/simpleByte.constraints | 4 +- .../integerValueTypes/simpleInt.bounds | 2 +- .../integerValueTypes/simpleInt.constraints | 2 +- .../integerValueTypes/simpleShort.bounds | 4 +- .../integerValueTypes/simpleShort.constraints | 4 +- .../direct/contravariant/varEqDepEq.bounds | 4 +- .../contravariant/varEqDepEq.constraints | 4 +- .../direct/contravariant/varEqDepSub.bounds | 4 +- .../contravariant/varEqDepSub.constraints | 4 +- .../direct/contravariant/varEqDepSuper.bounds | 4 +- .../contravariant/varEqDepSuper.constraints | 4 +- .../direct/contravariant/varSubDepEq.bounds | 4 +- .../contravariant/varSubDepEq.constraints | 4 +- .../direct/contravariant/varSubDepSub.bounds | 4 +- .../contravariant/varSubDepSub.constraints | 4 +- .../contravariant/varSubDepSuper.bounds | 4 +- .../contravariant/varSubDepSuper.constraints | 4 +- .../direct/contravariant/varSuperDepEq.bounds | 4 +- .../contravariant/varSuperDepEq.constraints | 4 +- .../contravariant/varSuperDepSub.bounds | 4 +- .../contravariant/varSuperDepSub.constraints | 4 +- .../contravariant/varSuperDepSuper.bounds | 4 +- .../varSuperDepSuper.constraints | 4 +- .../direct/covariant/varEqDepEq.bounds | 4 +- .../direct/covariant/varEqDepEq.constraints | 4 +- .../direct/covariant/varEqDepSub.bounds | 4 +- .../direct/covariant/varEqDepSub.constraints | 4 +- .../direct/covariant/varEqDepSuper.bounds | 4 +- .../covariant/varEqDepSuper.constraints | 4 +- .../direct/covariant/varSubDepEq.bounds | 4 +- .../direct/covariant/varSubDepEq.constraints | 4 +- .../direct/covariant/varSubDepSub.bounds | 4 +- .../direct/covariant/varSubDepSub.constraints | 4 +- .../direct/covariant/varSubDepSuper.bounds | 4 +- .../covariant/varSubDepSuper.constraints | 4 +- .../direct/covariant/varSuperDepEq.bounds | 4 +- .../covariant/varSuperDepEq.constraints | 4 +- .../direct/covariant/varSuperDepSub.bounds | 4 +- .../covariant/varSuperDepSub.constraints | 4 +- .../direct/covariant/varSuperDepSuper.bounds | 4 +- .../covariant/varSuperDepSuper.constraints | 4 +- .../direct/invariant/varEqDepEq.bounds | 4 +- .../direct/invariant/varEqDepEq.constraints | 4 +- .../direct/invariant/varEqDepSub.bounds | 4 +- .../direct/invariant/varEqDepSub.constraints | 4 +- .../direct/invariant/varEqDepSuper.bounds | 4 +- .../invariant/varEqDepSuper.constraints | 4 +- .../direct/invariant/varSubDepEq.bounds | 4 +- .../direct/invariant/varSubDepEq.constraints | 4 +- .../direct/invariant/varSubDepSub.bounds | 4 +- .../direct/invariant/varSubDepSub.constraints | 4 +- .../direct/invariant/varSubDepSuper.bounds | 4 +- .../invariant/varSubDepSuper.constraints | 4 +- .../direct/invariant/varSuperDepEq.bounds | 4 +- .../invariant/varSuperDepEq.constraints | 4 +- .../direct/invariant/varSuperDepSub.bounds | 4 +- .../invariant/varSuperDepSub.constraints | 4 +- .../direct/invariant/varSuperDepSuper.bounds | 4 +- .../invariant/varSuperDepSuper.constraints | 4 +- .../interdependency/interdependency1.bounds | 6 +- .../interdependency1.constraints | 6 +- .../interdependency/interdependency2.bounds | 6 +- .../interdependency2.constraints | 6 +- .../interdependency/interdependency3.bounds | 6 +- .../interdependency3.constraints | 6 +- .../nullable/contravariant/varEqDepEq.bounds | 4 +- .../contravariant/varEqDepEq.constraints | 4 +- .../nullable/contravariant/varEqDepSub.bounds | 4 +- .../contravariant/varEqDepSub.constraints | 4 +- .../contravariant/varEqDepSuper.bounds | 4 +- .../contravariant/varEqDepSuper.constraints | 4 +- .../nullable/contravariant/varSubDepEq.bounds | 4 +- .../contravariant/varSubDepEq.constraints | 4 +- .../contravariant/varSubDepSub.bounds | 4 +- .../contravariant/varSubDepSub.constraints | 4 +- .../contravariant/varSubDepSuper.bounds | 4 +- .../contravariant/varSubDepSuper.constraints | 4 +- .../contravariant/varSuperDepEq.bounds | 4 +- .../contravariant/varSuperDepEq.constraints | 4 +- .../contravariant/varSuperDepSub.bounds | 4 +- .../contravariant/varSuperDepSub.constraints | 4 +- .../contravariant/varSuperDepSuper.bounds | 4 +- .../varSuperDepSuper.constraints | 4 +- .../nullable/covariant/varEqDepEq.bounds | 4 +- .../nullable/covariant/varEqDepEq.constraints | 4 +- .../nullable/covariant/varEqDepSub.bounds | 4 +- .../covariant/varEqDepSub.constraints | 4 +- .../nullable/covariant/varEqDepSuper.bounds | 4 +- .../covariant/varEqDepSuper.constraints | 4 +- .../nullable/covariant/varSubDepEq.bounds | 4 +- .../covariant/varSubDepEq.constraints | 4 +- .../nullable/covariant/varSubDepSub.bounds | 4 +- .../covariant/varSubDepSub.constraints | 4 +- .../nullable/covariant/varSubDepSuper.bounds | 4 +- .../covariant/varSubDepSuper.constraints | 4 +- .../nullable/covariant/varSuperDepEq.bounds | 4 +- .../covariant/varSuperDepEq.constraints | 4 +- .../nullable/covariant/varSuperDepSub.bounds | 4 +- .../covariant/varSuperDepSub.constraints | 4 +- .../covariant/varSuperDepSuper.bounds | 4 +- .../covariant/varSuperDepSuper.constraints | 4 +- .../nullable/invariant/varEqDepEq.bounds | 4 +- .../nullable/invariant/varEqDepEq.constraints | 4 +- .../nullable/invariant/varEqDepSub.bounds | 4 +- .../invariant/varEqDepSub.constraints | 4 +- .../nullable/invariant/varEqDepSuper.bounds | 4 +- .../invariant/varEqDepSuper.constraints | 4 +- .../nullable/invariant/varSubDepEq.bounds | 4 +- .../invariant/varSubDepEq.constraints | 4 +- .../nullable/invariant/varSubDepSub.bounds | 4 +- .../invariant/varSubDepSub.constraints | 4 +- .../nullable/invariant/varSubDepSuper.bounds | 4 +- .../invariant/varSubDepSuper.constraints | 4 +- .../nullable/invariant/varSuperDepEq.bounds | 4 +- .../invariant/varSuperDepEq.constraints | 4 +- .../nullable/invariant/varSuperDepSub.bounds | 4 +- .../invariant/varSuperDepSub.constraints | 4 +- .../invariant/varSuperDepSuper.bounds | 4 +- .../invariant/varSuperDepSuper.constraints | 4 +- .../other/constraintForNullables.bounds | 4 +- .../other/constraintForNullables.constraints | 4 +- .../other/nestedConsumer.bounds | 4 +- .../other/nestedConsumer.constraints | 4 +- .../other/nestedConsumer1.bounds | 4 +- .../other/nestedConsumer1.constraints | 4 +- .../other/nestedInvConsumer.bounds | 4 +- .../other/nestedInvConsumer.constraints | 4 +- .../other/nestedInvProducer.bounds | 4 +- .../other/nestedInvProducer.constraints | 4 +- .../other/nestedProducer.bounds | 4 +- .../other/nestedProducer.constraints | 4 +- .../other/nestedProducerAndConsumer.bounds | 4 +- .../nestedProducerAndConsumer.constraints | 4 +- .../other/severalOccurrences.bounds | 4 +- .../other/severalOccurrences.constraints | 4 +- .../severalVariables/other/simpleFun.bounds | 10 +-- .../other/simpleFun.constraints | 6 +- .../other/simpleThreeVars.bounds | 6 +- .../other/simpleThreeVars.constraints | 6 +- .../simpleThreeVarsNoIncorporation.bounds | 6 +- ...simpleThreeVarsNoIncorporation.constraints | 6 +- ...simpleThreeVarsNoIncorporationFixed.bounds | 6 +- ...eThreeVarsNoIncorporationFixed.constraints | 6 +- .../recursive/implicitlyRecursive.bounds | 6 +- .../recursive/implicitlyRecursive.constraints | 6 +- .../recursive/mutuallyRecursive.bounds | 4 +- .../recursive/mutuallyRecursive.constraints | 4 +- .../recursive/simpleRecursive.bounds | 4 +- .../recursive/simpleRecursive.constraints | 4 +- .../reversed/contravariant/varEqDepEq.bounds | 4 +- .../contravariant/varEqDepEq.constraints | 4 +- .../reversed/contravariant/varEqDepSub.bounds | 4 +- .../contravariant/varEqDepSub.constraints | 4 +- .../contravariant/varEqDepSuper.bounds | 4 +- .../contravariant/varEqDepSuper.constraints | 4 +- .../reversed/contravariant/varSubDepEq.bounds | 4 +- .../contravariant/varSubDepEq.constraints | 4 +- .../contravariant/varSubDepSub.bounds | 4 +- .../contravariant/varSubDepSub.constraints | 4 +- .../contravariant/varSubDepSuper.bounds | 4 +- .../contravariant/varSubDepSuper.constraints | 4 +- .../contravariant/varSuperDepEq.bounds | 4 +- .../contravariant/varSuperDepEq.constraints | 4 +- .../contravariant/varSuperDepSub.bounds | 4 +- .../contravariant/varSuperDepSub.constraints | 4 +- .../contravariant/varSuperDepSuper.bounds | 4 +- .../varSuperDepSuper.constraints | 4 +- .../reversed/covariant/varEqDepEq.bounds | 4 +- .../reversed/covariant/varEqDepEq.constraints | 4 +- .../reversed/covariant/varEqDepSub.bounds | 4 +- .../covariant/varEqDepSub.constraints | 4 +- .../reversed/covariant/varEqDepSuper.bounds | 4 +- .../covariant/varEqDepSuper.constraints | 4 +- .../reversed/covariant/varSubDepEq.bounds | 4 +- .../covariant/varSubDepEq.constraints | 4 +- .../reversed/covariant/varSubDepSub.bounds | 4 +- .../covariant/varSubDepSub.constraints | 4 +- .../reversed/covariant/varSubDepSuper.bounds | 4 +- .../covariant/varSubDepSuper.constraints | 4 +- .../reversed/covariant/varSuperDepEq.bounds | 4 +- .../covariant/varSuperDepEq.constraints | 4 +- .../reversed/covariant/varSuperDepSub.bounds | 4 +- .../covariant/varSuperDepSub.constraints | 4 +- .../covariant/varSuperDepSuper.bounds | 4 +- .../covariant/varSuperDepSuper.constraints | 4 +- .../reversed/invariant/varEqDepEq.bounds | 4 +- .../reversed/invariant/varEqDepEq.constraints | 4 +- .../reversed/invariant/varEqDepSub.bounds | 4 +- .../invariant/varEqDepSub.constraints | 4 +- .../reversed/invariant/varEqDepSuper.bounds | 4 +- .../invariant/varEqDepSuper.constraints | 4 +- .../reversed/invariant/varSubDepEq.bounds | 4 +- .../invariant/varSubDepEq.constraints | 4 +- .../reversed/invariant/varSubDepSub.bounds | 4 +- .../invariant/varSubDepSub.constraints | 4 +- .../reversed/invariant/varSubDepSuper.bounds | 4 +- .../invariant/varSubDepSuper.constraints | 4 +- .../reversed/invariant/varSuperDepEq.bounds | 4 +- .../invariant/varSuperDepEq.constraints | 4 +- .../reversed/invariant/varSuperDepSub.bounds | 4 +- .../invariant/varSuperDepSub.constraints | 4 +- .../invariant/varSuperDepSuper.bounds | 4 +- .../invariant/varSuperDepSuper.constraints | 4 +- .../severalVariables/simpleDependency.bounds | 2 +- .../simpleDependency.constraints | 2 +- .../severalVariables/simpleEquality.bounds | 4 +- .../simpleEquality.constraints | 4 +- .../severalVariables/simpleEquality1.bounds | 4 +- .../simpleEquality1.constraints | 4 +- .../simpleReversedDependency.bounds | 4 +- .../simpleReversedDependency.constraints | 4 +- .../severalVariables/simpleSubtype.bounds | 4 +- .../simpleSubtype.constraints | 4 +- .../severalVariables/simpleSubtype1.bounds | 4 +- .../simpleSubtype1.constraints | 4 +- .../constraintSystem/variance/consumer.bounds | 2 +- .../variance/consumer.constraints | 2 +- .../variance/invariant.bounds | 2 +- .../variance/invariant.constraints | 2 +- .../constraintSystem/variance/producer.bounds | 2 +- .../variance/producer.constraints | 2 +- .../AbstractConstraintSystemTest.kt | 78 +++++++++---------- .../ConstraintSystemTestData.kt | 2 +- .../ConstraintSystemTestGenerated.java | 6 -- 254 files changed, 541 insertions(+), 574 deletions(-) delete mode 100644 compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds delete mode 100644 compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints rename compiler/testData/constraintSystem/{declarations => }/declarations.kt (100%) diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds index 3c867761ed0..c94c7bdeead 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUBTYPE T Int -SUPERTYPE T String +T <: Int +T >: String type parameter bounds: T <: Int, >: String diff --git a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints index a5ac8d81123..73b1e047485 100644 --- a/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints +++ b/compiler/testData/constraintSystem/checkStatus/conflictingConstraints.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUBTYPE T Int -SUPERTYPE T String \ No newline at end of file +T <: Int +T >: String diff --git a/compiler/testData/constraintSystem/checkStatus/successful.bounds b/compiler/testData/constraintSystem/checkStatus/successful.bounds index 43ac39868b2..c1078ef1761 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.bounds +++ b/compiler/testData/constraintSystem/checkStatus/successful.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUBTYPE T Int -SUPERTYPE T Int +T <: Int +T >: Int type parameter bounds: T <: Int, >: Int diff --git a/compiler/testData/constraintSystem/checkStatus/successful.constraints b/compiler/testData/constraintSystem/checkStatus/successful.constraints index c1b1b12a5fd..a6d9b0b7d12 100644 --- a/compiler/testData/constraintSystem/checkStatus/successful.constraints +++ b/compiler/testData/constraintSystem/checkStatus/successful.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUBTYPE T Int -SUPERTYPE T Int \ No newline at end of file +T <: Int +T >: Int diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds index c009c45087d..99a37d6f2a9 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUBTYPE List Int +List <: Int type parameter bounds: T diff --git a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints index 2e3b5a78d74..eedca733b0e 100644 --- a/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints +++ b/compiler/testData/constraintSystem/checkStatus/typeConstructorMismatch.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUBTYPE List Int \ No newline at end of file +List <: Int diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds index c0af2c301bb..db3ee6b0013 100644 --- a/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUBTYPE Any Any +Any <: Any type parameter bounds: T diff --git a/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints b/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints index 9e0d87313e9..01d5712133b 100644 --- a/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints +++ b/compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUBTYPE Any Any \ No newline at end of file +Any <: Any diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds deleted file mode 100644 index 1d6590c012d..00000000000 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.bounds +++ /dev/null @@ -1,21 +0,0 @@ -VARIABLES T - -SUBTYPE T Int -SUBTYPE T String weak - -type parameter bounds: -T <: Int, <: String - -status: --hasCannotCaptureTypesError: false --hasConflictingConstraints: true --hasContradiction: true --hasErrorInConstrainingTypes: false --hasParameterConstraintError: false --hasTypeInferenceIncorporationError: false --hasUnknownParameters: false --hasViolatedUpperBound: true --isSuccessful: false - -result: -T=??? diff --git a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints b/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints deleted file mode 100644 index ef8b411f40e..00000000000 --- a/compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints +++ /dev/null @@ -1,4 +0,0 @@ -VARIABLES T - -SUBTYPE T Int -SUBTYPE T String weak \ No newline at end of file diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.bounds b/compiler/testData/constraintSystem/computeValues/contradiction.bounds index 24bbf15b783..bc12fb789f0 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.bounds +++ b/compiler/testData/constraintSystem/computeValues/contradiction.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUBTYPE T B -SUPERTYPE T A +T <: B +T >: A type parameter bounds: T <: B, >: A diff --git a/compiler/testData/constraintSystem/computeValues/contradiction.constraints b/compiler/testData/constraintSystem/computeValues/contradiction.constraints index c90fa4b41d5..86de4a85dd0 100644 --- a/compiler/testData/constraintSystem/computeValues/contradiction.constraints +++ b/compiler/testData/constraintSystem/computeValues/contradiction.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUBTYPE T B -SUPERTYPE T A \ No newline at end of file +T <: B +T >: A diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds index 377928d944f..a3bfb8d58b0 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUBTYPE T A -SUBTYPE T B +T <: A +T <: B type parameter bounds: T <: A, <: B diff --git a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints index c7c0b551365..9cd0d24fe2c 100644 --- a/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints +++ b/compiler/testData/constraintSystem/computeValues/subTypeOfUpperBounds.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUBTYPE T A -SUBTYPE T B \ No newline at end of file +T <: A +T <: B diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds index b2ef6ae5068..b4285612fe6 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUBTYPE T A -SUPERTYPE T C +T <: A +T >: C type parameter bounds: T <: A, >: C diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints index 7a4c1d73476..40d55d2f8c8 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds1.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUBTYPE T A -SUPERTYPE T C \ No newline at end of file +T <: A +T >: C diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds index d6b88ca835c..478086db7c2 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.bounds @@ -1,8 +1,8 @@ VARIABLES T -SUBTYPE T A -SUPERTYPE T B -SUPERTYPE T C +T <: A +T >: B +T >: C type parameter bounds: T <: A, >: B, >: C diff --git a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints index fc1003c2de3..e1fed467904 100644 --- a/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints +++ b/compiler/testData/constraintSystem/computeValues/superTypeOfLowerBounds2.constraints @@ -1,5 +1,5 @@ VARIABLES T -SUBTYPE T A -SUPERTYPE T B -SUPERTYPE T C \ No newline at end of file +T <: A +T >: B +T >: C diff --git a/compiler/testData/constraintSystem/declarations/declarations.kt b/compiler/testData/constraintSystem/declarations.kt similarity index 100% rename from compiler/testData/constraintSystem/declarations/declarations.kt rename to compiler/testData/constraintSystem/declarations.kt diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds index 29d70c2e4d0..cf0ce4a09e2 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1000) -SUBTYPE T Byte +T >: IntegerValueType(1000) +T <: Byte type parameter bounds: T >: IntegerValueType(1000), <: Byte diff --git a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints index 008d49843d5..0473f499c94 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/byteOverflow.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1000) -SUBTYPE T Byte \ No newline at end of file +T >: IntegerValueType(1000) +T <: Byte diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds index b8a0f48d824..74f5472c15c 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T IntegerValueType(10000000000) +T >: IntegerValueType(1) +T >: IntegerValueType(10000000000) type parameter bounds: T >: IntegerValueType(1), >: IntegerValueType(10000000000) diff --git a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints index 2ba8bedaa26..6270d70a68a 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/defaultLong.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T IntegerValueType(10000000000) \ No newline at end of file +T >: IntegerValueType(1) +T >: IntegerValueType(10000000000) diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds index e2184e2315e..7c413e2e518 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Any +T >: IntegerValueType(1) +T <: Any type parameter bounds: T >: IntegerValueType(1), <: Any diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints index 89f32451478..da000c8feb0 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndAny.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Any \ No newline at end of file +T >: IntegerValueType(1) +T <: Any diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds index aed516efeff..2bbaa4171d7 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T String +T >: IntegerValueType(1) +T >: String type parameter bounds: T >: IntegerValueType(1), >: String diff --git a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints index 300daefcb17..9f91f37e011 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/numberAndString.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T String \ No newline at end of file +T >: IntegerValueType(1) +T >: String diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds index 187b41062f0..c9a92d60e95 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T IntegerValueType(1000) +T >: IntegerValueType(1) +T >: IntegerValueType(1000) type parameter bounds: T >: IntegerValueType(1), >: IntegerValueType(1000) diff --git a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints index 0e58b001f34..bafce1a8007 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/severalNumbers.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUPERTYPE T IntegerValueType(1000) \ No newline at end of file +T >: IntegerValueType(1) +T >: IntegerValueType(1000) diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds index a4fae5c8324..e6dd0530abd 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Byte +T >: IntegerValueType(1) +T <: Byte type parameter bounds: T >: IntegerValueType(1), <: Byte diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints index a8cb3c80fe3..9da0fc9e2c2 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleByte.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Byte \ No newline at end of file +T >: IntegerValueType(1) +T <: Byte diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds index 7cde4a14c94..e5bfdb6bba6 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) +T >: IntegerValueType(1) type parameter bounds: T >: IntegerValueType(1) diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints index 2a2545431db..aa8f78b19f4 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleInt.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) \ No newline at end of file +T >: IntegerValueType(1) diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds index b1d6044ccdc..83c7f50083d 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.bounds @@ -1,7 +1,7 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Short +T >: IntegerValueType(1) +T <: Short type parameter bounds: T >: IntegerValueType(1), <: Short diff --git a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints index 2de8feeb212..a3ba83baf5d 100644 --- a/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints +++ b/compiler/testData/constraintSystem/integerValueTypes/simpleShort.constraints @@ -1,4 +1,4 @@ VARIABLES T -SUPERTYPE T IntegerValueType(1) -SUBTYPE T Short \ No newline at end of file +T >: IntegerValueType(1) +T <: Short diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds index 767c74294bc..93379428dad 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P Consumer +T := Int +P := Consumer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints index e0751422bfb..e4e3eb8e1b0 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P Consumer +T := Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds index 7576d950b1a..52adc70cbf3 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Consumer +T := Int +P <: Consumer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints index 75fcfd4c9ff..67567cd2dee 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Consumer +T := Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds index 65d4e213440..2a6af20e622 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Consumer +T := Int +P >: Consumer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints index 7a1aec72d51..52d5a35b1e8 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Consumer +T := Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds index 6882e64a517..3f40aac7c0d 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Consumer +T <: Int +P := Consumer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints index 656c4453f9b..53d27506f5e 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Consumer +T <: Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds index 36ece479442..eb2067accb7 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Consumer +T <: Int +P <: Consumer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints index 2350a783ecd..dfa315bf976 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Consumer +T <: Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds index dc9bd4ee09f..93f9afb9610 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Consumer +T <: Int +P >: Consumer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints index 9aecf5e8d88..fa629778192 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Consumer +T <: Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds index aab4a696ef5..a737ec275dd 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Consumer +T >: Int +P := Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints index cbfda275da8..0549095d95c 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Consumer +T >: Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds index e43f73ab278..732e2825709 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Consumer +T >: Int +P <: Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints index 568af53e3ad..eafcc55663e 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Consumer +T >: Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds index c5e1ad524d5..53e2d9a1d0d 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Consumer +T >: Int +P >: Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints index 8b0dfe5cacc..3f9d691fab5 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/contravariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Consumer +T >: Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds index fa29eb3243c..a84ceea90b3 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P Producer +T := Int +P := Producer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints index 2746dec14a2..b8682d147da 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P Producer +T := Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds index 25302882cae..333ccca8bef 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Producer +T := Int +P <: Producer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints index bbf66b8dc5c..35965dee809 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Producer +T := Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds index 8f82371393f..cb9dc556a9a 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Producer +T := Int +P >: Producer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints index bf14baf3586..dc9922a8970 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Producer +T := Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds index 994192067e0..158b947451b 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Producer +T <: Int +P := Producer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints index ffb31352379..e396ec93736 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Producer +T <: Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds index 9a1c367b17e..d06e4aabe62 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer +T <: Int +P <: Producer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints index 6393295827d..591c1e73a05 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer +T <: Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds index fc04cd651dd..0cfe13d7fe4 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Producer +T <: Int +P >: Producer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints index b5020891ab8..f5afe6e411d 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Producer +T <: Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds index c20ba05af7e..58cd194a3a8 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Producer +T >: Int +P := Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints index 879c938ebd8..80c0c77152d 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Producer +T >: Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds index 663ed0261f1..012c754855b 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Producer +T >: Int +P <: Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints index f433623b950..d6697a53b90 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Producer +T >: Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds index e687ac76a53..7fcc24506eb 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Producer +T >: Int +P >: Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints index 8138eb7582f..b2345b38016 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/covariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Producer +T >: Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds index 2bf6c5e8394..605be5c1245 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P My +T := Int +P := My type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints index a422162d64a..8dbe999f027 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P My +T := Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds index 49bb91d9ec6..4db5d355c22 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P My +T := Int +P <: My type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints index b04f0ca41a0..3d7c94d3f01 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P My +T := Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds index bddbf2341d0..cb02905c3de 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P My +T := Int +P >: My type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints index 3b0b9ae47e3..ce2fae0e68e 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P My +T := Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds index 420b8574da7..ce9e75b129d 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P My +T <: Int +P := My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints index 877c4529d1b..07b20eef913 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P My +T <: Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds index 5ce7369428f..772a83b45a2 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My +T <: Int +P <: My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints index 90ae60529e4..3e58fb5b2a1 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My +T <: Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds index bfd0363ae79..57d3219b315 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P My +T <: Int +P >: My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints index d51ee811788..802fa4fa77f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P My +T <: Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds index ce9772e5472..e063aadb4b0 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P My +T >: Int +P := My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints index 785f2d53719..b4c5f83202f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P My +T >: Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds index 2a890311f20..0e0efdceff8 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P My +T >: Int +P <: My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints index 9d1ebe0beac..da6df183aa5 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P My +T >: Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds index 50c3e7a4752..d02a3bda19f 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P My +T >: Int +P >: My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints index e5f1c829e43..34597d6a9a7 100644 --- a/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/direct/invariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P My +T >: Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds index 0dd2f8ada64..7da19bb43dc 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.bounds @@ -1,9 +1,9 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE P My -SUBTYPE Successor P -SUBTYPE Int T +P <: My +Successor <: P +Int <: T type parameter bounds: T := T*, := E*, >: Int, := Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints index 2652dc43ebc..700a203d296 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency1.constraints @@ -1,6 +1,6 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE P My -SUBTYPE Successor P -SUBTYPE Int T +P <: My +Successor <: P +Int <: T diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds index 409c0397e2b..d1c12fbfb04 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.bounds @@ -1,9 +1,9 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE P My -SUBTYPE Int T -SUBTYPE Successor P +P <: My +Int <: T +Successor <: P type parameter bounds: T >: Int, := T*, := E*, := Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints index 3ca6e06e52a..c659df345ce 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency2.constraints @@ -1,6 +1,6 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE P My -SUBTYPE Int T -SUBTYPE Successor P +P <: My +Int <: T +Successor <: P diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds index 18ab4706b1a..3345b301150 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.bounds @@ -1,9 +1,9 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE Int T -SUBTYPE Successor P -SUBTYPE P My +Int <: T +Successor <: P +P <: My type parameter bounds: T >: Int, := T*, := E*, := Int diff --git a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints index f97c8a922fe..c004de9df4c 100644 --- a/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints +++ b/compiler/testData/constraintSystem/severalVariables/interdependency/interdependency3.constraints @@ -1,6 +1,6 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE Int T -SUBTYPE Successor P -SUBTYPE P My +Int <: T +Successor <: P +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds index 7a0185605f3..c75ca7b1e4b 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P Consumer +T := Int +P := Consumer type parameter bounds: T := Int, >: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints index 3b81189be3a..c1736b057c7 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P Consumer +T := Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds index d17252889f9..192ea287dd4 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Consumer +T := Int +P <: Consumer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints index 960d36fb28b..55f677f6ddb 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Consumer +T := Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds index 5e12daa2b73..cdc2b78a7ff 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Consumer +T := Int +P >: Consumer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints index b9b310e4a6d..09f513cc7b4 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Consumer +T := Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds index f09b862aa25..f28d713b932 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Consumer +T <: Int +P := Consumer type parameter bounds: T <: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints index 7c34b1d8080..5271ac8ec41 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Consumer +T <: Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds index 56aacfab893..3cf761b0bbc 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Consumer +T <: Int +P <: Consumer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints index 10ace6ad50f..ae64ed7c915 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Consumer +T <: Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds index 0cde5ba6e85..22e08657fce 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Consumer +T <: Int +P >: Consumer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints index ae5462e8c59..5ed24171e25 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Consumer +T <: Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds index 3da6d94e777..198d5797635 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Consumer +T >: Int +P := Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints index ae38a91ed57..af1292bcb12 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Consumer +T >: Int +P := Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds index e89d4a562fc..f8802073cf1 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Consumer +T >: Int +P <: Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints index b100806bf89..c40e9e4214e 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Consumer +T >: Int +P <: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds index b495badd3a4..a26fb134d3e 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Consumer +T >: Int +P >: Consumer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints index dffa79e2c6b..154953e0dc0 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/contravariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Consumer +T >: Int +P >: Consumer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds index 357b1270a3e..2dce152d14c 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P Producer +T := Int +P := Producer type parameter bounds: T := Int, >: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints index 6948d6c0b3b..c26a6ffd4e8 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P Producer +T := Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds index 3d01d408444..494df6e0593 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Producer +T := Int +P <: Producer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints index a505a22a8b6..05b999bba72 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P Producer +T := Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds index c22ace7b431..3274bad3c3a 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Producer +T := Int +P >: Producer type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints index 7220d3f21a0..696c4319d1d 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P Producer +T := Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds index b0c6573afd0..01c64e2e871 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Producer +T <: Int +P := Producer type parameter bounds: T <: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints index b22b4c68253..bca5d5feb30 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P Producer +T <: Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds index 4036de96dea..bc211c8a178 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer +T <: Int +P <: Producer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints index 7bd66f85cd3..7a0eaffde51 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer +T <: Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds index 0894f51acb5..0205bd703c2 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Producer +T <: Int +P >: Producer type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints index f68d9fc5a41..d0250712a47 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P Producer +T <: Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds index ac9716b151d..b605afccf08 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Producer +T >: Int +P := Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints index 6257394ddff..514bbd7d40c 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P Producer +T >: Int +P := Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds index 42576564a78..0c89b4904be 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Producer +T >: Int +P <: Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints index a1f80514814..a38123fd422 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P Producer +T >: Int +P <: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds index 65fd417579b..a0983242baa 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Producer +T >: Int +P >: Producer type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints index 2b1331f8bed..3e222362b82 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/covariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P Producer +T >: Int +P >: Producer diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds index 72fb56675de..a58d69765d7 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -EQUAL P My +T := Int +P := My type parameter bounds: T := Int, >: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints index 88264911d2c..84f297651e6 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -EQUAL P My +T := Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds index 1fdc719c1bf..edd6bb74e33 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P My +T := Int +P <: My type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints index 197a280d8ff..d37a697ae35 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUBTYPE P My +T := Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds index 35370ceea94..84bd8e2f19b 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P My +T := Int +P >: My type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints index cf7a4a42f5a..f693412f981 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T Int -SUPERTYPE P My +T := Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds index e8c1cc16eba..109e639b135 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P My +T <: Int +P := My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints index ff5bbb95a3e..5fd3076befd 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL P My +T <: Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds index 5bbd2622220..1398031e1db 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My +T <: Int +P <: My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints index 47a4cbb90f6..1814a0991d0 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My +T <: Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds index e4685fb8780..b6bd04c1ee7 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P My +T <: Int +P >: My type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints index 3c9bb446453..7b6aad251dc 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUPERTYPE P My +T <: Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds index 64218af7abd..364a456010a 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P My +T >: Int +P := My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints index 1065f6916e5..e6f0b95000a 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -EQUAL P My +T >: Int +P := My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds index dec3f74f059..812cef1a783 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P My +T >: Int +P <: My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints index 841df121682..f78eb65acfe 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUBTYPE P My +T >: Int +P <: My diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds index e0a2bd62868..bbe55fa05f8 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P My +T >: Int +P >: My type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints index 2ec50dca2bc..003e8f08470 100644 --- a/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/nullable/invariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE T Int -SUPERTYPE P My +T >: Int +P >: My diff --git a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds index b3338f2d3ef..2b7abe5e0fb 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T? P? -SUBTYPE P Int +T? <: P? +P <: Int type parameter bounds: T <: P?*, <: P*, <: Int, <: Int? diff --git a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints index df99da1ee94..673300163fa 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/constraintForNullables.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T? P? -SUBTYPE P Int +T? <: P? +P <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds index d91e89886b7..0981df3ed2a 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -EQUAL P Consumer> +Int <: T +P := Consumer> type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints index 11a84f8f0bf..2bcb86860f2 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -EQUAL P Consumer> \ No newline at end of file +Int <: T +P := Consumer> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds index e2c18c29f81..a2a48f29dd7 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P Consumer>> +Int <: T +P <: Consumer>> type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints index 37ec32c12f6..42efc5e0b40 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedConsumer1.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P Consumer>> \ No newline at end of file +Int <: T +P <: Consumer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds index bffb550873a..075eb977f1d 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P My>> +Int <: T +P <: My>> type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints index 9550d7f43e8..9106bea3942 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvConsumer.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P My>> \ No newline at end of file +Int <: T +P <: My>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds index 842dc6ea2a4..954ba31220b 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My>> +T <: Int +P <: My>> type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints index cf13d9fe377..adddfa74b0a 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedInvProducer.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P My>> \ No newline at end of file +T <: Int +P <: My>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds index 17b2a13fe09..02bb5b42f4b 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer>> +T <: Int +P <: Producer>> type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints index ac48c96fd07..a6504127d85 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducer.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Producer>> \ No newline at end of file +T <: Int +P <: Producer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds index 2d574cc3282..8a228f73979 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P Producer>> +Int <: T +P <: Producer>> type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints index 5b65fe00289..ee92ca64885 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/nestedProducerAndConsumer.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE P Producer>> +Int <: T +P <: Producer>> diff --git a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds index c8f586e0643..2b703b86732 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Fun,Producer> +T <: Int +P <: Fun,Producer> type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints index 21995bde4f7..61c4ed5cfcf 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/severalOccurrences.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P Fun,Producer> \ No newline at end of file +T <: Int +P <: Fun,Producer> diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds index 14722a37620..0bb4a19c34c 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.bounds @@ -1,13 +1,13 @@ VARIABLES T P E -SUBTYPE Int T -SUBTYPE P String -SUBTYPE E Fun +Int <: T +P <: String +E <: Fun type parameter bounds: T >: Int P <: String -E <: Fun*, <: Fun +E <: Fun*, <: Fun*, <: Fun, <: Fun* status: -hasCannotCaptureTypesError: false @@ -23,4 +23,4 @@ status: result: T=Int P=String -E=Fun +E=Fun \ No newline at end of file diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints index 29ac24ec9fe..cc3233beeec 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleFun.constraints @@ -1,5 +1,5 @@ VARIABLES T P E -SUBTYPE Int T -SUBTYPE P String -SUBTYPE E Fun \ No newline at end of file +Int <: T +P <: String +E <: Fun diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds index 6f1826c443c..1f5b59f30f9 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.bounds @@ -1,8 +1,8 @@ VARIABLES T P E -SUBTYPE T P -SUBTYPE P E -SUBTYPE E Int +T <: P +P <: E +E <: Int type parameter bounds: T <: P*, <: E*, <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints index f41341a3ef0..50616113b85 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVars.constraints @@ -1,5 +1,5 @@ VARIABLES T P E -SUBTYPE T P -SUBTYPE P E -SUBTYPE E Int +T <: P +P <: E +E <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds index 8dbddcf9c42..b4e6f9195b4 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.bounds @@ -1,8 +1,8 @@ VARIABLES T P E -SUBTYPE T P -SUBTYPE P E -SUBTYPE Int E +T <: P +P <: E +Int <: E type parameter bounds: T <: P*, <: E* diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints index 0c5479367b1..4ffb5c15c74 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporation.constraints @@ -1,5 +1,5 @@ VARIABLES T P E -SUBTYPE T P -SUBTYPE P E -SUBTYPE Int E +T <: P +P <: E +Int <: E diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds index 9647fc7cf43..fb24c3779eb 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.bounds @@ -1,9 +1,9 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE T P -SUBTYPE P E -SUBTYPE Int E +T <: P +P <: E +Int <: E type parameter bounds: T <: P*, <: E*, <: Int, := Int diff --git a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints index 83e149c9e95..e926273422b 100644 --- a/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints +++ b/compiler/testData/constraintSystem/severalVariables/other/simpleThreeVarsNoIncorporationFixed.constraints @@ -1,6 +1,6 @@ VARIABLES T P E FIX_VARIABLES -SUBTYPE T P -SUBTYPE P E -SUBTYPE Int E +T <: P +P <: E +Int <: E diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds index ddc2b06e136..b3fced08758 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.bounds @@ -1,8 +1,8 @@ VARIABLES T P E -SUBTYPE T Producer

-SUBTYPE P Producer -SUBTYPE E Producer

+T <: Producer

+P <: Producer +E <: Producer

type parameter bounds: T <: Producer

*, <: Producer>*, <: Producer>>* diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints index da4f2840fc4..beb7ef775e1 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints +++ b/compiler/testData/constraintSystem/severalVariables/recursive/implicitlyRecursive.constraints @@ -1,5 +1,5 @@ VARIABLES T P E -SUBTYPE T Producer

-SUBTYPE P Producer -SUBTYPE E Producer

+T <: Producer

+P <: Producer +E <: Producer

diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds index eba72e6eaf5..3865153b06b 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL T My

-EQUAL P Two +T := My

+P := Two type parameter bounds: T := My

* diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints index 67356268c6e..2ed17521412 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints +++ b/compiler/testData/constraintSystem/severalVariables/recursive/mutuallyRecursive.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL T My

-EQUAL P Two +T := My

+P := Two diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds index cf7d6634fcd..1648e2c0267 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.bounds @@ -1,7 +1,7 @@ VARIABLES T -EQUAL T Int -EQUAL T My +T := Int +T := My type parameter bounds: T := Int, := My*, := My diff --git a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints index 855ddd3e6d8..b9aa0ae37c9 100644 --- a/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints +++ b/compiler/testData/constraintSystem/severalVariables/recursive/simpleRecursive.constraints @@ -1,4 +1,4 @@ VARIABLES T -EQUAL T Int -EQUAL T My +T := Int +T := My diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds index cf98cfe1213..1795c416d39 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Consumer -EQUAL T Int +P := Consumer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints index 8d549c39c52..87ad3fd3433 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Consumer -EQUAL T Int +P := Consumer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds index 18ee276ac16..401fd9530fd 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Consumer -EQUAL T Int +P <: Consumer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints index ec2fdfb23cf..351d8eaf131 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Consumer -EQUAL T Int +P <: Consumer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds index eb228db31bb..2a742d23c3a 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Consumer -EQUAL T Int +P >: Consumer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints index 988014d00a0..369da5efafd 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Consumer -EQUAL T Int +P >: Consumer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds index f674e15203a..a149983ad25 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Consumer -SUBTYPE T Int +P := Consumer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints index 1108481bcc7..32270663ab3 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Consumer -SUBTYPE T Int +P := Consumer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds index a30bca567b7..389ff911b14 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Consumer -SUBTYPE T Int +P <: Consumer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints index f6b480df105..554dba141ff 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Consumer -SUBTYPE T Int +P <: Consumer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds index 56f9a03afcf..99b6278f3a9 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Consumer -SUBTYPE T Int +P >: Consumer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints index ba5d75b2383..133d23b9695 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Consumer -SUBTYPE T Int +P >: Consumer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds index 45500b013ed..56d84654e41 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Consumer -SUPERTYPE T Int +P := Consumer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints index 987c65f823a..bc5ef67d057 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Consumer -SUPERTYPE T Int +P := Consumer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds index 67b60d1479f..96d7264ad3b 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Consumer -SUPERTYPE T Int +P <: Consumer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints index 6cd684ec46d..8aa51d752f8 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Consumer -SUPERTYPE T Int +P <: Consumer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds index 6fc17a3171a..2a8fe671e57 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Consumer -SUPERTYPE T Int +P >: Consumer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints index 39ed31fc197..5508d75c40b 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/contravariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Consumer -SUPERTYPE T Int +P >: Consumer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds index 3c66b80507d..a3773af2958 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Producer -EQUAL T Int +P := Producer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints index bf63226aebd..e7fb378f929 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Producer -EQUAL T Int +P := Producer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds index 749c66cfa9a..0d8ad2b94ac 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Producer -EQUAL T Int +P <: Producer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints index dfe4439d966..29dd6ed603c 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Producer -EQUAL T Int +P <: Producer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds index eb1157e8521..300b1ea3056 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Producer -EQUAL T Int +P >: Producer +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints index 40fe9f33785..ef7338d2564 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Producer -EQUAL T Int +P >: Producer +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds index e58fbc75207..9fa78404a59 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Producer -SUBTYPE T Int +P := Producer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints index f36cf11bb11..fb8e245ccf5 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Producer -SUBTYPE T Int +P := Producer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds index 04f286917b3..01a5fec3d57 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Producer -SUBTYPE T Int +P <: Producer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints index adfb3431ffd..2d0376eff10 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Producer -SUBTYPE T Int +P <: Producer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds index 023ece28e13..c0813347848 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Producer -SUBTYPE T Int +P >: Producer +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints index 5d73d96277c..b917df226fe 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Producer -SUBTYPE T Int +P >: Producer +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds index 0885b3d60bc..4207c874b2f 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P Producer -SUPERTYPE T Int +P := Producer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints index aee017d21bc..ef9b6856bc2 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P Producer -SUPERTYPE T Int +P := Producer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds index ad45ed7c6db..8ae260d9c7c 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P Producer -SUPERTYPE T Int +P <: Producer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints index ee18e2cfff3..c59156c590c 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P Producer -SUPERTYPE T Int +P <: Producer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds index d3157cb8c0e..8d7e1902c21 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P Producer -SUPERTYPE T Int +P >: Producer +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints index 154bc6eccfb..225dedbb5ee 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/covariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P Producer -SUPERTYPE T Int +P >: Producer +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds index ecedf08544c..22b57745b7b 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P My -EQUAL T Int +P := My +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints index 2ab72319604..4d2c01477ce 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P My -EQUAL T Int +P := My +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds index 81a682e5ca7..d87dd002dc8 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P My -EQUAL T Int +P <: My +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints index 0e4e6decd53..82eb3f24f17 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P My -EQUAL T Int +P <: My +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds index 8f22965c275..cb319b51e66 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P My -EQUAL T Int +P >: My +T := Int type parameter bounds: T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints index ff801041f1a..579046f1a40 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varEqDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P My -EQUAL T Int +P >: My +T := Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds index e518963ba10..48e44a1583b 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P My -SUBTYPE T Int +P := My +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints index cc25624bebb..77fa46314fd 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P My -SUBTYPE T Int +P := My +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds index 5c15de74f7f..8b737201b99 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P My -SUBTYPE T Int +P <: My +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints index 8d20982d465..3ec171fd99d 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P My -SUBTYPE T Int +P <: My +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds index 7aa3f6787f1..bc766a0170e 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P My -SUBTYPE T Int +P >: My +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints index 58df9d3ee81..51521bac5f5 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSubDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P My -SUBTYPE T Int +P >: My +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds index 6dfc882fe47..43a0a302b7c 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.bounds @@ -1,7 +1,7 @@ VARIABLES T P -EQUAL P My -SUPERTYPE T Int +P := My +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints index 21247db3972..855195c6593 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepEq.constraints @@ -1,4 +1,4 @@ VARIABLES T P -EQUAL P My -SUPERTYPE T Int +P := My +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds index 39072b45d84..8f6fa7723b7 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE P My -SUPERTYPE T Int +P <: My +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints index 35025b0d1b7..cb57ae20f53 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSub.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE P My -SUPERTYPE T Int +P <: My +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds index 631127ad0af..47a058f35a9 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUPERTYPE P My -SUPERTYPE T Int +P >: My +T >: Int type parameter bounds: T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints index 8679f0410bf..57f94b389e7 100644 --- a/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints +++ b/compiler/testData/constraintSystem/severalVariables/reversed/invariant/varSuperDepSuper.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUPERTYPE P My -SUPERTYPE T Int +P >: My +T >: Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds index 3d719cd2c9c..16181e690db 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.bounds @@ -1,6 +1,6 @@ VARIABLES T P -SUBTYPE T Int +T <: Int type parameter bounds: T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints b/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints index 4c5f7e33f88..edc91fdd59c 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleDependency.constraints @@ -1,3 +1,3 @@ VARIABLES T P -SUBTYPE T Int \ No newline at end of file +T <: Int diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds index 7290a18d89e..cd17ade2378 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -EQUAL T P +T <: Int +T := P type parameter bounds: T <: Int, := P* diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints b/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints index b34fd87f315..4a053567d4c 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -EQUAL T P +T <: Int +T := P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds index c9d7700b5bc..838f4ec7630 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -EQUAL T P +Int <: T +T := P type parameter bounds: T >: Int, := P* diff --git a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints index e395d91e7d8..c048debe4f8 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleEquality1.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -EQUAL T P +Int <: T +T := P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds index 5c91ddf5be8..cf9fc0fa44a 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE T P +T <: Int +T <: P type parameter bounds: T <: Int, <: P* diff --git a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints index 6823743fa36..990c06be17a 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleReversedDependency.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE T P +T <: Int +T <: P diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds index 35f2e2d172b..f3c152d1d39 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P T +T <: Int +P <: T type parameter bounds: T <: Int, >: P* diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints index 902c73f7a6a..4c33878795e 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE T Int -SUBTYPE P T +T <: Int +P <: T diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds index 806f684e0f6..43f191ef7b0 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.bounds @@ -1,7 +1,7 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE T P +Int <: T +T <: P type parameter bounds: T >: Int, <: P* diff --git a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints index 68687efd421..7953a434603 100644 --- a/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints +++ b/compiler/testData/constraintSystem/severalVariables/simpleSubtype1.constraints @@ -1,4 +1,4 @@ VARIABLES T P -SUBTYPE Int T -SUBTYPE T P +Int <: T +T <: P diff --git a/compiler/testData/constraintSystem/variance/consumer.bounds b/compiler/testData/constraintSystem/variance/consumer.bounds index eb8ee755b49..c240da76aad 100644 --- a/compiler/testData/constraintSystem/variance/consumer.bounds +++ b/compiler/testData/constraintSystem/variance/consumer.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUBTYPE Consumer Consumer +Consumer <: Consumer type parameter bounds: T <: A diff --git a/compiler/testData/constraintSystem/variance/consumer.constraints b/compiler/testData/constraintSystem/variance/consumer.constraints index aa4ca88a3ee..7c8111bd7cb 100644 --- a/compiler/testData/constraintSystem/variance/consumer.constraints +++ b/compiler/testData/constraintSystem/variance/consumer.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUBTYPE Consumer Consumer \ No newline at end of file +Consumer <: Consumer diff --git a/compiler/testData/constraintSystem/variance/invariant.bounds b/compiler/testData/constraintSystem/variance/invariant.bounds index 1012e4008c9..01e9e36d310 100644 --- a/compiler/testData/constraintSystem/variance/invariant.bounds +++ b/compiler/testData/constraintSystem/variance/invariant.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUBTYPE My My +My <: My type parameter bounds: T := A diff --git a/compiler/testData/constraintSystem/variance/invariant.constraints b/compiler/testData/constraintSystem/variance/invariant.constraints index cb2df5faa67..239de367350 100644 --- a/compiler/testData/constraintSystem/variance/invariant.constraints +++ b/compiler/testData/constraintSystem/variance/invariant.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUBTYPE My My \ No newline at end of file +My <: My diff --git a/compiler/testData/constraintSystem/variance/producer.bounds b/compiler/testData/constraintSystem/variance/producer.bounds index e13388ee294..583b68e8847 100644 --- a/compiler/testData/constraintSystem/variance/producer.bounds +++ b/compiler/testData/constraintSystem/variance/producer.bounds @@ -1,6 +1,6 @@ VARIABLES T -SUBTYPE Producer Producer +Producer <: Producer type parameter bounds: T >: A diff --git a/compiler/testData/constraintSystem/variance/producer.constraints b/compiler/testData/constraintSystem/variance/producer.constraints index 2044f7f1535..a9efb4e6e39 100644 --- a/compiler/testData/constraintSystem/variance/producer.constraints +++ b/compiler/testData/constraintSystem/variance/producer.constraints @@ -1,3 +1,3 @@ VARIABLES T -SUBTYPE Producer Producer \ No newline at end of file +Producer <: Producer diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt index e554e2b80ec..d1031c6d7fd 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/AbstractConstraintSystemTest.kt @@ -17,30 +17,24 @@ package org.jetbrains.kotlin.resolve.constraintSystem import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.diagnostics.rendering.Renderers import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.TypeResolver import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemImpl import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.SPECIAL -import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.TYPE_BOUND_POSITION import org.jetbrains.kotlin.resolve.calls.inference.registerTypeVariables import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.JetLiteFixture import org.jetbrains.kotlin.test.JetTestUtils import org.jetbrains.kotlin.tests.di.createContainerForTests +import org.jetbrains.kotlin.types.ErrorUtils +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.Variance import java.io.File import java.util.ArrayList -import java.util.LinkedHashMap -import java.util.regex.Pattern abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { - private val typePattern = """([\w|<|\,|>|?|\(|\)]+)""" - val constraintPattern = Pattern.compile("""(SUBTYPE|SUPERTYPE|EQUAL)\s+$typePattern\s+$typePattern\s*(weak)?""") - val variablesPattern = Pattern.compile("VARIABLES\\s+(.*)") - val fixVariablesPattern = "FIX_VARIABLES" private var _typeResolver: TypeResolver? = null private val typeResolver: TypeResolver @@ -72,7 +66,7 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { } private fun analyzeDeclarations(): ConstraintSystemTestData { - val fileName = "declarations/declarations.kt" + val fileName = "declarations.kt" val psiFile = createPsiFile(null, fileName, loadFile(fileName))!! val bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile).bindingContext @@ -81,24 +75,29 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { public fun doTest(filePath: String) { val constraintsFile = File(filePath) - val constraintsFileText = JetTestUtils.doLoadFile(constraintsFile)!! + val constraintsFileText = constraintsFile.readLines() val constraintSystem = ConstraintSystemImpl() val variables = parseVariables(constraintsFileText) - val fixVariables = constraintsFileText.contains(fixVariablesPattern) + val fixVariables = constraintsFileText.contains("FIX_VARIABLES") val typeParameterDescriptors = variables.map { testDeclarations.getParameterDescriptor(it) } constraintSystem.registerTypeVariables(typeParameterDescriptors, { Variance.INVARIANT }) val constraints = parseConstraints(constraintsFileText) + fun JetType.assertNotError(): JetType { + assert(!ErrorUtils.containsErrorType(this)) { "Type $this is resolved to or contains error type" } + return this + } for (constraint in constraints) { - val firstType = testDeclarations.getType(constraint.firstType) - val secondType = testDeclarations.getType(constraint.secondType) - val position = if (constraint.isWeak) TYPE_BOUND_POSITION.position(0) else SPECIAL.position() + val firstType = testDeclarations.getType(constraint.firstType).assertNotError() + val secondType = testDeclarations.getType(constraint.secondType).assertNotError() + val position = SPECIAL.position() when (constraint.kind) { MyConstraintKind.SUBTYPE -> constraintSystem.addSubtypeConstraint(firstType, secondType, position) MyConstraintKind.SUPERTYPE -> constraintSystem.addSupertypeConstraint(firstType, secondType, position) - MyConstraintKind.EQUAL -> constraintSystem.addConstraint(ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position, topLevel = true) + MyConstraintKind.EQUAL -> constraintSystem.addConstraint( + ConstraintSystemImpl.ConstraintKind.EQUAL, firstType, secondType, position, topLevel = true) } } if (fixVariables) constraintSystem.fixVariables() @@ -109,38 +108,37 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() { val result = typeParameterDescriptors.map { val parameterType = testDeclarations.getType(it.getName().asString()) val resultType = resultingSubstitutor.substitute(parameterType, Variance.INVARIANT) - "${it.getName()}=${resultType?.let{ DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}" + "${it.getName()}=${resultType?.let { DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(it) }}" }.join("\n", prefix = "result:\n") val boundsFile = File(filePath.replace("constraints", "bounds")) - JetTestUtils.assertEqualsToFile(boundsFile, "$constraintsFileText\n\n$resultingStatus\n\n$result") + JetTestUtils.assertEqualsToFile(boundsFile, "${constraintsFileText.join("\n")}\n\n$resultingStatus\n\n$result") } - class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String, val isWeak: Boolean) - enum class MyConstraintKind { - SUBTYPE, SUPERTYPE, EQUAL + class MyConstraint(val kind: MyConstraintKind, val firstType: String, val secondType: String) + enum class MyConstraintKind + private constructor(val token: String) { + SUBTYPE("<:"), SUPERTYPE(">:"), EQUAL(":=") } - private fun parseVariables(text: String): List { - val matcher = variablesPattern.matcher(text) - if (matcher.find()) { - val variablesText = matcher.group(1)!! - val variables = variablesText.split(' ') - return variables.toList() + private fun parseVariables(lines: List): List { + val first = lines.first() + val variablesString = "VARIABLES " + assert (first.startsWith(variablesString)) { "The first line should contain variables: $first"} + val variables = first.substringAfter(variablesString).split(' ') + return variables.toList() + } + + private fun parseConstraints(lines: List): List { + val kindsMap = MyConstraintKind.values().map { it.token to it }.toMap() + val kinds = kindsMap.keySet() + val linesWithConstraints = lines.filter { line -> kinds.any { kind -> line.contains(kind) } } + return linesWithConstraints.map { + line -> + val kind = kinds.first { line.contains(it) } + val firstType = line.substringBefore(kind).trim() + val secondType = line.substringAfter(kind).trim() + MyConstraint(kindsMap[kind]!!, firstType, secondType) } - throw AssertionError("Type variable names should be declared") - } - - private fun parseConstraints(text: String): List { - val constraints = ArrayList() - val matcher = constraintPattern.matcher(text) - while (matcher.find()) { - val kind = MyConstraintKind.valueOf(matcher.group(1)!!) - val firstType = matcher.group(2)!! - val secondType = matcher.group(3)!! - val isWeak = matcher.groupCount() == 4 && matcher.group(4) == "weak" - constraints.add(MyConstraint(kind, firstType, secondType, isWeak)) - } - return constraints } } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt index c47ab6ae95b..fecd1623b5c 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestData.kt @@ -52,7 +52,7 @@ public class ConstraintSystemTestData( fun getParameterDescriptor(name: String): TypeParameterDescriptor { return functionFoo.getTypeParameters().firstOrNull { it.getName().asString() == name } ?: - throw AssertionError("Unsupported type parameter name: " + name + ".") + throw AssertionError("Unsupported type parameter name: $name. You may add it to constraintSystem/declarations.kt") } fun getType(name: String): JetType { diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java index 8ccbd2d42c1..4df6fba0cd3 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constraintSystem/ConstraintSystemTestGenerated.java @@ -66,12 +66,6 @@ public class ConstraintSystemTestGenerated extends AbstractConstraintSystemTest String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/unknownParameters.constraints"); doTest(fileName); } - - @TestMetadata("violatedUpperBound.constraints") - public void testViolatedUpperBound() throws Exception { - String fileName = JetTestUtils.navigationMetadata("compiler/testData/constraintSystem/checkStatus/violatedUpperBound.constraints"); - doTest(fileName); - } } @TestMetadata("compiler/testData/constraintSystem/computeValues") From 5126f01452307707cc28a8d4d4432e5e669e271a Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 26 Jun 2015 13:56:47 +0300 Subject: [PATCH 250/450] kotlin.annotation package with annotations "target" and "annotation" and enums AnnotationTarget and AnnotationRetention introduced. Targets for existing built-in annotations. Access to annotation package from packageFragmentProvider. Documentation for all classes in the package. --- .../jvm/TopDownAnalyzerFacadeForJVM.java | 1 + compiler/testData/builtin-classes.txt | 10 +- core/builtins/src/kotlin/Annotations.kt | 12 ++- .../src/kotlin/annotation/Annotations.kt | 91 +++++++++++++++++++ .../kotlin/builtins/KotlinBuiltIns.java | 10 +- .../BuiltInFictitiousFunctionClassFactory.kt | 3 + .../analyze/TopDownAnalyzerFacadeForJS.java | 1 + jslib_files.xml | 2 + 8 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 core/builtins/src/kotlin/annotation/Annotations.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.java index 03ea6fa532e..6fcc7b68219 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/TopDownAnalyzerFacadeForJVM.java @@ -58,6 +58,7 @@ public enum TopDownAnalyzerFacadeForJVM { List list = new ArrayList(); list.add(new ImportPath("java.lang.*")); list.add(new ImportPath("kotlin.*")); + list.add(new ImportPath("kotlin.annotation.*")); list.add(new ImportPath("kotlin.jvm.*")); list.add(new ImportPath("kotlin.io.*")); // all classes from package "kotlin" mapped to java classes are imported explicitly so that they take priority over classes from java.lang diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index c72043805a5..4f1e251a60d 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -1261,11 +1261,11 @@ public object Unit { /*primary*/ private constructor Unit() } -public final annotation class data : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) public final annotation class data : kotlin.Annotation { /*primary*/ public constructor data() } -public final annotation class deprecated : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER}) public final annotation class deprecated : kotlin.Annotation { /*primary*/ public constructor deprecated(/*0*/ value: kotlin.String, /*1*/ replaceWith: kotlin.ReplaceWith = ...) internal final val replaceWith: kotlin.ReplaceWith internal final fun (): kotlin.ReplaceWith @@ -1273,7 +1273,7 @@ public final annotation class deprecated : kotlin.Annotation { internal final fun (): kotlin.String } -public final annotation class extension : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class extension : kotlin.Annotation { /*primary*/ public constructor extension() } @@ -1293,12 +1293,12 @@ public final annotation class noinline : kotlin.Annotation { /*primary*/ public constructor noinline() } -public final annotation class suppress : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE}) public final annotation class suppress : kotlin.Annotation { /*primary*/ public constructor suppress(/*0*/ vararg names: kotlin.String /*kotlin.Array*/) internal final val names: kotlin.Array internal final fun (): kotlin.Array } -public final annotation class tailRecursive : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class tailRecursive : kotlin.Annotation { /*primary*/ public constructor tailRecursive() } diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index f5ac5a9a719..99fa0869d91 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -16,20 +16,26 @@ package kotlin +import kotlin.annotation.* +import kotlin.annotation.AnnotationTarget.* + /** * Marks the annotated class as a data class. The compiler automatically generates * equals()/hashCode(), toString(), componentN() and copy() functions for data classes. * See [the Kotlin language documentation](http://kotlinlang.org/docs/reference/data-classes.html) * for more information. */ +target(CLASSIFIER) public annotation class data /** - * Marks the annotated class, function or property as deprecated. + * Marks the annotated class, function, property, variable or parameter as deprecated. * @property value the message explaining the deprecation and recommending an alternative API to use. * @property replaceWith if present, specifies a code fragment which should be used as a replacement for * the deprecated API usage. */ +target(CLASSIFIER, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER, + LOCAL_VARIABLE, FIELD, VALUE_PARAMETER) public annotation class deprecated(val value: String, val replaceWith: ReplaceWith = ReplaceWith("")) /** @@ -50,12 +56,15 @@ public annotation class ReplaceWith(val expression: String, vararg val imports: /** * Signifies that the annotated functional type represents an extension function. */ +target(TYPE) public annotation class extension /** * Suppresses the given compilation warnings in the annotated element. * @property names names of the compiler diagnostics to suppress. */ +target(CLASSIFIER, ANNOTATION_CLASS, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER, + CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, EXPRESSION, FILE) public annotation class suppress(vararg val names: String) /** @@ -64,4 +73,5 @@ public annotation class suppress(vararg val names: String) * growing the stack depth. Tail call optimization is currently only supported by the JVM * backend. */ +target(FUNCTION) public annotation class tailRecursive diff --git a/core/builtins/src/kotlin/annotation/Annotations.kt b/core/builtins/src/kotlin/annotation/Annotations.kt new file mode 100644 index 00000000000..c23799585bc --- /dev/null +++ b/core/builtins/src/kotlin/annotation/Annotations.kt @@ -0,0 +1,91 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.annotation + +/** + * Contains the list of code elements which are the possible annotation targets + */ +public enum class AnnotationTarget { + /** Package directive */ + PACKAGE, + /** Class, interface or object, annotation class is also included */ + CLASSIFIER, + /** Annotation class only */ + ANNOTATION_CLASS, + /** Generic type parameter (unsupported yet) */ + TYPE_PARAMETER, + /** Property */ + PROPERTY, + /** Field, including property's backing field */ + FIELD, + /** Local variable */ + LOCAL_VARIABLE, + /** Value parameter of a function or a constructor */ + VALUE_PARAMETER, + /** Constructor only (primary or secondary) */ + CONSTRUCTOR, + /** Function (constructors are not included) */ + FUNCTION, + /** Property getter only */ + PROPERTY_GETTER, + /** Property setter only */ + PROPERTY_SETTER, + /** Type usage */ + TYPE, + /** Any expression */ + EXPRESSION, + /** File */ + FILE +} + +/** + * Contains the list of possible annotation's retentions. + * + * Determines how an annotation is stored in binary output. + */ +public enum class AnnotationRetention { + /** Annotation isn't stored in binary output */ + SOURCE, + /** Annotation is stored in binary output, but invisible for reflection */ + BINARY, + /** Annotation is stored in binary output and visible for reflection (default retention) */ + RUNTIME +} + +/** + * This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. + * + * If the target meta-annotation is not present on an annotation declaration, the annotation + * is applicable to any code element, except type parameters, type usages, expressions, and files. + * + * @property allowedTargets list of allowed annotation targets + */ +target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class target(vararg val allowedTargets: AnnotationTarget) + +/** + * This special meta-annotation is used to declare an annotation and to set its base properties. + * So a class in Kotlin is an annotation if and only if it has the "annotation" meta-annotation. + * + * @property retention determines whether the annotation is stored in binary output and visible for reflection. By default, both are true. + * @property repeatable true if annotation is repeatable (applicable twice or more on a single code element), otherwise false (default) + */ +target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class annotation ( + val retention: AnnotationRetention = AnnotationRetention.RUNTIME, + val repeatable: Boolean = false +) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 5c8a0a59259..4f4141383e9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -48,6 +48,7 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName; public class KotlinBuiltIns { public static final Name BUILT_INS_PACKAGE_NAME = Name.identifier("kotlin"); public static final FqName BUILT_INS_PACKAGE_FQ_NAME = FqName.topLevel(BUILT_INS_PACKAGE_NAME); + public static final FqName ANNOTATION_PACKAGE_FQ_NAME = BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier("annotation")); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -115,7 +116,7 @@ public class KotlinBuiltIns { PackageFragmentProvider packageFragmentProvider = BuiltinsPackage.createBuiltInPackageFragmentProvider( storageManager, builtInsModule, - setOf(BUILT_INS_PACKAGE_FQ_NAME, BuiltinsPackage.getKOTLIN_REFLECT_FQ_NAME()), + setOf(BUILT_INS_PACKAGE_FQ_NAME, ANNOTATION_PACKAGE_FQ_NAME, BuiltinsPackage.getKOTLIN_REFLECT_FQ_NAME()), new BuiltInFictitiousFunctionClassFactory(storageManager, builtInsModule), new Function1() { @Override @@ -175,6 +176,8 @@ public class KotlinBuiltIns { public final FqName noinline = fqName("noinline"); public final FqName inlineOptions = fqName("inlineOptions"); public final FqName extension = fqName("extension"); + public final FqName target = annotationName("target"); + public final FqName annotation = annotationName("annotation"); public final FqNameUnsafe kClass = new FqName("kotlin.reflect.KClass").toUnsafe(); @@ -198,6 +201,11 @@ public class KotlinBuiltIns { private static FqName fqName(@NotNull String simpleName) { return BUILT_INS_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)); } + + @NotNull + private static FqName annotationName(@NotNull String simpleName) { + return ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier(simpleName)); + } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt index be111eb74b8..335003c5aef 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/BuiltInFictitiousFunctionClassFactory.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.builtins.functions +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor.Kind import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor @@ -37,6 +38,8 @@ public class BuiltInFictitiousFunctionClassFactory( companion object { platformStatic public fun parseClassName(className: String, packageFqName: FqName): KindWithArity? { + // There is no functions in kotlin.annotation package + if (packageFqName == KotlinBuiltIns.ANNOTATION_PACKAGE_FQ_NAME) return null val kind = FunctionClassDescriptor.Kind.byPackage(packageFqName) ?: return null val prefix = kind.classNamePrefix diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.java b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.java index cec630a64a6..abaf86be75c 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.java @@ -43,6 +43,7 @@ public final class TopDownAnalyzerFacadeForJS { public static final List DEFAULT_IMPORTS = ImmutableList.of( new ImportPath("java.lang.*"), new ImportPath("kotlin.*"), + new ImportPath("kotlin.annotation.*"), new ImportPath("kotlin.js.*") ); diff --git a/jslib_files.xml b/jslib_files.xml index 6b228850dba..2c6a294e24e 100644 --- a/jslib_files.xml +++ b/jslib_files.xml @@ -2,6 +2,7 @@ + @@ -16,6 +17,7 @@ + From 7a6e5f66bd8c70d1101ff9e6ed54757799c81578 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 8 Jul 2015 18:37:54 +0300 Subject: [PATCH 251/450] Regression test: char + int = char --- compiler/testData/diagnostics/tests/regressions/intchar.kt | 1 + compiler/testData/diagnostics/tests/regressions/intchar.txt | 3 +++ .../kotlin/checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/regressions/intchar.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/intchar.txt diff --git a/compiler/testData/diagnostics/tests/regressions/intchar.kt b/compiler/testData/diagnostics/tests/regressions/intchar.kt new file mode 100644 index 00000000000..edfb8c134cb --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/intchar.kt @@ -0,0 +1 @@ +val x: Char = '1'.plus(1) diff --git a/compiler/testData/diagnostics/tests/regressions/intchar.txt b/compiler/testData/diagnostics/tests/regressions/intchar.txt new file mode 100644 index 00000000000..2f0f30574f6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/intchar.txt @@ -0,0 +1,3 @@ +package + +internal val x: kotlin.Char = \u0032 ('2') diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 1558a70e534..447854e66f9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10530,6 +10530,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("intchar.kt") + public void testIntchar() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/intchar.kt"); + doTest(fileName); + } + @TestMetadata("itselfAsUpperBound.kt") public void testItselfAsUpperBound() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/itselfAsUpperBound.kt"); From 1eac4d67de657517ba1f0c78897afd678c405997 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 26 Jun 2015 16:30:20 +0300 Subject: [PATCH 252/450] "annotation" is now parsed as an identifier. It is no longer a soft keyword. Sometimes it's allowed to parse "annotation" unescaped even if other annotations must be escaped. A set of annotations and their options tests. A swarm of existing tests fixed (mostly kotlin.annotation.annotation() added to txt-files). STUB_VERSION increased. Some quick fixes slightly changed. --- .../jetbrains/kotlin/diagnostics/Errors.java | 2 - .../rendering/DefaultErrorMessages.java | 1 - .../org/jetbrains/kotlin/lexer/JetTokens.java | 5 +- .../jetbrains/kotlin/psi/JetClassOrObject.kt | 12 +- .../jetbrains/kotlin/psi/addRemoveModifier.kt | 2 +- .../stubs/elements/JetFileElementType.java | 2 +- .../kotlin/resolve/DeclarationsChecker.java | 3 - .../resolve/calls/CallExpressionResolver.java | 2 +- compiler/testData/builtin-classes.txt | 166 +++++++++++++++- .../staticFields/AnnotationClass.txt | 14 +- .../staticFields/AnnotationTrait.txt | 14 +- ...singEnumReferencedInAnnotationArgument.txt | 2 +- .../annotations/AnnotatedConstructor.txt | 2 +- .../annotations/AnnotatedLocalObjectFun.txt | 2 +- .../AnnotatedLocalObjectProperty.txt | 2 +- .../tests/annotations/AnnotatedLoop.txt | 2 +- .../tests/annotations/AnnotatedResultType.txt | 2 +- .../tests/annotations/AnnotatedTryCatch.txt | 2 +- .../AnnotationAsDefaultParameter.kt | 5 + .../AnnotationAsDefaultParameter.txt | 24 +++ .../AnnotationForClassTypeParameter.txt | 4 +- .../AnnotationForFunctionTypeParameter.txt | 4 +- .../tests/annotations/AnnotationOnObject.txt | 2 +- .../annotations/AnnotationsForClasses.txt | 4 +- .../AnnotationsForPropertyTypeParameter.txt | 4 +- .../tests/annotations/BasicAnnotations.txt | 6 +- .../tests/annotations/ConstructorCall.txt | 10 +- .../tests/annotations/DanglingInScript.kt | 2 +- .../tests/annotations/DanglingMixed.txt | 4 +- .../tests/annotations/DanglingNoBrackets.txt | 2 +- .../annotations/DanglingWithBrackets.txt | 2 +- .../JavaAnnotationConstructors.txt | 4 +- ...allyRecursivelyAnnotatedGlobalFunction.txt | 2 +- .../annotations/RecursivelyAnnotated.txt | 2 +- .../RecursivelyAnnotatedFunctionParameter.txt | 2 +- .../RecursivelyAnnotatedGlobalFunction.txt | 2 +- .../RecursivelyAnnotatedGlobalProperty.txt | 2 +- .../RecursivelyAnnotatedParameter.txt | 2 +- .../RecursivelyAnnotatedParameterType.txt | 2 +- .../RecursivelyAnnotatedParameterWithAt.txt | 2 +- .../RecursivelyAnnotatedProperty.txt | 2 +- .../WrongAnnotationArgsOnObject.txt | 2 +- .../annotations/annotationInheritance.txt | 8 +- .../tests/annotations/annotationModifier.kt | 12 +- .../tests/annotations/annotationModifier.txt | 14 +- .../booleanLocalVal.txt | 2 +- .../compareAndEquals.txt | 2 +- .../enumConst.txt | 2 +- .../javaProperties.txt | 2 +- .../kotlinProperties.txt | 2 +- .../strings.txt | 2 +- .../annotationsOnLambdaAsCallArgument.txt | 2 +- .../tests/annotations/atAnnotationResolve.txt | 2 +- .../annotations/extensionFunctionType.txt | 2 +- .../forParameterAnnotationResolve.txt | 2 +- .../invalidTypesInAnnotationConstructor.txt | 36 ++-- .../tests/annotations/kt1860-positive.txt | 2 +- .../annotations/kt1886annotationBody.txt | 20 +- .../annotations/missingValOnParameter.txt | 2 +- .../tests/annotations/noNameProperty.txt | 2 +- .../tests/annotations/onExpression.txt | 2 +- .../tests/annotations/onFunctionParameter.txt | 2 +- .../tests/annotations/onInitializer.txt | 2 +- .../diagnostics/tests/annotations/onLoops.txt | 2 +- .../tests/annotations/onLoopsUnreachable.txt | 2 +- .../tests/annotations/onMultiDeclaration.txt | 2 +- .../tests/annotations/options/annotation.kt | 17 ++ .../tests/annotations/options/annotation.txt | 59 ++++++ .../annotations/options/annotationAsArg.kt | 14 ++ .../annotations/options/annotationAsArg.txt | 13 ++ .../options/annotationAsArgComplex.kt | 10 + .../options/annotationAsArgComplex.txt | 12 ++ .../tests/annotations/options/brackets.kt | 3 + .../tests/annotations/options/brackets.txt | 15 ++ .../tests/annotations/options/repeatable.kt | 3 + .../tests/annotations/options/repeatable.txt | 15 ++ .../tests/annotations/options/retention.kt | 3 + .../tests/annotations/options/retention.txt | 15 ++ .../tests/annotations/options/target.kt | 5 + .../tests/annotations/options/target.txt | 16 ++ .../function/abstractClassConstructors.txt | 2 +- .../FunctionWithMissingNames.txt | 2 +- .../illegalModifiersOnClass.txt | 2 +- .../deparenthesize/annotatedSafeCall.txt | 2 +- .../tests/deprecated/annotationUsage.txt | 4 +- .../duplicateJvmSignature/missingNames.txt | 4 +- .../tests/enum/modifiersOnEnumEntry.kt | 2 +- .../tests/enum/modifiersOnEnumEntry.txt | 10 + .../tests/evaluate/divisionByZero.txt | 2 +- .../tests/functionAsExpression/Common.txt | 2 +- .../functionAsExpression/WithoutBody.txt | 2 +- .../inner/classesInClassObjectHeader.txt | 2 +- .../tests/inner/illegalModifier.txt | 2 +- .../inner/selfAnnotationForClassObject.txt | 4 +- .../tests/modifiers/IllegalModifiers.kt | 8 +- .../tests/modifiers/IllegalModifiers.txt | 10 +- .../primaryConstructorMissingKeyword.txt | 2 +- .../recovery/namelessToplevelDeclarations.txt | 2 +- .../resolveAnnotatedLambdaArgument.txt | 2 +- .../ctrsAnnotationResolve.txt | 4 +- .../tests/when/AnnotatedWhenStatement.txt | 2 +- .../ClassObjectAnnotatedWithItsKClass.txt | 2 +- .../array.txt | 4 +- .../simple.txt | 8 +- .../vararg.txt | 4 +- .../kotlinAnnotationWithVarargArgument.txt | 2 +- .../defaultValueMustBeConstant.txt | 4 +- .../kClassArrayInAnnotationsInVariance.txt | 4 +- .../kClassArrayInAnnotationsOutVariance.txt | 4 +- .../annotations/kClass/kClassInAnnotation.txt | 6 +- .../kClass/kClassInAnnotationsInVariance.txt | 4 +- .../kClass/kClassInAnnotationsOutVariance.txt | 4 +- .../annotations/kClass/kClassInvariantTP.txt | 4 +- ...kClassOutArrayInAnnotationsOutVariance.txt | 2 +- .../kotlinAnnotation.txt | 2 +- .../annotations/qualifiedCallValue.txt | 10 +- .../annotations/AnnotatedAnnotation.txt | 2 +- .../AnnotationInAnnotationArguments.txt | 6 +- .../EnumArgumentWithCustomToString.txt | 4 +- .../MultiDimensionalArrayMethod.txt | 2 +- .../annotations/SimpleAnnotation.txt | 2 +- .../classMembers/ClassObjectPropertyField.txt | 2 +- .../annotations/classMembers/Constructor.txt | 2 +- .../classMembers/DelegatedProperty.txt | 2 +- .../annotations/classMembers/EnumArgument.txt | 2 +- .../annotations/classMembers/Function.txt | 2 +- .../annotations/classMembers/Getter.txt | 2 +- .../classMembers/PropertyField.txt | 2 +- .../annotations/classMembers/Setter.txt | 2 +- .../classes/AnnotationInClassObject.txt | 4 +- .../classes/ClassInClassObject.txt | 2 +- .../annotations/classes/ClassObject.txt | 2 +- .../classes/DollarsInAnnotationName.txt | 4 +- .../annotations/classes/EnumArgument.txt | 2 +- .../classes/MultipleAnnotations.txt | 6 +- .../annotations/classes/NestedAnnotation.txt | 2 +- .../annotations/classes/NestedClass.txt | 2 +- .../annotations/classes/Retention.txt | 2 +- .../annotations/classes/Simple.txt | 2 +- .../annotations/classes/WithArgument.txt | 16 +- .../classes/WithMultipleArguments.txt | 2 +- .../packageMembers/DelegatedProperty.txt | 2 +- .../packageMembers/EnumArgument.txt | 2 +- .../packageMembers/EnumArrayArgument.txt | 2 +- .../annotations/packageMembers/Function.txt | 2 +- .../annotations/packageMembers/Getter.txt | 2 +- .../packageMembers/PropertyField.txt | 2 +- .../annotations/packageMembers/Setter.txt | 2 +- .../packageMembers/StringArrayArgument.txt | 2 +- .../annotations/parameters/Constructor.txt | 4 +- .../parameters/EnumConstructor.txt | 4 +- .../parameters/ExtensionFunction.txt | 2 +- .../parameters/ExtensionFunctionInClass.txt | 2 +- .../parameters/ExtensionPropertySetter.txt | 2 +- .../parameters/FunctionInClass.txt | 2 +- .../parameters/FunctionInTrait.txt | 2 +- .../parameters/InnerClassConstructor.txt | 2 +- .../parameters/ManyAnnotations.txt | 8 +- .../parameters/PropertySetterInClass.txt | 2 +- .../parameters/TopLevelFunction.txt | 2 +- .../parameters/TopLevelPropertySetter.txt | 4 +- .../propertiesWithoutBackingFields/Class.txt | 2 +- .../ClassObject.txt | 2 +- .../ExtensionsWithSameNameClass.txt | 6 +- .../ExtensionsWithSameNamePackage.txt | 6 +- .../NestedTrait.txt | 2 +- .../TopLevel.txt | 2 +- .../propertiesWithoutBackingFields/Trait.txt | 2 +- .../TraitClassObject.txt | 2 +- .../annotations/types/ReceiverParameter.txt | 2 +- .../types/SimpleTypeAnnotation.txt | 2 +- .../annotations/types/SupertypesAndBounds.txt | 2 +- .../types/TypeAnnotationWithArguments.txt | 2 +- .../fromLoadJava/classObjectAnnotation.txt | 2 +- .../platformNames/functionName.txt | 2 +- compiler/testData/psi/SimpleModifiers.txt | 14 +- compiler/testData/psi/SoftKeywords.txt | 28 ++- .../testData/psi/annotation/Annotations.txt | 14 +- .../psi/annotation/Annotations_ERR.txt | 14 +- ...outFileAnnotationAndPackageDeclaration.txt | 7 +- .../annotation/options/annotAsArgComplex.kt | 9 + .../annotation/options/annotAsArgComplex.txt | 89 +++++++++ .../psi/annotation/options/annotation.kt | 20 ++ .../psi/annotation/options/annotation.txt | 188 ++++++++++++++++++ .../psi/annotation/options/annotationAsArg.kt | 14 ++ .../annotation/options/annotationAsArg.txt | 144 ++++++++++++++ .../options/annotationAsArgComplex.kt | 9 + .../options/annotationAsArgComplex.txt | 89 +++++++++ .../testData/psi/annotation/options/java.kt | 10 + .../testData/psi/annotation/options/java.txt | 118 +++++++++++ .../testData/psi/annotation/options/local.kt | 5 + .../testData/psi/annotation/options/local.txt | 62 ++++++ .../psi/annotation/options/options.kt | 12 ++ .../psi/annotation/options/options.txt | 173 ++++++++++++++++ compiler/testData/renderer/Classes.kt | 4 +- compiler/testData/renderer/KeywordsInNames.kt | 2 +- .../annotationArguments/annotation.txt | 6 +- .../annotationArguments/enum.txt | 4 +- .../annotationArguments/primitiveArrays.txt | 2 +- .../annotationArguments/primitives.txt | 2 +- .../annotationArguments/string.txt | 4 +- .../annotationArguments/varargs.txt | 4 +- .../builtinsSerializer/annotationTargets.txt | 2 +- .../checkers/JetDiagnosticsTestGenerated.java | 57 ++++++ .../parsing/JetParsingTestGenerated.java | 51 +++++ .../stubBuilder/ClassClsStubBuilder.kt | 1 - .../basic/common/annotations/Annotated.kt | 3 + .../common/annotations/AnnotationArguments.kt | 4 + .../common/annotations/AnnotationTarget.kt | 3 + .../testData/keywords/AfterClassProperty.kt | 1 - .../testData/keywords/AfterClasses.kt | 1 - .../testData/keywords/AfterFuns.kt | 1 - .../testData/keywords/FileKeyword.kt | 1 - .../keywords/GlobalPropertyAccessors.kt | 1 - .../testData/keywords/InClassBeforeFun.kt | 1 - .../testData/keywords/InClassScope.kt | 1 - .../keywords/InTopScopeAfterPackage.kt | 1 - .../testData/keywords/PropertyAccessors.kt | 1 - .../testData/keywords/PropertyAccessors2.kt | 1 - .../testData/keywords/PropertySetter.kt | 1 - .../testData/keywords/TopScope.kt | 1 - .../test/JSBasicCompletionTestGenerated.java | 18 ++ .../test/JvmBasicCompletionTestGenerated.java | 18 ++ .../MakeClassAnAnnotationClassFix.java | 19 +- .../idea/refactoring/jetRefactoringUtil.kt | 8 +- .../highlighter/TypesAndAnnotations.kt | 4 +- idea/testData/stubs/AnnotationClass.expected | 7 +- .../stubs/SecondaryConstructors.expected | 7 +- idea/testData/stubs/TypeAnnotation.expected | 14 +- .../annotationInSameFile.kt | 2 +- .../annotationInSameFile/annotations.txt | 8 +- 231 files changed, 1915 insertions(+), 334 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotation.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotation.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/brackets.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/brackets.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/repeatable.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/repeatable.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/retention.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/retention.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/target.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/target.txt create mode 100644 compiler/testData/psi/annotation/options/annotAsArgComplex.kt create mode 100644 compiler/testData/psi/annotation/options/annotAsArgComplex.txt create mode 100644 compiler/testData/psi/annotation/options/annotation.kt create mode 100644 compiler/testData/psi/annotation/options/annotation.txt create mode 100644 compiler/testData/psi/annotation/options/annotationAsArg.kt create mode 100644 compiler/testData/psi/annotation/options/annotationAsArg.txt create mode 100644 compiler/testData/psi/annotation/options/annotationAsArgComplex.kt create mode 100644 compiler/testData/psi/annotation/options/annotationAsArgComplex.txt create mode 100644 compiler/testData/psi/annotation/options/java.kt create mode 100644 compiler/testData/psi/annotation/options/java.txt create mode 100644 compiler/testData/psi/annotation/options/local.kt create mode 100644 compiler/testData/psi/annotation/options/local.txt create mode 100644 compiler/testData/psi/annotation/options/options.kt create mode 100644 compiler/testData/psi/annotation/options/options.txt create mode 100644 idea/idea-completion/testData/basic/common/annotations/Annotated.kt create mode 100644 idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt create mode 100644 idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 0237d6a49e0..dd94bff29ed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -124,8 +124,6 @@ public interface Errors { DiagnosticFactory0 ANNOTATION_CLASS_WITH_BODY = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INVALID_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 NULLABLE_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 ILLEGAL_ANNOTATION_KEYWORD = - DiagnosticFactory0.create(ERROR, modifierSetPosition(JetTokens.ANNOTATION_KEYWORD)); DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_CONST = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 076ff54bf19..41ec53aaf5e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -613,7 +613,6 @@ public class DefaultErrorMessages { MAP.put(ANNOTATION_CLASS_WITH_BODY, "Body is not allowed for annotation class"); MAP.put(INVALID_TYPE_OF_ANNOTATION_MEMBER, "Invalid type of annotation member"); MAP.put(NULLABLE_TYPE_OF_ANNOTATION_MEMBER, "An annotation parameter cannot be nullable"); - MAP.put(ILLEGAL_ANNOTATION_KEYWORD, "''annotation'' keyword is only applicable for class"); MAP.put(ANNOTATION_PARAMETER_MUST_BE_CONST, "An annotation parameter must be a compile-time constant"); MAP.put(ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST, "An enum annotation parameter must be a enum constant"); MAP.put(ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL, "An annotation parameter must be a class literal (T::class)"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java b/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java index 30d77adfab9..f3e44c2f7d1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java @@ -145,7 +145,6 @@ public interface JetTokens { JetModifierKeywordToken ENUM_KEYWORD = JetModifierKeywordToken.softKeywordModifier("enum"); JetModifierKeywordToken OPEN_KEYWORD = JetModifierKeywordToken.softKeywordModifier("open"); JetModifierKeywordToken INNER_KEYWORD = JetModifierKeywordToken.softKeywordModifier("inner"); - JetModifierKeywordToken ANNOTATION_KEYWORD = JetModifierKeywordToken.softKeywordModifier("annotation"); JetModifierKeywordToken OVERRIDE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("override"); JetModifierKeywordToken PRIVATE_KEYWORD = JetModifierKeywordToken.softKeywordModifier("private"); JetModifierKeywordToken PUBLIC_KEYWORD = JetModifierKeywordToken.softKeywordModifier("public"); @@ -172,7 +171,7 @@ public interface JetTokens { ); TokenSet SOFT_KEYWORDS = TokenSet.create(FILE_KEYWORD, IMPORT_KEYWORD, WHERE_KEYWORD, BY_KEYWORD, GET_KEYWORD, - SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD, + SET_KEYWORD, ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, CATCH_KEYWORD, FINALLY_KEYWORD, OUT_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD, DYNAMIC_KEYWORD, COMPANION_KEYWORD, CONSTRUCTOR_KEYWORD, INIT_KEYWORD, SEALED_KEYWORD @@ -185,7 +184,7 @@ public interface JetTokens { */ JetModifierKeywordToken[] MODIFIER_KEYWORDS_ARRAY = new JetModifierKeywordToken[] { - ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, ANNOTATION_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD, + ABSTRACT_KEYWORD, ENUM_KEYWORD, OPEN_KEYWORD, INNER_KEYWORD, OVERRIDE_KEYWORD, PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD, REIFIED_KEYWORD, COMPANION_KEYWORD, SEALED_KEYWORD }; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt index b58e39d1c60..7b3482cd6f9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt @@ -25,6 +25,7 @@ import com.intellij.psi.impl.CheckUtil import com.intellij.psi.impl.source.codeStyle.CodeEditUtil import com.intellij.psi.stubs.IStubElementType import org.jetbrains.kotlin.JetNodeTypes +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.stubs.KotlinClassOrObjectStub import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes @@ -64,7 +65,16 @@ abstract public class JetClassOrObject : JetTypeParameterListOwnerStub = getBody()?.getSecondaryConstructors().orEmpty() - public fun isAnnotation(): Boolean = hasModifier(JetTokens.ANNOTATION_KEYWORD) + public fun isAnnotation(): Boolean = hasAnnotation(KotlinBuiltIns.FQ_NAMES.annotation.shortName().asString()) + + private fun hasAnnotation(name: String): Boolean { + for (entry in getAnnotationEntries()) { + val typeReference = entry.getTypeReference() + val userType = typeReference?.getStubOrPsiChild(JetStubElementTypes.USER_TYPE) ?: continue + if (name == userType.getReferencedName()) return true + } + return false + } public override fun delete() { CheckUtil.checkWritable(this); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt index 74519420943..67ee4302bc7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/addRemoveModifier.kt @@ -102,4 +102,4 @@ private val MODIFIERS_ORDER = listOf(PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_ FINAL_KEYWORD, OPEN_KEYWORD, ABSTRACT_KEYWORD, OVERRIDE_KEYWORD, INNER_KEYWORD, - ANNOTATION_KEYWORD, ENUM_KEYWORD, COMPANION_KEYWORD) + ENUM_KEYWORD, COMPANION_KEYWORD) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java index 5a4320a31f5..0722bc11f1f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/stubs/elements/JetFileElementType.java @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.psi.stubs.impl.KotlinFileStubImpl; import java.io.IOException; public class JetFileElementType extends IStubFileElementType { - public static final int STUB_VERSION = 49; + public static final int STUB_VERSION = 50; private static final String NAME = "kotlin.FILE"; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index f84e64e8f68..b2dbd24d6b0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -128,9 +128,6 @@ public class DeclarationsChecker { if (declaration.hasModifier(JetTokens.ENUM_KEYWORD)) { trace.report(ILLEGAL_ENUM_ANNOTATION.on(declaration)); } - if (declaration.hasModifier(JetTokens.ANNOTATION_KEYWORD)) { - trace.report(ILLEGAL_ANNOTATION_KEYWORD.on(declaration)); - } } private void checkModifiersAndAnnotationsInPackageDirective(JetFile file) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index c8018e605c4..51cad1c463d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -269,7 +269,7 @@ public class CallExpressionResolver { else if (parent instanceof JetParameter) { JetClass jetClass = PsiTreeUtil.getParentOfType(parent, JetClass.class); if (jetClass != null) { - return jetClass.hasModifier(JetTokens.ANNOTATION_KEYWORD); + return jetClass.isAnnotation(); } } return false; diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 4f1e251a60d..f161e456fa9 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -8,6 +8,154 @@ public fun kotlin.Any?.toString(): kotlin.String public interface Annotation { } +public final enum class AnnotationRetention : kotlin.Enum { + public enum entry SOURCE : kotlin.annotation.AnnotationRetention { + /*primary*/ private constructor SOURCE() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry BINARY : kotlin.annotation.AnnotationRetention { + /*primary*/ private constructor BINARY() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry RUNTIME : kotlin.annotation.AnnotationRetention { + /*primary*/ private constructor RUNTIME() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + /*primary*/ private constructor AnnotationRetention() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): kotlin.AnnotationRetention + public final /*synthesized*/ fun values(): kotlin.Array +} + +public final enum class AnnotationTarget : kotlin.Enum { + public enum entry PACKAGE : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor PACKAGE() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry CLASSIFIER : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor CLASSIFIER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry ANNOTATION_CLASS : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor ANNOTATION_CLASS() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry TYPE_PARAMETER : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor TYPE_PARAMETER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry PROPERTY : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor PROPERTY() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry FIELD : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor FIELD() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry LOCAL_VARIABLE : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor LOCAL_VARIABLE() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry VALUE_PARAMETER : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor VALUE_PARAMETER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry CONSTRUCTOR : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor CONSTRUCTOR() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry FUNCTION : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor FUNCTION() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry PROPERTY_GETTER : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor PROPERTY_GETTER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry PROPERTY_SETTER : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor PROPERTY_SETTER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry TYPE : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor TYPE() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry EXPRESSION : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor EXPRESSION() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + public enum entry FILE : kotlin.annotation.AnnotationTarget { + /*primary*/ private constructor FILE() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + } + + /*primary*/ private constructor AnnotationTarget() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): kotlin.AnnotationTarget + public final /*synthesized*/ fun values(): kotlin.Array +} + public open class Any { /*primary*/ public constructor Any() } @@ -1261,7 +1409,15 @@ public object Unit { /*primary*/ private constructor Unit() } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) public final annotation class data : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) public final annotation class annotation : kotlin.Annotation { + /*primary*/ public constructor __annotation(/*0*/ retention: kotlin.AnnotationRetention = ..., /*1*/ repeatable: kotlin.Boolean = ...) + internal final val repeatable: kotlin.Boolean + internal final fun (): kotlin.Boolean + internal final val retention: kotlin.AnnotationRetention + internal final fun (): kotlin.AnnotationRetention +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) public final annotation class data : kotlin.Annotation { /*primary*/ public constructor data() } @@ -1299,6 +1455,12 @@ kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, Annotati internal final fun (): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class tailRecursive : kotlin.Annotation { +kotlin.target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class tailRecursive : kotlin.Annotation { /*primary*/ public constructor tailRecursive() } + +kotlin.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) public final annotation class target : kotlin.Annotation { + /*primary*/ public constructor target(/*0*/ vararg allowedTargets: kotlin.AnnotationTarget /*kotlin.Array*/) + internal final val allowedTargets: kotlin.Array + internal final fun (): kotlin.Array +} diff --git a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt index 04893348d74..72aa9140eaf 100644 --- a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt +++ b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt @@ -1,36 +1,36 @@ package test -internal final annotation class AByte : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AByte : kotlin.Annotation { public constructor AByte(/*0*/ kotlin.Byte) internal final val value: kotlin.Byte } -internal final annotation class AChar : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AChar : kotlin.Annotation { public constructor AChar(/*0*/ kotlin.Char) internal final val value: kotlin.Char } -internal final annotation class ADouble : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ADouble : kotlin.Annotation { public constructor ADouble(/*0*/ kotlin.Double) internal final val value: kotlin.Double } -internal final annotation class AFloat : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AFloat : kotlin.Annotation { public constructor AFloat(/*0*/ kotlin.Float) internal final val value: kotlin.Float } -internal final annotation class AInt : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AInt : kotlin.Annotation { public constructor AInt(/*0*/ kotlin.Int) internal final val value: kotlin.Int } -internal final annotation class ALong : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ALong : kotlin.Annotation { public constructor ALong(/*0*/ kotlin.Long) internal final val value: kotlin.Long } -internal final annotation class AString : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AString : kotlin.Annotation { public constructor AString(/*0*/ kotlin.String) internal final val value: kotlin.String } diff --git a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt index 98cd5456308..d9be3db2f41 100644 --- a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt +++ b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt @@ -1,36 +1,36 @@ package test -internal final annotation class AByte : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AByte : kotlin.Annotation { public constructor AByte(/*0*/ kotlin.Byte) internal final val value: kotlin.Byte } -internal final annotation class AChar : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AChar : kotlin.Annotation { public constructor AChar(/*0*/ kotlin.Char) internal final val value: kotlin.Char } -internal final annotation class ADouble : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ADouble : kotlin.Annotation { public constructor ADouble(/*0*/ kotlin.Double) internal final val value: kotlin.Double } -internal final annotation class AFloat : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AFloat : kotlin.Annotation { public constructor AFloat(/*0*/ kotlin.Float) internal final val value: kotlin.Float } -internal final annotation class AInt : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AInt : kotlin.Annotation { public constructor AInt(/*0*/ kotlin.Int) internal final val value: kotlin.Int } -internal final annotation class ALong : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ALong : kotlin.Annotation { public constructor ALong(/*0*/ kotlin.Long) internal final val value: kotlin.Long } -internal final annotation class AString : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AString : kotlin.Annotation { public constructor AString(/*0*/ kotlin.String) internal final val value: kotlin.String } diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt index 2647ef88568..cb2b210d1d8 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { public constructor Anno(/*0*/ e: [ERROR : test.E]) internal final val e: [ERROR : test.E] } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt index 24db66192dc..be859092854 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt @@ -8,7 +8,7 @@ internal final class Annotated { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt index 21dbc11cf3e..a8cb2ef610e 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt index f382ca4e9e7..b1d5e2f3548 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Int -internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt index 21dbc11cf3e..a8cb2ef610e 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt index bf4e310fa60..5ca42a7522c 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt @@ -2,7 +2,7 @@ package internal fun foo(): @[My(x = IntegerValueType(42))] kotlin.Int -internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt index 8df46703222..ed5812bd39b 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ arg: kotlin.Int): kotlin.Int -internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt new file mode 100644 index 00000000000..4d09e688396 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt @@ -0,0 +1,5 @@ +annotation class Base(val x: Int) + +annotation class UseBase(val b: Base = Base(0)) + +UseBase class My diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt new file mode 100644 index 00000000000..8da2e8abffe --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt @@ -0,0 +1,24 @@ +package + +kotlin.annotation.annotation() internal final annotation class Base : kotlin.Annotation { + public constructor Base(/*0*/ x: kotlin.Int) + internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +UseBase() internal final class My { + public constructor My() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation() internal final annotation class UseBase : kotlin.Annotation { + public constructor UseBase(/*0*/ b: Base = ...) + internal final val b: Base + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt index 62b649f6ceb..63336f0c387 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt @@ -1,13 +1,13 @@ package -internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt index 018ee58aa90..a8f7f0581dc 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt @@ -2,14 +2,14 @@ package internal fun topFun(): kotlin.Int -internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt index 8eebf0033a6..ac01753b989 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt @@ -2,7 +2,7 @@ package package test { - internal final annotation class A : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int = ..., /*1*/ b: kotlin.String = ..., /*2*/ c: kotlin.String) internal final val a: kotlin.Int internal final val b: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt index a6c370183cd..db0de398de3 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt @@ -1,13 +1,13 @@ package -java.lang.Deprecated() internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.Deprecated() internal final annotation class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -java.lang.Deprecated() internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.Deprecated() internal final annotation class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt index d7945ba9075..2cd7c1a72e4 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt @@ -2,14 +2,14 @@ package internal val topProp: kotlin.Int = 12 -internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt index ca8b44cb323..c7a9a1acc1e 100644 --- a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt @@ -7,14 +7,14 @@ my2() internal fun foo4(): kotlin.Unit my2() internal fun foo41(): kotlin.Unit my2(i = IntegerValueType(2)) internal fun foo42(): kotlin.Unit -internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class my1 : kotlin.Annotation { public constructor my1(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ internal final annotation class my1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class my2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class my2 : kotlin.Annotation { public constructor my2(/*0*/ i: kotlin.Int = ...) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt index 0c2884b2794..fe2358c16c2 100644 --- a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt +++ b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt @@ -7,14 +7,14 @@ internal fun foo(): kotlin.Unit internal fun javaClass(): java.lang.Class internal fun kotlin.String.invoke(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ a: kotlin.Int) internal final val a: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ a: Ann1) internal final val a: Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -30,7 +30,7 @@ internal final annotation class Ann2 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ a: Ann1 = ...) internal final val a: Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -38,7 +38,7 @@ internal final annotation class Ann3 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann4 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann4 : kotlin.Annotation { public constructor Ann4(/*0*/ value: kotlin.String) internal final val value: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingInScript.kt b/compiler/testData/diagnostics/tests/annotations/DanglingInScript.kt index e5ea165258e..aaa6c306aeb 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingInScript.kt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingInScript.kt @@ -1,5 +1,5 @@ // FILE: script.kts -annotation class Ann +@annotation class Ann @Ann \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt b/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt index f6b20078b1e..7d717629e2a 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt @@ -1,13 +1,13 @@ package -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt b/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt index 9c246457a26..73272a69e57 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt @@ -1,6 +1,6 @@ package -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt b/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt index ecc8869fdd9..49b1179cd42 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt @@ -1,6 +1,6 @@ package -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt index f5009eff58f..d7458d0cc85 100644 --- a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt +++ b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt @@ -1,13 +1,13 @@ package -java.lang.annotation.Retention(value = RetentionPolicy.CLASS) internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.CLASS) internal final annotation class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt index 1a968299ed7..a93c3ee35e0 100644 --- a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt +++ b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt @@ -3,7 +3,7 @@ package ann() internal fun bar(): kotlin.Int ann() internal fun foo(): kotlin.Int -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt index fb9a04575dc..cd8b8330b27 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt @@ -1,6 +1,6 @@ package -RecursivelyAnnotated(x = IntegerValueType(1)) internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +RecursivelyAnnotated(x = IntegerValueType(1)) kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt index 06458119e3f..7e02bec3b7f 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ ann() x: kotlin.Int): kotlin.Int -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt index d2c0ba12aba..2a8ee5a14b7 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt @@ -2,7 +2,7 @@ package ann() internal fun foo(): kotlin.Int -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt index f8efd97dd87..e876d7bfe73 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt @@ -2,7 +2,7 @@ package ann(x = 1) internal val x: kotlin.Int = 1 -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt index f2ba95e7bb6..63856371b5a 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt @@ -1,6 +1,6 @@ package -internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt index 65b104b7cec..05e163c56fd 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt @@ -1,6 +1,6 @@ package -internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int) internal final val x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt index f2ba95e7bb6..63856371b5a 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt @@ -1,6 +1,6 @@ package -internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt index 3e9d365c990..2083a6eef89 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt @@ -8,7 +8,7 @@ internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt index 21d20839c5c..44f8f2ffc6c 100644 --- a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt @@ -3,7 +3,7 @@ package package test { internal val some: test.SomeObject - internal final annotation class BadAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class BadAnnotation : kotlin.Annotation { public constructor BadAnnotation(/*0*/ s: kotlin.String) internal final val s: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt index f65d2209b73..4bcbbaf7487 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt @@ -2,28 +2,28 @@ package internal val a: T -internal final annotation class Ann : C { +kotlin.annotation.annotation() internal final annotation class Ann : C { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : T { +kotlin.annotation.annotation() internal final annotation class Ann2 : T { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann3 : T { +kotlin.annotation.annotation() internal final annotation class Ann3 : T { public constructor Ann3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann4 : C, T { +kotlin.annotation.annotation() internal final annotation class Ann4 : C, T { public constructor Ann4() public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt index 8c5e211eead..a62a21476bb 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt @@ -1,15 +1,15 @@ annotation class B class A { - annotation companion object {} + annotation companion object {} } -annotation object O {} +annotation object O {} -annotation interface T {} +annotation interface T {} -annotation fun f() = 0 +annotation fun f() = 0 -annotation val x = 0 +annotation val x = 0 -annotation var y = 0 +annotation var y = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt index a576fe07507..89ed33fb51f 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt @@ -1,8 +1,8 @@ package -internal val x: kotlin.Int = 0 -internal var y: kotlin.Int -internal fun f(): kotlin.Int +kotlin.annotation.annotation() internal val x: kotlin.Int = 0 +kotlin.annotation.annotation() internal var y: kotlin.Int +kotlin.annotation.annotation() internal fun f(): kotlin.Int internal final class A { public constructor A() @@ -10,7 +10,7 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public companion object Companion { + kotlin.annotation.annotation() public companion object Companion { private constructor Companion() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -18,21 +18,21 @@ internal final class A { } } -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { public constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal object O { +kotlin.annotation.annotation() internal object O { private constructor O() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal interface T : kotlin.Annotation { +kotlin.annotation.annotation() internal interface T : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt index 98b3a61f3a6..0cebb69f97e 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Boolean /*kotlin.BooleanArray*/) internal final val i: kotlin.BooleanArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt index 98b3a61f3a6..0cebb69f97e 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Boolean /*kotlin.BooleanArray*/) internal final val i: kotlin.BooleanArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt index 9548f773149..374ce3a0743 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt @@ -2,7 +2,7 @@ package internal val e: MyEnum -internal final annotation class AnnE : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnE : kotlin.Annotation { public constructor AnnE(/*0*/ i: MyEnum) internal final val i: MyEnum public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt index 60ec1a463c3..f668b06ebe5 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt @@ -7,7 +7,7 @@ Ann(i = {1, 1, 1}) internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt index 8f8c736994c..7ea52668e62 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt @@ -7,7 +7,7 @@ internal val i4: kotlin.Int = 1 internal var i5: kotlin.Int internal var i6: kotlin.Int -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt index 65763ee3097..84691e400a0 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt @@ -3,7 +3,7 @@ package internal val topLevel: kotlin.String = "topLevel" internal fun foo(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.String /*kotlin.Array*/) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt index e765ee0269a..b0dcaa535f8 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt @@ -3,7 +3,7 @@ package kotlin.inline() internal fun bar(/*0*/ block: () -> kotlin.Int): kotlin.Int internal fun foo(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt index f52947cfa19..d8bc8365b8d 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt @@ -10,7 +10,7 @@ Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueTy public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt b/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt index dbef146c30d..b23c290f7d9 100644 --- a/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt +++ b/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt @@ -10,7 +10,7 @@ internal interface Some { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt index 585ecd5808b..a83e76784e4 100644 --- a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt @@ -15,7 +15,7 @@ kotlin.data() internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt b/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt index d5a67e9a496..68ca164db63 100644 --- a/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt +++ b/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt @@ -2,7 +2,7 @@ package package test { - internal final annotation class Ann1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ p1: kotlin.Int, /*1*/ p2: kotlin.Byte, /*2*/ p3: kotlin.Short, /*3*/ p4: kotlin.Long, /*4*/ p5: kotlin.Double, /*5*/ p6: kotlin.Float, /*6*/ p7: kotlin.Char, /*7*/ p8: kotlin.Boolean) internal final val p1: kotlin.Int internal final val p2: kotlin.Byte @@ -17,7 +17,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ p1: kotlin.String) internal final val p1: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -25,7 +25,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann3 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ p1: test.Ann1) internal final val p1: test.Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -33,7 +33,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann4 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann4 : kotlin.Annotation { public constructor Ann4(/*0*/ p1: kotlin.IntArray, /*1*/ p2: kotlin.ByteArray, /*2*/ p3: kotlin.ShortArray, /*3*/ p4: kotlin.LongArray, /*4*/ p5: kotlin.DoubleArray, /*5*/ p6: kotlin.FloatArray, /*6*/ p7: kotlin.CharArray, /*7*/ p8: kotlin.BooleanArray) internal final val p1: kotlin.IntArray internal final val p2: kotlin.ByteArray @@ -48,7 +48,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann5 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann5 : kotlin.Annotation { public constructor Ann5(/*0*/ p1: test.MyEnum) internal final val p1: test.MyEnum public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -56,7 +56,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann6 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann6 : kotlin.Annotation { public constructor Ann6(/*0*/ p: java.lang.Class<*>) internal final val p: java.lang.Class<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -64,7 +64,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann7 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann7 : kotlin.Annotation { public constructor Ann7(/*0*/ p: java.lang.annotation.RetentionPolicy) internal final val p: java.lang.annotation.RetentionPolicy public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -72,7 +72,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann8 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann8 : kotlin.Annotation { public constructor Ann8(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array>, /*2*/ p3: kotlin.Array, /*3*/ p4: kotlin.Array) internal final val p1: kotlin.Array internal final val p2: kotlin.Array> @@ -83,7 +83,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class Ann9 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Ann9 : kotlin.Annotation { public constructor Ann9(/*0*/ vararg p1: kotlin.String /*kotlin.Array*/, /*1*/ vararg p2: java.lang.Class<*> /*kotlin.Array>*/, /*2*/ vararg p3: test.MyEnum /*kotlin.Array*/, /*3*/ vararg p4: test.Ann1 /*kotlin.Array*/, /*4*/ vararg p5: kotlin.Int /*kotlin.IntArray*/) internal final val p1: kotlin.Array internal final val p2: kotlin.Array> @@ -95,7 +95,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn1 : kotlin.Annotation { public constructor InAnn1(/*0*/ p1: kotlin.Int?, /*1*/ p3: kotlin.Short?, /*2*/ p4: kotlin.Long?, /*3*/ p5: kotlin.Double?, /*4*/ p6: kotlin.Float?, /*5*/ p7: kotlin.Char?, /*6*/ p8: kotlin.Boolean?) internal final val p1: kotlin.Int? internal final val p3: kotlin.Short? @@ -109,7 +109,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn10 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn10 : kotlin.Annotation { public constructor InAnn10(/*0*/ p1: kotlin.String?) internal final val p1: kotlin.String? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -117,7 +117,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn11 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn11 : kotlin.Annotation { public constructor InAnn11(/*0*/ p1: test.Ann1?) internal final val p1: test.Ann1? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -125,7 +125,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn12 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn12 : kotlin.Annotation { public constructor InAnn12(/*0*/ p1: test.MyEnum?) internal final val p1: test.MyEnum? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -133,7 +133,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn4 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn4 : kotlin.Annotation { public constructor InAnn4(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array?) internal final val p1: kotlin.Array internal final val p2: kotlin.Array? @@ -142,7 +142,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn6 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn6 : kotlin.Annotation { public constructor InAnn6(/*0*/ p: java.lang.Class<*>?) internal final val p: java.lang.Class<*>? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -150,7 +150,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn7 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn7 : kotlin.Annotation { public constructor InAnn7(/*0*/ p: java.lang.annotation.RetentionPolicy?) internal final val p: java.lang.annotation.RetentionPolicy? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -158,7 +158,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn8 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn8 : kotlin.Annotation { public constructor InAnn8(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array, /*2*/ p3: kotlin.Array, /*3*/ p4: kotlin.Array) internal final val p1: kotlin.Array internal final val p2: kotlin.Array @@ -169,7 +169,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InAnn9 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InAnn9 : kotlin.Annotation { public constructor InAnn9(/*0*/ p: test.MyClass) internal final val p: test.MyClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt index 47eb0519cf7..5f9436f463d 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt @@ -11,7 +11,7 @@ internal final class Hello { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class test : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class test : kotlin.Annotation { public constructor test() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt b/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt index eace797f536..dc668dc34c9 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt @@ -1,20 +1,20 @@ package -internal final annotation class Annotation1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation1 : kotlin.Annotation { public constructor Annotation1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation10 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation10 : kotlin.Annotation { public constructor Annotation10() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation2 : kotlin.Annotation { public constructor Annotation2() public final val s: kotlin.String = "" public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ internal final annotation class Annotation2 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation3 : kotlin.Annotation { public constructor Annotation3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit @@ -30,7 +30,7 @@ internal final annotation class Annotation3 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation4 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation4 : kotlin.Annotation { public constructor Annotation4() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -44,7 +44,7 @@ internal final annotation class Annotation4 : kotlin.Annotation { } } -internal final annotation class Annotation5 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation5 : kotlin.Annotation { public constructor Annotation5() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -58,14 +58,14 @@ internal final annotation class Annotation5 : kotlin.Annotation { } } -internal final annotation class Annotation6 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation6 : kotlin.Annotation { public constructor Annotation6() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation7 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation7 : kotlin.Annotation { public constructor Annotation7(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -73,7 +73,7 @@ internal final annotation class Annotation7 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation8 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation8 : kotlin.Annotation { public constructor Annotation8(/*0*/ name: kotlin.String = ...) internal final var name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -81,7 +81,7 @@ internal final annotation class Annotation8 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Annotation9 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Annotation9 : kotlin.Annotation { public constructor Annotation9(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt b/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt index 7811b7df8c2..2ad51fa26d7 100644 --- a/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt @@ -1,6 +1,6 @@ package -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int, /*2*/ c: kotlin.String) internal final val a: kotlin.Int internal final var b: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt b/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt index f6c24f088a1..34a8a5548bd 100644 --- a/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt @@ -1,6 +1,6 @@ package -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ : [ERROR : Type annotation was missing for parameter ]) internal final val : [ERROR : Annotation is absent] internal final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onExpression.txt b/compiler/testData/diagnostics/tests/annotations/onExpression.txt index b081ffe6529..882524e7529 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.txt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Int -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt index bceef25b890..a9365dcac93 100644 --- a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt @@ -4,7 +4,7 @@ internal val bar: (kotlin.Int) -> kotlin.Unit internal val bas: (kotlin.Int) -> kotlin.Unit internal fun test(/*0*/ ann() p: kotlin.Int): kotlin.Unit -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onInitializer.txt b/compiler/testData/diagnostics/tests/annotations/onInitializer.txt index 56ed2530a13..b15a7444d68 100644 --- a/compiler/testData/diagnostics/tests/annotations/onInitializer.txt +++ b/compiler/testData/diagnostics/tests/annotations/onInitializer.txt @@ -13,7 +13,7 @@ internal interface T { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onLoops.txt b/compiler/testData/diagnostics/tests/annotations/onLoops.txt index 1023249041d..fc0855189ee 100644 --- a/compiler/testData/diagnostics/tests/annotations/onLoops.txt +++ b/compiler/testData/diagnostics/tests/annotations/onLoops.txt @@ -2,7 +2,7 @@ package internal fun test(): kotlin.Unit -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt b/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt index 1023249041d..fc0855189ee 100644 --- a/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt +++ b/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt @@ -2,7 +2,7 @@ package internal fun test(): kotlin.Unit -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt b/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt index 64919807789..cdc24442601 100644 --- a/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt +++ b/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt @@ -14,7 +14,7 @@ kotlin.data() internal final class P { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotation.kt b/compiler/testData/diagnostics/tests/annotations/options/annotation.kt new file mode 100644 index 00000000000..fd33f6dff3c --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotation.kt @@ -0,0 +1,17 @@ +// Annotations used for annotations :) +enum class Target { + CLASSIFIER, + FUNCTION +} + +target(Target.CLASSIFIER) +public annotation class target(vararg val allowedTargets: Target) + +target(Target.CLASSIFIER) +public annotation(AnnotationRetention.SOURCE) class annotation( + val retention: AnnotationRetention = AnnotationRetention.RUNTIME, + val repeatable: Boolean = false +) + +annotation class some + diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotation.txt b/compiler/testData/diagnostics/tests/annotations/options/annotation.txt new file mode 100644 index 00000000000..198ad1c81c6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotation.txt @@ -0,0 +1,59 @@ +package + +internal final enum class Target : kotlin.Enum { + public enum entry CLASSIFIER : Target { + private constructor CLASSIFIER() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Target): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public enum entry FUNCTION : Target { + private constructor FUNCTION() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Target): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor Target() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Target): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Target + public final /*synthesized*/ fun values(): kotlin.Array +} + +target(allowedTargets = {Target.CLASSIFIER}) annotation(retention = AnnotationRetention.SOURCE) public final annotation class annotation : kotlin.Annotation { + public constructor annotation(/*0*/ retention: kotlin.annotation.AnnotationRetention = ..., /*1*/ repeatable: kotlin.Boolean = ...) + internal final val repeatable: kotlin.Boolean + internal final val retention: kotlin.annotation.AnnotationRetention + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +annotation() internal final annotation class some : kotlin.Annotation { + public constructor some() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +target(allowedTargets = {Target.CLASSIFIER}) annotation() public final annotation class target : kotlin.Annotation { + public constructor target(/*0*/ vararg allowedTargets: Target /*kotlin.Array*/) + internal final val allowedTargets: kotlin.Array + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.kt b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.kt new file mode 100644 index 00000000000..5484366eef0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.kt @@ -0,0 +1,14 @@ +class Annotation(val x: Int) { + fun baz() {} + fun bar() = x +} + +fun foo(annotation: Annotation): Int { + if (annotation.bar() == 0) { + annotation.baz() + return 0 + } + else { + return -1 + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.txt b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.txt new file mode 100644 index 00000000000..7d88c4c5161 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.txt @@ -0,0 +1,13 @@ +package + +internal fun foo(/*0*/ annotation: Annotation): kotlin.Int + +internal final class Annotation { + public constructor Annotation(/*0*/ x: kotlin.Int) + internal final val x: kotlin.Int + internal final fun bar(): kotlin.Int + internal final fun baz(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.kt b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.kt new file mode 100644 index 00000000000..e2c064206da --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.kt @@ -0,0 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +class Annotation { + fun setProblemGroup() {} + fun getQuickFixes() = 0 +} + +fun registerQuickFix(annotation: Annotation) { + annotation.setProblemGroup() + val fixes = annotation.getQuickFixes() +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.txt b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.txt new file mode 100644 index 00000000000..663d7b216bd --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.txt @@ -0,0 +1,12 @@ +package + +internal fun registerQuickFix(/*0*/ annotation: Annotation): kotlin.Unit + +internal final class Annotation { + public constructor Annotation() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun getQuickFixes(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final fun setProblemGroup(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/brackets.kt b/compiler/testData/diagnostics/tests/annotations/options/brackets.kt new file mode 100644 index 00000000000..303fae05cfc --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/brackets.kt @@ -0,0 +1,3 @@ +annotation() class emptyBrackets + +emptyBrackets class base diff --git a/compiler/testData/diagnostics/tests/annotations/options/brackets.txt b/compiler/testData/diagnostics/tests/annotations/options/brackets.txt new file mode 100644 index 00000000000..1c973ff3e93 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/brackets.txt @@ -0,0 +1,15 @@ +package + +emptyBrackets() internal final class base { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation() internal final annotation class emptyBrackets : kotlin.Annotation { + public constructor emptyBrackets() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt b/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt new file mode 100644 index 00000000000..d4080ec2f62 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt @@ -0,0 +1,3 @@ +annotation(repeatable = true) class repann + +repann repann class DoubleAnnotated \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt new file mode 100644 index 00000000000..cfb2fb1f2fe --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt @@ -0,0 +1,15 @@ +package + +repann() repann() internal final class DoubleAnnotated { + public constructor DoubleAnnotated() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation(repeatable = true) internal final annotation class repann : kotlin.Annotation { + public constructor repann() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/retention.kt b/compiler/testData/diagnostics/tests/annotations/options/retention.kt new file mode 100644 index 00000000000..b2faff44864 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/retention.kt @@ -0,0 +1,3 @@ +annotation(AnnotationRetention.SOURCE) class sourceann + +sourceann class AnnotatedAtSource diff --git a/compiler/testData/diagnostics/tests/annotations/options/retention.txt b/compiler/testData/diagnostics/tests/annotations/options/retention.txt new file mode 100644 index 00000000000..679d908bc7d --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/retention.txt @@ -0,0 +1,15 @@ +package + +sourceann() internal final class AnnotatedAtSource { + public constructor AnnotatedAtSource() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation(retention = AnnotationRetention.SOURCE) internal final annotation class sourceann : kotlin.Annotation { + public constructor sourceann() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/target.kt b/compiler/testData/diagnostics/tests/annotations/options/target.kt new file mode 100644 index 00000000000..1b47729396a --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/target.kt @@ -0,0 +1,5 @@ +target(AnnotationTarget.CLASSIFIER) +annotation class base + +base data class My + diff --git a/compiler/testData/diagnostics/tests/annotations/options/target.txt b/compiler/testData/diagnostics/tests/annotations/options/target.txt new file mode 100644 index 00000000000..c2ff25c4794 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/target.txt @@ -0,0 +1,16 @@ +package + +base() kotlin.data() internal final class My { + public constructor My() + public final /*synthesized*/ fun copy(): My + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt b/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt index 7461e6948ce..af982686f82 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt +++ b/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt @@ -15,7 +15,7 @@ internal abstract class B { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class C : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class C : kotlin.Annotation { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt index 7b7614be495..f71ecf397f6 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt +++ b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt @@ -29,7 +29,7 @@ internal final class Outer { internal final fun B.(): kotlin.Unit } -internal final annotation class a : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class a : kotlin.Annotation { public constructor a() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt index 45b31383fca..7ea444df8ee 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt +++ b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt @@ -83,7 +83,7 @@ internal interface D { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal open annotation class E : kotlin.Annotation { +kotlin.annotation.annotation() internal open annotation class E : kotlin.Annotation { public constructor E() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt index a096f8c95ce..adbc1b6ce10 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt @@ -2,7 +2,7 @@ package internal fun f(/*0*/ s: kotlin.String?): kotlin.Boolean -internal final annotation class foo : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class foo : kotlin.Annotation { public constructor foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt index 2400bc23c00..b6707e92e98 100644 --- a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt +++ b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt @@ -14,14 +14,14 @@ obsoleteWithParam(text = "text") internal final class Obsolete2 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.deprecated(value = "text") internal final annotation class obsolete : kotlin.Annotation { +kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final annotation class obsolete : kotlin.Annotation { public constructor obsolete() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.deprecated(value = "text") internal final annotation class obsoleteWithParam : kotlin.Annotation { +kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final annotation class obsoleteWithParam : kotlin.Annotation { public constructor obsoleteWithParam(/*0*/ text: kotlin.String) internal final val text: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt index 0d573d1c24f..b987a4e3d20 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt @@ -32,7 +32,7 @@ internal final enum class : kotlin.Enum<> { public final /*synthesized*/ fun values(): kotlin.Array<> } -internal final annotation class : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -81,7 +81,7 @@ internal final class Outer { public final /*synthesized*/ fun values(): kotlin.Array> } - internal final annotation class : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.kt b/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.kt index 4cd63001527..2a76a527fb7 100644 --- a/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.kt +++ b/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.kt @@ -14,7 +14,7 @@ enum class E { final FINAL, inner INNER, - annotation ANNOTATION, + annotation ANNOTATION, enum ENUM, out OUT, in IN, diff --git a/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.txt b/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.txt index 37b38f2a0f9..bb2397fee56 100644 --- a/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.txt +++ b/compiler/testData/diagnostics/tests/enum/modifiersOnEnumEntry.txt @@ -102,6 +102,16 @@ internal final enum class E : kotlin.Enum { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } + public enum entry annotation : E { + private constructor annotation() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + public enum entry ANNOTATION : E { private constructor ANNOTATION() public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt index 5e7d7081d39..9f39b50c712 100644 --- a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt +++ b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt @@ -12,7 +12,7 @@ internal val a9: kotlin.Int internal val b1: kotlin.Byte Ann() internal val b2: kotlin.Int = 1 -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt b/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt index 850048ccdce..357ebb7e3e4 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt @@ -18,7 +18,7 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt index d0260cb3578..1c4568fe3c2 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt @@ -4,7 +4,7 @@ internal val bas: () -> kotlin.Unit internal fun bar(/*0*/ a: kotlin.Any): () -> kotlin.Unit internal fun outer(): kotlin.Unit -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt b/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt index 3da9ff2e581..b65c7f0e43c 100644 --- a/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt +++ b/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt @@ -13,7 +13,7 @@ internal final class Test { public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class InnerAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class InnerAnnotation : kotlin.Annotation { public constructor InnerAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/illegalModifier.txt b/compiler/testData/diagnostics/tests/inner/illegalModifier.txt index ddfca693e0c..86141ba352e 100644 --- a/compiler/testData/diagnostics/tests/inner/illegalModifier.txt +++ b/compiler/testData/diagnostics/tests/inner/illegalModifier.txt @@ -71,7 +71,7 @@ internal final class D { public final /*synthesized*/ fun values(): kotlin.Array } - internal final annotation class S : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class S : kotlin.Annotation { public constructor S() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt b/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt index 0ade0d0df69..bcefa1a0250 100644 --- a/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt +++ b/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt @@ -12,7 +12,7 @@ internal final class Test { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - internal final annotation class ClassObjectAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class ClassObjectAnnotation : kotlin.Annotation { public constructor ClassObjectAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -20,7 +20,7 @@ internal final class Test { } } - internal final annotation class NestedAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class NestedAnnotation : kotlin.Annotation { public constructor NestedAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt index d6c6f91412f..84ae388ed55 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt @@ -97,7 +97,7 @@ abstract class IllegalModifiers6() { class IllegalModifiers7() { enum inner - annotation + annotation out in vararg @@ -105,7 +105,7 @@ class IllegalModifiers7() { val x = 1 enum inner - annotation + annotation out in vararg @@ -119,7 +119,7 @@ class IllegalModifiers8 { enum open inner - annotation + annotation override out in @@ -143,7 +143,7 @@ class IllegalModifiers10 enum open inner -annotation +annotation override out in diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt index bb0511c48c6..621e0e99aba 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt @@ -45,7 +45,7 @@ package illegal_modifiers { } internal final class IllegalModifiers10 { - public constructor IllegalModifiers10() + kotlin.annotation.annotation() public constructor IllegalModifiers10() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -100,15 +100,15 @@ package illegal_modifiers { internal open class IllegalModifiers7 { public constructor IllegalModifiers7() - internal final val x: kotlin.Int = 1 + kotlin.annotation.annotation() internal final val x: kotlin.Int = 1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal final fun foo(): kotlin.Unit + kotlin.annotation.annotation() internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } internal final class IllegalModifiers8 { - public constructor IllegalModifiers8() + kotlin.annotation.annotation() public constructor IllegalModifiers8() public constructor IllegalModifiers8(/*0*/ x: kotlin.Int) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -138,7 +138,7 @@ package illegal_modifiers { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class annotated : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class annotated : kotlin.Annotation { public constructor annotated(/*0*/ text: kotlin.String = ...) internal final val text: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt index 48fa3a24d61..7a1433d4be0 100644 --- a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt +++ b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt @@ -17,7 +17,7 @@ internal final class A { } } -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt index 3ab980b59b1..190218c136c 100644 --- a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt +++ b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt @@ -30,7 +30,7 @@ internal final enum class : kotlin.Enum<> { public final /*synthesized*/ fun values(): kotlin.Array<> } -internal final annotation class : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt index 07a4482db96..bdd93816afd 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt +++ b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt @@ -3,7 +3,7 @@ package internal fun bar(/*0*/ block: (T) -> kotlin.Int): kotlin.Unit internal fun foo(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt index fe82d9818f9..c6263fedc43 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt @@ -9,14 +9,14 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt index a1a550e49f0..6cd40599d2a 100644 --- a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt +++ b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ a: kotlin.Int): kotlin.Unit -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt index b6f5edd1e9b..e1031c8f225 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt @@ -2,7 +2,7 @@ package package test { - internal final annotation class AnnClass : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class AnnClass : kotlin.Annotation { public constructor AnnClass(/*0*/ a: kotlin.reflect.KClass<*>) internal final val a: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt index db00d009415..daf42a4580c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt @@ -6,7 +6,7 @@ internal val i3: kotlin.Int internal val iAnn: Ann internal fun foo(): kotlin.Int -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.IntArray) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,7 +14,7 @@ internal final annotation class Ann : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class AnnAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnAnn : kotlin.Annotation { public constructor AnnAnn(/*0*/ i: kotlin.Array) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt index fa1d18de8ab..daf04ac3f9c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt @@ -6,7 +6,7 @@ internal val ia: kotlin.IntArray internal val sa: kotlin.Array internal fun foo(): kotlin.Int -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,14 +14,14 @@ internal final annotation class Ann : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class AnnIA : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnIA : kotlin.Annotation { public constructor AnnIA(/*0*/ ia: kotlin.IntArray) internal final val ia: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -29,7 +29,7 @@ internal final annotation class AnnIA : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class AnnSA : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnSA : kotlin.Annotation { public constructor AnnSA(/*0*/ sa: kotlin.Array) internal final val sa: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt index 6e2588a7779..f56afafb342 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt @@ -6,7 +6,7 @@ internal val i3: kotlin.Int internal val iAnn: Ann internal fun foo(): kotlin.Int -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,7 +14,7 @@ internal final annotation class Ann : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class AnnAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnAnn : kotlin.Annotation { public constructor AnnAnn(/*0*/ vararg i: Ann /*kotlin.Array*/) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt index b721ac4d876..3d6d1b39e0b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt @@ -2,7 +2,7 @@ package B(args = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { public constructor B(/*0*/ vararg args: kotlin.String /*kotlin.Array*/) internal final val args: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt index 811b3654351..a12adfd65b1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt @@ -5,7 +5,7 @@ internal val nonConst: kotlin.Int internal val nonConstKClass: kotlin.reflect.KClass internal fun foo(): kotlin.Int -internal final annotation class InvalidAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class InvalidAnn : kotlin.Annotation { public constructor InvalidAnn(/*0*/ p1: kotlin.Int = ..., /*1*/ p2: kotlin.Int = ..., /*2*/ p3: kotlin.reflect.KClass<*> = ...) internal final val p1: kotlin.Int internal final val p2: kotlin.Int @@ -15,7 +15,7 @@ internal final annotation class InvalidAnn : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class ValidAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ValidAnn : kotlin.Annotation { public constructor ValidAnn(/*0*/ p1: kotlin.Int = ..., /*1*/ p2: kotlin.String = ..., /*2*/ p3: kotlin.reflect.KClass<*> = ..., /*3*/ p4: kotlin.IntArray = ..., /*4*/ p5: kotlin.Array = ..., /*5*/ p6: kotlin.Array> = ...) internal final val p1: kotlin.Int internal final val p2: kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt index a6765ac3675..4cd49a057d2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt index c0ec82f6272..f90ae74eaea 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt index e40b008836d..91c9611a4c5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt @@ -16,7 +16,7 @@ internal final class A2 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass<*>) internal final val arg: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -24,7 +24,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ vararg arg: kotlin.reflect.KClass<*> /*kotlin.Array>*/) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -32,7 +32,7 @@ internal final annotation class Ann2 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt index 16b953e974c..fb014b3e4a1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt index 69adfb817a3..e3f12e9d99a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt index 4b1b1e7b528..7b2fb1b0873 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ internal final annotation class Ann1 : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt index 57bb6dcede5..4641ce46200 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt index c655e78749f..f1a842cbadf 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt @@ -4,7 +4,7 @@ Ann(value = "a", x = IntegerValueType(1), y = 1.0.toDouble()) internal fun foo1( Ann(value = "b", x = IntegerValueType(2), y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit Ann(value = "c", x = IntegerValueType(3), y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ value: kotlin.String, /*2*/ y: kotlin.Double) internal final val value: kotlin.String internal final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt index 55ed1ce17e4..a29557f9f7c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt @@ -13,7 +13,7 @@ package a { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - internal final annotation class IAnn : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class IAnn : kotlin.Annotation { public constructor IAnn() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -21,7 +21,7 @@ package a { } } - internal final annotation class ann1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class ann1 : kotlin.Annotation { public constructor ann1(/*0*/ p: kotlin.deprecated = ...) internal final val p: kotlin.deprecated public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -29,7 +29,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class ann2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class ann2 : kotlin.Annotation { public constructor ann2(/*0*/ p: a.b.c.ann1 = ...) internal final val p: a.b.c.ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -37,7 +37,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class ann3 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class ann3 : kotlin.Annotation { public constructor ann3(/*0*/ p: a.b.c.A.IAnn = ..., /*1*/ p2: a.b.c.A.IAnn = ...) internal final val p: a.b.c.A.IAnn internal final val p2: a.b.c.A.IAnn @@ -46,7 +46,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - internal final annotation class annArray : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class annArray : kotlin.Annotation { public constructor annArray(/*0*/ p: kotlin.Array = ...) internal final val p: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/AnnotatedAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/AnnotatedAnnotation.txt index d1caf03972e..dc0aeab2ec7 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/AnnotatedAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/AnnotatedAnnotation.txt @@ -1,5 +1,5 @@ package test -test.AnnotatedAnnotation() public final annotation class AnnotatedAnnotation : kotlin.Annotation { +test.AnnotatedAnnotation() kotlin.annotation.annotation() public final annotation class AnnotatedAnnotation : kotlin.Annotation { /*primary*/ public constructor AnnotatedAnnotation() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.txt index bf8bb667d3b..9f7d03729aa 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.txt @@ -22,13 +22,13 @@ internal final enum class E : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -internal final annotation class EnumOption : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class EnumOption : kotlin.Annotation { /*primary*/ public constructor EnumOption(/*0*/ option: test.E) internal final val option: test.E internal final fun (): test.E } -internal final annotation class OptionGroups : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class OptionGroups : kotlin.Annotation { /*primary*/ public constructor OptionGroups(/*0*/ o1: test.StringOptions, /*1*/ o2: test.EnumOption) internal final val o1: test.StringOptions internal final fun (): test.StringOptions @@ -36,7 +36,7 @@ internal final annotation class OptionGroups : kotlin.Annotation { internal final fun (): test.EnumOption } -internal final annotation class StringOptions : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class StringOptions : kotlin.Annotation { /*primary*/ public constructor StringOptions(/*0*/ vararg option: kotlin.String /*kotlin.Array*/) internal final val option: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt b/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt index 74a4ece988e..0356b39bc5a 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt @@ -18,7 +18,7 @@ internal final enum class E : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -internal final annotation class EnumAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class EnumAnno : kotlin.Annotation { /*primary*/ public constructor EnumAnno(/*0*/ value: test.E) internal final val value: test.E internal final fun (): test.E @@ -29,7 +29,7 @@ public final class EnumArgumentWithCustomToString { test.EnumAnno(value = E.CAKE) test.EnumArrayAnno(value = {E.CAKE, E.CAKE}) internal final fun annotated(): kotlin.Unit } -internal final annotation class EnumArrayAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class EnumArrayAnno : kotlin.Annotation { /*primary*/ public constructor EnumArrayAnno(/*0*/ vararg value: test.E /*kotlin.Array*/) internal final val value: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt b/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt index 457fe635eee..51117cc7663 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt index 99a705e74ff..5e6cfce6549 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt @@ -1,5 +1,5 @@ package test -public final annotation class SimpleAnnotation : kotlin.Annotation { +kotlin.annotation.annotation() public final annotation class SimpleAnnotation : kotlin.Annotation { /*primary*/ public constructor SimpleAnnotation() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt index c253b8d5a4d..f11f12849ca 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt index 7632f8e8dc0..8af7dfcdf44 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ value: kotlin.String) internal final val value: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt index d269b2347a0..9d09f00cdb8 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt index c8637c254e2..22c826ecca4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt index 35b8b67f0ff..b52d3b3dea7 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt index 8dc529d4f7d..232718e6ad8 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt index 6f98192e1e6..221a25a0db3 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt index c3ead292592..c3c12f29f73 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt index 29a6baac275..a3aff97886e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt @@ -6,14 +6,14 @@ internal final class A { public companion object Companion { /*primary*/ private constructor Companion() - internal final annotation class Anno1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Anno1 : kotlin.Annotation { /*primary*/ public constructor Anno1() } internal final class B { /*primary*/ public constructor B() - internal final annotation class Anno2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Anno2 : kotlin.Annotation { /*primary*/ public constructor Anno2() } } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt index ca4816dab10..37fb81b01bc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt index ea76204d029..3f0a7c24240 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt index 92194a689e2..59992e8e4c3 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt @@ -1,6 +1,6 @@ package test -internal final annotation class `$$$$$$` : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class `$$$$$$` : kotlin.Annotation { /*primary*/ public constructor `$$$$$$`() } @@ -8,7 +8,7 @@ test.`$$$$$$`() internal final class A { /*primary*/ public constructor A() } -internal final annotation class `Anno$tation` : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class `Anno$tation` : kotlin.Annotation { /*primary*/ public constructor `Anno$tation`() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt index 3c830300993..c592d495c9e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt index 7fc605e1161..ae9de1d4caf 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt @@ -1,14 +1,14 @@ package test -internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { /*primary*/ public constructor A1() } -internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { /*primary*/ public constructor A2() } -internal final annotation class A3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A3 : kotlin.Annotation { /*primary*/ public constructor A3() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt index 45e5bdac392..d6e2929cf91 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt @@ -3,7 +3,7 @@ package test internal final class A { /*primary*/ public constructor A() - internal final annotation class Anno : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt index cf073499c7d..2b142756a49 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt index 6ff485396f2..5b62bb55b8f 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt @@ -1,5 +1,5 @@ package test -java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) internal final annotation class Anno : kotlin.Annotation { +java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt index 5172f44f966..ea52afc4b87 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt index c0287d9def2..02cded471d1 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt @@ -1,18 +1,18 @@ package test -internal final annotation class BooleanAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class BooleanAnno : kotlin.Annotation { /*primary*/ public constructor BooleanAnno(/*0*/ value: kotlin.Boolean) internal final val value: kotlin.Boolean internal final fun (): kotlin.Boolean } -internal final annotation class ByteAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ByteAnno : kotlin.Annotation { /*primary*/ public constructor ByteAnno(/*0*/ value: kotlin.Byte) internal final val value: kotlin.Byte internal final fun (): kotlin.Byte } -internal final annotation class CharAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class CharAnno : kotlin.Annotation { /*primary*/ public constructor CharAnno(/*0*/ value: kotlin.Char) internal final val value: kotlin.Char internal final fun (): kotlin.Char @@ -22,31 +22,31 @@ test.IntAnno(value = 42) test.ShortAnno(value = 42.toShort()) test.ByteAnno(valu /*primary*/ public constructor Class() } -internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno(/*0*/ value: kotlin.Double) internal final val value: kotlin.Double internal final fun (): kotlin.Double } -internal final annotation class FloatAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class FloatAnno : kotlin.Annotation { /*primary*/ public constructor FloatAnno(/*0*/ value: kotlin.Float) internal final val value: kotlin.Float internal final fun (): kotlin.Float } -internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno(/*0*/ value: kotlin.Int) internal final val value: kotlin.Int internal final fun (): kotlin.Int } -internal final annotation class LongAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class LongAnno : kotlin.Annotation { /*primary*/ public constructor LongAnno(/*0*/ value: kotlin.Long) internal final val value: kotlin.Long internal final fun (): kotlin.Long } -internal final annotation class ShortAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ShortAnno : kotlin.Annotation { /*primary*/ public constructor ShortAnno(/*0*/ value: kotlin.Short) internal final val value: kotlin.Short internal final fun (): kotlin.Short diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt index 8c56ddfb41d..94ef8eda087 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ int: kotlin.Int, /*1*/ string: kotlin.String, /*2*/ double: kotlin.Double) internal final val double: kotlin.Double internal final fun (): kotlin.Double diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt index 33cfe343b75..352a71cacdc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt @@ -3,6 +3,6 @@ package test test.Anno() internal val x: kotlin.Int internal fun (): kotlin.Int -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt index 0aff1f871e6..d17b6d8782b 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt @@ -4,7 +4,7 @@ test.Anno(t = ElementType.FIELD) internal val bar: kotlin.Int = 42 internal fun (): kotlin.Int test.Anno(t = ElementType.METHOD) internal fun foo(): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt index 9039fb35eda..855c2ffc454 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt @@ -5,7 +5,7 @@ test.Anno(t = {ElementType.PACKAGE}) internal val bar: kotlin.Int = 42 test.Anno(t = {}) internal fun baz(): kotlin.Unit test.Anno(t = {ElementType.METHOD, ElementType.FIELD}) internal fun foo(): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ vararg t: java.lang.annotation.ElementType /*kotlin.Array*/) internal final val t: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt index 4783daf41d6..585aaee7bf4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt @@ -2,6 +2,6 @@ package test test.Anno() internal fun function(): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt index f39ae47fe92..31f46a51f2e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt @@ -3,6 +3,6 @@ package test internal val property: kotlin.Int test.Anno() internal fun (): kotlin.Int -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt index 31c1b1fdf12..8e0a02fa96e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt @@ -4,6 +4,6 @@ test.Anno() internal var property: kotlin.Int internal fun (): kotlin.Int internal fun (/*0*/ : kotlin.Int): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt index 22bb8faa2dd..04fb642e419 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt @@ -4,6 +4,6 @@ internal var property: kotlin.Int internal fun (): kotlin.Int test.Anno() internal fun (/*0*/ value: kotlin.Int): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt index b0b4765b8bf..8974c0fc9b3 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt @@ -5,7 +5,7 @@ test.Anno(t = {"prosper"}) internal val bar: kotlin.Int = 42 test.Anno(t = {}) internal fun baz(): kotlin.Unit test.Anno(t = {"live", "long"}) internal fun foo(): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ vararg t: kotlin.String /*kotlin.Array*/) internal final val t: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt index be17a96e471..6b27388be55 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt @@ -1,10 +1,10 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt index 01a39ef6bb0..3b4ec2434af 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt @@ -1,10 +1,10 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt index 7b1b075ce94..d09853c0ddc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt @@ -2,6 +2,6 @@ package test internal fun kotlin.Int.foo(/*0*/ test.A() x: kotlin.Int): kotlin.Unit -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt index 073b165297f..4f23c527fcd 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt index a071d5ecd84..5dcbed29e07 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt @@ -1,6 +1,6 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt index 6f983d509e5..236a876ec32 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt index 5c9f78e5745..70e5a27be90 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt index d1546823bc5..1a929ba986c 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt @@ -1,6 +1,6 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt index fecebf555ba..8a7ca50d4eb 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt @@ -3,18 +3,18 @@ package test internal fun bar(/*0*/ test.A() test.B() test.C() test.D() x: kotlin.Int): kotlin.Unit internal fun foo(/*0*/ test.A() test.B() x: kotlin.Int, /*1*/ test.A() test.C() y: kotlin.Double, /*2*/ test.B() test.C() test.D() z: kotlin.String): kotlin.Unit -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { /*primary*/ public constructor B() } -internal final annotation class C : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class C : kotlin.Annotation { /*primary*/ public constructor C() } -internal final annotation class D : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class D : kotlin.Annotation { /*primary*/ public constructor D() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt index 7cf6937db80..144beb4d129 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt @@ -1,6 +1,6 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt index eda01e83b37..c2891374258 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt @@ -2,6 +2,6 @@ package test internal fun foo(/*0*/ test.Anno() x: kotlin.Int): kotlin.Unit -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt index 0ec4bce6951..e71ccf19f0e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt @@ -4,10 +4,10 @@ internal var foo: kotlin.Int internal fun (): kotlin.Int internal fun (/*0*/ test.A() test.B() value: kotlin.Int): kotlin.Unit -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } -internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt index af76793d7b7..f5102295613 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt index 5b093257651..d5293e678f4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt index 198c49875e9..d628a915d32 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt @@ -10,14 +10,14 @@ internal final class Class { internal final fun kotlin.String.(): kotlin.String } -internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno() } -internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno() } -internal final annotation class StringAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class StringAnno : kotlin.Annotation { /*primary*/ public constructor StringAnno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt index 1d022c66ed8..617bfcd67a2 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt @@ -7,14 +7,14 @@ test.IntAnno() internal val kotlin.Int.extension: kotlin.Int test.StringAnno() internal val kotlin.String.extension: kotlin.String internal fun kotlin.String.(): kotlin.String -internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno() } -internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno() } -internal final annotation class StringAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class StringAnno : kotlin.Annotation { /*primary*/ public constructor StringAnno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt index c5983f0ac0f..5c060817c2e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt index 0da708e5673..dcd9b1875eb 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt @@ -3,6 +3,6 @@ package test test.Anno() internal val property: kotlin.Int internal fun (): kotlin.Int -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt index d4e5d39b108..cc0f7717db0 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt index 02901516852..9ad34b16d1a 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt index 821362e88fa..47190d4e0e4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt @@ -2,6 +2,6 @@ package test internal fun @[test.A()] kotlin.String.foo(): kotlin.Unit -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt index 2e19340c417..6083e5af9d5 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt @@ -1,6 +1,6 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt index c19b9bbc9fc..81a5e323a3b 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt @@ -1,6 +1,6 @@ package test -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt index 5e6e5a4658c..c919d0e0304 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt @@ -1,6 +1,6 @@ package test -internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { /*primary*/ public constructor Ann(/*0*/ x: kotlin.String, /*1*/ y: kotlin.Double) internal final val x: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt index a9f8f7f5278..78c5da4693d 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt @@ -6,7 +6,7 @@ internal final class Some { test.Some.Companion.TestAnnotation() public companion object Companion { /*primary*/ private constructor Companion() - internal final annotation class TestAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final annotation class TestAnnotation : kotlin.Annotation { /*primary*/ public constructor TestAnnotation() } } diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt b/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt index c35cd5a3556..a44a114910e 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt @@ -5,7 +5,7 @@ test.A(s = "2") internal var v: kotlin.Int kotlin.platform.platformName(name = "vset") test.A(s = "4") internal fun (/*0*/ : kotlin.Int): kotlin.Unit kotlin.platform.platformName(name = "bar") test.A(s = "1") internal fun foo(): kotlin.String -internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/psi/SimpleModifiers.txt b/compiler/testData/psi/SimpleModifiers.txt index 24d0a897668..4f12a5390f4 100644 --- a/compiler/testData/psi/SimpleModifiers.txt +++ b/compiler/testData/psi/SimpleModifiers.txt @@ -25,7 +25,12 @@ JetFile: SimpleModifiers.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') @@ -67,7 +72,12 @@ JetFile: SimpleModifiers.kt PsiWhiteSpace('\n ') PsiElement(open)('open') PsiWhiteSpace('\n ') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n ') PsiElement(override)('override') PsiWhiteSpace('\n ') diff --git a/compiler/testData/psi/SoftKeywords.txt b/compiler/testData/psi/SoftKeywords.txt index 9a8f32e1a1e..b99c8b8983e 100644 --- a/compiler/testData/psi/SoftKeywords.txt +++ b/compiler/testData/psi/SoftKeywords.txt @@ -38,7 +38,12 @@ JetFile: SoftKeywords.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') @@ -113,7 +118,12 @@ JetFile: SoftKeywords.kt PsiWhiteSpace('\n ') PsiElement(open)('open') PsiWhiteSpace('\n ') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n ') PsiElement(override)('override') PsiWhiteSpace('\n ') @@ -972,7 +982,12 @@ JetFile: SoftKeywords.kt PsiWhiteSpace('\n ') PsiElement(open)('open') PsiWhiteSpace('\n ') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n ') PsiElement(override)('override') PsiWhiteSpace('\n ') @@ -1292,7 +1307,12 @@ JetFile: SoftKeywords.kt PsiWhiteSpace('\n ') PsiElement(open)('open') PsiWhiteSpace('\n ') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n ') PsiElement(override)('override') PsiWhiteSpace('\n ') diff --git a/compiler/testData/psi/annotation/Annotations.txt b/compiler/testData/psi/annotation/Annotations.txt index 4113551639f..863e9201d08 100644 --- a/compiler/testData/psi/annotation/Annotations.txt +++ b/compiler/testData/psi/annotation/Annotations.txt @@ -25,7 +25,12 @@ JetFile: Annotations.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') @@ -266,7 +271,12 @@ JetFile: Annotations.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/annotation/Annotations_ERR.txt b/compiler/testData/psi/annotation/Annotations_ERR.txt index 80389fcc24d..48b229fc3e5 100644 --- a/compiler/testData/psi/annotation/Annotations_ERR.txt +++ b/compiler/testData/psi/annotation/Annotations_ERR.txt @@ -25,7 +25,12 @@ JetFile: Annotations_ERR.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') @@ -221,7 +226,12 @@ JetFile: Annotations_ERR.kt PsiWhiteSpace('\n') PsiElement(open)('open') PsiWhiteSpace('\n') - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace('\n') PsiElement(override)('override') PsiWhiteSpace('\n') diff --git a/compiler/testData/psi/annotation/onFile/withoutFileAnnotationAndPackageDeclaration.txt b/compiler/testData/psi/annotation/onFile/withoutFileAnnotationAndPackageDeclaration.txt index 6f56c7d133a..5ff571a1866 100644 --- a/compiler/testData/psi/annotation/onFile/withoutFileAnnotationAndPackageDeclaration.txt +++ b/compiler/testData/psi/annotation/onFile/withoutFileAnnotationAndPackageDeclaration.txt @@ -35,7 +35,12 @@ JetFile: withoutFileAnnotationAndPackageDeclaration.kt PsiWhiteSpace('\n\n') CLASS MODIFIER_LIST - PsiElement(annotation)('annotation') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') PsiWhiteSpace(' ') PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/annotation/options/annotAsArgComplex.kt b/compiler/testData/psi/annotation/options/annotAsArgComplex.kt new file mode 100644 index 00000000000..87da177827e --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotAsArgComplex.kt @@ -0,0 +1,9 @@ +class Annotation { + fun setProblemGroup() {} + fun getQuickFixes() = 0 +} + +fun registerQuickFix(annot: Annotation) { + annot.setProblemGroup() + val fixes = annot.getQuickFixes() +} diff --git a/compiler/testData/psi/annotation/options/annotAsArgComplex.txt b/compiler/testData/psi/annotation/options/annotAsArgComplex.txt new file mode 100644 index 00000000000..ac790f3733a --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotAsArgComplex.txt @@ -0,0 +1,89 @@ +JetFile: annotAsArgComplex.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Annotation') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('setProblemGroup') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('getQuickFixes') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('registerQuickFix') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('annot') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Annotation') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annot') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('setProblemGroup') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('fixes') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annot') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('getQuickFixes') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/annotation.kt b/compiler/testData/psi/annotation/options/annotation.kt new file mode 100644 index 00000000000..05e089a8935 --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotation.kt @@ -0,0 +1,20 @@ +// Annotations used for annotations :) +enum class Target { + CLASSIFIER, + FUNCTION +} + +enum class Retention { + SOURCE, + BINARY, + RUNTIME +} + +target(Target.CLASSIFIER) +public annotation class target(vararg val allowedTargets: Target) + +target(Target.CLASSIFIER) +public annotation(Retention.SOURCE) class annotation( + val retention: Retention = Retention.RUNTIME, + val repeatable: Boolean = false +) diff --git a/compiler/testData/psi/annotation/options/annotation.txt b/compiler/testData/psi/annotation/options/annotation.txt new file mode 100644 index 00000000000..f1df48cc47f --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotation.txt @@ -0,0 +1,188 @@ +JetFile: annotation.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiComment(EOL_COMMENT)('// Annotations used for annotations :)') + PsiWhiteSpace('\n') + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Target') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('CLASSIFIER') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('FUNCTION') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Retention') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('SOURCE') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('BINARY') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('RUNTIME') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('target') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('CLASSIFIER') + PsiElement(RPAR)(')') + PsiWhiteSpace(' \n') + PsiElement(public)('public') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('target') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + MODIFIER_LIST + PsiElement(vararg)('vararg') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('allowedTargets') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('target') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('CLASSIFIER') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(public)('public') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('SOURCE') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('annotation') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('retention') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('RUNTIME') + PsiElement(COMMA)(',') + PsiWhiteSpace('\n ') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('repeatable') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Boolean') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiWhiteSpace('\n') + PsiElement(RPAR)(')') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/annotationAsArg.kt b/compiler/testData/psi/annotation/options/annotationAsArg.kt new file mode 100644 index 00000000000..5484366eef0 --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotationAsArg.kt @@ -0,0 +1,14 @@ +class Annotation(val x: Int) { + fun baz() {} + fun bar() = x +} + +fun foo(annotation: Annotation): Int { + if (annotation.bar() == 0) { + annotation.baz() + return 0 + } + else { + return -1 + } +} diff --git a/compiler/testData/psi/annotation/options/annotationAsArg.txt b/compiler/testData/psi/annotation/options/annotationAsArg.txt new file mode 100644 index 00000000000..4a9e7c9ab32 --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotationAsArg.txt @@ -0,0 +1,144 @@ +JetFile: annotationAsArg.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Annotation') + PRIMARY_CONSTRUCTOR + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('baz') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('bar') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('annotation') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Annotation') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + IF + PsiElement(if)('if') + PsiWhiteSpace(' ') + PsiElement(LPAR)('(') + CONDITION + BINARY_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(EQEQ)('==') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + THEN + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('baz') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + PsiElement(else)('else') + PsiWhiteSpace(' ') + ELSE + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + PREFIX_EXPRESSION + OPERATION_REFERENCE + PsiElement(MINUS)('-') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/annotationAsArgComplex.kt b/compiler/testData/psi/annotation/options/annotationAsArgComplex.kt new file mode 100644 index 00000000000..2f8aa3161d0 --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotationAsArgComplex.kt @@ -0,0 +1,9 @@ +class Annotation { + fun setProblemGroup() {} + fun getQuickFixes() = 0 +} + +fun registerQuickFix(annotation: Annotation) { + annotation.setProblemGroup() + val fixes = annotation.getQuickFixes() +} diff --git a/compiler/testData/psi/annotation/options/annotationAsArgComplex.txt b/compiler/testData/psi/annotation/options/annotationAsArgComplex.txt new file mode 100644 index 00000000000..6000806b13d --- /dev/null +++ b/compiler/testData/psi/annotation/options/annotationAsArgComplex.txt @@ -0,0 +1,89 @@ +JetFile: annotationAsArgComplex.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Annotation') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('setProblemGroup') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('getQuickFixes') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('0') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('registerQuickFix') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + VALUE_PARAMETER + PsiElement(IDENTIFIER)('annotation') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Annotation') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('setProblemGroup') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n ') + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('fixes') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('getQuickFixes') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/java.kt b/compiler/testData/psi/annotation/options/java.kt new file mode 100644 index 00000000000..64d86b337ca --- /dev/null +++ b/compiler/testData/psi/annotation/options/java.kt @@ -0,0 +1,10 @@ +import java.lang.annotation.* + +annotation +@java.lang.annotation.Retention(RetentionPolicy.CLASS) +class my + +annotation +Retention(RetentionPolicy.RUNTIME) +Target(ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR) +class my1 diff --git a/compiler/testData/psi/annotation/options/java.txt b/compiler/testData/psi/annotation/options/java.txt new file mode 100644 index 00000000000..7609d622a01 --- /dev/null +++ b/compiler/testData/psi/annotation/options/java.txt @@ -0,0 +1,118 @@ +JetFile: java.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + IMPORT_DIRECTIVE + PsiElement(import)('import') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + PsiElement(MUL)('*') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' \n') + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('lang') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('RetentionPolicy') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('CLASS') + PsiElement(RPAR)(')') + PsiWhiteSpace(' \n') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('my') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' \n') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('RetentionPolicy') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('RUNTIME') + PsiElement(RPAR)(')') + PsiWhiteSpace(' \n') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ElementType') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ANNOTATION_TYPE') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('ElementType') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('CONSTRUCTOR') + PsiElement(RPAR)(')') + PsiWhiteSpace(' \n') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('my1') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/local.kt b/compiler/testData/psi/annotation/options/local.kt new file mode 100644 index 00000000000..21c6e0b4629 --- /dev/null +++ b/compiler/testData/psi/annotation/options/local.kt @@ -0,0 +1,5 @@ +fun foo(): Int { + @annotation class Ann + @Ann val x = 1 + return x +} \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/local.txt b/compiler/testData/psi/annotation/options/local.txt new file mode 100644 index 00000000000..9a25e12b7be --- /dev/null +++ b/compiler/testData/psi/annotation/options/local.txt @@ -0,0 +1,62 @@ +JetFile: local.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('foo') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('Ann') + PsiWhiteSpace('\n ') + PROPERTY + MODIFIER_LIST + ANNOTATION_ENTRY + PsiElement(AT)('@') + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Ann') + PsiWhiteSpace(' ') + PsiElement(val)('val') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiWhiteSpace('\n ') + RETURN + PsiElement(return)('return') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/options.kt b/compiler/testData/psi/annotation/options/options.kt new file mode 100644 index 00000000000..f51b6127ec7 --- /dev/null +++ b/compiler/testData/psi/annotation/options/options.kt @@ -0,0 +1,12 @@ +annotation class base + +annotation() class empty + +annotation(repeatable = true) class ann + +annotation(Retention.BINARY, false) class ann2 + +annotation(retention = Retention.RUNTIME) class ann3 + +target(Target.FUNCTION, Target.CLASSIFIER, Target.EXPRESSION) +annotation(Retention.SOURCE) class ann4 \ No newline at end of file diff --git a/compiler/testData/psi/annotation/options/options.txt b/compiler/testData/psi/annotation/options/options.txt new file mode 100644 index 00000000000..0352a3b4644 --- /dev/null +++ b/compiler/testData/psi/annotation/options/options.txt @@ -0,0 +1,173 @@ +JetFile: options.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('base') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('empty') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('repeatable') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + BOOLEAN_CONSTANT + PsiElement(true)('true') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ann') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('BINARY') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + BOOLEAN_CONSTANT + PsiElement(false)('false') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ann2') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + VALUE_ARGUMENT_NAME + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('retention') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('RUNTIME') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ann3') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('target') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('FUNCTION') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('CLASSIFIER') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Target') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('EXPRESSION') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Retention') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('SOURCE') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ann4') \ No newline at end of file diff --git a/compiler/testData/renderer/Classes.kt b/compiler/testData/renderer/Classes.kt index 31df8ff1a43..9a6b220b470 100644 --- a/compiler/testData/renderer/Classes.kt +++ b/compiler/testData/renderer/Classes.kt @@ -35,9 +35,9 @@ public class WithReified public interface TwoUpperBounds where T : Number, T : Any //package rendererTest -//internal final annotation class TheAnnotation : kotlin.Annotation defined in rendererTest +//kotlin.annotation.annotation internal final annotation class TheAnnotation : kotlin.Annotation defined in rendererTest //public constructor TheAnnotation() defined in rendererTest.TheAnnotation -//internal final annotation class AnotherAnnotation : kotlin.Annotation defined in rendererTest +//kotlin.annotation.annotation internal final annotation class AnotherAnnotation : kotlin.Annotation defined in rendererTest //public constructor AnotherAnnotation() defined in rendererTest.AnotherAnnotation //rendererTest.TheAnnotation public open class TheClass defined in rendererTest // defined in rendererTest.TheClass diff --git a/compiler/testData/renderer/KeywordsInNames.kt b/compiler/testData/renderer/KeywordsInNames.kt index 1c92b06d8f7..cfd65f664f8 100644 --- a/compiler/testData/renderer/KeywordsInNames.kt +++ b/compiler/testData/renderer/KeywordsInNames.kt @@ -17,7 +17,7 @@ val AS_SAFE = 1 val NOT_IN = 2 val NOT_IS = 3 -//internal final annotation class `true` : kotlin.Annotation defined in root package +//kotlin.annotation.annotation internal final annotation class `true` : kotlin.Annotation defined in root package //public constructor `true`() defined in `true` //internal val `val`: kotlin.Int defined in root package //`true` internal interface `interface` defined in root package diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt index 406e0750e80..6f95aea08e2 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt @@ -1,6 +1,6 @@ package test -internal final annotation class AnnotationArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class AnnotationArray : kotlin.Annotation { public constructor AnnotationArray(/*0*/ annotationArray: kotlin.Array) internal final val annotationArray: kotlin.Array } @@ -13,11 +13,11 @@ test.AnnotationArray(annotationArray = {test.JustAnnotation(annotation = test.Em public constructor C2() } -internal final annotation class Empty : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Empty : kotlin.Annotation { public constructor Empty() } -internal final annotation class JustAnnotation : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class JustAnnotation : kotlin.Annotation { public constructor JustAnnotation(/*0*/ annotation: test.Empty) internal final val annotation: test.Empty } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt index 11a76ebc119..f01734d10e8 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt @@ -8,12 +8,12 @@ test.EnumArray(enumArray = {Weapon.PAPER, Weapon.ROCK}) internal final class C2 public constructor C2() } -internal final annotation class EnumArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class EnumArray : kotlin.Annotation { public constructor EnumArray(/*0*/ enumArray: kotlin.Array) internal final val enumArray: kotlin.Array } -internal final annotation class JustEnum : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class JustEnum : kotlin.Annotation { public constructor JustEnum(/*0*/ weapon: test.Weapon) internal final val weapon: test.Weapon } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt index d21aca61ed4..f5c7253a19d 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt @@ -8,7 +8,7 @@ test.PrimitiveArrays(booleanArray = {}, byteArray = {}, charArray = {}, doubleAr public constructor C2() } -internal final annotation class PrimitiveArrays : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class PrimitiveArrays : kotlin.Annotation { public constructor PrimitiveArrays(/*0*/ byteArray: kotlin.ByteArray, /*1*/ charArray: kotlin.CharArray, /*2*/ shortArray: kotlin.ShortArray, /*3*/ intArray: kotlin.IntArray, /*4*/ longArray: kotlin.LongArray, /*5*/ floatArray: kotlin.FloatArray, /*6*/ doubleArray: kotlin.DoubleArray, /*7*/ booleanArray: kotlin.BooleanArray) internal final val booleanArray: kotlin.BooleanArray internal final val byteArray: kotlin.ByteArray diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt index 9607ed110cf..84b02aa9784 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt @@ -8,7 +8,7 @@ test.Primitives(boolean = true, byte = 7.toByte(), char = \u0025 ('%'), double = public constructor D() } -internal final annotation class Primitives : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class Primitives : kotlin.Annotation { public constructor Primitives(/*0*/ byte: kotlin.Byte, /*1*/ char: kotlin.Char, /*2*/ short: kotlin.Short, /*3*/ int: kotlin.Int, /*4*/ long: kotlin.Long, /*5*/ float: kotlin.Float, /*6*/ double: kotlin.Double, /*7*/ boolean: kotlin.Boolean) internal final val boolean: kotlin.Boolean internal final val byte: kotlin.Byte diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt index 27a8890911b..fceb8171734 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt @@ -8,12 +8,12 @@ test.StringArray(stringArray = {"java", ""}) internal final class C2 { public constructor C2() } -internal final annotation class JustString : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class JustString : kotlin.Annotation { public constructor JustString(/*0*/ string: kotlin.String) internal final val string: kotlin.String } -internal final annotation class StringArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class StringArray : kotlin.Annotation { public constructor StringArray(/*0*/ stringArray: kotlin.Array) internal final val stringArray: kotlin.Array } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt index a65fdc5c1b1..30d245911e6 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt @@ -32,11 +32,11 @@ internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann(/*0*/ vararg m: test.My /*kotlin.Array*/) internal final val m: kotlin.Array } -test.ann(m = {My.ALPHA, My.BETA}) internal final annotation class annotated : kotlin.Annotation { +test.ann(m = {My.ALPHA, My.BETA}) kotlin.annotation.annotation() internal final annotation class annotated : kotlin.Annotation { public constructor annotated() } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt b/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt index 0ab4c38a7b1..b03c61aeceb 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt @@ -21,7 +21,7 @@ test.anno(x = "top level class") internal final class C1 { } } -internal final annotation class anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class anno : kotlin.Annotation { public constructor anno(/*0*/ x: kotlin.String) internal final val x: kotlin.String } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 447854e66f9..7a794179b36 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -645,6 +645,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("AnnotationAsDefaultParameter.kt") + public void testAnnotationAsDefaultParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.kt"); + doTest(fileName); + } + @TestMetadata("AnnotationForClassTypeParameter.kt") public void testAnnotationForClassTypeParameter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.kt"); @@ -977,6 +983,57 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } } + + @TestMetadata("compiler/testData/diagnostics/tests/annotations/options") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Options extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInOptions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/annotations/options"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/annotation.kt"); + doTest(fileName); + } + + @TestMetadata("annotationAsArg.kt") + public void testAnnotationAsArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/annotationAsArg.kt"); + doTest(fileName); + } + + @TestMetadata("annotationAsArgComplex.kt") + public void testAnnotationAsArgComplex() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/annotationAsArgComplex.kt"); + doTest(fileName); + } + + @TestMetadata("brackets.kt") + public void testBrackets() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/brackets.kt"); + doTest(fileName); + } + + @TestMetadata("repeatable.kt") + public void testRepeatable() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/repeatable.kt"); + doTest(fileName); + } + + @TestMetadata("retention.kt") + public void testRetention() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/retention.kt"); + doTest(fileName); + } + + @TestMetadata("target.kt") + public void testTarget() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/target.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/backingField") diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index 0d212813153..c08487d9191 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -899,6 +899,57 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } } + + @TestMetadata("compiler/testData/psi/annotation/options") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Options extends AbstractJetParsingTest { + public void testAllFilesPresentInOptions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/psi/annotation/options"), Pattern.compile("^(.*)\\.kts?$"), true); + } + + @TestMetadata("annotAsArgComplex.kt") + public void testAnnotAsArgComplex() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/annotAsArgComplex.kt"); + doParsingTest(fileName); + } + + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/annotation.kt"); + doParsingTest(fileName); + } + + @TestMetadata("annotationAsArg.kt") + public void testAnnotationAsArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/annotationAsArg.kt"); + doParsingTest(fileName); + } + + @TestMetadata("annotationAsArgComplex.kt") + public void testAnnotationAsArgComplex() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/annotationAsArgComplex.kt"); + doParsingTest(fileName); + } + + @TestMetadata("java.kt") + public void testJava() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/java.kt"); + doParsingTest(fileName); + } + + @TestMetadata("local.kt") + public void testLocal() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/local.kt"); + doParsingTest(fileName); + } + + @TestMetadata("options.kt") + public void testOptions() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/annotation/options/options.kt"); + doParsingTest(fileName); + } + } } @TestMetadata("compiler/testData/psi/examples") diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt index f6db9e92272..a68424c06a1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClassClsStubBuilder.kt @@ -94,7 +94,6 @@ private class ClassClsStubBuilder( } val additionalModifiers = when (classKind) { ProtoBuf.Class.Kind.ENUM_CLASS -> listOf(JetTokens.ENUM_KEYWORD) - ProtoBuf.Class.Kind.ANNOTATION_CLASS -> listOf(JetTokens.ANNOTATION_KEYWORD) ProtoBuf.Class.Kind.CLASS_OBJECT -> listOf(JetTokens.COMPANION_KEYWORD) else -> listOf() } diff --git a/idea/idea-completion/testData/basic/common/annotations/Annotated.kt b/idea/idea-completion/testData/basic/common/annotations/Annotated.kt new file mode 100644 index 00000000000..f2cd74d106d --- /dev/null +++ b/idea/idea-completion/testData/basic/common/annotations/Annotated.kt @@ -0,0 +1,3 @@ + class Annotated + +// EXIST: annotation \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt b/idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt new file mode 100644 index 00000000000..c978d07c743 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt @@ -0,0 +1,4 @@ +annotation() class Annotated + +// EXIST: retention +// EXIST: repeatable diff --git a/idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt b/idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt new file mode 100644 index 00000000000..b5aeaea8b6c --- /dev/null +++ b/idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt @@ -0,0 +1,3 @@ + annotation class Annotated + +// EXIST: target diff --git a/idea/idea-completion/testData/keywords/AfterClassProperty.kt b/idea/idea-completion/testData/keywords/AfterClassProperty.kt index e1c48a3f01b..93f3851a6e9 100644 --- a/idea/idea-completion/testData/keywords/AfterClassProperty.kt +++ b/idea/idea-completion/testData/keywords/AfterClassProperty.kt @@ -5,7 +5,6 @@ class MouseMovedEventArgs } // EXIST: abstract -// EXIST: annotation // EXIST: as // EXIST: class // EXIST: enum diff --git a/idea/idea-completion/testData/keywords/AfterClasses.kt b/idea/idea-completion/testData/keywords/AfterClasses.kt index 40c822bde0e..46b0c294c42 100644 --- a/idea/idea-completion/testData/keywords/AfterClasses.kt +++ b/idea/idea-completion/testData/keywords/AfterClasses.kt @@ -13,7 +13,6 @@ class B { // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/testData/keywords/AfterFuns.kt b/idea/idea-completion/testData/keywords/AfterFuns.kt index 3cb320a7ab4..d7cde5ea482 100644 --- a/idea/idea-completion/testData/keywords/AfterFuns.kt +++ b/idea/idea-completion/testData/keywords/AfterFuns.kt @@ -11,7 +11,6 @@ class A { } // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/testData/keywords/FileKeyword.kt b/idea/idea-completion/testData/keywords/FileKeyword.kt index d7163b48ad8..78d5ef641ec 100644 --- a/idea/idea-completion/testData/keywords/FileKeyword.kt +++ b/idea/idea-completion/testData/keywords/FileKeyword.kt @@ -1,7 +1,6 @@ @[] // EXIST: {"lookupString":"abstract","itemText":"abstract","attributes":"bold"} -// EXIST: {"lookupString":"annotation","itemText":"annotation","attributes":"bold"} // EXIST: {"lookupString":"class","itemText":"class","attributes":"bold"} // EXIST: {"lookupString":"companion object","itemText":"companion object","attributes":"bold"} // EXIST: {"lookupString":"enum","itemText":"enum","attributes":"bold"} diff --git a/idea/idea-completion/testData/keywords/GlobalPropertyAccessors.kt b/idea/idea-completion/testData/keywords/GlobalPropertyAccessors.kt index 1071377222e..26e88f60f75 100644 --- a/idea/idea-completion/testData/keywords/GlobalPropertyAccessors.kt +++ b/idea/idea-completion/testData/keywords/GlobalPropertyAccessors.kt @@ -10,7 +10,6 @@ var a : Int // EXIST: abstract -// EXIST: annotation // EXIST: by // EXIST: class // EXIST: enum diff --git a/idea/idea-completion/testData/keywords/InClassBeforeFun.kt b/idea/idea-completion/testData/keywords/InClassBeforeFun.kt index 7a59f949c52..32a9133121d 100644 --- a/idea/idea-completion/testData/keywords/InClassBeforeFun.kt +++ b/idea/idea-completion/testData/keywords/InClassBeforeFun.kt @@ -9,7 +9,6 @@ public class Test { // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/testData/keywords/InClassScope.kt b/idea/idea-completion/testData/keywords/InClassScope.kt index 9158b047cf0..93ea7db0a6b 100644 --- a/idea/idea-completion/testData/keywords/InClassScope.kt +++ b/idea/idea-completion/testData/keywords/InClassScope.kt @@ -3,7 +3,6 @@ class TestClass { } // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/testData/keywords/InTopScopeAfterPackage.kt b/idea/idea-completion/testData/keywords/InTopScopeAfterPackage.kt index cfd2c497048..139a7da2242 100644 --- a/idea/idea-completion/testData/keywords/InTopScopeAfterPackage.kt +++ b/idea/idea-completion/testData/keywords/InTopScopeAfterPackage.kt @@ -3,7 +3,6 @@ package Test // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/testData/keywords/PropertyAccessors.kt b/idea/idea-completion/testData/keywords/PropertyAccessors.kt index 97fed3ffa6c..8d1a7f35848 100644 --- a/idea/idea-completion/testData/keywords/PropertyAccessors.kt +++ b/idea/idea-completion/testData/keywords/PropertyAccessors.kt @@ -4,7 +4,6 @@ class Some { } // EXIST: abstract -// EXIST: annotation // EXIST: by // EXIST: class // EXIST: enum diff --git a/idea/idea-completion/testData/keywords/PropertyAccessors2.kt b/idea/idea-completion/testData/keywords/PropertyAccessors2.kt index d0f18e763f3..5c00b0b9f28 100644 --- a/idea/idea-completion/testData/keywords/PropertyAccessors2.kt +++ b/idea/idea-completion/testData/keywords/PropertyAccessors2.kt @@ -4,7 +4,6 @@ class Some { } // EXIST: abstract -// EXIST: annotation // EXIST: as // EXIST: class // EXIST: enum diff --git a/idea/idea-completion/testData/keywords/PropertySetter.kt b/idea/idea-completion/testData/keywords/PropertySetter.kt index d1c3ac16d2e..024f79c4062 100644 --- a/idea/idea-completion/testData/keywords/PropertySetter.kt +++ b/idea/idea-completion/testData/keywords/PropertySetter.kt @@ -5,7 +5,6 @@ class Some { } // EXIST: abstract -// EXIST: annotation // EXIST: as // EXIST: class // EXIST: enum diff --git a/idea/idea-completion/testData/keywords/TopScope.kt b/idea/idea-completion/testData/keywords/TopScope.kt index df2f8c318ca..470e9e640d5 100644 --- a/idea/idea-completion/testData/keywords/TopScope.kt +++ b/idea/idea-completion/testData/keywords/TopScope.kt @@ -1,7 +1,6 @@ // EXIST: abstract -// EXIST: annotation // EXIST: class // EXIST: enum // EXIST: final diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index df3dca167dc..f4c5eb64996 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -885,6 +885,24 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/annotations"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("Annotated.kt") + public void testAnnotated() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/Annotated.kt"); + doTest(fileName); + } + + @TestMetadata("AnnotationArguments.kt") + public void testAnnotationArguments() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("AnnotationTarget.kt") + public void testAnnotationTarget() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt"); + doTest(fileName); + } + @TestMetadata("FunctionAnnotation1.kt") public void testFunctionAnnotation1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/FunctionAnnotation1.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 4a7e00f9a02..3f3935b0f2b 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -885,6 +885,24 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/idea-completion/testData/basic/common/annotations"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("Annotated.kt") + public void testAnnotated() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/Annotated.kt"); + doTest(fileName); + } + + @TestMetadata("AnnotationArguments.kt") + public void testAnnotationArguments() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/AnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("AnnotationTarget.kt") + public void testAnnotationTarget() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/AnnotationTarget.kt"); + doTest(fileName); + } + @TestMetadata("FunctionAnnotation1.kt") public void testFunctionAnnotation1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/annotations/FunctionAnnotation1.kt"); diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java index b01f9b97b41..30a8f9466e3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeClassAnAnnotationClassFix.java @@ -26,13 +26,12 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.idea.JetBundle; import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil; import org.jetbrains.kotlin.psi.*; -import static org.jetbrains.kotlin.lexer.JetTokens.ANNOTATION_KEYWORD; - public class MakeClassAnAnnotationClassFix extends JetIntentionAction { private final JetAnnotationEntry annotationEntry; private JetClass annotationClass; @@ -83,8 +82,20 @@ public class MakeClassAnAnnotationClassFix extends JetIntentionAction PsiElement.getAndRemoveCopyableUserData(key: Key): T? { val data = getCopyableUserData(key) @@ -406,7 +408,11 @@ private fun copyModifierListItems(from: PsiModifierList, to: PsiModifierList, wi } } for (annotation in from.getAnnotations()) { - to.addAnnotation(annotation.getQualifiedName()!!) + val annotationName = annotation.getQualifiedName()!! + if (KotlinBuiltIns.FQ_NAMES.annotation.asString() != annotationName + && javaClass().getName() != annotationName) { + to.addAnnotation(annotationName) + } } } diff --git a/idea/testData/highlighter/TypesAndAnnotations.kt b/idea/testData/highlighter/TypesAndAnnotations.kt index 77ece2f4208..2ebdd6f3681 100644 --- a/idea/testData/highlighter/TypesAndAnnotations.kt +++ b/idea/testData/highlighter/TypesAndAnnotations.kt @@ -4,8 +4,8 @@ interface TheTrait { class TheClass : TheTrait { } -annotation class magnificent -annotation class deprecated +annotation class magnificent +annotation class deprecated @deprecated magnificent abstract class AbstractClass<T> { diff --git a/idea/testData/stubs/AnnotationClass.expected b/idea/testData/stubs/AnnotationClass.expected index 03b373d2a49..74a06f90d3c 100644 --- a/idea/testData/stubs/AnnotationClass.expected +++ b/idea/testData/stubs/AnnotationClass.expected @@ -2,4 +2,9 @@ PsiJetFileStubImpl[package=] PACKAGE_DIRECTIVE: IMPORT_LIST: CLASS:[fqName=Test, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=Test, superNames=[]] - MODIFIER_LIST:[annotation] + MODIFIER_LIST:[] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=annotation] diff --git a/idea/testData/stubs/SecondaryConstructors.expected b/idea/testData/stubs/SecondaryConstructors.expected index 278b03e45a1..080524dd1d3 100644 --- a/idea/testData/stubs/SecondaryConstructors.expected +++ b/idea/testData/stubs/SecondaryConstructors.expected @@ -77,4 +77,9 @@ PsiJetFileStubImpl[package=test] MODIFIER_LIST:[internal] VALUE_PARAMETER_LIST: CLASS:[fqName=test.anno, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=anno, superNames=[]] - MODIFIER_LIST:[annotation] + MODIFIER_LIST:[] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=annotation] diff --git a/idea/testData/stubs/TypeAnnotation.expected b/idea/testData/stubs/TypeAnnotation.expected index ecf82fcfa4f..b85e0320508 100644 --- a/idea/testData/stubs/TypeAnnotation.expected +++ b/idea/testData/stubs/TypeAnnotation.expected @@ -2,9 +2,19 @@ PsiJetFileStubImpl[package=] PACKAGE_DIRECTIVE: IMPORT_LIST: CLASS:[fqName=a, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=a, superNames=[]] - MODIFIER_LIST:[annotation] + MODIFIER_LIST:[] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=annotation] CLASS:[fqName=b, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=b, superNames=[]] - MODIFIER_LIST:[annotation] + MODIFIER_LIST:[] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=annotation] PRIMARY_CONSTRUCTOR: VALUE_PARAMETER_LIST: VALUE_PARAMETER:[fqName=b.e, hasDefaultValue=false, hasValOrVar=true, isMutable=false, name=e] diff --git a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotationInSameFile.kt b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotationInSameFile.kt index 6d4608fa2ac..238f42450cc 100644 --- a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotationInSameFile.kt +++ b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotationInSameFile.kt @@ -1,6 +1,6 @@ package org.test -public annotation class SomeAnnotation +public annotation(retention = AnnotationRetention.BINARY) class SomeAnnotation SomeAnnotation public class SomeClass { diff --git a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt index 89c154ea586..e111145ea84 100644 --- a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt @@ -1,4 +1,6 @@ -a org.test.SomeAnnotation 0 +a kotlin.annotation.annotation 0 p org.test 0 -c 0 0/SomeClass -m 0 0/SomeClass annotatedFunction +c 0 0/SomeAnnotation +a org.test.SomeAnnotation 1 +c 1 0/SomeClass +m 1 0/SomeClass annotatedFunction From 4a27b4d614c7771946b435e8d5726e8cbb29fa3b Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 14 Jul 2015 15:45:14 +0300 Subject: [PATCH 253/450] JetClassOrObject.isAnnotation() is deprecated --- .../frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt index 7b3482cd6f9..e41a4a0e9f1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt @@ -65,6 +65,7 @@ abstract public class JetClassOrObject : JetTypeParameterListOwnerStub = getBody()?.getSecondaryConstructors().orEmpty() + deprecated(value = "It's no more possible to determine it exactly using AST. Use ClassDescriptor methods instead, e.g. getKind()") public fun isAnnotation(): Boolean = hasAnnotation(KotlinBuiltIns.FQ_NAMES.annotation.shortName().asString()) private fun hasAnnotation(name: String): Boolean { From 609d69620239517dacb0197d2192b5a653bd8a06 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 3 Jul 2015 12:11:08 +0300 Subject: [PATCH 254/450] Annotations have now retention of "RUNTIME" by default. Java retention is generated as given by kotlin annotation. Annotation rendering changed. Annotation arguments with default values are rendered as ... if renderDefaultAnnotationArguments is true. Tests: java retention does not taken into account by Descriptor comparator. Java retentinon changed to kotlin retention in some tests + one new test with java retention added. More accurate tests for intentions in byte code (visibility controlled). --- .../kotlin/codegen/AnnotationCodegen.java | 46 ++++++++++++++++++- ...vaNegativePropertyAsAnnotationParameter.kt | 6 +-- .../javaPropertyAsAnnotationParameter.kt | 6 +-- .../javaPropertyWithIntInitializer.kt | 6 +-- .../annotatedSamFunExpression.kt | 4 +- .../annotationsWithKClass/array/array.kt | 4 +- .../annotationsWithKClass/basic/basic.kt | 4 +- .../annotationsWithKClass/vararg/vararg.kt | 4 +- .../annotations/simpleClassObject.kt | 5 +- .../annotations/annotatedEnumEntry.kt | 8 +--- .../annotatedLambda/funExpression.kt | 4 +- .../annotations/annotationsOnDefault.kt | 4 +- .../annotations/defaultParameterValues.kt | 5 +- .../annotations/delegatedPropertySetter.kt | 5 +- ...otlinPropertyFromClassObjectAsParameter.kt | 6 +-- .../kotlinTopLevelPropertyAsParameter.kt | 6 +-- .../nestedClassPropertyAsParameter.kt | 6 +-- .../annotations/parameterWithPrimitiveType.kt | 6 +-- ...rtyWithPropertyInInitializerAsParameter.kt | 6 +-- .../varargInAnnotationParameter.kt | 6 +-- .../codegen/boxWithStdlib/evaluate/char.kt | 6 +-- .../codegen/boxWithStdlib/evaluate/divide.kt | 6 +-- .../boxWithStdlib/evaluate/infixCallBinary.kt | 6 +-- .../boxWithStdlib/evaluate/intrincics.kt | 6 +-- .../boxWithStdlib/evaluate/maxValue.kt | 6 +-- .../boxWithStdlib/evaluate/maxValueByte.kt | 6 +-- .../boxWithStdlib/evaluate/maxValueInt.kt | 6 +-- .../boxWithStdlib/evaluate/miltiply.kt | 6 +-- .../codegen/boxWithStdlib/evaluate/minus.kt | 6 +-- .../codegen/boxWithStdlib/evaluate/mod.kt | 6 +-- .../boxWithStdlib/evaluate/paranthesized.kt | 6 +-- .../codegen/boxWithStdlib/evaluate/plus.kt | 6 +-- .../evaluate/simpleCallBinary.kt | 6 +-- .../boxWithStdlib/evaluate/unaryMinus.kt | 6 +-- .../boxWithStdlib/evaluate/unaryPlus.kt | 6 +-- .../reflection/kClassInAnnotation/array.kt | 4 +- .../reflection/kClassInAnnotation/basic.kt | 4 +- .../reflection/kClassInAnnotation/vararg.kt | 4 +- .../boxWithStdlib/regressions/kt1932.kt | 4 +- .../annotationJavaRetentionPolicyRuntime.kt | 9 ++++ .../annotationRetentionPolicyClass.kt | 10 ++-- .../annotationRetentionPolicyRuntime.kt | 9 ++-- .../annotationRetentionPolicySource.kt | 6 +-- .../properties/syntheticMethod/inClass.kt | 4 +- .../properties/syntheticMethod/inTrait.kt | 4 +- .../properties/syntheticMethod/topLevel.kt | 4 +- .../AnnotationInTrait.A.kt | 5 +- .../InlinedConstants.A.kt | 6 +-- .../KotlinPropertyAsAnnotationParameter.B.kt | 5 +- .../JavaAnnotationConstructors.txt | 4 +- .../annotations/TargetedAnnotation.kt | 6 +++ .../annotations/TargetedAnnotation.txt | 5 ++ .../annotations/classes/DataClass.kt | 3 ++ .../annotations/classes/DataClass.txt | 9 ++++ .../annotations/classes/Retention.kt | 4 +- .../annotations/classes/Retention.txt | 2 +- .../codegen/BytecodeTextTestGenerated.java | 6 +++ .../AbstractCompileJavaAgainstKotlinTest.java | 3 ++ .../jvm/compiler/LoadJavaTestGenerated.java | 12 +++++ .../AbstractJvmRuntimeDescriptorLoaderTest.kt | 21 +++------ ...mRuntimeDescriptorLoaderTestGenerated.java | 12 +++++ .../util/RecursiveDescriptorComparator.java | 14 ++++-- .../kotlin/renderer/DescriptorRenderer.kt | 1 + .../kotlin/renderer/DescriptorRendererImpl.kt | 13 +++++- .../renderer/DescriptorRendererOptionsImpl.kt | 1 + .../stubs/ResolveByStubTestGenerated.java | 12 +++++ libraries/stdlib/test/AnnotationsTest.kt | 5 +- .../annotationInSameFile/annotations.txt | 8 ++-- 68 files changed, 214 insertions(+), 242 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeText/annotationJavaRetentionPolicyRuntime.kt create mode 100644 compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt create mode 100644 compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt create mode 100644 compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt create mode 100644 compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.txt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index e8a775f7884..a5c3f95a6e3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -119,6 +119,12 @@ public abstract class AnnotationCodegen { generateNullabilityAnnotation(descriptor.getReturnType(), annotationDescriptorsAlreadyPresent); } } + if (annotated instanceof ClassDescriptor) { + ClassDescriptor classDescriptor = (ClassDescriptor) annotated; + if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { + generateRetentionAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent); + } + } } private static boolean isInvisibleFromTheOutside(@Nullable DeclarationDescriptor descriptor) { @@ -160,6 +166,15 @@ public abstract class AnnotationCodegen { generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass); } + private void generateRetentionAnnotation(@NotNull ClassDescriptor classDescriptor, @NotNull Set annotationDescriptorsAlreadyPresent) { + RetentionPolicy policy = getRetentionPolicy(classDescriptor); + String descriptor = Type.getType(Retention.class).getDescriptor(); + if (!annotationDescriptorsAlreadyPresent.add(descriptor)) return; + AnnotationVisitor visitor = visitAnnotation(descriptor, true); + visitor.visitEnum("value", Type.getType(RetentionPolicy.class).getDescriptor(), policy.name()); + visitor.visitEnd(); + } + private void generateAnnotationIfNotPresent(Set annotationDescriptorsAlreadyPresent, Class annotationClass) { String descriptor = Type.getType(annotationClass).getDescriptor(); if (!annotationDescriptorsAlreadyPresent.contains(descriptor)) { @@ -318,8 +333,37 @@ public abstract class AnnotationCodegen { value.accept(argumentVisitor, null); } + private enum KotlinRetention { + SOURCE(RetentionPolicy.SOURCE), + BINARY(RetentionPolicy.CLASS), + RUNTIME(RetentionPolicy.RUNTIME); + + final RetentionPolicy mapped; + + KotlinRetention(RetentionPolicy mapped) { + this.mapped = mapped; + } + } + @NotNull private RetentionPolicy getRetentionPolicy(@NotNull Annotated descriptor) { + AnnotationDescriptor kotlinAnnotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.annotation); + if (kotlinAnnotation != null) { + for (Map.Entry> argument: kotlinAnnotation.getAllValueArguments().entrySet()) { + if ("retention".equals(argument.getKey().getName().asString()) && argument.getValue() instanceof EnumValue) { + ClassDescriptor enumEntry = ((EnumValue) argument.getValue()).getValue(); + JetType classObjectType = getClassObjectType(enumEntry); + if (classObjectType != null) { + if ("kotlin/annotation/AnnotationRetention".equals(typeMapper.mapType(classObjectType).getInternalName())) { + String entryName = enumEntry.getName().asString(); + for (KotlinRetention retention: KotlinRetention.values()) { + if (retention.name().equals(entryName)) return retention.mapped; + } + } + } + } + } + } AnnotationDescriptor retentionAnnotation = descriptor.getAnnotations().findAnnotation(new FqName(Retention.class.getName())); if (retentionAnnotation != null) { Collection> valueArguments = retentionAnnotation.getAllValueArguments().values(); @@ -337,7 +381,7 @@ public abstract class AnnotationCodegen { } } - return RetentionPolicy.CLASS; + return RetentionPolicy.RUNTIME; } @NotNull diff --git a/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt index b3cf2d96acf..0146526a3a7 100644 --- a/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b) class MyClass fun box(): String { @@ -15,8 +12,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt index 60170c36cba..aa6d75c3acb 100644 --- a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass fun box(): String { @@ -18,8 +15,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt index 67875adf7f6..4e621be9447 100644 --- a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt +++ b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.c) class MyClass fun box(): String { @@ -16,8 +13,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/codegen/boxWithJava/annotatedSamFunExpression/annotatedSamFunExpression.kt b/compiler/testData/codegen/boxWithJava/annotatedSamFunExpression/annotatedSamFunExpression.kt index 798e6a86839..582e297caa7 100644 --- a/compiler/testData/codegen/boxWithJava/annotatedSamFunExpression/annotatedSamFunExpression.kt +++ b/compiler/testData/codegen/boxWithJava/annotatedSamFunExpression/annotatedSamFunExpression.kt @@ -1,10 +1,8 @@ -import java.lang.annotation.* import java.lang.reflect.Method import kotlin.reflect.jvm.java import kotlin.test.assertEquals -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val x: String) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: String) fun testMethod(method: Method, name: String) { assertEquals("OK", method.getAnnotation(javaClass()).x, "On method of test named `$name`") diff --git a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/array/array.kt b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/array/array.kt index 0f8718e1bc0..f4f88aa7c14 100644 --- a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/array/array.kt +++ b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/array/array.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val args: Array>) fun box(): String { diff --git a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/basic/basic.kt b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/basic/basic.kt index b0c937dff79..c346d5ec59c 100644 --- a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/basic/basic.kt +++ b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/basic/basic.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val arg: KClass<*>) fun box(): String { diff --git a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/vararg/vararg.kt b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/vararg/vararg.kt index d22a733d399..cf39dfd67ca 100644 --- a/compiler/testData/codegen/boxWithJava/annotationsWithKClass/vararg/vararg.kt +++ b/compiler/testData/codegen/boxWithJava/annotationsWithKClass/vararg/vararg.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(vararg val args: KClass<*>) fun box(): String { diff --git a/compiler/testData/codegen/boxWithJava/platformStatic/annotations/simpleClassObject.kt b/compiler/testData/codegen/boxWithJava/platformStatic/annotations/simpleClassObject.kt index a57849fb795..296cd8224cb 100644 --- a/compiler/testData/codegen/boxWithJava/platformStatic/annotations/simpleClassObject.kt +++ b/compiler/testData/codegen/boxWithJava/platformStatic/annotations/simpleClassObject.kt @@ -1,9 +1,6 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy import kotlin.platform.platformStatic -Retention(RetentionPolicy.RUNTIME) -annotation class testAnnotation +annotation(retention = AnnotationRetention.RUNTIME) class testAnnotation class A { diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedEnumEntry.kt b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedEnumEntry.kt index 95143c59e78..ead0b2e2156 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedEnumEntry.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedEnumEntry.kt @@ -1,12 +1,8 @@ // KT-5665 -import java.lang.annotation.* +annotation(retention = AnnotationRetention.RUNTIME) class First -Retention(RetentionPolicy.RUNTIME) -annotation class First - -Retention(RetentionPolicy.RUNTIME) -annotation class Second(val value: String) +annotation(retention = AnnotationRetention.RUNTIME) class Second(val value: String) enum class E { @First diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/funExpression.kt b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/funExpression.kt index e1a35abe22b..3bcc483afe4 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/funExpression.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/funExpression.kt @@ -1,10 +1,8 @@ -import java.lang.annotation.* import java.lang.reflect.Method import kotlin.reflect.jvm.java import kotlin.test.assertEquals -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val x: String) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: String) fun foo0(block: () -> Unit) = block.javaClass fun foo1(block: (String) -> Unit) = block.javaClass diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/annotationsOnDefault.kt b/compiler/testData/codegen/boxWithStdlib/annotations/annotationsOnDefault.kt index 3ae2dd93f86..6179a2439ea 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/annotationsOnDefault.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/annotationsOnDefault.kt @@ -1,8 +1,6 @@ -import java.lang.annotation.* import kotlin.test.assertEquals -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val x: Int) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: Int) class A { Ann(1) fun foo(x: Int, y: Int = 2, z: Int) {} diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/defaultParameterValues.kt b/compiler/testData/codegen/boxWithStdlib/annotations/defaultParameterValues.kt index 304e1fcce29..d99408f2f40 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/defaultParameterValues.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/defaultParameterValues.kt @@ -1,10 +1,7 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy import kotlin.reflect.KClass import kotlin.reflect.jvm.java -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int = 1, val s: String = "a", val a: Ann2 = Ann2(), diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt index 24e7376a8a3..34356bf7a12 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/delegatedPropertySetter.kt @@ -1,7 +1,4 @@ -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) -annotation class First +annotation(retention = AnnotationRetention.RUNTIME) class First class MyClass() { public var x: String by Delegate() diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/kotlinPropertyFromClassObjectAsParameter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/kotlinPropertyFromClassObjectAsParameter.kt index ec16c008089..835385e0b5e 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/kotlinPropertyFromClassObjectAsParameter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/kotlinPropertyFromClassObjectAsParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass fun box(): String { @@ -18,8 +15,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/kotlinTopLevelPropertyAsParameter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/kotlinTopLevelPropertyAsParameter.kt index 8356c404d74..eaaafbf3f6e 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/kotlinTopLevelPropertyAsParameter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/kotlinTopLevelPropertyAsParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(i, s, f, d, l, b, bool, c, str) class MyClass fun box(): String { @@ -18,8 +15,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/nestedClassPropertyAsParameter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/nestedClassPropertyAsParameter.kt index 48a935e5c2f..d7dd3805275 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/nestedClassPropertyAsParameter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/nestedClassPropertyAsParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(A.B.i) class MyClass fun box(): String { @@ -10,8 +7,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val i: Int) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val i: Int) class A { class B { diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/parameterWithPrimitiveType.kt b/compiler/testData/codegen/boxWithStdlib/annotations/parameterWithPrimitiveType.kt index 3b7914376da..6469958ea93 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/parameterWithPrimitiveType.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/parameterWithPrimitiveType.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val b: Byte, val s: Short, val i: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/propertyWithPropertyInInitializerAsParameter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/propertyWithPropertyInInitializerAsParameter.kt index 97afafad53c..268155c7a59 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/propertyWithPropertyInInitializerAsParameter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/propertyWithPropertyInInitializerAsParameter.kt @@ -1,6 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann(i) class MyClass fun box(): String { @@ -10,8 +7,7 @@ fun box(): String { return "OK" } -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val i: Int) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val i: Int) val i2: Int = 1 val i: Int = i2 diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/varargInAnnotationParameter.kt b/compiler/testData/codegen/boxWithStdlib/annotations/varargInAnnotationParameter.kt index bcb6d456c13..ed2fe14f038 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/varargInAnnotationParameter.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/varargInAnnotationParameter.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(vararg val p: Int) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(vararg val p: Int) Ann() class MyClass1 Ann(1) class MyClass2 diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/char.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/char.kt index 22674ee4f60..6fe0644ffe4 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/char.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/char.kt @@ -1,10 +1,6 @@ package test -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val c1: Int) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val c1: Int) Ann('a' - 'a') class MyClass diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/divide.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/divide.kt index ca891eb6eac..1273569707b 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/divide.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/divide.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val b: Byte, val s: Short, val i: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt index 3ecdbb17b1f..52666d81d24 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/infixCallBinary.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Int, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/intrincics.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/intrincics.kt index f63fdef4400..07cbc06acb8 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/intrincics.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/intrincics.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Short, val p3: Byte, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValue.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValue.kt index 1cb3dcb089c..7ec02fad346 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValue.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Int, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueByte.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueByte.kt index c927a96f218..11e6517a39e 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueByte.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueByte.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Byte, val p4: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueInt.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueInt.kt index 8317171ba77..2b81c8bac02 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueInt.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/maxValueInt.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Int, val p4: Long, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/miltiply.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/miltiply.kt index aca9bf3c2de..5125caa4557 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/miltiply.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/miltiply.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/minus.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/minus.kt index 626c85df9b7..baeeab6de9f 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/minus.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/minus.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/mod.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/mod.kt index 5042c163602..64ba6b944ea 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/mod.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/mod.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/paranthesized.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/paranthesized.kt index 62629fe5b1f..f9815c6940b 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/paranthesized.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/paranthesized.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/plus.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/plus.kt index c84910aa5cb..bfa000dfe76 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/plus.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/plus.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/simpleCallBinary.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/simpleCallBinary.kt index 84999de929f..2be9ecb8298 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/simpleCallBinary.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/simpleCallBinary.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Int, val p2: Int, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/unaryMinus.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/unaryMinus.kt index 68d4077cedc..a40663c2e87 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/unaryMinus.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/unaryMinus.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/evaluate/unaryPlus.kt b/compiler/testData/codegen/boxWithStdlib/evaluate/unaryPlus.kt index a75bc397886..b330439042e 100644 --- a/compiler/testData/codegen/boxWithStdlib/evaluate/unaryPlus.kt +++ b/compiler/testData/codegen/boxWithStdlib/evaluate/unaryPlus.kt @@ -1,8 +1,4 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val p1: Byte, val p2: Short, val p3: Int, diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/array.kt b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/array.kt index baf6024ecf4..05fc8d82bed 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/array.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/array.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val args: Array>) class O diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/basic.kt b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/basic.kt index eb42b6d11b8..16039ba0f60 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/basic.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/basic.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val arg: KClass<*>) class OK diff --git a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/vararg.kt b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/vararg.kt index 5033ea07085..41d79e7c693 100644 --- a/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/vararg.kt +++ b/compiler/testData/codegen/boxWithStdlib/reflection/kClassInAnnotation/vararg.kt @@ -1,8 +1,6 @@ import kotlin.reflect.KClass -import java.lang.annotation.* -Retention(RetentionPolicy.RUNTIME) -annotation +annotation(retention = AnnotationRetention.RUNTIME) class Ann(vararg val args: KClass<*>) class O diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt1932.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt1932.kt index b8040c69354..b5d58877650 100644 --- a/compiler/testData/codegen/boxWithStdlib/regressions/kt1932.kt +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt1932.kt @@ -1,8 +1,6 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy import java.lang.annotation.Annotation -Retention(RetentionPolicy.RUNTIME) annotation class foo(val name : String) +annotation(retention = AnnotationRetention.RUNTIME) class foo(val name : String) class Test() { foo("OK") fun hello(input : String) { diff --git a/compiler/testData/codegen/bytecodeText/annotationJavaRetentionPolicyRuntime.kt b/compiler/testData/codegen/bytecodeText/annotationJavaRetentionPolicyRuntime.kt new file mode 100644 index 00000000000..649f4d30daf --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/annotationJavaRetentionPolicyRuntime.kt @@ -0,0 +1,9 @@ +import java.lang.annotation.Retention +import java.lang.annotation.RetentionPolicy + +Ann class MyClass + +Retention(RetentionPolicy.RUNTIME) +annotation class Ann + +// 1 @LAnn;() \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyClass.kt b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyClass.kt index aef672ab0de..6e2e89a7c8d 100644 --- a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyClass.kt +++ b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyClass.kt @@ -1,9 +1,7 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann class MyClass -Retention(RetentionPolicy.CLASS) -annotation class Ann +annotation(retention = AnnotationRetention.BINARY) class Ann + +// 1 @LAnn;() +// 1 invisible -// 1 @LAnn;() \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyRuntime.kt b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyRuntime.kt index 649f4d30daf..08c29cd3766 100644 --- a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyRuntime.kt +++ b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicyRuntime.kt @@ -1,9 +1,6 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann class MyClass -Retention(RetentionPolicy.RUNTIME) -annotation class Ann +annotation(retention = AnnotationRetention.RUNTIME) class Ann -// 1 @LAnn;() \ No newline at end of file +// 1 @LAnn;() +// 0 invisible diff --git a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicySource.kt b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicySource.kt index a2248c7740b..7260c31a09b 100644 --- a/compiler/testData/codegen/bytecodeText/annotationRetentionPolicySource.kt +++ b/compiler/testData/codegen/bytecodeText/annotationRetentionPolicySource.kt @@ -1,9 +1,5 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - Ann class MyClass -Retention(RetentionPolicy.SOURCE) -annotation class Ann +annotation(retention = AnnotationRetention.SOURCE) class Ann // 0 @LAnn;() \ No newline at end of file diff --git a/compiler/testData/codegen/properties/syntheticMethod/inClass.kt b/compiler/testData/codegen/properties/syntheticMethod/inClass.kt index f17c4afc14c..c050fdabadc 100644 --- a/compiler/testData/codegen/properties/syntheticMethod/inClass.kt +++ b/compiler/testData/codegen/properties/syntheticMethod/inClass.kt @@ -1,6 +1,4 @@ -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String) +annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String) class A { @SomeAnnotation("OK") val property: Int diff --git a/compiler/testData/codegen/properties/syntheticMethod/inTrait.kt b/compiler/testData/codegen/properties/syntheticMethod/inTrait.kt index fecb7aed395..20006213ee7 100644 --- a/compiler/testData/codegen/properties/syntheticMethod/inTrait.kt +++ b/compiler/testData/codegen/properties/syntheticMethod/inTrait.kt @@ -1,6 +1,4 @@ -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String) +annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String) interface T { @SomeAnnotation("OK") val property: Int diff --git a/compiler/testData/codegen/properties/syntheticMethod/topLevel.kt b/compiler/testData/codegen/properties/syntheticMethod/topLevel.kt index 9bd6284ea32..c5948fc87dd 100644 --- a/compiler/testData/codegen/properties/syntheticMethod/topLevel.kt +++ b/compiler/testData/codegen/properties/syntheticMethod/topLevel.kt @@ -1,6 +1,4 @@ -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) annotation class SomeAnnotation(val value: String) +annotation(retention = AnnotationRetention.RUNTIME) class SomeAnnotation(val value: String) @SomeAnnotation("OK") val property: Int get() = 42 diff --git a/compiler/testData/compileKotlinAgainstKotlin/AnnotationInTrait.A.kt b/compiler/testData/compileKotlinAgainstKotlin/AnnotationInTrait.A.kt index a04ee6dda50..199cf2d375f 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/AnnotationInTrait.A.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/AnnotationInTrait.A.kt @@ -1,9 +1,6 @@ package a -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) -annotation class Ann +annotation(retention = AnnotationRetention.RUNTIME) class Ann interface Tr { Ann diff --git a/compiler/testData/compileKotlinAgainstKotlin/InlinedConstants.A.kt b/compiler/testData/compileKotlinAgainstKotlin/InlinedConstants.A.kt index 35e5e84c913..dc9584be3c9 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/InlinedConstants.A.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/InlinedConstants.A.kt @@ -1,8 +1,5 @@ package constants -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy - public val b: Byte = 100 public val s: Short = 20000 public val i: Int = 2000000 @@ -14,5 +11,4 @@ public val c: Char = '\u03c0' // pi symbol public val str: String = ":)" -@Retention(RetentionPolicy.RUNTIME) -public annotation class AnnotationClass(public val value: String) \ No newline at end of file +public annotation(retention = AnnotationRetention.RUNTIME) class AnnotationClass(public val value: String) \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstKotlin/KotlinPropertyAsAnnotationParameter.B.kt b/compiler/testData/compileKotlinAgainstKotlin/KotlinPropertyAsAnnotationParameter.B.kt index 32e6000ec7a..86274b17551 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/KotlinPropertyAsAnnotationParameter.B.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/KotlinPropertyAsAnnotationParameter.B.kt @@ -1,5 +1,3 @@ -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy import a.* Ann(i, s, f, d, l, b, bool, c, str) @@ -8,8 +6,7 @@ class MyClass1 Ann(i2, s2, f2, d2, l2, b2, bool2, c2, str2) class MyClass2 -Retention(RetentionPolicy.RUNTIME) -annotation class Ann( +annotation(retention = AnnotationRetention.RUNTIME) class Ann( val i: Int, val s: Short, val f: Float, diff --git a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt index d7458d0cc85..397822550f8 100644 --- a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt +++ b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt @@ -1,13 +1,13 @@ package -kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.CLASS) internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() internal final annotation class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt new file mode 100644 index 00000000000..5127231dbc9 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt @@ -0,0 +1,6 @@ +// ALLOW_AST_ACCESS + +package test + +target(AnnotationTarget.CLASSIFIER) +public annotation class TargetedAnnotation diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt new file mode 100644 index 00000000000..5d67f42b301 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() public final annotation class TargetedAnnotation : kotlin.Annotation { + /*primary*/ public constructor TargetedAnnotation() +} diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt new file mode 100644 index 00000000000..423299db385 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt @@ -0,0 +1,3 @@ +package test + +data class My(val x: Int) diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.txt new file mode 100644 index 00000000000..89946f14107 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.txt @@ -0,0 +1,9 @@ +package test + +kotlin.data() internal final class My { + /*primary*/ public constructor My(/*0*/ x: kotlin.Int) + internal final val x: kotlin.Int + internal final fun (): kotlin.Int + internal final /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): test.My +} diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.kt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.kt index 6f1ded2bbd0..bd9b66be01f 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.kt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.kt @@ -2,6 +2,4 @@ //SKIP_IN_RUNTIME_TEST package test -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) annotation class Anno +annotation(retention = AnnotationRetention.RUNTIME) class Anno diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt index 5b62bb55b8f..95dc30c54f9 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt @@ -1,5 +1,5 @@ package test -java.lang.annotation.Retention(value = RetentionPolicy.RUNTIME) kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation(retention = AnnotationRetention.RUNTIME) internal final annotation class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index ac3f1ea6b05..d7b551fb128 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -47,6 +47,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { doTest(fileName); } + @TestMetadata("annotationJavaRetentionPolicyRuntime.kt") + public void testAnnotationJavaRetentionPolicyRuntime() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/annotationJavaRetentionPolicyRuntime.kt"); + doTest(fileName); + } + @TestMetadata("annotationRetentionPolicyClass.kt") public void testAnnotationRetentionPolicyClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/annotationRetentionPolicyClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileJavaAgainstKotlinTest.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileJavaAgainstKotlinTest.java index eccfaa7ed35..cd23c5db5e7 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileJavaAgainstKotlinTest.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractCompileJavaAgainstKotlinTest.java @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.descriptors.PackageViewDescriptor; +import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.JetFile; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.renderer.DescriptorRendererOptions; @@ -35,6 +36,7 @@ import org.junit.Assert; import java.io.File; import java.io.IOException; +import java.lang.annotation.Retention; import java.util.Collections; import static org.jetbrains.kotlin.test.JetTestUtils.*; @@ -53,6 +55,7 @@ public abstract class AbstractCompileJavaAgainstKotlinTest extends TestCaseWithT options.setWithDefinedIn(false); options.setParameterNameRenderingPolicy(ParameterNameRenderingPolicy.NONE); options.setVerbose(true); + options.setExcludedAnnotationClasses(Collections.singleton(new FqName(Retention.class.getName()))); return Unit.INSTANCE$; } } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 8787889e66f..1e88eca050c 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -1942,6 +1942,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledKotlin(fileName); } + @TestMetadata("TargetedAnnotation.kt") + public void testTargetedAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt"); + doTestCompiledKotlin(fileName); + } + @TestMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -2031,6 +2037,12 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledKotlin(fileName); } + @TestMetadata("DataClass.kt") + public void testDataClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt"); + doTestCompiledKotlin(fileName); + } + @TestMetadata("Deprecated.kt") public void testDeprecated() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/Deprecated.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt index 116a8affaee..9c7c0e8612d 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/AbstractJvmRuntimeDescriptorLoaderTest.kt @@ -44,6 +44,7 @@ import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator.Configuratio import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.utils.sure import java.io.File +import java.lang.annotation.Retention import java.net.URLClassLoader import java.util.regex.Pattern @@ -52,21 +53,18 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi private val renderer = DescriptorRenderer.withOptions { withDefinedIn = false excludedAnnotationClasses = (listOf( - ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME, - // TODO: add these annotations when they are retained at runtime - "kotlin.deprecated", - "kotlin.data", - "kotlin.inline" - ).map { FqName(it) } + JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES).toSet() + FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME) + ) + JvmAnnotationNames.ANNOTATIONS_COPIED_TO_TYPES).toSet() overrideRenderingPolicy = OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE parameterNameRenderingPolicy = ParameterNameRenderingPolicy.NONE includePropertyConstant = false verbose = true + renderDefaultAnnotationArguments = true } } // NOTE: this test does a dirty hack of text substitution to make all annotations defined in source code retain at runtime. - // Specifically each "annotation class" in Kotlin sources is replaced by "Retention(RUNTIME) annotation class", and the same in Java + // Specifically each @interface in Java sources is extended by @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) // Also type related annotations are removed from Java because they are invisible at runtime protected fun doTest(fileName: String) { val file = File(fileName) @@ -123,7 +121,7 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi val environment = JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( myTestRootDisposable, ConfigurationKind.ALL, jdkKind ) - val jetFile = JetTestUtils.createFile(file.getPath(), addRuntimeRetentionToKotlinSource(text), environment.project) + val jetFile = JetTestUtils.createFile(file.getPath(), text, environment.project) GenerationUtils.compileFileGetClassFileFactoryForTest(jetFile).writeAllTo(tmpdir) } } @@ -166,13 +164,6 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi return SyntheticPackageViewForTest(module, packageScopes, classes) } - private fun addRuntimeRetentionToKotlinSource(text: String): String { - return text.replace( - "annotation class", - "@[java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)] annotation class" - ) - } - private fun adaptJavaSource(text: String): String { val typeAnnotations = arrayOf("NotNull", "Nullable", "ReadOnly", "Mutable") return typeAnnotations.fold(text) { text, annotation -> text.replace("@$annotation", "") }.replace( diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java index 9e1c62d4995..cf574eae3eb 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/runtime/JvmRuntimeDescriptorLoaderTestGenerated.java @@ -81,6 +81,12 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD doTest(fileName); } + @TestMetadata("TargetedAnnotation.kt") + public void testTargetedAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -170,6 +176,12 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD doTest(fileName); } + @TestMetadata("DataClass.kt") + public void testDataClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt"); + doTest(fileName); + } + @TestMetadata("Deprecated.kt") public void testDeprecated() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/Deprecated.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java b/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java index 6fe0cfe2c58..b43c957a1b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java @@ -40,20 +40,26 @@ import org.jetbrains.kotlin.utils.Printer; import org.junit.Assert; import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.lang.annotation.Retention; +import java.util.*; import static org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry; import static org.jetbrains.kotlin.test.util.DescriptorValidator.ValidationVisitor.errorTypesForbidden; public class RecursiveDescriptorComparator { + + private static final Set excludedAnnotations = new HashSet(); + static { + excludedAnnotations.add(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)); + excludedAnnotations.add(new FqName(Retention.class.getName())); + } + private static final DescriptorRenderer DEFAULT_RENDERER = DescriptorRenderer.Companion.withOptions( new Function1() { @Override public Unit invoke(DescriptorRendererOptions options) { options.setWithDefinedIn(false); - options.setExcludedAnnotationClasses(Collections.singleton(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME))); + options.setExcludedAnnotationClasses(excludedAnnotations); options.setOverrideRenderingPolicy(OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE); options.setIncludePropertyConstant(true); options.setNameShortness(NameShortness.FULLY_QUALIFIED); diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index 01a38387c11..89fe98bdfab 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -176,6 +176,7 @@ public interface DescriptorRendererOptions { public var flexibleTypesForCode: Boolean public var secondaryConstructorsAsPrimary: Boolean public var renderAccessors: Boolean + public var renderDefaultAnnotationArguments: Boolean } public enum class RenderingFormat { diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 0c0d18d43b3..dd48739459f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -366,13 +366,22 @@ internal class DescriptorRendererImpl( } private fun renderAndSortAnnotationArguments(descriptor: AnnotationDescriptor): List { - return descriptor.getAllValueArguments().entrySet() + val allValueArguments = descriptor.getAllValueArguments() + val classDescriptor = if (renderDefaultAnnotationArguments) TypeUtils.getClassDescriptor(descriptor.getType()) else null + val parameterDescriptorsWithDefaultValue = classDescriptor?.getUnsubstitutedPrimaryConstructor()?.getValueParameters()?.filter { + it.declaresDefaultValue() + } ?: emptyList() + val defaultList = parameterDescriptorsWithDefaultValue.filter { !allValueArguments.containsKey(it) }.map { + "${it.getName().asString()} = ..." + }.sort() + val argumentList = allValueArguments.entrySet() .map { entry -> val name = entry.key.getName().asString() - val value = renderConstant(entry.value) + val value = if (!parameterDescriptorsWithDefaultValue.contains(entry.key)) renderConstant(entry.value) else "..." "$name = $value" } .sort() + return (defaultList + argumentList).sort() } private fun renderConstant(value: CompileTimeConstant<*>): String { diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index 51c0b33739d..29613c13b51 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -85,6 +85,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { override var receiverAfterName by property(false) override var renderCompanionObjectName by property(false) override var renderAccessors by property(false) + override var renderDefaultAnnotationArguments by property(false) override var excludedAnnotationClasses by property(emptySet()) diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java index 6d52f481654..295e8ef3c35 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/ResolveByStubTestGenerated.java @@ -79,6 +79,12 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest { doTest(fileName); } + @TestMetadata("TargetedAnnotation.kt") + public void testTargetedAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classMembers") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) @@ -168,6 +174,12 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest { doTest(fileName); } + @TestMetadata("DataClass.kt") + public void testDataClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/DataClass.kt"); + doTest(fileName); + } + @TestMetadata("Deprecated.kt") public void testDeprecated() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/annotations/classes/Deprecated.kt"); diff --git a/libraries/stdlib/test/AnnotationsTest.kt b/libraries/stdlib/test/AnnotationsTest.kt index 40c45c3b3e6..cb6967f9cc4 100644 --- a/libraries/stdlib/test/AnnotationsTest.kt +++ b/libraries/stdlib/test/AnnotationsTest.kt @@ -3,11 +3,8 @@ package test.annotations import kotlin.* import kotlin.test.assertTrue import org.junit.Test as test -import java.lang.annotation.* - -Retention(RetentionPolicy.RUNTIME) -annotation class MyAnno +annotation(retention = AnnotationRetention.RUNTIME) class MyAnno MyAnno Deprecated diff --git a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt index e111145ea84..45399e7808f 100644 --- a/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt +++ b/plugins/annotation-collector/testData/collectToFile/annotationInSameFile/annotations.txt @@ -1,6 +1,8 @@ a kotlin.annotation.annotation 0 p org.test 0 c 0 0/SomeAnnotation -a org.test.SomeAnnotation 1 -c 1 0/SomeClass -m 1 0/SomeClass annotatedFunction +a java.lang.annotation.Retention 1 +c 1 0/SomeAnnotation +a org.test.SomeAnnotation 2 +c 2 0/SomeClass +m 2 0/SomeClass annotatedFunction From 0d2a81f09892569f700a33a614bac7c08d36c589 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 6 Jul 2015 20:00:06 +0300 Subject: [PATCH 255/450] Annotation target checking in front-end, a set of tests for different annotation targets, existing test fixes No checks for erroneous annotations. Additional checks for identifiers. --- .../jetbrains/kotlin/diagnostics/Errors.java | 1 + .../rendering/DefaultErrorMessages.java | 1 + .../kotlin/resolve/AnnotationTargetChecker.kt | 135 ++++++++++++++++++ .../kotlin/resolve/DeclarationsChecker.java | 3 + .../kotlin/resolve/ModifiersChecker.java | 2 + .../ExpressionTypingVisitorDispatcher.java | 5 +- .../ExpressionTypingVisitorForStatements.java | 5 +- .../cli/js/diagnosticForUnhandledElements.kt | 1 + .../cli/js/diagnosticForUnhandledElements.out | 2 +- .../annotatedSamLambda/annotatedSamLambda.kt | 5 +- .../annotations/annotatedLambda/lambda.kt | 5 +- compiler/testData/diagnostics/tests/Casts.kt | 2 +- .../tests/annotations/AnnotatedResultType.kt | 1 + .../tests/annotations/AnnotatedResultType.txt | 2 +- .../RecursivelyAnnotatedParameterType.kt | 1 + .../RecursivelyAnnotatedParameterType.txt | 2 +- .../tests/annotations/annotationModifier.kt | 6 +- .../annotationsOnLambdaAsCallArgument.kt | 3 +- .../annotationsOnLambdaAsCallArgument.txt | 2 +- .../tests/annotations/atAnnotationResolve.kt | 5 +- .../tests/annotations/atAnnotationResolve.txt | 2 +- .../tests/annotations/kt1860-positive.kt | 1 + .../tests/annotations/kt1860-positive.txt | 2 +- .../tests/annotations/onExpression.kt | 1 + .../tests/annotations/onExpression.txt | 2 +- .../tests/annotations/onInitializer.kt | 16 +-- .../annotations/options/targets/accessors.kt | 16 +++ .../annotations/options/targets/accessors.txt | 31 ++++ .../annotations/options/targets/annotation.kt | 20 +++ .../options/targets/annotation.txt | 61 ++++++++ .../annotations/options/targets/classifier.kt | 21 +++ .../options/targets/classifier.txt | 61 ++++++++ .../options/targets/constructor.kt | 20 +++ .../options/targets/constructor.txt | 61 ++++++++ .../annotations/options/targets/empty.kt | 21 +++ .../annotations/options/targets/empty.txt | 61 ++++++++ .../tests/annotations/options/targets/expr.kt | 11 ++ .../annotations/options/targets/expr.txt | 18 +++ .../tests/annotations/options/targets/file.kt | 23 +++ .../annotations/options/targets/file.txt | 32 +++++ .../annotations/options/targets/function.kt | 22 +++ .../annotations/options/targets/function.txt | 62 ++++++++ .../options/targets/funtypeargs.kt | 13 ++ .../options/targets/funtypeargs.txt | 18 +++ .../annotations/options/targets/incorrect.kt | 21 +++ .../annotations/options/targets/incorrect.txt | 61 ++++++++ .../tests/annotations/options/targets/init.kt | 6 + .../annotations/options/targets/init.txt | 15 ++ .../annotations/options/targets/local.kt | 20 +++ .../annotations/options/targets/local.txt | 61 ++++++++ .../annotations/options/targets/nested.kt | 15 ++ .../annotations/options/targets/nested.txt | 37 +++++ .../annotations/options/targets/property.kt | 21 +++ .../annotations/options/targets/property.txt | 61 ++++++++ .../annotations/options/targets/returntype.kt | 9 ++ .../options/targets/returntype.txt | 25 ++++ .../annotations/options/targets/suppress.kt | 1 + .../annotations/options/targets/suppress.txt | 1 + .../tests/annotations/options/targets/type.kt | 20 +++ .../annotations/options/targets/type.txt | 61 ++++++++ .../annotations/options/targets/typeargs.kt | 3 + .../annotations/options/targets/typeargs.txt | 10 ++ .../annotations/options/targets/valueparam.kt | 21 +++ .../options/targets/valueparam.txt | 61 ++++++++ .../tests/deparenthesize/annotatedSafeCall.kt | 1 + .../deparenthesize/annotatedSafeCall.txt | 2 +- .../tests/modifiers/IllegalModifiers.kt | 12 +- .../resolve/resolveAnnotatedLambdaArgument.kt | 3 +- .../resolveAnnotatedLambdaArgument.txt | 2 +- .../annotations/types/SimpleTypeAnnotation.kt | 3 + .../types/SimpleTypeAnnotation.txt | 2 +- .../types/TypeAnnotationWithArguments.kt | 1 + .../types/TypeAnnotationWithArguments.txt | 2 +- .../checkers/JetDiagnosticsTestGenerated.java | 123 ++++++++++++++++ idea/testData/checker/AnnotationOnFile.kt | 5 +- .../decompiledText/Annotations/Dependency.kt | 8 ++ .../stubBuilder/Annotations/Annotations.kt | 7 +- idea/testData/highlighter/Annotations.kt | 1 + .../convertToBlockBody/annotatedExpr.kt | 1 + .../convertToBlockBody/annotatedExpr.kt.after | 1 + .../suppress/forStatement/annotatedExpr.kt | 1 + .../forStatement/annotatedExpr.kt.after | 1 + 82 files changed, 1445 insertions(+), 46 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/accessors.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/annotation.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/classifier.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/constructor.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/empty.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/file.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/file.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/function.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/function.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/init.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/init.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/local.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/local.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/property.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/property.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/returntype.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/type.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/type.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index dd94bff29ed..e4966923dc3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -114,6 +114,7 @@ public interface Errors { DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(WARNING); DiagnosticFactory0 INAPPLICABLE_ANNOTATION = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INAPPLICABLE_PLATFORM_NAME = DiagnosticFactory0.create(ERROR); + DiagnosticFactory1 WRONG_ANNOTATION_TARGET = DiagnosticFactory1.create(ERROR); // Annotations diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 41ec53aaf5e..599c79db94b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -137,6 +137,7 @@ public class DefaultErrorMessages { MAP.put(REPEATED_MODIFIER, "Repeated ''{0}''", TO_STRING); MAP.put(INAPPLICABLE_ANNOTATION, "This annotation is only applicable to top level functions"); MAP.put(INAPPLICABLE_PLATFORM_NAME, "platformName annotation is not applicable to this declaration"); + MAP.put(WRONG_ANNOTATION_TARGET, "This annotation is not applicable to target ''{0}''", TO_STRING); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); MAP.put(ABSTRACT_MODIFIER_IN_TRAIT, "Modifier ''abstract'' is redundant in interface"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt new file mode 100644 index 00000000000..307be5f064d --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt @@ -0,0 +1,135 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve + +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries +import org.jetbrains.kotlin.resolve.constants.ArrayValue +import org.jetbrains.kotlin.resolve.constants.EnumValue +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeUtils +import java.util.* + +public object AnnotationTargetChecker { + + // NOTE: this enum must have the same entries with kotlin.annotation.AnnotationTarget + public enum class Target(val description: String, val isDefault: Boolean = true) { + PACKAGE("package"), + CLASSIFIER("classifier"), + ANNOTATION_CLASS("annotation class"), + TYPE_PARAMETER("type parameter", false), + PROPERTY("property"), + FIELD("field"), + LOCAL_VARIABLE("local variable"), + VALUE_PARAMETER("value parameter"), + CONSTRUCTOR("constructor"), + FUNCTION("function"), + PROPERTY_GETTER("getter"), + PROPERTY_SETTER("setter"), + TYPE("type usage", false), + EXPRESSION("expression", false), + FILE("file", false) + } + + private val DEFAULT_TARGET_LIST = Target.values().filter { it.isDefault }.map { it.name() } + + private val ALL_TARGET_LIST = Target.values().map { it.name() } + + public fun check(annotated: JetAnnotated, trace: BindingTrace) { + if (annotated is JetTypeParameter) return // TODO: support type parameter annotations + val actualTargets = getActualTargetList(annotated) + for (entry in annotated.getAnnotationEntries()) { + checkAnnotationEntry(entry, actualTargets, trace) + } + if (annotated is JetCallableDeclaration) { + annotated.getTypeReference()?.let { check(it, trace) } + } + if (annotated is JetFunction) { + for (parameter in annotated.getValueParameters()) { + if (!parameter.hasValOrVar()) { + check(parameter, trace) + if (annotated is JetFunctionLiteral) { + parameter.getTypeReference()?.let { check(it, trace) } + } + } + } + } + if (annotated is JetClassOrObject) { + for (initializer in annotated.getAnonymousInitializers()) { + check(initializer, trace) + } + } + } + + public fun checkExpression(expression: JetExpression, trace: BindingTrace) { + for (entry in expression.getAnnotationEntries()) { + checkAnnotationEntry(entry, listOf(Target.EXPRESSION), trace) + } + if (expression is JetFunctionLiteralExpression) { + for (parameter in expression.getValueParameters()) { + parameter.getTypeReference()?.let { check(it, trace) } + } + } + } + + private fun possibleTargetList(entry: JetAnnotationEntry, trace: BindingTrace): List { + val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return DEFAULT_TARGET_LIST + // For descriptor with error type, all targets are considered as possible + if (descriptor.getType().isError()) return ALL_TARGET_LIST + val classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType()) ?: return DEFAULT_TARGET_LIST + val targetEntryDescriptor = classDescriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.target) + ?: return DEFAULT_TARGET_LIST + val valueArguments = targetEntryDescriptor.getAllValueArguments() + val valueArgument = valueArguments.entrySet().firstOrNull()?.getValue() as? ArrayValue ?: return DEFAULT_TARGET_LIST + return valueArgument.getValue().filterIsInstance().map { it.getValue().getName().asString() } + } + + private fun checkAnnotationEntry(entry: JetAnnotationEntry, actualTargets: List, trace: BindingTrace) { + val possibleTargets = possibleTargetList(entry, trace) + for (actualTarget in actualTargets) { + if (actualTarget.name() in possibleTargets) return + } + trace.report(Errors.WRONG_ANNOTATION_TARGET.on(entry, actualTargets.firstOrNull()?.description ?: "unidentified target")) + } + + private fun getActualTargetList(annotated: JetAnnotated): List { + if (annotated is JetClassOrObject) { + if (annotated is JetEnumEntry) return listOf(Target.PROPERTY, Target.FIELD) + return if (annotated.isAnnotation()) listOf(Target.ANNOTATION_CLASS, Target.CLASSIFIER) else listOf(Target.CLASSIFIER) + } + if (annotated is JetProperty) { + return if (annotated.isLocal()) listOf(Target.LOCAL_VARIABLE) else listOf(Target.PROPERTY, Target.FIELD) + } + if (annotated is JetParameter) { + return if (annotated.hasValOrVar()) listOf(Target.PROPERTY, Target.FIELD) else listOf(Target.VALUE_PARAMETER) + } + if (annotated is JetConstructor<*>) return listOf(Target.CONSTRUCTOR) + if (annotated is JetFunction) return listOf(Target.FUNCTION) + if (annotated is JetPropertyAccessor) { + return if (annotated.isGetter()) listOf(Target.PROPERTY_GETTER) else listOf(Target.PROPERTY_SETTER) + } + if (annotated is JetPackageDirective) return listOf(Target.PACKAGE) + if (annotated is JetTypeReference) return listOf(Target.TYPE) + if (annotated is JetFile) return listOf(Target.FILE) + if (annotated is JetTypeParameter) return listOf(Target.TYPE_PARAMETER) + return listOf() + } +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index b2dbd24d6b0..75268351eab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -67,6 +67,7 @@ public class DeclarationsChecker { public void process(@NotNull BodiesResolveContext bodiesResolveContext) { for (JetFile file : bodiesResolveContext.getFiles()) { checkModifiersAndAnnotationsInPackageDirective(file); + AnnotationTargetChecker.INSTANCE$.check(file, trace); } Map classes = bodiesResolveContext.getDeclaredClasses(); @@ -146,6 +147,7 @@ public class DeclarationsChecker { } } } + AnnotationTargetChecker.INSTANCE$.check(packageDirective, trace); ModifiersChecker.reportIllegalModifiers(modifierList, Arrays.asList(JetTokens.MODIFIER_KEYWORDS_ARRAY), trace); } @@ -302,6 +304,7 @@ public class DeclarationsChecker { if (typeParameter != null) { DescriptorResolver.checkConflictingUpperBounds(trace, typeParameter, jetTypeParameter); } + AnnotationTargetChecker.INSTANCE$.check(jetTypeParameter, trace); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java index bea60497b7c..1a4f6c9e987 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java @@ -150,6 +150,7 @@ public class ModifiersChecker { } checkPlatformNameApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); + AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace); } private void checkVarargsModifiers(@NotNull JetDeclaration owner, @NotNull MemberDescriptor descriptor) { @@ -163,6 +164,7 @@ public class ModifiersChecker { reportIllegalVisibilityModifiers(modifierListOwner); checkPlatformNameApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); + AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace); } public void reportIllegalModalityModifiers(@NotNull JetModifierListOwner modifierListOwner) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java index 48a22d06915..586ec8986e4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorDispatcher.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.diagnostics.DiagnosticUtils; import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.psi.*; +import org.jetbrains.kotlin.resolve.AnnotationTargetChecker; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.scopes.WritableScope; @@ -143,7 +144,9 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor()).x, "On method of test named `$name`") diff --git a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/lambda.kt b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/lambda.kt index 81a259382c7..e5de02774ae 100644 --- a/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/lambda.kt +++ b/compiler/testData/codegen/boxWithStdlib/annotations/annotatedLambda/lambda.kt @@ -1,10 +1,9 @@ -import java.lang.annotation.* import java.lang.reflect.Method import kotlin.reflect.jvm.java import kotlin.test.assertEquals -Retention(RetentionPolicy.RUNTIME) -annotation class Ann(val x: String) +target(AnnotationTarget.EXPRESSION) +annotation(retention = AnnotationRetention.RUNTIME) class Ann(val x: String) fun foo0(block: () -> Unit) = block.javaClass diff --git a/compiler/testData/diagnostics/tests/Casts.kt b/compiler/testData/diagnostics/tests/Casts.kt index 46f575f2730..3ac37660d11 100644 --- a/compiler/testData/diagnostics/tests/Casts.kt +++ b/compiler/testData/diagnostics/tests/Casts.kt @@ -18,6 +18,6 @@ fun test() : Unit { val s = "" as Any ("" as String?)?.length() (data@("" as String?))?.length() - (@data()( "" as String?))?.length() + (@data()( "" as String?))?.length() Unit } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt index 00839cb1af6..c38ec8d9835 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.kt @@ -1,4 +1,5 @@ // Result type can be annotated +target(AnnotationTarget.TYPE) annotation class My(val x: Int) fun foo(): @My(42) Int = 24 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt index 5ca42a7522c..9a014ebe437 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt @@ -2,7 +2,7 @@ package internal fun foo(): @[My(x = IntegerValueType(42))] kotlin.Int -kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { public constructor My(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.kt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.kt index fbe79905ad2..a44dfffb3f1 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.kt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.kt @@ -1,2 +1,3 @@ // Class constructor parameter type CAN be recursively annotated +target(AnnotationTarget.TYPE) annotation class RecursivelyAnnotated(val x: @RecursivelyAnnotated(1) Int) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt index 05e163c56fd..c5994b1e87d 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int) internal final val x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt index a62a21476bb..c6d58e791c3 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt @@ -8,8 +8,8 @@ annotation object O {} annotation interface T {} -annotation fun f() = 0 +annotation fun f() = 0 -annotation val x = 0 +annotation val x = 0 -annotation var y = 0 \ No newline at end of file +annotation var y = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.kt b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.kt index 352a0d9fe3f..11ff6202e1c 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.kt @@ -1,4 +1,5 @@ -annotation class Ann(val x: Int = 1) +target(AnnotationTarget.EXPRESSION) +annotation(repeatable = true) class Ann(val x: Int = 1) inline fun bar(block: () -> Int): Int = block() diff --git a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt index b0dcaa535f8..0c44086913f 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt @@ -3,7 +3,7 @@ package kotlin.inline() internal fun bar(/*0*/ block: () -> kotlin.Int): kotlin.Int internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.kt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.kt index ae8a5d0a94f..2443d32f32a 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.kt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.kt @@ -1,5 +1,8 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -annotation class Ann(val x: Int = 6) +target(AnnotationTarget.TYPE, AnnotationTarget.CLASSIFIER, + AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, + AnnotationTarget.EXPRESSION, AnnotationTarget.PROPERTY) +annotation(repeatable = true) class Ann(val x: Int = 6) @Ann(1) @Ann(2) @Ann(3) @private class A @Ann constructor() { @Ann(x = 5) fun foo() { diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt index d8bc8365b8d..21b5655e9f7 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt @@ -10,7 +10,7 @@ Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueTy public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASSIFIER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.EXPRESSION, AnnotationTarget.PROPERTY}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt index c23fa9142a0..c4751e8cf8b 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt @@ -1,3 +1,4 @@ +target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) annotation class test fun foo(test f : Int) {} diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt index 5f9436f463d..2335c66eb3f 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt @@ -11,7 +11,7 @@ internal final class Hello { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class test : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class test : kotlin.Annotation { public constructor test() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onExpression.kt b/compiler/testData/diagnostics/tests/annotations/onExpression.kt index 72697adbaf5..f1d47b1fde4 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.kt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.kt @@ -1,3 +1,4 @@ fun foo() = @ann 1 +target(AnnotationTarget.EXPRESSION) annotation class ann \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/onExpression.txt b/compiler/testData/diagnostics/tests/annotations/onExpression.txt index 882524e7529..6334c0133bc 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.txt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onInitializer.kt b/compiler/testData/diagnostics/tests/annotations/onInitializer.kt index 94e69bbf308..150b324718d 100644 --- a/compiler/testData/diagnostics/tests/annotations/onInitializer.kt +++ b/compiler/testData/diagnostics/tests/annotations/onInitializer.kt @@ -1,15 +1,15 @@ class A { - ann init {} - @ann init {} - aaa init {} - @aaa init {} + ann init {} + @ann init {} + aaa init {} + @aaa init {} } interface T { - ann init {} - @ann init {} - aaa init {} - @aaa init {} + ann init {} + @ann init {} + aaa init {} + @aaa init {} } annotation class ann \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.kt new file mode 100644 index 00000000000..a5f5fd27205 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.kt @@ -0,0 +1,16 @@ +target(AnnotationTarget.PROPERTY_GETTER) +annotation class smartget + +target(AnnotationTarget.PROPERTY_SETTER) +annotation class smartset + +target(AnnotationTarget.FUNCTION) +annotation class base + +class My(x: Int) { + smartget var y = x + @base @smartget @smartset get + @base @smartget @smartset set + + base smartget smartset fun foo() = y +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt new file mode 100644 index 00000000000..7bd6d9c347e --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt @@ -0,0 +1,31 @@ +package + +internal final class My { + public constructor My(/*0*/ x: kotlin.Int) + smartget() internal final var y: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + base() smartget() smartset() internal final fun foo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_GETTER}) kotlin.annotation.annotation() internal final annotation class smartget : kotlin.Annotation { + public constructor smartget() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_SETTER}) kotlin.annotation.annotation() internal final annotation class smartset : kotlin.Annotation { + public constructor smartset() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.kt new file mode 100644 index 00000000000..7b789761ccb --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.kt @@ -0,0 +1,20 @@ +target(AnnotationTarget.ANNOTATION_CLASS) annotation class base + +base annotation class derived + +base class correct(base val x: Int) { + base constructor(): this(0) +} + +base enum class My { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt new file mode 100644 index 00000000000..8b552426e94 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.kt new file mode 100644 index 00000000000..1bedffc957d --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +target(AnnotationTarget.CLASSIFIER) annotation class base + +base annotation class derived + +base class correct(base val x: Int, base w: @base Int) { + base constructor(): this(0, 0) +} + +base enum class My @base constructor() { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt new file mode 100644 index 00000000000..7aeb85464e7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int, /*1*/ base() w: @[base()] kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.kt new file mode 100644 index 00000000000..dce66d46d27 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.kt @@ -0,0 +1,20 @@ +target(AnnotationTarget.CONSTRUCTOR) annotation class base + +base annotation class derived + +base class correct(base val x: Int) { + base constructor(): this(0) +} + +base enum class My @base constructor() { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt new file mode 100644 index 00000000000..b6349ff0521 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CONSTRUCTOR}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/empty.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.kt new file mode 100644 index 00000000000..5af7fcb516c --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +target() annotation class empty + +empty annotation class derived + +empty class correct(empty val x: Int, empty w: @empty Int) { + empty constructor(): this(0, 0) +} + +empty enum class My @empty constructor() { + @empty FIRST, + @empty SECOND +} + +empty fun foo(empty y: @empty Int): Int { + @empty fun bar(empty z: @empty Int) = z + 1 + @empty val local = bar(y) + return local +} + +empty val z = @empty 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt new file mode 100644 index 00000000000..1cda0cbb71b --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt @@ -0,0 +1,61 @@ +package + +empty() internal val z: kotlin.Int +empty() internal fun foo(/*0*/ empty() y: @[empty()] kotlin.Int): kotlin.Int + +empty() internal final enum class My : kotlin.Enum { + empty() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + empty() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + empty() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +empty() internal final class correct { + empty() public constructor correct() + public constructor correct(/*0*/ empty() x: kotlin.Int, /*1*/ empty() w: @[empty()] kotlin.Int) + empty() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +empty() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final annotation class empty : kotlin.Annotation { + public constructor empty() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt new file mode 100644 index 00000000000..fff356d1dc8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt @@ -0,0 +1,11 @@ +annotation class base + +target(AnnotationTarget.EXPRESSION) annotation class special + +fun transform(i: Int, tr: (Int) -> Int): Int = @base @special tr(@special i) + +base special fun foo(i: Int): Int { + val j = @base @special i + 1 + if (j == 1) return foo(@special @base 42) + return transform(@special j, @base @special { @special it * 2 }) +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt new file mode 100644 index 00000000000..d1ccd693c0b --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt @@ -0,0 +1,18 @@ +package + +base() special() internal fun foo(/*0*/ i: kotlin.Int): kotlin.Int +internal fun transform(/*0*/ i: kotlin.Int, /*1*/ tr: (kotlin.Int) -> kotlin.Int): kotlin.Int + +kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { + public constructor special() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt new file mode 100644 index 00000000000..76072bdaf90 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt @@ -0,0 +1,23 @@ +// FILE: annotation.kt + +package test + +target(AnnotationTarget.FILE) annotation class special + +annotation class common + +// FILE: other.kt + +@file:special + +package test + +special class Incorrect + +// FILE: another.kt + +@file:common + +package test + +common class Correct diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt new file mode 100644 index 00000000000..d9a0c13e9fb --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt @@ -0,0 +1,32 @@ +package + +package test { + + test.common() internal final class Correct { + public constructor Correct() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + test.special() internal final class Incorrect { + public constructor Incorrect() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + kotlin.annotation.annotation() internal final annotation class common : kotlin.Annotation { + public constructor common() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + kotlin.annotation.target(allowedTargets = {AnnotationTarget.FILE}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { + public constructor special() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/function.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/function.kt new file mode 100644 index 00000000000..7c6251bb42f --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/function.kt @@ -0,0 +1,22 @@ +target(AnnotationTarget.FUNCTION) annotation class base + +base annotation class derived + +base class correct(base val x: Int) { + base constructor(): this(0) + + base public fun baz() {} +} + +base enum class My @base constructor() { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt new file mode 100644 index 00000000000..b637c7e45a1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt @@ -0,0 +1,62 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int) + base() internal final val x: kotlin.Int + base() public final fun baz(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt new file mode 100644 index 00000000000..d158d935f4e --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt @@ -0,0 +1,13 @@ +target(AnnotationTarget.EXPRESSION) +annotation class special + +target(AnnotationTarget.TYPE) +annotation class base + +fun transform(i: Int, tr: (@special Int) -> Int): Int = @special tr(@special i) + +fun foo(i: Int): Int { + val j = @special i + 1 + if (j == 1) return foo(@special 42) + return transform(@special j, @special { i: @base Int -> @base i * 2 }) +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt new file mode 100644 index 00000000000..b73fa4a2c92 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt @@ -0,0 +1,18 @@ +package + +internal fun foo(/*0*/ i: kotlin.Int): kotlin.Int +internal fun transform(/*0*/ i: kotlin.Int, /*1*/ tr: (kotlin.Int) -> kotlin.Int): kotlin.Int + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { + public constructor special() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.kt new file mode 100644 index 00000000000..d6dd3e4fcc1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +target(AnnotationTarget.INIT) annotation class incorrect + +incorrect annotation class derived + +incorrect class correct(incorrect val x: Int, incorrect w: @incorrect Int) { + incorrect constructor(): this(0, 0) +} + +incorrect enum class My @incorrect constructor() { + @incorrect FIRST, + @incorrect SECOND +} + +incorrect fun foo(incorrect y: @incorrect Int): Int { + @incorrect fun bar(incorrect z: @incorrect Int) = z + 1 + @incorrect val local = bar(y) + return local +} + +incorrect val z = @incorrect 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt new file mode 100644 index 00000000000..16fc5207109 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt @@ -0,0 +1,61 @@ +package + +incorrect() internal val z: kotlin.Int +incorrect() internal fun foo(/*0*/ incorrect() y: @[incorrect()] kotlin.Int): kotlin.Int + +incorrect() internal final enum class My : kotlin.Enum { + incorrect() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + incorrect() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + incorrect() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +incorrect() internal final class correct { + incorrect() public constructor correct() + public constructor correct(/*0*/ incorrect() x: kotlin.Int, /*1*/ incorrect() w: @[incorrect()] kotlin.Int) + incorrect() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +incorrect() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final annotation class incorrect : kotlin.Annotation { + public constructor incorrect() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/init.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/init.kt new file mode 100644 index 00000000000..e87e08a03a1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/init.kt @@ -0,0 +1,6 @@ +annotation class base + +base class My { + @base init { + } +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt new file mode 100644 index 00000000000..f982ecf3ed0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt @@ -0,0 +1,15 @@ +package + +base() internal final class My { + public constructor My() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/local.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/local.kt new file mode 100644 index 00000000000..ebe2cd8a8e7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/local.kt @@ -0,0 +1,20 @@ +target(AnnotationTarget.LOCAL_VARIABLE) annotation class base + +base annotation class derived + +base class correct(base val x: Int) { + base constructor(): this(0) +} + +base enum class My { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt new file mode 100644 index 00000000000..09bab8ef41c --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.LOCAL_VARIABLE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt new file mode 100644 index 00000000000..150737260e9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt @@ -0,0 +1,15 @@ +target(AnnotationTarget.CLASSIFIER) +annotation class base + +target(AnnotationTarget.ANNOTATION_CLASS) +annotation class meta + +base class Outer { + base meta class Nested + + base meta annotation class Annotated + + fun foo() { + @base @meta class Local + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt new file mode 100644 index 00000000000..527e9a08bc0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt @@ -0,0 +1,37 @@ +package + +base() internal final class Outer { + public constructor Outer() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + base() meta() kotlin.annotation.annotation() internal final annotation class Annotated : kotlin.Annotation { + public constructor Annotated() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() meta() internal final class Nested { + public constructor Nested() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final annotation class meta : kotlin.Annotation { + public constructor meta() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/property.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/property.kt new file mode 100644 index 00000000000..5ae884fc531 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/property.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +target(AnnotationTarget.PROPERTY) annotation class base + +base annotation class derived + +base class correct(base val x: Int, base w: Int) { + base constructor(): this(0, 0) +} + +base enum class My { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt new file mode 100644 index 00000000000..67c7280e71a --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int, /*1*/ base() w: kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.kt new file mode 100644 index 00000000000..ccbb7aab7bc --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.kt @@ -0,0 +1,9 @@ +annotation class base + +target(AnnotationTarget.TYPE) +annotation class typed + +base class My(val x: @base @typed Int, y: @base @typed Int) { + val z: @base @typed Int = y + fun foo(): @base @typed Int = z +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt new file mode 100644 index 00000000000..b598f3a1315 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt @@ -0,0 +1,25 @@ +package + +base() internal final class My { + public constructor My(/*0*/ x: @[base() typed()] kotlin.Int, /*1*/ y: @[base() typed()] kotlin.Int) + internal final val x: @[base() typed()] kotlin.Int + internal final val z: @[base() typed()] kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun foo(): @[base() typed()] kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class typed : kotlin.Annotation { + public constructor typed() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt new file mode 100644 index 00000000000..4c0ce521946 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt @@ -0,0 +1 @@ +@file:suppress("abc") diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt new file mode 100644 index 00000000000..ba3bd787383 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt @@ -0,0 +1 @@ +package diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt new file mode 100644 index 00000000000..d3f8e3d8a23 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt @@ -0,0 +1,20 @@ +target(AnnotationTarget.TYPE) annotation class base + +base annotation class derived + +base class correct(base val x: @base Int) { + base constructor(): this(0) +} + +base enum class My @base constructor() { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt new file mode 100644 index 00000000000..61f16ff5b15 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: @[base()] kotlin.Int) + base() internal final val x: @[base()] kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt new file mode 100644 index 00000000000..31e91705afd --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt @@ -0,0 +1,3 @@ +annotation class base + +val x: List<@base String>? = null \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt new file mode 100644 index 00000000000..f6a16227230 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt @@ -0,0 +1,10 @@ +package + +internal val x: kotlin.List? = null + +kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.kt new file mode 100644 index 00000000000..226f95273e6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +target(AnnotationTarget.VALUE_PARAMETER) annotation class base + +base annotation class derived + +base class correct(base val x: Int, base w: Int) { + base constructor(): this(0, 0) +} + +base enum class My { + @base FIRST, + @base SECOND +} + +base fun foo(base y: @base Int): Int { + @base fun bar(base z: @base Int) = z + 1 + @base val local = bar(y) + return local +} + +base val z = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt new file mode 100644 index 00000000000..48bc7e297b2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt @@ -0,0 +1,61 @@ +package + +base() internal val z: kotlin.Int = 0 +base() internal fun foo(/*0*/ base() y: @[base()] kotlin.Int): kotlin.Int + +base() internal final enum class My : kotlin.Enum { + base() public enum entry FIRST : My { + private constructor FIRST() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + base() public enum entry SECOND : My { + private constructor SECOND() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor My() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: My): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): My + public final /*synthesized*/ fun values(): kotlin.Array +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { + public constructor base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() internal final class correct { + base() public constructor correct() + public constructor correct(/*0*/ base() x: kotlin.Int, /*1*/ base() w: kotlin.Int) + base() internal final val x: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { + public constructor derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt index 1d4b00298cf..b191ad37d03 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt @@ -1,3 +1,4 @@ +target(AnnotationTarget.EXPRESSION) annotation class foo fun f(s : String?) : Boolean { diff --git a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt index adbc1b6ce10..b259d40e6f1 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt @@ -2,7 +2,7 @@ package internal fun f(/*0*/ s: kotlin.String?): kotlin.Boolean -kotlin.annotation.annotation() internal final annotation class foo : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class foo : kotlin.Annotation { public constructor foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt index 84ae388ed55..f4f0706f2eb 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.kt @@ -83,9 +83,9 @@ abstract class IllegalModifiers6() { open init {} final init {} - public annotated init {} + public annotated init {} - private IllegalModifiers6() init {} + private IllegalModifiers6() init {} } // strange inappropriate modifiers usages @@ -97,7 +97,7 @@ abstract class IllegalModifiers6() { class IllegalModifiers7() { enum inner - annotation + annotation out in vararg @@ -105,7 +105,7 @@ class IllegalModifiers7() { val x = 1 enum inner - annotation + annotation out in vararg @@ -119,7 +119,7 @@ class IllegalModifiers8 { enum open inner - annotation + annotation override out in @@ -143,7 +143,7 @@ class IllegalModifiers10 enum open inner -annotation +annotation override out in diff --git a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.kt b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.kt index 2425a866945..78a2967dd2d 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.kt @@ -1,5 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER -annotation class Ann +target(AnnotationTarget.EXPRESSION) +annotation(repeatable = true) class Ann fun bar(block: (T) -> Int) {} diff --git a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt index bdd93816afd..ec267707044 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt +++ b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt @@ -3,7 +3,7 @@ package internal fun bar(/*0*/ block: (T) -> kotlin.Int): kotlin.Unit internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.kt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.kt index 81fe623b989..2e545ac8769 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.kt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.kt @@ -1,5 +1,8 @@ +// ALLOW_AST_ACCESS + package test +target(AnnotationTarget.TYPE) annotation class A class SimpleTypeAnnotation { diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt index 6083e5af9d5..bf596b8f642 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.kt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.kt index 9e09e32ac43..40278100b5a 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.kt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.kt @@ -2,6 +2,7 @@ package test +target(AnnotationTarget.TYPE) annotation class Ann(val x: String, val y: Double) class TypeAnnotationWithArguments { diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt index c919d0e0304..a034f7b1084 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { /*primary*/ public constructor Ann(/*0*/ x: kotlin.String, /*1*/ y: kotlin.Double) internal final val x: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 7a794179b36..39c8d2abb34 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -1033,6 +1033,129 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/target.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/diagnostics/tests/annotations/options/targets") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Targets extends AbstractJetDiagnosticsTest { + @TestMetadata("accessors.kt") + public void testAccessors() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/accessors.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInTargets() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/annotations/options/targets"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/annotation.kt"); + doTest(fileName); + } + + @TestMetadata("classifier.kt") + public void testClassifier() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/classifier.kt"); + doTest(fileName); + } + + @TestMetadata("constructor.kt") + public void testConstructor() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/constructor.kt"); + doTest(fileName); + } + + @TestMetadata("empty.kt") + public void testEmpty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/empty.kt"); + doTest(fileName); + } + + @TestMetadata("expr.kt") + public void testExpr() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt"); + doTest(fileName); + } + + @TestMetadata("file.kt") + public void testFile() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/file.kt"); + doTest(fileName); + } + + @TestMetadata("function.kt") + public void testFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/function.kt"); + doTest(fileName); + } + + @TestMetadata("funtypeargs.kt") + public void testFuntypeargs() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt"); + doTest(fileName); + } + + @TestMetadata("incorrect.kt") + public void testIncorrect() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.kt"); + doTest(fileName); + } + + @TestMetadata("init.kt") + public void testInit() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/init.kt"); + doTest(fileName); + } + + @TestMetadata("local.kt") + public void testLocal() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/local.kt"); + doTest(fileName); + } + + @TestMetadata("nested.kt") + public void testNested() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt"); + doTest(fileName); + } + + @TestMetadata("property.kt") + public void testProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/property.kt"); + doTest(fileName); + } + + @TestMetadata("returntype.kt") + public void testReturntype() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/returntype.kt"); + doTest(fileName); + } + + @TestMetadata("suppress.kt") + public void testSuppress() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt"); + doTest(fileName); + } + + @TestMetadata("type.kt") + public void testType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/type.kt"); + doTest(fileName); + } + + @TestMetadata("typeargs.kt") + public void testTypeargs() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.kt"); + doTest(fileName); + } + + @TestMetadata("valueparam.kt") + public void testValueparam() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.kt"); + doTest(fileName); + } + } } } diff --git a/idea/testData/checker/AnnotationOnFile.kt b/idea/testData/checker/AnnotationOnFile.kt index 893e1f14484..b7268c4c2c9 100644 --- a/idea/testData/checker/AnnotationOnFile.kt +++ b/idea/testData/checker/AnnotationOnFile.kt @@ -1,8 +1,8 @@ -@file:kotlin.deprecated("message") +@file:kotlin.deprecated("message") @file:suppress(BAR) @file:suppress(BAZ) -@kotlin.deprecated("message") +@kotlin.deprecated("message") @suppress(BAR) @suppress(BAZ) @@ -19,4 +19,5 @@ package boo val BAZ = "baz" val N = 0 +target(AnnotationTarget.FILE) annotation class myAnnotation(val i: Int, val s: String) diff --git a/idea/testData/decompiler/decompiledText/Annotations/Dependency.kt b/idea/testData/decompiler/decompiledText/Annotations/Dependency.kt index 2142cdf131e..b43d7999b16 100644 --- a/idea/testData/decompiler/decompiledText/Annotations/Dependency.kt +++ b/idea/testData/decompiler/decompiledText/Annotations/Dependency.kt @@ -1,5 +1,13 @@ package dependency +target(AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, + AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE) annotation class A(val s: String) + +target(AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, + AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.TYPE) annotation class B(val i: Int) + +target(AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, + AnnotationTarget.VALUE_PARAMETER) annotation class C diff --git a/idea/testData/decompiler/stubBuilder/Annotations/Annotations.kt b/idea/testData/decompiler/stubBuilder/Annotations/Annotations.kt index 30ca8428164..6eaf41a5c51 100644 --- a/idea/testData/decompiler/stubBuilder/Annotations/Annotations.kt +++ b/idea/testData/decompiler/stubBuilder/Annotations/Annotations.kt @@ -25,8 +25,13 @@ a public class Annotations private @a constructor(private @a val c1: Int, @a val fun types(param: @a @b(E.E1) DoubleRange): @a @b(E.E2) Unit {} } +target(AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION, + AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, + AnnotationTarget.TYPE, AnnotationTarget.CLASSIFIER) annotation class a -annotation class b(val e: E) +target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.CLASSIFIER, + AnnotationTarget.CONSTRUCTOR, AnnotationTarget.TYPE) +annotation(repeatable = false) class b(val e: E) enum class E { E1 E2 } \ No newline at end of file diff --git a/idea/testData/highlighter/Annotations.kt b/idea/testData/highlighter/Annotations.kt index 466267fe97a..2f1ee3c46a2 100644 --- a/idea/testData/highlighter/Annotations.kt +++ b/idea/testData/highlighter/Annotations.kt @@ -1,3 +1,4 @@ +target(AnnotationTarget.CLASSIFIER, AnnotationTarget.EXPRESSION) annotation class Ann Ann class A1 diff --git a/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt b/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt index 11f52949590..04d788b43ee 100644 --- a/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt +++ b/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt @@ -1,3 +1,4 @@ +target(AnnotationTarget.EXPRESSION) annotation class ann fun foo(): Int = @ann 1 \ No newline at end of file diff --git a/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt.after b/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt.after index ddc10faa4b3..33e6615c957 100644 --- a/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt.after +++ b/idea/testData/intentions/convertToBlockBody/annotatedExpr.kt.after @@ -1,3 +1,4 @@ +target(AnnotationTarget.EXPRESSION) annotation class ann fun foo(): Int { diff --git a/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt b/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt index 2f870eee7bb..7a193109653 100644 --- a/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt +++ b/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt @@ -4,4 +4,5 @@ fun foo() { @ann ""!! } +target(AnnotationTarget.EXPRESSION) annotation class ann \ No newline at end of file diff --git a/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt.after b/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt.after index 9c74cb6f380..25bc15164a8 100644 --- a/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt.after +++ b/idea/testData/quickfix/suppress/forStatement/annotatedExpr.kt.after @@ -5,4 +5,5 @@ fun foo() { @ann ""!! } +target(AnnotationTarget.EXPRESSION) annotation class ann \ No newline at end of file From 37b2e97e565d7054a860e1970b4b6795e931dfe2 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 9 Jul 2015 15:02:41 +0300 Subject: [PATCH 256/450] Rendering changed: "annotation class" is now just "class" (with kotlin.annotation.annotation if it's kotlin annotation). A swarm of tests fixed accordingly. --- .../staticFields/AnnotationClass.txt | 14 ++++---- .../staticFields/AnnotationTrait.txt | 14 ++++---- .../staticFields/kt3698.txt | 2 +- ...singEnumReferencedInAnnotationArgument.txt | 2 +- .../annotations/AnnotatedConstructor.txt | 2 +- .../annotations/AnnotatedLocalObjectFun.txt | 2 +- .../AnnotatedLocalObjectProperty.txt | 2 +- .../tests/annotations/AnnotatedLoop.txt | 2 +- .../tests/annotations/AnnotatedResultType.txt | 2 +- .../tests/annotations/AnnotatedTryCatch.txt | 2 +- .../AnnotationAsDefaultParameter.txt | 4 +-- .../AnnotationForClassTypeParameter.txt | 4 +-- .../AnnotationForFunctionTypeParameter.txt | 4 +-- .../tests/annotations/AnnotationOnObject.txt | 2 +- .../annotations/AnnotationsForClasses.txt | 4 +-- .../AnnotationsForPropertyTypeParameter.txt | 4 +-- .../tests/annotations/BasicAnnotations.txt | 6 ++-- .../tests/annotations/ConstructorCall.txt | 10 +++--- .../tests/annotations/DanglingMixed.txt | 4 +-- .../tests/annotations/DanglingNoBrackets.txt | 2 +- .../annotations/DanglingWithBrackets.txt | 2 +- .../JavaAnnotationConstructors.txt | 4 +-- ...allyRecursivelyAnnotatedGlobalFunction.txt | 2 +- .../annotations/RecursivelyAnnotated.txt | 2 +- .../RecursivelyAnnotatedFunctionParameter.txt | 2 +- .../RecursivelyAnnotatedGlobalFunction.txt | 2 +- .../RecursivelyAnnotatedGlobalProperty.txt | 2 +- .../RecursivelyAnnotatedParameter.txt | 2 +- .../RecursivelyAnnotatedParameterType.txt | 2 +- .../RecursivelyAnnotatedParameterWithAt.txt | 2 +- .../RecursivelyAnnotatedProperty.txt | 2 +- .../WrongAnnotationArgsOnObject.txt | 2 +- .../annotations/annotationInheritance.txt | 8 ++--- .../tests/annotations/annotationModifier.txt | 2 +- .../booleanLocalVal.txt | 2 +- .../compareAndEquals.txt | 2 +- .../enumConst.txt | 2 +- .../javaProperties.txt | 2 +- .../kotlinProperties.txt | 2 +- .../strings.txt | 2 +- .../annotationsOnLambdaAsCallArgument.txt | 2 +- .../tests/annotations/atAnnotationResolve.txt | 2 +- .../annotations/extensionFunctionType.txt | 2 +- .../forParameterAnnotationResolve.txt | 2 +- .../invalidTypesInAnnotationConstructor.txt | 36 +++++++++---------- .../tests/annotations/kt1860-positive.txt | 2 +- .../annotations/kt1886annotationBody.txt | 20 +++++------ .../annotations/missingValOnParameter.txt | 2 +- .../tests/annotations/noNameProperty.txt | 2 +- .../tests/annotations/onExpression.txt | 2 +- .../tests/annotations/onFunctionParameter.txt | 2 +- .../tests/annotations/onInitializer.txt | 2 +- .../diagnostics/tests/annotations/onLoops.txt | 2 +- .../tests/annotations/onLoopsUnreachable.txt | 2 +- .../tests/annotations/onMultiDeclaration.txt | 2 +- .../tests/annotations/options/annotation.txt | 6 ++-- .../tests/annotations/options/brackets.txt | 2 +- .../tests/annotations/options/repeatable.txt | 2 +- .../tests/annotations/options/retention.txt | 2 +- .../tests/annotations/options/target.txt | 2 +- .../annotations/options/targets/accessors.txt | 6 ++-- .../options/targets/annotation.txt | 4 +-- .../options/targets/classifier.txt | 4 +-- .../options/targets/constructor.txt | 4 +-- .../annotations/options/targets/empty.txt | 4 +-- .../annotations/options/targets/expr.txt | 4 +-- .../annotations/options/targets/file.txt | 4 +-- .../annotations/options/targets/function.txt | 4 +-- .../options/targets/funtypeargs.txt | 4 +-- .../annotations/options/targets/incorrect.txt | 4 +-- .../annotations/options/targets/init.txt | 2 +- .../annotations/options/targets/local.txt | 4 +-- .../annotations/options/targets/nested.txt | 6 ++-- .../annotations/options/targets/property.txt | 4 +-- .../options/targets/returntype.txt | 4 +-- .../annotations/options/targets/type.txt | 4 +-- .../annotations/options/targets/typeargs.txt | 2 +- .../options/targets/valueparam.txt | 4 +-- .../function/abstractClassConstructors.txt | 2 +- .../FunctionWithMissingNames.txt | 2 +- .../illegalModifiersOnClass.txt | 2 +- .../deparenthesize/annotatedSafeCall.txt | 2 +- .../tests/deprecated/annotationUsage.txt | 4 +-- .../duplicateJvmSignature/missingNames.txt | 4 +-- .../tests/evaluate/divisionByZero.txt | 2 +- .../tests/functionAsExpression/Common.txt | 2 +- .../functionAsExpression/WithoutBody.txt | 2 +- .../inner/classesInClassObjectHeader.txt | 2 +- .../tests/inner/illegalModifier.txt | 2 +- .../inner/selfAnnotationForClassObject.txt | 4 +-- .../tests/modifiers/IllegalModifiers.txt | 2 +- .../primaryConstructorMissingKeyword.txt | 2 +- .../namedArguments/allowForJavaAnnotation.txt | 2 +- .../recovery/namelessToplevelDeclarations.txt | 2 +- .../resolveAnnotatedLambdaArgument.txt | 2 +- .../ctrsAnnotationResolve.txt | 4 +-- .../tests/when/AnnotatedWhenStatement.txt | 2 +- .../ClassObjectAnnotatedWithItsKClass.txt | 2 +- .../annotations/annotationClassMethodCall.txt | 2 +- .../array.txt | 4 +-- .../simple.txt | 8 ++--- .../vararg.txt | 4 +-- .../annotationParameters/orderWithValue.txt | 2 +- .../orderWithoutValue.txt | 2 +- .../annotationParameters/valueArray.txt | 2 +- .../valueArrayAndOtherDefault.txt | 2 +- .../annotationParameters/valueArrayOnly.txt | 2 +- .../valueArrayWithDefault.txt | 2 +- .../javaAnnotationWithVarargArgument.txt | 2 +- .../kotlinAnnotationWithVarargArgument.txt | 2 +- .../defaultValueMustBeConstant.txt | 4 +-- .../annotationAsArgument.txt | 4 +-- .../arg.txt | 2 +- .../argAndOtherDefault.txt | 2 +- .../argArray.txt | 2 +- .../argWithDefault.txt | 2 +- .../argWithDefaultAndOther.txt | 2 +- .../twoArgs.txt | 2 +- .../value.txt | 2 +- .../valueAndOtherDefault.txt | 2 +- .../valueArray.txt | 2 +- .../valueWithDefault.txt | 2 +- .../valueWithDefaultAndOther.txt | 2 +- .../kClassArrayInAnnotationsInVariance.txt | 4 +-- .../kClassArrayInAnnotationsOutVariance.txt | 4 +-- .../annotations/kClass/kClassInAnnotation.txt | 6 ++-- .../kClass/kClassInAnnotationsInVariance.txt | 4 +-- .../kClass/kClassInAnnotationsOutVariance.txt | 4 +-- .../annotations/kClass/kClassInvariantTP.txt | 4 +-- ...kClassOutArrayInAnnotationsOutVariance.txt | 2 +- .../kotlinAnnotation.txt | 2 +- .../tooManyArgs.txt | 2 +- .../typeMismatch.txt | 2 +- .../prohibitPositionedArgument/withValue.txt | 2 +- .../withoutValue.txt | 2 +- .../annotations/qualifiedCallValue.txt | 10 +++--- .../annotations/AnnotatedAnnotation.txt | 2 +- .../annotations/AnnotatedConstructor.txt | 2 +- .../annotations/AnnotatedField.txt | 2 +- .../annotations/AnnotatedMethod.txt | 2 +- .../annotations/AnnotatedValueParameter.txt | 2 +- .../annotations/AnnotationInParam.txt | 12 +++---- .../ArithmeticExpressionInParam.txt | 2 +- .../annotations/ArrayOfEnumInParam.txt | 2 +- .../annotations/ArrayOfStringInParam.txt | 2 +- .../annotations/ClassObjectArrayInParam.txt | 2 +- .../annotations/ClassObjectInParam.txt | 2 +- .../annotations/ClassObjectInParamRaw.txt | 2 +- .../ClassObjectInParamVariance.txt | 2 +- .../annotations/CustomAnnotation.txt | 2 +- .../CustomAnnotationWithDefaultParameter.txt | 2 +- .../annotations/EmptyArrayInParam.txt | 2 +- .../EnumArgumentWithCustomToString.txt | 4 +-- .../annotations/EnumConstructorParameter.txt | 2 +- .../compiledJava/annotations/EnumInParam.txt | 4 +-- .../annotations/NestedEnumArgument.txt | 2 +- .../annotations/PrimitiveValueInParam.txt | 2 +- .../annotations/RecursiveAnnotation.txt | 4 +-- .../annotations/RecursiveAnnotation2.txt | 4 +-- .../annotations/SimpleAnnotation.txt | 2 +- .../StringConcatenationInParam.txt | 2 +- .../annotations/StringConstantInParam.txt | 2 +- .../annotations/StringInParam.txt | 2 +- .../annotations/AnnotatedAnnotation.txt | 2 +- .../AnnotationInAnnotationArguments.txt | 6 ++-- .../EnumArgumentWithCustomToString.txt | 4 +-- .../MultiDimensionalArrayMethod.txt | 2 +- .../annotations/SimpleAnnotation.txt | 2 +- .../annotations/TargetedAnnotation.txt | 2 +- .../classMembers/ClassObjectPropertyField.txt | 2 +- .../annotations/classMembers/Constructor.txt | 2 +- .../classMembers/DelegatedProperty.txt | 2 +- .../annotations/classMembers/EnumArgument.txt | 2 +- .../annotations/classMembers/Function.txt | 2 +- .../annotations/classMembers/Getter.txt | 2 +- .../classMembers/PropertyField.txt | 2 +- .../annotations/classMembers/Setter.txt | 2 +- .../classes/AnnotationInClassObject.txt | 4 +-- .../classes/ClassInClassObject.txt | 2 +- .../annotations/classes/ClassObject.txt | 2 +- .../classes/DollarsInAnnotationName.txt | 4 +-- .../annotations/classes/EnumArgument.txt | 2 +- .../classes/MultipleAnnotations.txt | 6 ++-- .../annotations/classes/NestedAnnotation.txt | 2 +- .../annotations/classes/NestedClass.txt | 2 +- .../annotations/classes/Retention.txt | 2 +- .../annotations/classes/Simple.txt | 2 +- .../annotations/classes/WithArgument.txt | 16 ++++----- .../classes/WithMultipleArguments.txt | 2 +- .../packageMembers/DelegatedProperty.txt | 2 +- .../packageMembers/EnumArgument.txt | 2 +- .../packageMembers/EnumArrayArgument.txt | 2 +- .../annotations/packageMembers/Function.txt | 2 +- .../annotations/packageMembers/Getter.txt | 2 +- .../packageMembers/PropertyField.txt | 2 +- .../annotations/packageMembers/Setter.txt | 2 +- .../packageMembers/StringArrayArgument.txt | 2 +- .../annotations/parameters/Constructor.txt | 4 +-- .../parameters/EnumConstructor.txt | 4 +-- .../parameters/ExtensionFunction.txt | 2 +- .../parameters/ExtensionFunctionInClass.txt | 2 +- .../parameters/ExtensionPropertySetter.txt | 2 +- .../parameters/FunctionInClass.txt | 2 +- .../parameters/FunctionInTrait.txt | 2 +- .../parameters/InnerClassConstructor.txt | 2 +- .../parameters/ManyAnnotations.txt | 8 ++--- .../parameters/PropertySetterInClass.txt | 2 +- .../parameters/TopLevelFunction.txt | 2 +- .../parameters/TopLevelPropertySetter.txt | 4 +-- .../propertiesWithoutBackingFields/Class.txt | 2 +- .../ClassObject.txt | 2 +- .../ExtensionsWithSameNameClass.txt | 6 ++-- .../ExtensionsWithSameNamePackage.txt | 6 ++-- .../NestedTrait.txt | 2 +- .../TopLevel.txt | 2 +- .../propertiesWithoutBackingFields/Trait.txt | 2 +- .../TraitClassObject.txt | 2 +- .../annotations/types/ReceiverParameter.txt | 2 +- .../types/SimpleTypeAnnotation.txt | 2 +- .../annotations/types/SupertypesAndBounds.txt | 2 +- .../types/TypeAnnotationWithArguments.txt | 2 +- .../fromLoadJava/classObjectAnnotation.txt | 2 +- .../platformNames/functionName.txt | 2 +- .../loadJava/sourceJava/NullInAnnotation.txt | 2 +- compiler/testData/renderer/Classes.kt | 4 +-- compiler/testData/renderer/KeywordsInNames.kt | 2 +- .../annotationArguments/annotation.txt | 6 ++-- .../annotationArguments/enum.txt | 4 +-- .../annotationArguments/primitiveArrays.txt | 2 +- .../annotationArguments/primitives.txt | 2 +- .../annotationArguments/string.txt | 4 +-- .../annotationArguments/varargs.txt | 4 +-- .../builtinsSerializer/annotationTargets.txt | 2 +- .../kotlin/renderer/DescriptorRenderer.kt | 2 +- .../AnnotationClass/AnnotationClass.txt | 22 +++++++++++- .../stubBuilder/ClassObject/ClassObject.txt | 22 +++++++++++- 236 files changed, 411 insertions(+), 371 deletions(-) diff --git a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt index 72aa9140eaf..c1267305f6b 100644 --- a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt +++ b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationClass.txt @@ -1,36 +1,36 @@ package test -kotlin.annotation.annotation() internal final annotation class AByte : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AByte : kotlin.Annotation { public constructor AByte(/*0*/ kotlin.Byte) internal final val value: kotlin.Byte } -kotlin.annotation.annotation() internal final annotation class AChar : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AChar : kotlin.Annotation { public constructor AChar(/*0*/ kotlin.Char) internal final val value: kotlin.Char } -kotlin.annotation.annotation() internal final annotation class ADouble : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ADouble : kotlin.Annotation { public constructor ADouble(/*0*/ kotlin.Double) internal final val value: kotlin.Double } -kotlin.annotation.annotation() internal final annotation class AFloat : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AFloat : kotlin.Annotation { public constructor AFloat(/*0*/ kotlin.Float) internal final val value: kotlin.Float } -kotlin.annotation.annotation() internal final annotation class AInt : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AInt : kotlin.Annotation { public constructor AInt(/*0*/ kotlin.Int) internal final val value: kotlin.Int } -kotlin.annotation.annotation() internal final annotation class ALong : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ALong : kotlin.Annotation { public constructor ALong(/*0*/ kotlin.Long) internal final val value: kotlin.Long } -kotlin.annotation.annotation() internal final annotation class AString : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AString : kotlin.Annotation { public constructor AString(/*0*/ kotlin.String) internal final val value: kotlin.String } diff --git a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt index d9be3db2f41..4f0b36ea32f 100644 --- a/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt +++ b/compiler/testData/compileJavaAgainstKotlin/staticFields/AnnotationTrait.txt @@ -1,36 +1,36 @@ package test -kotlin.annotation.annotation() internal final annotation class AByte : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AByte : kotlin.Annotation { public constructor AByte(/*0*/ kotlin.Byte) internal final val value: kotlin.Byte } -kotlin.annotation.annotation() internal final annotation class AChar : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AChar : kotlin.Annotation { public constructor AChar(/*0*/ kotlin.Char) internal final val value: kotlin.Char } -kotlin.annotation.annotation() internal final annotation class ADouble : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ADouble : kotlin.Annotation { public constructor ADouble(/*0*/ kotlin.Double) internal final val value: kotlin.Double } -kotlin.annotation.annotation() internal final annotation class AFloat : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AFloat : kotlin.Annotation { public constructor AFloat(/*0*/ kotlin.Float) internal final val value: kotlin.Float } -kotlin.annotation.annotation() internal final annotation class AInt : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AInt : kotlin.Annotation { public constructor AInt(/*0*/ kotlin.Int) internal final val value: kotlin.Int } -kotlin.annotation.annotation() internal final annotation class ALong : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ALong : kotlin.Annotation { public constructor ALong(/*0*/ kotlin.Long) internal final val value: kotlin.Long } -kotlin.annotation.annotation() internal final annotation class AString : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AString : kotlin.Annotation { public constructor AString(/*0*/ kotlin.String) internal final val value: kotlin.String } diff --git a/compiler/testData/compileJavaAgainstKotlin/staticFields/kt3698.txt b/compiler/testData/compileJavaAgainstKotlin/staticFields/kt3698.txt index fe3d067c610..16f4f02d951 100644 --- a/compiler/testData/compileJavaAgainstKotlin/staticFields/kt3698.txt +++ b/compiler/testData/compileJavaAgainstKotlin/staticFields/kt3698.txt @@ -12,7 +12,7 @@ internal final class KotlinClass { public open class kt3698 { public constructor kt3698() - public/*package*/ final annotation class Foo : kotlin.Annotation { + public/*package*/ final class Foo : kotlin.Annotation { public/*package*/ constructor Foo(/*0*/ kotlin.Int) public final val value: kotlin.Int public abstract fun value(): kotlin.Int diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt index cb2b210d1d8..324116aa37a 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/missingEnumReferencedInAnnotationArgument/missingEnumReferencedInAnnotationArgument.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ e: [ERROR : test.E]) internal final val e: [ERROR : test.E] } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt index be859092854..496574921bd 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedConstructor.txt @@ -8,7 +8,7 @@ internal final class Annotated { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt index a8cb2ef610e..fcce010b9b2 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectFun.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt index b1d5e2f3548..260fc95945a 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLocalObjectProperty.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt index a8cb2ef610e..fcce010b9b2 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedLoop.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt index 9a014ebe437..aa0615c7e0b 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt @@ -2,7 +2,7 @@ package internal fun foo(): @[My(x = IntegerValueType(42))] kotlin.Int -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt index ed5812bd39b..6d159c39fe1 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedTryCatch.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ arg: kotlin.Int): kotlin.Int -kotlin.annotation.annotation() internal final annotation class My : kotlin.Annotation { +kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt index 8da2e8abffe..0231895ca4b 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationAsDefaultParameter.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class Base : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Base : kotlin.Annotation { public constructor Base(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ UseBase() internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class UseBase : kotlin.Annotation { +kotlin.annotation.annotation() internal final class UseBase : kotlin.Annotation { public constructor UseBase(/*0*/ b: Base = ...) internal final val b: Base public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt index 63336f0c387..060db6d4c60 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.txt @@ -1,13 +1,13 @@ package -kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt index a8f7f0581dc..7ca10075d05 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.txt @@ -2,14 +2,14 @@ package internal fun topFun(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt index ac01753b989..3ffe8307356 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt @@ -2,7 +2,7 @@ package package test { - kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { + kotlin.annotation.annotation() internal final class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int = ..., /*1*/ b: kotlin.String = ..., /*2*/ c: kotlin.String) internal final val a: kotlin.Int internal final val b: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt index db0de398de3..cd4d9230b13 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForClasses.txt @@ -1,13 +1,13 @@ package -kotlin.annotation.annotation() java.lang.Deprecated() internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.Deprecated() internal final class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() java.lang.Deprecated() internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.Deprecated() internal final class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt index 2cd7c1a72e4..7606613f710 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.txt @@ -2,14 +2,14 @@ package internal val topProp: kotlin.Int = 12 -kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A1 : kotlin.Annotation { public constructor A1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A2 : kotlin.Annotation { public constructor A2(/*0*/ some: kotlin.Int = ...) internal final val some: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt index c7a9a1acc1e..a1080dfccfa 100644 --- a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt @@ -7,14 +7,14 @@ my2() internal fun foo4(): kotlin.Unit my2() internal fun foo41(): kotlin.Unit my2(i = IntegerValueType(2)) internal fun foo42(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() internal final class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class my1 : kotlin.Annotation { public constructor my1(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ kotlin.annotation.annotation() internal final annotation class my1 : kotlin.Anno public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class my2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class my2 : kotlin.Annotation { public constructor my2(/*0*/ i: kotlin.Int = ...) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt index fe2358c16c2..6762022a638 100644 --- a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt +++ b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt @@ -7,14 +7,14 @@ internal fun foo(): kotlin.Unit internal fun javaClass(): java.lang.Class internal fun kotlin.String.invoke(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ a: kotlin.Int) internal final val a: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ a: Ann1) internal final val a: Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -30,7 +30,7 @@ kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ a: Ann1 = ...) internal final val a: Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -38,7 +38,7 @@ kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann4 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann4 : kotlin.Annotation { public constructor Ann4(/*0*/ value: kotlin.String) internal final val value: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt b/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt index 7d717629e2a..21d8689635a 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingMixed.txt @@ -1,13 +1,13 @@ package -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt b/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt index 73272a69e57..07b847fab59 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingNoBrackets.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt b/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt index 49b1179cd42..0bb690e6be8 100644 --- a/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt +++ b/compiler/testData/diagnostics/tests/annotations/DanglingWithBrackets.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt index 397822550f8..bb382d11bd2 100644 --- a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt +++ b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt @@ -1,13 +1,13 @@ package -kotlin.annotation.annotation() internal final annotation class my : kotlin.Annotation { +kotlin.annotation.annotation() internal final class my : kotlin.Annotation { public constructor my() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final annotation class my1 : kotlin.Annotation { +kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt index a93c3ee35e0..27dc28b3fa2 100644 --- a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt +++ b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.txt @@ -3,7 +3,7 @@ package ann() internal fun bar(): kotlin.Int ann() internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt index cd8b8330b27..3ce20f4bfb6 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt @@ -1,6 +1,6 @@ package -RecursivelyAnnotated(x = IntegerValueType(1)) kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +RecursivelyAnnotated(x = IntegerValueType(1)) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt index 7e02bec3b7f..3e581906594 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ ann() x: kotlin.Int): kotlin.Int -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt index 2a8ee5a14b7..02471ce11b6 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.txt @@ -2,7 +2,7 @@ package ann() internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt index e876d7bfe73..b1510e02906 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalProperty.txt @@ -2,7 +2,7 @@ package ann(x = 1) internal val x: kotlin.Int = 1 -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt index 63856371b5a..aa410c44299 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt index c5994b1e87d..111ffbf2d28 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int) internal final val x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt index 63856371b5a..aa410c44299 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class RecursivelyAnnotated : kotlin.Annotation { +kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt index 2083a6eef89..f8e48441007 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.txt @@ -8,7 +8,7 @@ internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt index 44f8f2ffc6c..4593d4f7324 100644 --- a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt @@ -3,7 +3,7 @@ package package test { internal val some: test.SomeObject - kotlin.annotation.annotation() internal final annotation class BadAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final class BadAnnotation : kotlin.Annotation { public constructor BadAnnotation(/*0*/ s: kotlin.String) internal final val s: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt index 4bcbbaf7487..964e089f8ed 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationInheritance.txt @@ -2,28 +2,28 @@ package internal val a: T -kotlin.annotation.annotation() internal final annotation class Ann : C { +kotlin.annotation.annotation() internal final class Ann : C { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : T { +kotlin.annotation.annotation() internal final class Ann2 : T { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann3 : T { +kotlin.annotation.annotation() internal final class Ann3 : T { public constructor Ann3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann4 : C, T { +kotlin.annotation.annotation() internal final class Ann4 : C, T { public constructor Ann4() public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt index 89ed33fb51f..07873eeeea1 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt @@ -18,7 +18,7 @@ internal final class A { } } -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { public constructor B() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt index 0cebb69f97e..c4dcedead55 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Boolean /*kotlin.BooleanArray*/) internal final val i: kotlin.BooleanArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt index 0cebb69f97e..c4dcedead55 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Boolean /*kotlin.BooleanArray*/) internal final val i: kotlin.BooleanArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt index 374ce3a0743..6aff3a44df4 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.txt @@ -2,7 +2,7 @@ package internal val e: MyEnum -kotlin.annotation.annotation() internal final annotation class AnnE : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnE : kotlin.Annotation { public constructor AnnE(/*0*/ i: MyEnum) internal final val i: MyEnum public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt index f668b06ebe5..6b3e2e6c5b8 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.txt @@ -7,7 +7,7 @@ Ann(i = {1, 1, 1}) internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt index 7ea52668e62..923186e5b28 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.txt @@ -7,7 +7,7 @@ internal val i4: kotlin.Int = 1 internal var i5: kotlin.Int internal var i6: kotlin.Int -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt index 84691e400a0..643282d24c9 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.txt @@ -3,7 +3,7 @@ package internal val topLevel: kotlin.String = "topLevel" internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.String /*kotlin.Array*/) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt index 0c44086913f..98a9c0f6da4 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationsOnLambdaAsCallArgument.txt @@ -3,7 +3,7 @@ package kotlin.inline() internal fun bar(/*0*/ block: () -> kotlin.Int): kotlin.Int internal fun foo(): kotlin.Unit -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt index 21b5655e9f7..195d72eac5c 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt @@ -10,7 +10,7 @@ Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueTy public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASSIFIER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.EXPRESSION, AnnotationTarget.PROPERTY}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASSIFIER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.EXPRESSION, AnnotationTarget.PROPERTY}) kotlin.annotation.annotation(repeatable = true) internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt b/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt index b23c290f7d9..d7f1091fb38 100644 --- a/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt +++ b/compiler/testData/diagnostics/tests/annotations/extensionFunctionType.txt @@ -10,7 +10,7 @@ internal interface Some { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt index a83e76784e4..295d0ab72c5 100644 --- a/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.txt @@ -15,7 +15,7 @@ kotlin.data() internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt b/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt index 68ca164db63..0c727b02bec 100644 --- a/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt +++ b/compiler/testData/diagnostics/tests/annotations/invalidTypesInAnnotationConstructor.txt @@ -2,7 +2,7 @@ package package test { - kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ p1: kotlin.Int, /*1*/ p2: kotlin.Byte, /*2*/ p3: kotlin.Short, /*3*/ p4: kotlin.Long, /*4*/ p5: kotlin.Double, /*5*/ p6: kotlin.Float, /*6*/ p7: kotlin.Char, /*7*/ p8: kotlin.Boolean) internal final val p1: kotlin.Int internal final val p2: kotlin.Byte @@ -17,7 +17,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ p1: kotlin.String) internal final val p1: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -25,7 +25,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ p1: test.Ann1) internal final val p1: test.Ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -33,7 +33,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann4 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann4 : kotlin.Annotation { public constructor Ann4(/*0*/ p1: kotlin.IntArray, /*1*/ p2: kotlin.ByteArray, /*2*/ p3: kotlin.ShortArray, /*3*/ p4: kotlin.LongArray, /*4*/ p5: kotlin.DoubleArray, /*5*/ p6: kotlin.FloatArray, /*6*/ p7: kotlin.CharArray, /*7*/ p8: kotlin.BooleanArray) internal final val p1: kotlin.IntArray internal final val p2: kotlin.ByteArray @@ -48,7 +48,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann5 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann5 : kotlin.Annotation { public constructor Ann5(/*0*/ p1: test.MyEnum) internal final val p1: test.MyEnum public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -56,7 +56,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann6 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann6 : kotlin.Annotation { public constructor Ann6(/*0*/ p: java.lang.Class<*>) internal final val p: java.lang.Class<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -64,7 +64,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann7 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann7 : kotlin.Annotation { public constructor Ann7(/*0*/ p: java.lang.annotation.RetentionPolicy) internal final val p: java.lang.annotation.RetentionPolicy public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -72,7 +72,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann8 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann8 : kotlin.Annotation { public constructor Ann8(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array>, /*2*/ p3: kotlin.Array, /*3*/ p4: kotlin.Array) internal final val p1: kotlin.Array internal final val p2: kotlin.Array> @@ -83,7 +83,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class Ann9 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Ann9 : kotlin.Annotation { public constructor Ann9(/*0*/ vararg p1: kotlin.String /*kotlin.Array*/, /*1*/ vararg p2: java.lang.Class<*> /*kotlin.Array>*/, /*2*/ vararg p3: test.MyEnum /*kotlin.Array*/, /*3*/ vararg p4: test.Ann1 /*kotlin.Array*/, /*4*/ vararg p5: kotlin.Int /*kotlin.IntArray*/) internal final val p1: kotlin.Array internal final val p2: kotlin.Array> @@ -95,7 +95,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn1 : kotlin.Annotation { public constructor InAnn1(/*0*/ p1: kotlin.Int?, /*1*/ p3: kotlin.Short?, /*2*/ p4: kotlin.Long?, /*3*/ p5: kotlin.Double?, /*4*/ p6: kotlin.Float?, /*5*/ p7: kotlin.Char?, /*6*/ p8: kotlin.Boolean?) internal final val p1: kotlin.Int? internal final val p3: kotlin.Short? @@ -109,7 +109,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn10 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn10 : kotlin.Annotation { public constructor InAnn10(/*0*/ p1: kotlin.String?) internal final val p1: kotlin.String? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -117,7 +117,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn11 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn11 : kotlin.Annotation { public constructor InAnn11(/*0*/ p1: test.Ann1?) internal final val p1: test.Ann1? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -125,7 +125,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn12 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn12 : kotlin.Annotation { public constructor InAnn12(/*0*/ p1: test.MyEnum?) internal final val p1: test.MyEnum? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -133,7 +133,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn4 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn4 : kotlin.Annotation { public constructor InAnn4(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array?) internal final val p1: kotlin.Array internal final val p2: kotlin.Array? @@ -142,7 +142,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn6 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn6 : kotlin.Annotation { public constructor InAnn6(/*0*/ p: java.lang.Class<*>?) internal final val p: java.lang.Class<*>? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -150,7 +150,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn7 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn7 : kotlin.Annotation { public constructor InAnn7(/*0*/ p: java.lang.annotation.RetentionPolicy?) internal final val p: java.lang.annotation.RetentionPolicy? public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -158,7 +158,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn8 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn8 : kotlin.Annotation { public constructor InAnn8(/*0*/ p1: kotlin.Array, /*1*/ p2: kotlin.Array, /*2*/ p3: kotlin.Array, /*3*/ p4: kotlin.Array) internal final val p1: kotlin.Array internal final val p2: kotlin.Array @@ -169,7 +169,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InAnn9 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InAnn9 : kotlin.Annotation { public constructor InAnn9(/*0*/ p: test.MyClass) internal final val p: test.MyClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt index 2335c66eb3f..bb12f4d9876 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt @@ -11,7 +11,7 @@ internal final class Hello { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class test : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final class test : kotlin.Annotation { public constructor test() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt b/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt index dc668dc34c9..8a04f9cd324 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1886annotationBody.txt @@ -1,20 +1,20 @@ package -kotlin.annotation.annotation() internal final annotation class Annotation1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation1 : kotlin.Annotation { public constructor Annotation1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation10 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation10 : kotlin.Annotation { public constructor Annotation10() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation2 : kotlin.Annotation { public constructor Annotation2() public final val s: kotlin.String = "" public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -22,7 +22,7 @@ kotlin.annotation.annotation() internal final annotation class Annotation2 : kot public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation3 : kotlin.Annotation { public constructor Annotation3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public final fun foo(): kotlin.Unit @@ -30,7 +30,7 @@ kotlin.annotation.annotation() internal final annotation class Annotation3 : kot public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation4 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation4 : kotlin.Annotation { public constructor Annotation4() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -44,7 +44,7 @@ kotlin.annotation.annotation() internal final annotation class Annotation4 : kot } } -kotlin.annotation.annotation() internal final annotation class Annotation5 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation5 : kotlin.Annotation { public constructor Annotation5() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -58,14 +58,14 @@ kotlin.annotation.annotation() internal final annotation class Annotation5 : kot } } -kotlin.annotation.annotation() internal final annotation class Annotation6 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation6 : kotlin.Annotation { public constructor Annotation6() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation7 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation7 : kotlin.Annotation { public constructor Annotation7(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -73,7 +73,7 @@ kotlin.annotation.annotation() internal final annotation class Annotation7 : kot public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation8 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation8 : kotlin.Annotation { public constructor Annotation8(/*0*/ name: kotlin.String = ...) internal final var name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -81,7 +81,7 @@ kotlin.annotation.annotation() internal final annotation class Annotation8 : kot public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Annotation9 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Annotation9 : kotlin.Annotation { public constructor Annotation9(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt b/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt index 2ad51fa26d7..d97e7526c9d 100644 --- a/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/missingValOnParameter.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int, /*2*/ c: kotlin.String) internal final val a: kotlin.Int internal final var b: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt b/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt index 34a8a5548bd..d21bd493602 100644 --- a/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt +++ b/compiler/testData/diagnostics/tests/annotations/noNameProperty.txt @@ -1,6 +1,6 @@ package -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ : [ERROR : Type annotation was missing for parameter ]) internal final val : [ERROR : Annotation is absent] internal final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onExpression.txt b/compiler/testData/diagnostics/tests/annotations/onExpression.txt index 6334c0133bc..483adc1101c 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.txt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.txt @@ -2,7 +2,7 @@ package internal fun foo(): kotlin.Int -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt index a9365dcac93..275ad1ebb8c 100644 --- a/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/onFunctionParameter.txt @@ -4,7 +4,7 @@ internal val bar: (kotlin.Int) -> kotlin.Unit internal val bas: (kotlin.Int) -> kotlin.Unit internal fun test(/*0*/ ann() p: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onInitializer.txt b/compiler/testData/diagnostics/tests/annotations/onInitializer.txt index b15a7444d68..f986750a6e9 100644 --- a/compiler/testData/diagnostics/tests/annotations/onInitializer.txt +++ b/compiler/testData/diagnostics/tests/annotations/onInitializer.txt @@ -13,7 +13,7 @@ internal interface T { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onLoops.txt b/compiler/testData/diagnostics/tests/annotations/onLoops.txt index fc0855189ee..9d3e9a20d6b 100644 --- a/compiler/testData/diagnostics/tests/annotations/onLoops.txt +++ b/compiler/testData/diagnostics/tests/annotations/onLoops.txt @@ -2,7 +2,7 @@ package internal fun test(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt b/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt index fc0855189ee..9d3e9a20d6b 100644 --- a/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt +++ b/compiler/testData/diagnostics/tests/annotations/onLoopsUnreachable.txt @@ -2,7 +2,7 @@ package internal fun test(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt b/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt index cdc24442601..638c6f3ebde 100644 --- a/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt +++ b/compiler/testData/diagnostics/tests/annotations/onMultiDeclaration.txt @@ -14,7 +14,7 @@ kotlin.data() internal final class P { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/annotation.txt b/compiler/testData/diagnostics/tests/annotations/options/annotation.txt index 198ad1c81c6..6e7bdae469f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/annotation.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/annotation.txt @@ -34,7 +34,7 @@ internal final enum class Target : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -target(allowedTargets = {Target.CLASSIFIER}) annotation(retention = AnnotationRetention.SOURCE) public final annotation class annotation : kotlin.Annotation { +target(allowedTargets = {Target.CLASSIFIER}) annotation(retention = AnnotationRetention.SOURCE) public final class annotation : kotlin.Annotation { public constructor annotation(/*0*/ retention: kotlin.annotation.AnnotationRetention = ..., /*1*/ repeatable: kotlin.Boolean = ...) internal final val repeatable: kotlin.Boolean internal final val retention: kotlin.annotation.AnnotationRetention @@ -43,14 +43,14 @@ target(allowedTargets = {Target.CLASSIFIER}) annotation(retention = AnnotationRe public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -annotation() internal final annotation class some : kotlin.Annotation { +annotation() internal final class some : kotlin.Annotation { public constructor some() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -target(allowedTargets = {Target.CLASSIFIER}) annotation() public final annotation class target : kotlin.Annotation { +target(allowedTargets = {Target.CLASSIFIER}) annotation() public final class target : kotlin.Annotation { public constructor target(/*0*/ vararg allowedTargets: Target /*kotlin.Array*/) internal final val allowedTargets: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/options/brackets.txt b/compiler/testData/diagnostics/tests/annotations/options/brackets.txt index 1c973ff3e93..58f0f9f3087 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/brackets.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/brackets.txt @@ -7,7 +7,7 @@ emptyBrackets() internal final class base { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class emptyBrackets : kotlin.Annotation { +kotlin.annotation.annotation() internal final class emptyBrackets : kotlin.Annotation { public constructor emptyBrackets() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt index cfb2fb1f2fe..a396fa6b17f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt @@ -7,7 +7,7 @@ repann() repann() internal final class DoubleAnnotated { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation(repeatable = true) internal final annotation class repann : kotlin.Annotation { +kotlin.annotation.annotation(repeatable = true) internal final class repann : kotlin.Annotation { public constructor repann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/retention.txt b/compiler/testData/diagnostics/tests/annotations/options/retention.txt index 679d908bc7d..b96dea2f173 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/retention.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/retention.txt @@ -7,7 +7,7 @@ sourceann() internal final class AnnotatedAtSource { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation(retention = AnnotationRetention.SOURCE) internal final annotation class sourceann : kotlin.Annotation { +kotlin.annotation.annotation(retention = AnnotationRetention.SOURCE) internal final class sourceann : kotlin.Annotation { public constructor sourceann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/target.txt b/compiler/testData/diagnostics/tests/annotations/options/target.txt index c2ff25c4794..09152f6db0f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/target.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/target.txt @@ -8,7 +8,7 @@ base() kotlin.data() internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt index 7bd6d9c347e..641527b226c 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.txt @@ -9,21 +9,21 @@ internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_GETTER}) kotlin.annotation.annotation() internal final annotation class smartget : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_GETTER}) kotlin.annotation.annotation() internal final class smartget : kotlin.Annotation { public constructor smartget() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_SETTER}) kotlin.annotation.annotation() internal final annotation class smartset : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_SETTER}) kotlin.annotation.annotation() internal final class smartset : kotlin.Annotation { public constructor smartset() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt index 8b552426e94..4a78537850d 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt index 7aeb85464e7..b9bb02b00a6 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt index b6349ff0521..1aecd91bde6 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CONSTRUCTOR}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CONSTRUCTOR}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt index 1cda0cbb71b..20ef832c08c 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/empty.txt @@ -46,14 +46,14 @@ empty() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -empty() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +empty() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final annotation class empty : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final class empty : kotlin.Annotation { public constructor empty() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt index d1ccd693c0b..58e6479fa39 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt @@ -3,14 +3,14 @@ package base() special() internal fun foo(/*0*/ i: kotlin.Int): kotlin.Int internal fun transform(/*0*/ i: kotlin.Int, /*1*/ tr: (kotlin.Int) -> kotlin.Int): kotlin.Int -kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final class special : kotlin.Annotation { public constructor special() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt index d9a0c13e9fb..084c6b9a796 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/file.txt @@ -16,14 +16,14 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class common : kotlin.Annotation { + kotlin.annotation.annotation() internal final class common : kotlin.Annotation { public constructor common() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.target(allowedTargets = {AnnotationTarget.FILE}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { + kotlin.annotation.target(allowedTargets = {AnnotationTarget.FILE}) kotlin.annotation.annotation() internal final class special : kotlin.Annotation { public constructor special() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt index b637c7e45a1..fd0f3cc25a5 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/function.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -54,7 +54,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt index b73fa4a2c92..f0528388ae0 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt @@ -3,14 +3,14 @@ package internal fun foo(/*0*/ i: kotlin.Int): kotlin.Int internal fun transform(/*0*/ i: kotlin.Int, /*1*/ tr: (kotlin.Int) -> kotlin.Int): kotlin.Int -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class special : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final class special : kotlin.Annotation { public constructor special() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt index 16fc5207109..7349f38fb4a 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.txt @@ -46,14 +46,14 @@ incorrect() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -incorrect() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +incorrect() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final annotation class incorrect : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() internal final class incorrect : kotlin.Annotation { public constructor incorrect() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt index f982ecf3ed0..c6358f550ed 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/init.txt @@ -7,7 +7,7 @@ base() internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt index 09bab8ef41c..ef69abc5583 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/local.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.LOCAL_VARIABLE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.LOCAL_VARIABLE}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt index 527e9a08bc0..8387782eb3f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.txt @@ -7,7 +7,7 @@ base() internal final class Outer { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - base() meta() kotlin.annotation.annotation() internal final annotation class Annotated : kotlin.Annotation { + base() meta() kotlin.annotation.annotation() internal final class Annotated : kotlin.Annotation { public constructor Annotated() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -22,14 +22,14 @@ base() internal final class Outer { } } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final annotation class meta : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() internal final class meta : kotlin.Annotation { public constructor meta() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt index 67c7280e71a..51a25e3e6e0 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/property.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt index b598f3a1315..134aba571d9 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/returntype.txt @@ -10,14 +10,14 @@ base() internal final class My { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class typed : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class typed : kotlin.Annotation { public constructor typed() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt index 61f16ff5b15..cb2288581ff 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/type.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt index f6a16227230..df24e4d4b28 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeargs.txt @@ -2,7 +2,7 @@ package internal val x: kotlin.List? = null -kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt index 48bc7e297b2..2bf1f70df71 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.txt @@ -37,7 +37,7 @@ base() internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) kotlin.annotation.annotation() internal final annotation class base : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) kotlin.annotation.annotation() internal final class base : kotlin.Annotation { public constructor base() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -53,7 +53,7 @@ base() internal final class correct { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -base() kotlin.annotation.annotation() internal final annotation class derived : kotlin.Annotation { +base() kotlin.annotation.annotation() internal final class derived : kotlin.Annotation { public constructor derived() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt b/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt index af982686f82..74af0216149 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt +++ b/compiler/testData/diagnostics/tests/callableReference/function/abstractClassConstructors.txt @@ -15,7 +15,7 @@ internal abstract class B { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class C : kotlin.Annotation { +kotlin.annotation.annotation() internal final class C : kotlin.Annotation { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt index f71ecf397f6..bb83655f05b 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt +++ b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.txt @@ -29,7 +29,7 @@ internal final class Outer { internal final fun B.(): kotlin.Unit } -kotlin.annotation.annotation() internal final annotation class a : kotlin.Annotation { +kotlin.annotation.annotation() internal final class a : kotlin.Annotation { public constructor a() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt index 7ea444df8ee..afd5407a54f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt +++ b/compiler/testData/diagnostics/tests/declarationChecks/illegalModifiersOnClass.txt @@ -83,7 +83,7 @@ internal interface D { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal open annotation class E : kotlin.Annotation { +kotlin.annotation.annotation() internal open class E : kotlin.Annotation { public constructor E() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt index b259d40e6f1..0e1cfbb02fd 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt @@ -2,7 +2,7 @@ package internal fun f(/*0*/ s: kotlin.String?): kotlin.Boolean -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final annotation class foo : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation() internal final class foo : kotlin.Annotation { public constructor foo() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt index b6707e92e98..0df0472fb3e 100644 --- a/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt +++ b/compiler/testData/diagnostics/tests/deprecated/annotationUsage.txt @@ -14,14 +14,14 @@ obsoleteWithParam(text = "text") internal final class Obsolete2 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final annotation class obsolete : kotlin.Annotation { +kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final class obsolete : kotlin.Annotation { public constructor obsolete() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final annotation class obsoleteWithParam : kotlin.Annotation { +kotlin.deprecated(value = "text") kotlin.annotation.annotation() internal final class obsoleteWithParam : kotlin.Annotation { public constructor obsoleteWithParam(/*0*/ text: kotlin.String) internal final val text: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt index b987a4e3d20..0ec587b3416 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.txt @@ -32,7 +32,7 @@ internal final enum class : kotlin.Enum<> { public final /*synthesized*/ fun values(): kotlin.Array<> } -kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { +kotlin.annotation.annotation() internal final class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -81,7 +81,7 @@ internal final class Outer { public final /*synthesized*/ fun values(): kotlin.Array> } - kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { + kotlin.annotation.annotation() internal final class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt index 9f39b50c712..a59c065f023 100644 --- a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt +++ b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.txt @@ -12,7 +12,7 @@ internal val a9: kotlin.Int internal val b1: kotlin.Byte Ann() internal val b2: kotlin.Int = 1 -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt b/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt index 357ebb7e3e4..08042e068ce 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/Common.txt @@ -18,7 +18,7 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ name: kotlin.String) internal final val name: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt index 1c4568fe3c2..2dbb32eea0c 100644 --- a/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt +++ b/compiler/testData/diagnostics/tests/functionAsExpression/WithoutBody.txt @@ -4,7 +4,7 @@ internal val bas: () -> kotlin.Unit internal fun bar(/*0*/ a: kotlin.Any): () -> kotlin.Unit internal fun outer(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt b/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt index b65c7f0e43c..9d1f545c42f 100644 --- a/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt +++ b/compiler/testData/diagnostics/tests/inner/classesInClassObjectHeader.txt @@ -13,7 +13,7 @@ internal final class Test { public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class InnerAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final class InnerAnnotation : kotlin.Annotation { public constructor InnerAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/illegalModifier.txt b/compiler/testData/diagnostics/tests/inner/illegalModifier.txt index 86141ba352e..722225dc574 100644 --- a/compiler/testData/diagnostics/tests/inner/illegalModifier.txt +++ b/compiler/testData/diagnostics/tests/inner/illegalModifier.txt @@ -71,7 +71,7 @@ internal final class D { public final /*synthesized*/ fun values(): kotlin.Array } - kotlin.annotation.annotation() internal final annotation class S : kotlin.Annotation { + kotlin.annotation.annotation() internal final class S : kotlin.Annotation { public constructor S() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt b/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt index bcefa1a0250..ecdb25a2d37 100644 --- a/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt +++ b/compiler/testData/diagnostics/tests/inner/selfAnnotationForClassObject.txt @@ -12,7 +12,7 @@ internal final class Test { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - kotlin.annotation.annotation() internal final annotation class ClassObjectAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final class ClassObjectAnnotation : kotlin.Annotation { public constructor ClassObjectAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -20,7 +20,7 @@ internal final class Test { } } - kotlin.annotation.annotation() internal final annotation class NestedAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final class NestedAnnotation : kotlin.Annotation { public constructor NestedAnnotation() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt index 621e0e99aba..c0302f33667 100644 --- a/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt +++ b/compiler/testData/diagnostics/tests/modifiers/IllegalModifiers.txt @@ -138,7 +138,7 @@ package illegal_modifiers { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class annotated : kotlin.Annotation { + kotlin.annotation.annotation() internal final class annotated : kotlin.Annotation { public constructor annotated(/*0*/ text: kotlin.String = ...) internal final val text: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt index 7a1433d4be0..b10e1ac4536 100644 --- a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt +++ b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt @@ -17,7 +17,7 @@ internal final class A { } } -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int = ...) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt b/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt index a732ee60232..72c58383a23 100644 --- a/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt +++ b/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt @@ -2,7 +2,7 @@ package A(x = IntegerValueType(1), y = "2") internal fun test(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) public final val x: kotlin.Int public final val y: kotlin.String diff --git a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt index 190218c136c..b36af47c889 100644 --- a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt +++ b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.txt @@ -30,7 +30,7 @@ internal final enum class : kotlin.Enum<> { public final /*synthesized*/ fun values(): kotlin.Array<> } -kotlin.annotation.annotation() internal final annotation class : kotlin.Annotation { +kotlin.annotation.annotation() internal final class : kotlin.Annotation { public constructor () public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt index ec267707044..ee455a37a64 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt +++ b/compiler/testData/diagnostics/tests/resolve/resolveAnnotatedLambdaArgument.txt @@ -3,7 +3,7 @@ package internal fun bar(/*0*/ block: (T) -> kotlin.Int): kotlin.Unit internal fun foo(): kotlin.Unit -kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.EXPRESSION}) kotlin.annotation.annotation(repeatable = true) internal final class Ann : kotlin.Annotation { public constructor Ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt index c6263fedc43..1a3899fe003 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt @@ -9,14 +9,14 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt index 6cd40599d2a..996fffb1cc4 100644 --- a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt +++ b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.txt @@ -2,7 +2,7 @@ package internal fun foo(/*0*/ a: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt index e1031c8f225..06cd552887e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/ClassObjectAnnotatedWithItsKClass.txt @@ -2,7 +2,7 @@ package package test { - kotlin.annotation.annotation() internal final annotation class AnnClass : kotlin.Annotation { + kotlin.annotation.annotation() internal final class AnnClass : kotlin.Annotation { public constructor AnnClass(/*0*/ a: kotlin.reflect.KClass<*>) internal final val a: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt index cb1cabf4374..5d763d51ae8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt @@ -3,7 +3,7 @@ package internal fun foo(/*0*/ ann: A): kotlin.Unit internal fun A.bar(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.String, /*1*/ arg: kotlin.Int) public final val arg: kotlin.Int public final val value: kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt index daf42a4580c..bc95994fb3f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt @@ -6,7 +6,7 @@ internal val i3: kotlin.Int internal val iAnn: Ann internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.IntArray) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,7 +14,7 @@ kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Anno public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class AnnAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnAnn : kotlin.Annotation { public constructor AnnAnn(/*0*/ i: kotlin.Array) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt index daf04ac3f9c..c97995c25ea 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.txt @@ -6,7 +6,7 @@ internal val ia: kotlin.IntArray internal val sa: kotlin.Array internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ i: kotlin.Int) internal final val i: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,14 +14,14 @@ kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Anno public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class AnnIA : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnIA : kotlin.Annotation { public constructor AnnIA(/*0*/ ia: kotlin.IntArray) internal final val ia: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -29,7 +29,7 @@ kotlin.annotation.annotation() internal final annotation class AnnIA : kotlin.An public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class AnnSA : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnSA : kotlin.Annotation { public constructor AnnSA(/*0*/ sa: kotlin.Array) internal final val sa: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt index f56afafb342..f1a137aefb6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt @@ -6,7 +6,7 @@ internal val i3: kotlin.Int internal val iAnn: Ann internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ vararg i: kotlin.Int /*kotlin.IntArray*/) internal final val i: kotlin.IntArray public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -14,7 +14,7 @@ kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Anno public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class AnnAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnAnn : kotlin.Annotation { public constructor AnnAnn(/*0*/ vararg i: Ann /*kotlin.Array*/) internal final val i: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt index 8eb4cc4a5cc..41bc6d8a4e3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithValue.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.String, /*1*/ b: kotlin.Double, /*2*/ x1: kotlin.reflect.KClass<*>, /*3*/ a: kotlin.Int, /*4*/ x: kotlin.reflect.KClass<*>, /*5*/ x2: kotlin.reflect.KClass<*>) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt index df8f9fb54aa..6a068e6b817 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/orderWithoutValue.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ b: kotlin.Double, /*1*/ x1: kotlin.reflect.KClass<*>, /*2*/ a: kotlin.Int, /*3*/ x: kotlin.reflect.KClass<*>, /*4*/ x2: kotlin.reflect.KClass<*>) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt index c5af1272f2e..032f49996fc 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt @@ -9,7 +9,7 @@ A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = IntegerValueType(6)) int A(value = {}, y = IntegerValueType(7)) internal fun test7(): kotlin.Unit A(value = {"8", "9", "10"}) internal fun test8(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: kotlin.Int) public final val value: kotlin.Array public final val x: kotlin.reflect.KClass<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt index 3a0f8acfd92..56f9dfb46d6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt @@ -12,7 +12,7 @@ A(value = {}) internal fun test7(): kotlin.Unit A(value = {}) internal fun test8(): kotlin.Unit A(value = {}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test9(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: kotlin.Int = ...) public final val value: kotlin.Array public final val x: kotlin.reflect.KClass<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.txt index bc2cf56de7a..c8b06abd6c4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayOnly.txt @@ -6,7 +6,7 @@ A(value = {{"5", "6"}, "7"}) internal fun test3(): kotlin.Unit A(value = {}) internal fun test4(): kotlin.Unit A(value = {}) internal fun test5(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public final val value: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.txt index ffaeaa870ba..ab13f0ae3e1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayWithDefault.txt @@ -6,7 +6,7 @@ A(value = {{"5", "6"}, "7"}) internal fun test3(): kotlin.Unit A() internal fun test4(): kotlin.Unit A() internal fun test5(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/ = ...) public final val value: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt index 8493cb21b51..fd257b84b8c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt @@ -2,7 +2,7 @@ package A(value = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public final val value: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt index 3d6d1b39e0b..ac5ed31f939 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt @@ -2,7 +2,7 @@ package B(args = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { public constructor B(/*0*/ vararg args: kotlin.String /*kotlin.Array*/) internal final val args: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt index a12adfd65b1..bc66b807956 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/defaultValueMustBeConstant.txt @@ -5,7 +5,7 @@ internal val nonConst: kotlin.Int internal val nonConstKClass: kotlin.reflect.KClass internal fun foo(): kotlin.Int -kotlin.annotation.annotation() internal final annotation class InvalidAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final class InvalidAnn : kotlin.Annotation { public constructor InvalidAnn(/*0*/ p1: kotlin.Int = ..., /*1*/ p2: kotlin.Int = ..., /*2*/ p3: kotlin.reflect.KClass<*> = ...) internal final val p1: kotlin.Int internal final val p2: kotlin.Int @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class InvalidAnn : kotl public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class ValidAnn : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ValidAnn : kotlin.Annotation { public constructor ValidAnn(/*0*/ p1: kotlin.Int = ..., /*1*/ p2: kotlin.String = ..., /*2*/ p3: kotlin.reflect.KClass<*> = ..., /*3*/ p4: kotlin.IntArray = ..., /*4*/ p5: kotlin.Array = ..., /*5*/ p6: kotlin.Array> = ...) internal final val p1: kotlin.Int internal final val p2: kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt index 12130f57a1f..a6254ef6253 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int = ..., /*2*/ b: B) public final val arg: kotlin.reflect.KClass<*> public final val b: B @@ -13,7 +13,7 @@ public final annotation class A : kotlin.Annotation { public abstract fun x(): kotlin.Int } -public final annotation class B : kotlin.Annotation { +public final class B : kotlin.Annotation { public constructor B(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ y: kotlin.Int = ...) public final val arg: kotlin.reflect.KClass<*> public final val y: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt index e4717d047f2..e6bc9ffc1e1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/arg.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.reflect.KClass<*>) public final val arg: kotlin.reflect.KClass<*> public abstract fun arg(): kotlin.reflect.KClass<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt index 4f2666750ec..c2c0e772a6d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.reflect.KClass<*>, /*1*/ x: kotlin.Int = ...) public final val arg: kotlin.reflect.KClass<*> public final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt index ad9fc65193e..29b347d1df1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argArray.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.Array>) public final val arg: kotlin.Array> public abstract fun arg(): kotlin.Array> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt index dfe18e08c97..364ad61d6b7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefault.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ...) public final val arg: kotlin.reflect.KClass<*> public abstract fun arg(): kotlin.reflect.KClass<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt index 4585128b24c..0ad8f243afb 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int) public final val arg: kotlin.reflect.KClass<*> public final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt index cf23b3bef0b..ee6386f2a0b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/twoArgs.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ arg1: kotlin.reflect.KClass<*>, /*1*/ arg2: kotlin.reflect.KClass<*>) public final val arg1: kotlin.reflect.KClass<*> public final val arg2: kotlin.reflect.KClass<*> diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt index ce33baa7cb8..75ad0c7ba9d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/value.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.reflect.KClass<*>) public final val value: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt index 8a7894a5aea..783990fc9f0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.reflect.KClass<*>, /*1*/ x: kotlin.Int = ...) public final val value: kotlin.reflect.KClass<*> public final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt index 404b8943c43..d3f68330c80 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueArray.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array>*/) public final val value: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt index b2d4e88c8c1..8f230970148 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefault.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.reflect.KClass<*> = ...) public final val value: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt index 72d973e8303..15eb1a6a038 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt @@ -1,6 +1,6 @@ package -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.reflect.KClass<*> = ..., /*1*/ x: kotlin.Int) public final val value: kotlin.reflect.KClass<*> public final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt index 4cd49a057d2..5c140838c73 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsInVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt index f90ae74eaea..4d041ec83e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassArrayInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt index 91c9611a4c5..c35e04678e9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.txt @@ -16,7 +16,7 @@ internal final class A2 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass<*>) internal final val arg: kotlin.reflect.KClass<*> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -24,7 +24,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ vararg arg: kotlin.reflect.KClass<*> /*kotlin.Array>*/) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -32,7 +32,7 @@ kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann3 : kotlin.Annotation { public constructor Ann3(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt index fb014b3e4a1..0a89c9c7ba1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsInVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt index e3f12e9d99a..6aed0440f52 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt index 7b2fb1b0873..9e160a446e1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInvariantTP.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -15,7 +15,7 @@ kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Ann public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ arg: kotlin.reflect.KClass) internal final val arg: kotlin.reflect.KClass public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt index 4641ce46200..a070f6c89aa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassOutArrayInAnnotationsOutVariance.txt @@ -7,7 +7,7 @@ internal open class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class Ann1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann1 : kotlin.Annotation { public constructor Ann1(/*0*/ arg: kotlin.Array>) internal final val arg: kotlin.Array> public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt index f1a842cbadf..2ad42368826 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt @@ -4,7 +4,7 @@ Ann(value = "a", x = IntegerValueType(1), y = 1.0.toDouble()) internal fun foo1( Ann(value = "b", x = IntegerValueType(2), y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit Ann(value = "c", x = IntegerValueType(3), y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ value: kotlin.String, /*2*/ y: kotlin.Double) internal final val value: kotlin.String internal final val x: kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.txt index 699fa97cffe..208bbf61e93 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/tooManyArgs.txt @@ -2,7 +2,7 @@ package A(a = false, b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double, /*2*/ x: kotlin.Boolean) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.txt index a64bbd54aa0..5822e0e3670 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/typeMismatch.txt @@ -3,7 +3,7 @@ package A(a = false, b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit A(a = 2.0.toDouble(), b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double, /*2*/ x: kotlin.Boolean) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt index f4fbbf7c874..964ccf60e5e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt @@ -5,7 +5,7 @@ A(a = IntegerValueType(2), b = 2.0.toDouble(), value = "v2", x = true) internal A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo3(): kotlin.Unit A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo4(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.String, /*1*/ a: kotlin.Int, /*2*/ b: kotlin.Double, /*3*/ x: kotlin.Boolean) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt index 6c282e4da72..af89ce48848 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt @@ -4,7 +4,7 @@ A(a = IntegerValueType(1), b = 1.0.toDouble(), x = false) internal fun foo1(): k A(a = IntegerValueType(2), b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit A(a = IntegerValueType(4), b = 3.0.toDouble(), x = true) internal fun foo3(): kotlin.Unit -public final annotation class A : kotlin.Annotation { +public final class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double, /*2*/ x: kotlin.Boolean) public final val a: kotlin.Int public final val b: kotlin.Double diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt index a29557f9f7c..dc2e947c62e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/qualifiedCallValue.txt @@ -13,7 +13,7 @@ package a { public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - kotlin.annotation.annotation() internal final annotation class IAnn : kotlin.Annotation { + kotlin.annotation.annotation() internal final class IAnn : kotlin.Annotation { public constructor IAnn() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -21,7 +21,7 @@ package a { } } - kotlin.annotation.annotation() internal final annotation class ann1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class ann1 : kotlin.Annotation { public constructor ann1(/*0*/ p: kotlin.deprecated = ...) internal final val p: kotlin.deprecated public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -29,7 +29,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class ann2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class ann2 : kotlin.Annotation { public constructor ann2(/*0*/ p: a.b.c.ann1 = ...) internal final val p: a.b.c.ann1 public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean @@ -37,7 +37,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class ann3 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class ann3 : kotlin.Annotation { public constructor ann3(/*0*/ p: a.b.c.A.IAnn = ..., /*1*/ p2: a.b.c.A.IAnn = ...) internal final val p: a.b.c.A.IAnn internal final val p2: a.b.c.A.IAnn @@ -46,7 +46,7 @@ package a { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - kotlin.annotation.annotation() internal final annotation class annArray : kotlin.Annotation { + kotlin.annotation.annotation() internal final class annArray : kotlin.Annotation { public constructor annArray(/*0*/ p: kotlin.Array = ...) internal final val p: kotlin.Array public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedAnnotation.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedAnnotation.txt index f96ba4792ab..493171abcab 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedAnnotation.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedAnnotation.txt @@ -1,5 +1,5 @@ package test -test.AnnotatedAnnotation() public final annotation class AnnotatedAnnotation : kotlin.Annotation { +test.AnnotatedAnnotation() public final class AnnotatedAnnotation : kotlin.Annotation { public constructor AnnotatedAnnotation() } diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedConstructor.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedConstructor.txt index 95dca11e461..09d42cde161 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedConstructor.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedConstructor.txt @@ -3,7 +3,7 @@ package test public open class AnnotatedConstructor { test.AnnotatedConstructor.Anno(value = "constructor") public constructor AnnotatedConstructor() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedField.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedField.txt index 10e51ea5c51..701973217fb 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedField.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedField.txt @@ -4,7 +4,7 @@ public open class AnnotatedField { public constructor AnnotatedField() test.AnnotatedField.Anno(value = "member") public final val y: kotlin.Int = 0 - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedMethod.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedMethod.txt index 3289d27d40d..468eab0dfb9 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedMethod.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedMethod.txt @@ -4,7 +4,7 @@ public open class AnnotatedMethod { public constructor AnnotatedMethod() test.AnnotatedMethod.Anno(value = 42) public open fun f(): kotlin.Unit - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.Int) public final val value: kotlin.Int public abstract fun value(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedValueParameter.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedValueParameter.txt index 16ceafcc8b5..f8253f22a54 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedValueParameter.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedValueParameter.txt @@ -4,7 +4,7 @@ public open class AnnotatedValueParameter { public constructor AnnotatedValueParameter() public open fun f(/*0*/ test.AnnotatedValueParameter.Anno(value = "non-empty") p0: kotlin.(Mutable)List!): kotlin.Unit - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt index 6a571b0e9d0..04376a23376 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationInParam.txt @@ -14,19 +14,19 @@ public interface AnnotationInParam { public constructor C() } - public final annotation class MyAnnotation : kotlin.Annotation { + public final class MyAnnotation : kotlin.Annotation { public constructor MyAnnotation(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String } - public final annotation class MyAnnotation2 : kotlin.Annotation { + public final class MyAnnotation2 : kotlin.Annotation { public constructor MyAnnotation2(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public final val value: kotlin.Array public abstract fun value(): kotlin.Array } - public final annotation class MyAnnotation3 : kotlin.Annotation { + public final class MyAnnotation3 : kotlin.Annotation { public constructor MyAnnotation3(/*0*/ first: kotlin.String, /*1*/ second: kotlin.String) public final val first: kotlin.String public final val second: kotlin.String @@ -34,19 +34,19 @@ public interface AnnotationInParam { public abstract fun second(): kotlin.String } - public final annotation class MyAnnotationWithParam : kotlin.Annotation { + public final class MyAnnotationWithParam : kotlin.Annotation { public constructor MyAnnotationWithParam(/*0*/ value: test.AnnotationInParam.MyAnnotation) public final val value: test.AnnotationInParam.MyAnnotation public abstract fun value(): test.AnnotationInParam.MyAnnotation } - public final annotation class MyAnnotationWithParam2 : kotlin.Annotation { + public final class MyAnnotationWithParam2 : kotlin.Annotation { public constructor MyAnnotationWithParam2(/*0*/ value: test.AnnotationInParam.MyAnnotation2) public final val value: test.AnnotationInParam.MyAnnotation2 public abstract fun value(): test.AnnotationInParam.MyAnnotation2 } - public final annotation class MyAnnotationWithParam3 : kotlin.Annotation { + public final class MyAnnotationWithParam3 : kotlin.Annotation { public constructor MyAnnotationWithParam3(/*0*/ value: test.AnnotationInParam.MyAnnotation3) public final val value: test.AnnotationInParam.MyAnnotation3 public abstract fun value(): test.AnnotationInParam.MyAnnotation3 diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArithmeticExpressionInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArithmeticExpressionInParam.txt index 2018810e8e4..70f2c1f562a 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArithmeticExpressionInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArithmeticExpressionInParam.txt @@ -3,7 +3,7 @@ package test public open class ArithmeticExpressionInParam { public constructor ArithmeticExpressionInParam() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.Int) public final val value: kotlin.Int public abstract fun value(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt index e8f1e248e0a..b1052c7af49 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt @@ -2,7 +2,7 @@ package test public interface ArrayOfEnumInParam { - java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}) public final annotation class targetAnnotation : kotlin.Annotation { + java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}) public final class targetAnnotation : kotlin.Annotation { public constructor targetAnnotation(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt index 6ea8dbd0b25..dc32eb3b47b 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfStringInParam.txt @@ -6,7 +6,7 @@ public interface ArrayOfStringInParam { public constructor A() } - public final annotation class MyAnnotation : kotlin.Annotation { + public final class MyAnnotation : kotlin.Annotation { public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public final val value: kotlin.Array public abstract fun value(): kotlin.Array diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt index 9ab3346d4b5..2f37306b809 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectArrayInParam.txt @@ -3,7 +3,7 @@ package test public open class ClassObjectArrayInParam { public constructor ClassObjectArrayInParam() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ vararg value: kotlin.reflect.KClass<*> /*kotlin.Array>*/) public final val value: kotlin.Array> public abstract fun value(): kotlin.Array> diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt index 30b7148f686..c27804ebb3c 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParam.txt @@ -3,7 +3,7 @@ package test public open class ClassObjectInParam { public constructor ClassObjectInParam() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>) public final val value: kotlin.reflect.KClass<*> public abstract fun value(): kotlin.reflect.KClass<*> diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt index 884d7d88a9e..52ef7432620 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamRaw.txt @@ -3,7 +3,7 @@ package test public open class ClassObjectInParamRaw { public constructor ClassObjectInParamRaw() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ value: kotlin.reflect.KClass<*>, /*1*/ arg: kotlin.Array>) public final val arg: kotlin.Array> public final val value: kotlin.reflect.KClass<*> diff --git a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt index da7962c1fcc..0c8555932d6 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ClassObjectInParamVariance.txt @@ -3,7 +3,7 @@ package test public open class ClassObjectInParamVariance { public constructor ClassObjectInParamVariance() - public final annotation class Anno : kotlin.Annotation { + public final class Anno : kotlin.Annotation { public constructor Anno(/*0*/ arg1: kotlin.reflect.KClass, /*1*/ arg2: kotlin.reflect.KClass, /*2*/ arg3: kotlin.Array>, /*3*/ arg4: kotlin.Array>, /*4*/ arg5: kotlin.Array!>>, /*5*/ arg6: kotlin.Array!>>, /*6*/ arg7: kotlin.Array!>>, /*7*/ arg8: kotlin.Array!>>) public final val arg1: kotlin.reflect.KClass public final val arg2: kotlin.reflect.KClass diff --git a/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.txt b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.txt index ad2240254a2..3c4e239984b 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.txt @@ -2,7 +2,7 @@ package test public interface CustomAnnotation { - public final annotation class MyAnnotation : kotlin.Annotation { + public final class MyAnnotation : kotlin.Annotation { public constructor MyAnnotation(/*0*/ value: test.CustomAnnotation.MyEnum) public final val value: test.CustomAnnotation.MyEnum public abstract fun value(): test.CustomAnnotation.MyEnum diff --git a/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.txt b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.txt index 0aeb32d87e9..c1868ddb32e 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.txt @@ -2,7 +2,7 @@ package test public interface CustomAnnotationWithDefaultParameter { - public final annotation class MyAnnotation : kotlin.Annotation { + public final class MyAnnotation : kotlin.Annotation { public constructor MyAnnotation(/*0*/ first: kotlin.String, /*1*/ second: kotlin.String = ...) public final val first: kotlin.String public final val second: kotlin.String diff --git a/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt index 67585145f3f..9b035d95478 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/EmptyArrayInParam.txt @@ -6,7 +6,7 @@ public interface EmptyArrayInParam { public constructor A() } - public final annotation class MyAnnotation : kotlin.Annotation { + public final class MyAnnotation : kotlin.Annotation { public constructor MyAnnotation(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) public final val value: kotlin.Array public abstract fun value(): kotlin.Array diff --git a/compiler/testData/loadJava/compiledJava/annotations/EnumArgumentWithCustomToString.txt b/compiler/testData/loadJava/compiledJava/annotations/EnumArgumentWithCustomToString.txt index dc660338c96..c9aa39761ce 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/EnumArgumentWithCustomToString.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/EnumArgumentWithCustomToString.txt @@ -22,13 +22,13 @@ public open class EnumArgumentWithCustomToString { public final /*synthesized*/ fun values(): kotlin.Array } - public final annotation class EnumAnno : kotlin.Annotation { + public final class EnumAnno : kotlin.Annotation { public constructor EnumAnno(/*0*/ value: test.EnumArgumentWithCustomToString.E) public final val value: test.EnumArgumentWithCustomToString.E public abstract fun value(): test.EnumArgumentWithCustomToString.E } - public final annotation class EnumArrayAnno : kotlin.Annotation { + public final class EnumArrayAnno : kotlin.Annotation { public constructor EnumArrayAnno(/*0*/ vararg value: test.EnumArgumentWithCustomToString.E /*kotlin.Array*/) public final val value: kotlin.Array public abstract fun value(): kotlin.Array diff --git a/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.txt b/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.txt index aa5d3e430a5..f7431df93f5 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.txt @@ -14,7 +14,7 @@ public final enum class EnumConstructorParameter : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.annotation() internal final annotation class EnumOption : kotlin.Annotation { +kotlin.annotation.annotation() internal final class EnumOption : kotlin.Annotation { /*primary*/ public constructor EnumOption(/*0*/ option: test.E) internal final val option: test.E internal final fun (): test.E } -kotlin.annotation.annotation() internal final annotation class OptionGroups : kotlin.Annotation { +kotlin.annotation.annotation() internal final class OptionGroups : kotlin.Annotation { /*primary*/ public constructor OptionGroups(/*0*/ o1: test.StringOptions, /*1*/ o2: test.EnumOption) internal final val o1: test.StringOptions internal final fun (): test.StringOptions @@ -36,7 +36,7 @@ kotlin.annotation.annotation() internal final annotation class OptionGroups : ko internal final fun (): test.EnumOption } -kotlin.annotation.annotation() internal final annotation class StringOptions : kotlin.Annotation { +kotlin.annotation.annotation() internal final class StringOptions : kotlin.Annotation { /*primary*/ public constructor StringOptions(/*0*/ vararg option: kotlin.String /*kotlin.Array*/) internal final val option: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt b/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt index 0356b39bc5a..9ecf3aaec69 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/EnumArgumentWithCustomToString.txt @@ -18,7 +18,7 @@ internal final enum class E : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.annotation() internal final annotation class EnumAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class EnumAnno : kotlin.Annotation { /*primary*/ public constructor EnumAnno(/*0*/ value: test.E) internal final val value: test.E internal final fun (): test.E @@ -29,7 +29,7 @@ public final class EnumArgumentWithCustomToString { test.EnumAnno(value = E.CAKE) test.EnumArrayAnno(value = {E.CAKE, E.CAKE}) internal final fun annotated(): kotlin.Unit } -kotlin.annotation.annotation() internal final annotation class EnumArrayAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class EnumArrayAnno : kotlin.Annotation { /*primary*/ public constructor EnumArrayAnno(/*0*/ vararg value: test.E /*kotlin.Array*/) internal final val value: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt b/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt index 51117cc7663..c961f664c64 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/MultiDimensionalArrayMethod.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt index 5e6cfce6549..1ebd05de6b8 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/SimpleAnnotation.txt @@ -1,5 +1,5 @@ package test -kotlin.annotation.annotation() public final annotation class SimpleAnnotation : kotlin.Annotation { +kotlin.annotation.annotation() public final class SimpleAnnotation : kotlin.Annotation { /*primary*/ public constructor SimpleAnnotation() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt index 5d67f42b301..fab329677cf 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/TargetedAnnotation.txt @@ -1,5 +1,5 @@ package test -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() public final annotation class TargetedAnnotation : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() public final class TargetedAnnotation : kotlin.Annotation { /*primary*/ public constructor TargetedAnnotation() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt index f11f12849ca..4ad780aedfb 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/ClassObjectPropertyField.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt index 8af7dfcdf44..32fa1fab70d 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Constructor.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ value: kotlin.String) internal final val value: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt index 9d09f00cdb8..c7e0e9473ed 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/DelegatedProperty.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt index 22c826ecca4..42e31ecfc79 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/EnumArgument.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt index b52d3b3dea7..eabef133146 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Function.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt index 232718e6ad8..1e3f2918105 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Getter.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt index 221a25a0db3..44c27f1ce64 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/PropertyField.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt index c3c12f29f73..3d032c01d95 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classMembers/Setter.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt index a3aff97886e..91d3ed913c9 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/AnnotationInClassObject.txt @@ -6,14 +6,14 @@ internal final class A { public companion object Companion { /*primary*/ private constructor Companion() - kotlin.annotation.annotation() internal final annotation class Anno1 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Anno1 : kotlin.Annotation { /*primary*/ public constructor Anno1() } internal final class B { /*primary*/ public constructor B() - kotlin.annotation.annotation() internal final annotation class Anno2 : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Anno2 : kotlin.Annotation { /*primary*/ public constructor Anno2() } } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt index 37fb81b01bc..96fb06f7282 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassInClassObject.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt index 3f0a7c24240..2aa2a930bbe 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/ClassObject.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt index 59992e8e4c3..19eeea564aa 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/DollarsInAnnotationName.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class `$$$$$$` : kotlin.Annotation { +kotlin.annotation.annotation() internal final class `$$$$$$` : kotlin.Annotation { /*primary*/ public constructor `$$$$$$`() } @@ -8,7 +8,7 @@ test.`$$$$$$`() internal final class A { /*primary*/ public constructor A() } -kotlin.annotation.annotation() internal final annotation class `Anno$tation` : kotlin.Annotation { +kotlin.annotation.annotation() internal final class `Anno$tation` : kotlin.Annotation { /*primary*/ public constructor `Anno$tation`() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt index c592d495c9e..10b33f0bdd9 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/EnumArgument.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt index ae9de1d4caf..35b2e56e329 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/MultipleAnnotations.txt @@ -1,14 +1,14 @@ package test -kotlin.annotation.annotation() internal final annotation class A1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A1 : kotlin.Annotation { /*primary*/ public constructor A1() } -kotlin.annotation.annotation() internal final annotation class A2 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A2 : kotlin.Annotation { /*primary*/ public constructor A2() } -kotlin.annotation.annotation() internal final annotation class A3 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A3 : kotlin.Annotation { /*primary*/ public constructor A3() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt index d6e2929cf91..f7a5a2a5a0b 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedAnnotation.txt @@ -3,7 +3,7 @@ package test internal final class A { /*primary*/ public constructor A() - kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { + kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt index 2b142756a49..365077aef49 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/NestedClass.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt index 95dc30c54f9..8159335fcc1 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Retention.txt @@ -1,5 +1,5 @@ package test -kotlin.annotation.annotation(retention = AnnotationRetention.RUNTIME) internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation(retention = AnnotationRetention.RUNTIME) internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt index ea52afc4b87..2c2ed8919e3 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/Simple.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt index 02cded471d1..b58cb2c56bc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithArgument.txt @@ -1,18 +1,18 @@ package test -kotlin.annotation.annotation() internal final annotation class BooleanAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class BooleanAnno : kotlin.Annotation { /*primary*/ public constructor BooleanAnno(/*0*/ value: kotlin.Boolean) internal final val value: kotlin.Boolean internal final fun (): kotlin.Boolean } -kotlin.annotation.annotation() internal final annotation class ByteAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ByteAnno : kotlin.Annotation { /*primary*/ public constructor ByteAnno(/*0*/ value: kotlin.Byte) internal final val value: kotlin.Byte internal final fun (): kotlin.Byte } -kotlin.annotation.annotation() internal final annotation class CharAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class CharAnno : kotlin.Annotation { /*primary*/ public constructor CharAnno(/*0*/ value: kotlin.Char) internal final val value: kotlin.Char internal final fun (): kotlin.Char @@ -22,31 +22,31 @@ test.IntAnno(value = 42) test.ShortAnno(value = 42.toShort()) test.ByteAnno(valu /*primary*/ public constructor Class() } -kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno(/*0*/ value: kotlin.Double) internal final val value: kotlin.Double internal final fun (): kotlin.Double } -kotlin.annotation.annotation() internal final annotation class FloatAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class FloatAnno : kotlin.Annotation { /*primary*/ public constructor FloatAnno(/*0*/ value: kotlin.Float) internal final val value: kotlin.Float internal final fun (): kotlin.Float } -kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno(/*0*/ value: kotlin.Int) internal final val value: kotlin.Int internal final fun (): kotlin.Int } -kotlin.annotation.annotation() internal final annotation class LongAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class LongAnno : kotlin.Annotation { /*primary*/ public constructor LongAnno(/*0*/ value: kotlin.Long) internal final val value: kotlin.Long internal final fun (): kotlin.Long } -kotlin.annotation.annotation() internal final annotation class ShortAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ShortAnno : kotlin.Annotation { /*primary*/ public constructor ShortAnno(/*0*/ value: kotlin.Short) internal final val value: kotlin.Short internal final fun (): kotlin.Short diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt index 94ef8eda087..c9810d4bc12 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/classes/WithMultipleArguments.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ int: kotlin.Int, /*1*/ string: kotlin.String, /*2*/ double: kotlin.Double) internal final val double: kotlin.Double internal final fun (): kotlin.Double diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt index 352a71cacdc..41fb1aa192b 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/DelegatedProperty.txt @@ -3,6 +3,6 @@ package test test.Anno() internal val x: kotlin.Int internal fun (): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt index d17b6d8782b..9d851d40c4e 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArgument.txt @@ -4,7 +4,7 @@ test.Anno(t = ElementType.FIELD) internal val bar: kotlin.Int = 42 internal fun (): kotlin.Int test.Anno(t = ElementType.METHOD) internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ t: java.lang.annotation.ElementType) internal final val t: java.lang.annotation.ElementType internal final fun (): java.lang.annotation.ElementType diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt index 855c2ffc454..a4eabd6ee5d 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/EnumArrayArgument.txt @@ -5,7 +5,7 @@ test.Anno(t = {ElementType.PACKAGE}) internal val bar: kotlin.Int = 42 test.Anno(t = {}) internal fun baz(): kotlin.Unit test.Anno(t = {ElementType.METHOD, ElementType.FIELD}) internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ vararg t: java.lang.annotation.ElementType /*kotlin.Array*/) internal final val t: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt index 585aaee7bf4..5bb274c0472 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Function.txt @@ -2,6 +2,6 @@ package test test.Anno() internal fun function(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt index 31f46a51f2e..b92b8539aac 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Getter.txt @@ -3,6 +3,6 @@ package test internal val property: kotlin.Int test.Anno() internal fun (): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt index 8e0a02fa96e..8f138279dfc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/PropertyField.txt @@ -4,6 +4,6 @@ test.Anno() internal var property: kotlin.Int internal fun (): kotlin.Int internal fun (/*0*/ : kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt index 04fb642e419..84b2c392e1a 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/Setter.txt @@ -4,6 +4,6 @@ internal var property: kotlin.Int internal fun (): kotlin.Int test.Anno() internal fun (/*0*/ value: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt index 8974c0fc9b3..b5fd307a2f4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/packageMembers/StringArrayArgument.txt @@ -5,7 +5,7 @@ test.Anno(t = {"prosper"}) internal val bar: kotlin.Int = 42 test.Anno(t = {}) internal fun baz(): kotlin.Unit test.Anno(t = {"live", "long"}) internal fun foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno(/*0*/ vararg t: kotlin.String /*kotlin.Array*/) internal final val t: kotlin.Array internal final fun (): kotlin.Array diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt index 6b27388be55..ab0e3a3c78c 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/Constructor.txt @@ -1,10 +1,10 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt index 3b4ec2434af..3f2bf6f2b1a 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/EnumConstructor.txt @@ -1,10 +1,10 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt index d09853c0ddc..3e8eb8ed2d7 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunction.txt @@ -2,6 +2,6 @@ package test internal fun kotlin.Int.foo(/*0*/ test.A() x: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt index 4f23c527fcd..000278bdc48 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionFunctionInClass.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt index 5dcbed29e07..b920161d443 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ExtensionPropertySetter.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt index 236a876ec32..6188cef5000 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInClass.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt index 70e5a27be90..35407d90748 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/FunctionInTrait.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt index 1a929ba986c..41fe04dd9dc 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/InnerClassConstructor.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt index 8a7ca50d4eb..abb4292a20c 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/ManyAnnotations.txt @@ -3,18 +3,18 @@ package test internal fun bar(/*0*/ test.A() test.B() test.C() test.D() x: kotlin.Int): kotlin.Unit internal fun foo(/*0*/ test.A() test.B() x: kotlin.Int, /*1*/ test.A() test.C() y: kotlin.Double, /*2*/ test.B() test.C() test.D() z: kotlin.String): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { /*primary*/ public constructor B() } -kotlin.annotation.annotation() internal final annotation class C : kotlin.Annotation { +kotlin.annotation.annotation() internal final class C : kotlin.Annotation { /*primary*/ public constructor C() } -kotlin.annotation.annotation() internal final annotation class D : kotlin.Annotation { +kotlin.annotation.annotation() internal final class D : kotlin.Annotation { /*primary*/ public constructor D() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt index 144beb4d129..064d3f53fe4 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/PropertySetterInClass.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt index c2891374258..8bc9d7e5a07 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelFunction.txt @@ -2,6 +2,6 @@ package test internal fun foo(/*0*/ test.Anno() x: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt index e71ccf19f0e..9bf02b3fb29 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/parameters/TopLevelPropertySetter.txt @@ -4,10 +4,10 @@ internal var foo: kotlin.Int internal fun (): kotlin.Int internal fun (/*0*/ test.A() test.B() value: kotlin.Int): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } -kotlin.annotation.annotation() internal final annotation class B : kotlin.Annotation { +kotlin.annotation.annotation() internal final class B : kotlin.Annotation { /*primary*/ public constructor B() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt index f5102295613..45cc5c02a33 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Class.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt index d5293e678f4..7d80dc02fd7 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ClassObject.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt index d628a915d32..41b9bc19b9c 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNameClass.txt @@ -10,14 +10,14 @@ internal final class Class { internal final fun kotlin.String.(): kotlin.String } -kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno() } -kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno() } -kotlin.annotation.annotation() internal final annotation class StringAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class StringAnno : kotlin.Annotation { /*primary*/ public constructor StringAnno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt index 617bfcd67a2..3f24c08d080 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/ExtensionsWithSameNamePackage.txt @@ -7,14 +7,14 @@ test.IntAnno() internal val kotlin.Int.extension: kotlin.Int test.StringAnno() internal val kotlin.String.extension: kotlin.String internal fun kotlin.String.(): kotlin.String -kotlin.annotation.annotation() internal final annotation class DoubleAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class DoubleAnno : kotlin.Annotation { /*primary*/ public constructor DoubleAnno() } -kotlin.annotation.annotation() internal final annotation class IntAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class IntAnno : kotlin.Annotation { /*primary*/ public constructor IntAnno() } -kotlin.annotation.annotation() internal final annotation class StringAnno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class StringAnno : kotlin.Annotation { /*primary*/ public constructor StringAnno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt index 5c060817c2e..370dcc1b041 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/NestedTrait.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt index dcd9b1875eb..a1f6fc2342d 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TopLevel.txt @@ -3,6 +3,6 @@ package test test.Anno() internal val property: kotlin.Int internal fun (): kotlin.Int -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt index cc0f7717db0..197bcc1db98 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/Trait.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt index 9ad34b16d1a..813266df8f0 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/propertiesWithoutBackingFields/TraitClassObject.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class Anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Anno : kotlin.Annotation { /*primary*/ public constructor Anno() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt index 47190d4e0e4..49b0ae3d3da 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/ReceiverParameter.txt @@ -2,6 +2,6 @@ package test internal fun @[test.A()] kotlin.String.foo(): kotlin.Unit -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt index bf596b8f642..e28ef2829f2 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SimpleTypeAnnotation.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt index 81a5e323a3b..7650fdaabbe 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/SupertypesAndBounds.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A() } diff --git a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt index a034f7b1084..f7a5831e0ac 100644 --- a/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt +++ b/compiler/testData/loadJava/compiledKotlin/annotations/types/TypeAnnotationWithArguments.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final annotation class Ann : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { /*primary*/ public constructor Ann(/*0*/ x: kotlin.String, /*1*/ y: kotlin.Double) internal final val x: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt index 78c5da4693d..27141a06545 100644 --- a/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt +++ b/compiler/testData/loadJava/compiledKotlin/fromLoadJava/classObjectAnnotation.txt @@ -6,7 +6,7 @@ internal final class Some { test.Some.Companion.TestAnnotation() public companion object Companion { /*primary*/ private constructor Companion() - kotlin.annotation.annotation() internal final annotation class TestAnnotation : kotlin.Annotation { + kotlin.annotation.annotation() internal final class TestAnnotation : kotlin.Annotation { /*primary*/ public constructor TestAnnotation() } } diff --git a/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt b/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt index a44a114910e..3eb82760baf 100644 --- a/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt +++ b/compiler/testData/loadJava/compiledKotlinWithStdlib/platformNames/functionName.txt @@ -5,7 +5,7 @@ test.A(s = "2") internal var v: kotlin.Int kotlin.platform.platformName(name = "vset") test.A(s = "4") internal fun (/*0*/ : kotlin.Int): kotlin.Unit kotlin.platform.platformName(name = "bar") test.A(s = "1") internal fun foo(): kotlin.String -kotlin.annotation.annotation() internal final annotation class A : kotlin.Annotation { +kotlin.annotation.annotation() internal final class A : kotlin.Annotation { /*primary*/ public constructor A(/*0*/ s: kotlin.String) internal final val s: kotlin.String internal final fun (): kotlin.String diff --git a/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt b/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt index 6faf51d956c..4724d7b698c 100644 --- a/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt +++ b/compiler/testData/loadJava/sourceJava/NullInAnnotation.txt @@ -5,7 +5,7 @@ public /*synthesized*/ fun NullInAnnotation(/*0*/ function: () -> kotlin.Unit): public interface NullInAnnotation { test.NullInAnnotation.Ann(a = null, b = {null}) public abstract fun foo(): kotlin.Unit - public final annotation class Ann : kotlin.Annotation { + public final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Array) public final val a: kotlin.String public final val b: kotlin.Array diff --git a/compiler/testData/renderer/Classes.kt b/compiler/testData/renderer/Classes.kt index 9a6b220b470..722173536e6 100644 --- a/compiler/testData/renderer/Classes.kt +++ b/compiler/testData/renderer/Classes.kt @@ -35,9 +35,9 @@ public class WithReified public interface TwoUpperBounds where T : Number, T : Any //package rendererTest -//kotlin.annotation.annotation internal final annotation class TheAnnotation : kotlin.Annotation defined in rendererTest +//kotlin.annotation.annotation internal final class TheAnnotation : kotlin.Annotation defined in rendererTest //public constructor TheAnnotation() defined in rendererTest.TheAnnotation -//kotlin.annotation.annotation internal final annotation class AnotherAnnotation : kotlin.Annotation defined in rendererTest +//kotlin.annotation.annotation internal final class AnotherAnnotation : kotlin.Annotation defined in rendererTest //public constructor AnotherAnnotation() defined in rendererTest.AnotherAnnotation //rendererTest.TheAnnotation public open class TheClass defined in rendererTest // defined in rendererTest.TheClass diff --git a/compiler/testData/renderer/KeywordsInNames.kt b/compiler/testData/renderer/KeywordsInNames.kt index cfd65f664f8..b76e7c22f7c 100644 --- a/compiler/testData/renderer/KeywordsInNames.kt +++ b/compiler/testData/renderer/KeywordsInNames.kt @@ -17,7 +17,7 @@ val AS_SAFE = 1 val NOT_IN = 2 val NOT_IS = 3 -//kotlin.annotation.annotation internal final annotation class `true` : kotlin.Annotation defined in root package +//kotlin.annotation.annotation internal final class `true` : kotlin.Annotation defined in root package //public constructor `true`() defined in `true` //internal val `val`: kotlin.Int defined in root package //`true` internal interface `interface` defined in root package diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt index 6f95aea08e2..09c493ea2a4 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/annotation.txt @@ -1,6 +1,6 @@ package test -kotlin.annotation.annotation() internal final annotation class AnnotationArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final class AnnotationArray : kotlin.Annotation { public constructor AnnotationArray(/*0*/ annotationArray: kotlin.Array) internal final val annotationArray: kotlin.Array } @@ -13,11 +13,11 @@ test.AnnotationArray(annotationArray = {test.JustAnnotation(annotation = test.Em public constructor C2() } -kotlin.annotation.annotation() internal final annotation class Empty : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Empty : kotlin.Annotation { public constructor Empty() } -kotlin.annotation.annotation() internal final annotation class JustAnnotation : kotlin.Annotation { +kotlin.annotation.annotation() internal final class JustAnnotation : kotlin.Annotation { public constructor JustAnnotation(/*0*/ annotation: test.Empty) internal final val annotation: test.Empty } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt index f01734d10e8..d37e6bbe6e8 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/enum.txt @@ -8,12 +8,12 @@ test.EnumArray(enumArray = {Weapon.PAPER, Weapon.ROCK}) internal final class C2 public constructor C2() } -kotlin.annotation.annotation() internal final annotation class EnumArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final class EnumArray : kotlin.Annotation { public constructor EnumArray(/*0*/ enumArray: kotlin.Array) internal final val enumArray: kotlin.Array } -kotlin.annotation.annotation() internal final annotation class JustEnum : kotlin.Annotation { +kotlin.annotation.annotation() internal final class JustEnum : kotlin.Annotation { public constructor JustEnum(/*0*/ weapon: test.Weapon) internal final val weapon: test.Weapon } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt index f5c7253a19d..ba43984c650 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitiveArrays.txt @@ -8,7 +8,7 @@ test.PrimitiveArrays(booleanArray = {}, byteArray = {}, charArray = {}, doubleAr public constructor C2() } -kotlin.annotation.annotation() internal final annotation class PrimitiveArrays : kotlin.Annotation { +kotlin.annotation.annotation() internal final class PrimitiveArrays : kotlin.Annotation { public constructor PrimitiveArrays(/*0*/ byteArray: kotlin.ByteArray, /*1*/ charArray: kotlin.CharArray, /*2*/ shortArray: kotlin.ShortArray, /*3*/ intArray: kotlin.IntArray, /*4*/ longArray: kotlin.LongArray, /*5*/ floatArray: kotlin.FloatArray, /*6*/ doubleArray: kotlin.DoubleArray, /*7*/ booleanArray: kotlin.BooleanArray) internal final val booleanArray: kotlin.BooleanArray internal final val byteArray: kotlin.ByteArray diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt index 84b02aa9784..36f1e4f7b0a 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/primitives.txt @@ -8,7 +8,7 @@ test.Primitives(boolean = true, byte = 7.toByte(), char = \u0025 ('%'), double = public constructor D() } -kotlin.annotation.annotation() internal final annotation class Primitives : kotlin.Annotation { +kotlin.annotation.annotation() internal final class Primitives : kotlin.Annotation { public constructor Primitives(/*0*/ byte: kotlin.Byte, /*1*/ char: kotlin.Char, /*2*/ short: kotlin.Short, /*3*/ int: kotlin.Int, /*4*/ long: kotlin.Long, /*5*/ float: kotlin.Float, /*6*/ double: kotlin.Double, /*7*/ boolean: kotlin.Boolean) internal final val boolean: kotlin.Boolean internal final val byte: kotlin.Byte diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt index fceb8171734..4c074ac6138 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/string.txt @@ -8,12 +8,12 @@ test.StringArray(stringArray = {"java", ""}) internal final class C2 { public constructor C2() } -kotlin.annotation.annotation() internal final annotation class JustString : kotlin.Annotation { +kotlin.annotation.annotation() internal final class JustString : kotlin.Annotation { public constructor JustString(/*0*/ string: kotlin.String) internal final val string: kotlin.String } -kotlin.annotation.annotation() internal final annotation class StringArray : kotlin.Annotation { +kotlin.annotation.annotation() internal final class StringArray : kotlin.Annotation { public constructor StringArray(/*0*/ stringArray: kotlin.Array) internal final val stringArray: kotlin.Array } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt b/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt index 30d245911e6..af5bb7fcbb9 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationArguments/varargs.txt @@ -32,11 +32,11 @@ internal final enum class My : kotlin.Enum { public final /*synthesized*/ fun values(): kotlin.Array } -kotlin.annotation.annotation() internal final annotation class ann : kotlin.Annotation { +kotlin.annotation.annotation() internal final class ann : kotlin.Annotation { public constructor ann(/*0*/ vararg m: test.My /*kotlin.Array*/) internal final val m: kotlin.Array } -test.ann(m = {My.ALPHA, My.BETA}) kotlin.annotation.annotation() internal final annotation class annotated : kotlin.Annotation { +test.ann(m = {My.ALPHA, My.BETA}) kotlin.annotation.annotation() internal final class annotated : kotlin.Annotation { public constructor annotated() } diff --git a/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt b/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt index b03c61aeceb..6389756693d 100644 --- a/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt +++ b/compiler/testData/serialization/builtinsSerializer/annotationTargets.txt @@ -21,7 +21,7 @@ test.anno(x = "top level class") internal final class C1 { } } -kotlin.annotation.annotation() internal final annotation class anno : kotlin.Annotation { +kotlin.annotation.annotation() internal final class anno : kotlin.Annotation { public constructor anno(/*0*/ x: kotlin.String) internal final val x: kotlin.String } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index 89fe98bdfab..422e3036d08 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -140,7 +140,7 @@ public interface DescriptorRenderer : Renderer { ClassKind.INTERFACE -> "interface" ClassKind.ENUM_CLASS -> "enum class" ClassKind.OBJECT -> "object" - ClassKind.ANNOTATION_CLASS -> "annotation class" + ClassKind.ANNOTATION_CLASS -> "class" ClassKind.ENUM_ENTRY -> "enum entry" } } diff --git a/idea/testData/decompiler/stubBuilder/AnnotationClass/AnnotationClass.txt b/idea/testData/decompiler/stubBuilder/AnnotationClass/AnnotationClass.txt index fe8754994bf..f9f3011a981 100644 --- a/idea/testData/decompiler/stubBuilder/AnnotationClass/AnnotationClass.txt +++ b/idea/testData/decompiler/stubBuilder/AnnotationClass/AnnotationClass.txt @@ -5,7 +5,27 @@ PsiJetFileStubImpl[package=test.a] REFERENCE_EXPRESSION:[referencedName=a] IMPORT_LIST: CLASS:[fqName=test.a.AnnotationClass, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=AnnotationClass, superNames=[Annotation]] - MODIFIER_LIST:[annotation public final] + MODIFIER_LIST:[public final] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=annotation] + REFERENCE_EXPRESSION:[referencedName=annotation] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=Retention] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=java] + REFERENCE_EXPRESSION:[referencedName=lang] + REFERENCE_EXPRESSION:[referencedName=annotation] + REFERENCE_EXPRESSION:[referencedName=Retention] PRIMARY_CONSTRUCTOR: MODIFIER_LIST:[public] VALUE_PARAMETER_LIST: diff --git a/idea/testData/decompiler/stubBuilder/ClassObject/ClassObject.txt b/idea/testData/decompiler/stubBuilder/ClassObject/ClassObject.txt index 018c213880e..d9f5b894866 100644 --- a/idea/testData/decompiler/stubBuilder/ClassObject/ClassObject.txt +++ b/idea/testData/decompiler/stubBuilder/ClassObject/ClassObject.txt @@ -113,7 +113,27 @@ PsiJetFileStubImpl[package=test.class_object] REFERENCE_EXPRESSION:[referencedName=kotlin] REFERENCE_EXPRESSION:[referencedName=Unit] CLASS:[fqName=test.class_object.ClassObject.B.Companion.C.Companion.D.Companion.Anno, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Anno, superNames=[Annotation]] - MODIFIER_LIST:[annotation internal final] + MODIFIER_LIST:[internal final] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=annotation] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=kotlin] + REFERENCE_EXPRESSION:[referencedName=annotation] + REFERENCE_EXPRESSION:[referencedName=annotation] + ANNOTATION_ENTRY:[hasValueArguments=false, shortName=Retention] + CONSTRUCTOR_CALLEE: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=java] + REFERENCE_EXPRESSION:[referencedName=lang] + REFERENCE_EXPRESSION:[referencedName=annotation] + REFERENCE_EXPRESSION:[referencedName=Retention] PRIMARY_CONSTRUCTOR: MODIFIER_LIST:[public] VALUE_PARAMETER_LIST: From a84fe53256ca54e63a7aa8c27e528f7ef1ac8af4 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 13 Jul 2015 20:16:21 +0300 Subject: [PATCH 257/450] Minor refactoring of LookupElementsCollector --- .../completion/LookupElementsCollector.kt | 71 +++++++++++-------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index 0ac00825641..d69cc0df920 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.completion.handlers.* +import org.jetbrains.kotlin.types.JetType import java.util.ArrayList import java.util.LinkedHashMap @@ -103,37 +104,7 @@ class LookupElementsCollector( // add special item for function with one argument of function type with more than one parameter if (context != Context.INFIX_CALL && descriptor is FunctionDescriptor) { - val parameters = descriptor.getValueParameters() - if (parameters.size() == 1) { - val parameterType = parameters.get(0).getType() - if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { - val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() - if (parameterCount > 1) { - var lookupElement = lookupElementFactory.createLookupElement(descriptor, true) - - lookupElement = object : LookupElementDecorator(lookupElement) { - override fun renderElement(presentation: LookupElementPresentation) { - super.renderElement(presentation) - - val tails = presentation.getTailFragments() - presentation.clearTail() - presentation.appendTailText(" " + buildLambdaPresentation(parameterType) + " ", false) - tails.forEach { presentation.appendTailText(it.text, true) } - } - - override fun handleInsert(context: InsertionContext) { - KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, true)).handleInsert(context, this) - } - } - - if (context == Context.STRING_TEMPLATE_AFTER_DOLLAR) { - lookupElement = lookupElement.withBracesSurrounding() - } - - addElement(lookupElement) - } - } - } + addSpecialFunctionDescriptorElementIfNeeded(descriptor) } if (descriptor is PropertyDescriptor) { @@ -147,6 +118,44 @@ class LookupElementsCollector( } } + private fun addSpecialFunctionDescriptorElementIfNeeded(descriptor: FunctionDescriptor) { + val parameters = descriptor.getValueParameters() + if (parameters.size() == 1) { + val parameterType = parameters.get(0).getType() + if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { + val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() + if (parameterCount > 1) { + addSpecialFunctionDescriptorElement(descriptor, parameterType) + } + } + } + } + + private fun addSpecialFunctionDescriptorElement(descriptor: FunctionDescriptor, parameterType: JetType) { + var lookupElement = lookupElementFactory.createLookupElement(descriptor, true) + + lookupElement = object : LookupElementDecorator(lookupElement) { + override fun renderElement(presentation: LookupElementPresentation) { + super.renderElement(presentation) + + val tails = presentation.getTailFragments() + presentation.clearTail() + presentation.appendTailText(" " + buildLambdaPresentation(parameterType) + " ", false) + tails.forEach { presentation.appendTailText(it.text, true) } + } + + override fun handleInsert(context: InsertionContext) { + KotlinFunctionInsertHandler(CaretPosition.IN_BRACKETS, GenerateLambdaInfo(parameterType, true)).handleInsert(context, this) + } + } + + if (context == Context.STRING_TEMPLATE_AFTER_DOLLAR) { + lookupElement = lookupElement.withBracesSurrounding() + } + + addElement(lookupElement) + } + public fun addElement(element: LookupElement, prefixMatcher: PrefixMatcher = defaultPrefixMatcher) { if (prefixMatcher.prefixMatches(element)) { val decorated = object : LookupElementDecorator(element) { From 55c11539f82a196556371bf5adb92439dcb6a638 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Jul 2015 14:59:47 +0200 Subject: [PATCH 258/450] drop tuples support from parser --- .../kotlin/parsing/JetExpressionParsing.java | 47 ------------------- .../testData/psi/script/ShebangIncorrect.txt | 32 +++++-------- 2 files changed, 12 insertions(+), 67 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index f124063866b..41aef763d22 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -604,7 +604,6 @@ public class JetExpressionParsing extends AbstractJetParsing { /* * atomicExpression - * : tupleLiteral // or parenthesized element * : "this" label? * : "super" ("<" type ">")? label? * : objectLiteral @@ -628,9 +627,6 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(LPAR)) { parseParenthesizedExpression(); } - else if (at(HASH)) { - parseTupleExpression(); - } else if (at(PACKAGE_KEYWORD)) { parseOneTokenExpression(ROOT_PACKAGE); } @@ -1782,49 +1778,6 @@ public class JetExpressionParsing extends AbstractJetParsing { mark.done(PARENTHESIZED); } - /* - * tupleLiteral - * : "#" "(" (((SimpleName "=")? expression){","})? ")" - * ; - */ - @Deprecated // Tuples are dropped, but parsing is left to minimize surprising. This code should be removed some time (in Kotlin 1.0?) - private void parseTupleExpression() { - assert _at(HASH); - PsiBuilder.Marker mark = mark(); - - advance(); // HASH - advance(); // LPAR - myBuilder.disableNewlines(); - if (!at(RPAR)) { - while (true) { - while (at(COMMA)) { - advance(); - } - - if (at(IDENTIFIER) && lookahead(1) == EQ) { - advance(); // IDENTIFIER - advance(); // EQ - parseExpression(); - } - else { - parseExpression(); - } - - if (!at(COMMA)) break; - advance(); // COMMA - - if (at(RPAR)) { - break; - } - } - - } - consumeIf(RPAR); - myBuilder.restoreNewlinesState(); - - mark.error("Tuples are not supported. Use data classes instead."); - } - /* * "this" label? */ diff --git a/compiler/testData/psi/script/ShebangIncorrect.txt b/compiler/testData/psi/script/ShebangIncorrect.txt index b7abfe89664..e1f21b76705 100644 --- a/compiler/testData/psi/script/ShebangIncorrect.txt +++ b/compiler/testData/psi/script/ShebangIncorrect.txt @@ -16,24 +16,16 @@ JetFile: ShebangIncorrect.kts PsiElement(RPAR)(')') PsiElement(SEMICOLON)(';') PsiWhiteSpace(' ') - BINARY_EXPRESSION - PsiErrorElement:Tuples are not supported. Use data classes instead. - PsiElement(HASH)('#') - PsiElement(EXCL)('!') - PsiErrorElement:Expecting an expression - - OPERATION_REFERENCE - PsiElement(DIV)('/') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('usr') + PsiErrorElement:Expecting an element + PsiElement(HASH)('#') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(EXCL)('!') + PsiElement(DIV)('/') + PsiElement(IDENTIFIER)('usr') PsiWhiteSpace('\n\n') - BINARY_EXPRESSION - PsiErrorElement:Tuples are not supported. Use data classes instead. - PsiElement(HASH)('#') - PsiElement(EXCL)('!') - PsiErrorElement:Expecting an expression - - OPERATION_REFERENCE - PsiElement(DIV)('/') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('hi') + PsiErrorElement:Expecting an element + PsiElement(HASH)('#') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(EXCL)('!') + PsiElement(DIV)('/') + PsiElement(IDENTIFIER)('hi') \ No newline at end of file From 64860345e32f8ae031440835fa6e04ed2e417ba3 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Jul 2015 17:09:09 +0200 Subject: [PATCH 259/450] drop tuple type support from parser --- .../jetbrains/kotlin/parsing/JetParsing.java | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java index 3cac49927bc..5885429de1c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetParsing.java @@ -1823,7 +1823,6 @@ public class JetParsing extends AbstractJetParsing { * : selfType * : functionType * : userType - * : tupleType * : nullableType * : "dynamic" * ; @@ -1857,9 +1856,6 @@ public class JetParsing extends AbstractJetParsing { else if (at(IDENTIFIER) || at(PACKAGE_KEYWORD) || atParenthesizedMutableForPlatformTypes(0)) { parseUserType(); } - else if (at(HASH)) { - parseTupleType(); - } else if (at(LPAR)) { PsiBuilder.Marker functionOrParenthesizedType = mark(); @@ -2117,51 +2113,6 @@ public class JetParsing extends AbstractJetParsing { createTruncatedBuilder(lastId).parseModifierList(ALLOW_UNESCAPED_REGULAR_ANNOTATIONS); } - /* - * tupleType - * : "#" "(" type{","}? ")" - * : "#" "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility - * ; - */ - @Deprecated // Tuples are dropped, but parsing is left to minimize surprising. This code should be removed some time (in Kotlin 1.0?) - private void parseTupleType() { - assert _at(HASH); - - PsiBuilder.Marker tuple = mark(); - - myBuilder.disableNewlines(); - advance(); // HASH - consumeIf(LPAR); - - if (!at(RPAR)) { - while (true) { - if (at(COLON)) { - errorAndAdvance("Expecting a name for tuple entry"); - } - - if (at(IDENTIFIER) && lookahead(1) == COLON) { - advance(); // IDENTIFIER - advance(); // COLON - parseTypeRef(); - } - else if (TYPE_REF_FIRST.contains(tt())) { - parseTypeRef(); - } - else { - error("Type expected"); - break; - } - if (!at(COMMA)) break; - advance(); // COMMA - } - } - - consumeIf(RPAR); - myBuilder.restoreNewlinesState(); - - tuple.error("Tuples are not supported. Use data classes instead."); - } - /* * functionType * : "(" (parameter | modifiers type){","}? ")" "->" type? From 0295b13cc7211ac1ee360481e93ccbdd49ef90eb Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Jul 2015 17:14:33 +0200 Subject: [PATCH 260/450] couple more tuple leftovers --- .../kotlin/parsing/JetExpressionParsing.java | 3 --- .../testData/psi/script/ShebangIncorrect.txt | 18 +++++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java index 41aef763d22..b91fb01d414 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/parsing/JetExpressionParsing.java @@ -77,7 +77,6 @@ public class JetExpressionParsing extends AbstractJetParsing { COLONCOLON, // callable reference LPAR, // parenthesized - HASH, // Tuple // literal constant TRUE_KEYWORD, FALSE_KEYWORD, @@ -88,8 +87,6 @@ public class JetExpressionParsing extends AbstractJetParsing { LBRACE, // functionLiteral FUN_KEYWORD, // expression function - LPAR, // tuple - THIS_KEYWORD, // this SUPER_KEYWORD, // super diff --git a/compiler/testData/psi/script/ShebangIncorrect.txt b/compiler/testData/psi/script/ShebangIncorrect.txt index e1f21b76705..2a6d234577d 100644 --- a/compiler/testData/psi/script/ShebangIncorrect.txt +++ b/compiler/testData/psi/script/ShebangIncorrect.txt @@ -18,13 +18,17 @@ JetFile: ShebangIncorrect.kts PsiWhiteSpace(' ') PsiErrorElement:Expecting an element PsiElement(HASH)('#') - PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) - PsiElement(EXCL)('!') - PsiElement(DIV)('/') - PsiElement(IDENTIFIER)('usr') - PsiWhiteSpace('\n\n') - PsiErrorElement:Expecting an element - PsiElement(HASH)('#') + BINARY_EXPRESSION + PREFIX_EXPRESSION + OPERATION_REFERENCE + PsiElement(EXCL)('!') + PsiErrorElement:Expecting an element + PsiElement(DIV)('/') + OPERATION_REFERENCE + PsiElement(IDENTIFIER)('usr') + PsiWhiteSpace('\n\n') + PsiErrorElement:Expecting an element + PsiElement(HASH)('#') PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) PsiElement(EXCL)('!') PsiElement(DIV)('/') From 2b541a560ea8a19f93cf3c558fb81d302b44939e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 14 Jul 2015 21:19:44 +0300 Subject: [PATCH 261/450] Make function references compiled with old compiler work with new runtime --- .../jvm/internal/ReflectionFactoryImpl.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java index 6f86ff69d36..27f730367ef 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/ReflectionFactoryImpl.java @@ -16,6 +16,7 @@ package kotlin.reflect.jvm.internal; +import kotlin.jvm.KotlinReflectionNotSupportedError; import kotlin.jvm.internal.*; import kotlin.reflect.*; @@ -43,7 +44,19 @@ public class ReflectionFactoryImpl extends ReflectionFactory { @Override public KFunction function(FunctionReference f) { - return new KFunctionFromReferenceImpl(f); + try { + return new KFunctionFromReferenceImpl(f); + } + catch (KotlinReflectionNotSupportedError e) { + // If this function reference is compiled with an older compiler, it doesn't have the newer methods + // (getName(), getOwner(), getSignature()), so the default implementation from FunctionReference will be invoked + // and KotlinReflectionNotSupportedError will be thrown. + // Instead it's much better to use the reference as a KFunction. Yes, it will throw "no kotlin-reflect.jar was found" + // exceptions even if it exists in the classpath. However, at least it can be used as a function (invoke() will work). + // Moreover, old function references were not supposed to be introspected anyway because there was no reflection API back then. + // TODO: drop after M13 + return f; + } } // Properties From e23c7f457bb1d04a80d0efef9031a47150d1e437 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 14 Jul 2015 14:20:39 +0300 Subject: [PATCH 262/450] Preserve type annotations on type parameter when substituting Subsitute(@A T, T:@B String) = @B @A String Nullability when loading Java: Subsitute(@NotNull T, T:String) = @NotNull String Subsitute(@NotNull T, T:String!) = @NotNull String Subsitute(@NotNull T, T:String?) = @NotNull String Subsitute(@Nullable T, T:String) = @Nullable String? Subsitute(@Nullable T, T:String!) = @Nullable String? Subsitute(@Nullable T, T:String?) = @Nullable String? --- ...gumentsNullability-NotNull-SpecialTypes.kt | 3 +- ...umentsNullability-NotNull-SpecialTypes.txt | 4 +- ...eArgumentsNullability-NotNull-UserTypes.kt | 3 +- ...ArgumentsNullability-NotNull-UserTypes.txt | 4 +- .../saveAnnotationAfterSubstitution.kt | 47 ++++++++++++++++ .../saveAnnotationAfterSubstitution.txt | 56 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++ .../descriptors/annotations/Annotations.kt | 2 + .../kotlin/types/TypeSubstitutor.java | 9 +++ .../UnusedReceiverParameterInspection.kt | 2 +- .../inspections/UnusedSymbolInspection.kt | 2 +- 11 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt create mode 100644 compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.txt diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt index 205bc4f0ca3..52fc47305f0 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.kt @@ -19,6 +19,5 @@ public class Y extends X { fun main() { checkSubtype(Y().fooN()) - Y().barN(null); + Y().barN(null); } - diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt index 04ca74d4447..8a73fb1f86b 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-SpecialTypes.txt @@ -20,9 +20,9 @@ public open class X { public open class Y : X { public constructor Y() - public/*package*/ open override /*1*/ /*fake_override*/ fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: kotlin.String!): kotlin.Unit + public/*package*/ open override /*1*/ /*fake_override*/ fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: kotlin.String): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ /*fake_override*/ fun fooN(): kotlin.String! + org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ /*fake_override*/ fun fooN(): kotlin.String public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt index 1c9610d9195..2dc98dd7583 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.kt @@ -19,6 +19,5 @@ public class Y extends X { fun main() { checkSubtype(Y().fooN()) - Y().barN(null); + Y().barN(null); } - diff --git a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt index 0363db8ebbb..af87cc89d5b 100644 --- a/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt +++ b/compiler/testData/diagnostics/tests/j+k/SupertypeArgumentsNullability-NotNull-UserTypes.txt @@ -20,9 +20,9 @@ public open class X { public open class Y : X { public constructor Y() - public/*package*/ open override /*1*/ /*fake_override*/ fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: A!): kotlin.Unit + public/*package*/ open override /*1*/ /*fake_override*/ fun barN(/*0*/ org.jetbrains.annotations.NotNull() a: A): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ /*fake_override*/ fun fooN(): A! + org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ /*fake_override*/ fun fooN(): A public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt new file mode 100644 index 00000000000..33bdd9ca0f1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt @@ -0,0 +1,47 @@ +// FILE: A.java + +import org.jetbrains.annotations.*; + +interface A { + void foo(@NotNull T x, @Nullable T y); +} + +// FILE: B1.java + +// contains fake_override fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?) +interface B1 extends A {} + +// FILE: B2.java +import org.jetbrains.annotations.*; + +interface B2 extends A { + // Ok, consistent override + // override fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?) + void foo(@NotNull String x, @Nullable String y); +} + +// FILE: B3.java +import org.jetbrains.annotations.*; + +interface B3 extends A { + // inconsistent override, second parameter type is platform + // TODO: first one should be platform too, but it's not because when substituting T -> String!, + // value parameter type becomes platform and it can be overridden with @NotNull String. + // Conceptual problem: we can use type parameter as T?, but there is no way to specify same semantics as in Java `@NotNull T`. + + // override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?, /*1*/ org.jetbrains.annotations.NotNull() y: kotlin.String!): kotlin.Unit + void foo(@Nullable String x, @NotNull String y); +} + +// FILE: main.kt + +// fake_override fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit +interface C1 : A + +// fake_override fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String?, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit +interface C2 : A + +interface C3 : B1 { + // inconsistent override + override fun foo(x: String?, y: String?); +} diff --git a/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.txt b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.txt new file mode 100644 index 00000000000..a9a6a6124a4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.txt @@ -0,0 +1,56 @@ +package + +public/*package*/ /*synthesized*/ fun A(/*0*/ function: (T!, T!) -> kotlin.Unit): A +public/*package*/ /*synthesized*/ fun B1(/*0*/ function: (kotlin.String!, kotlin.String?) -> kotlin.Unit): B1 +public/*package*/ /*synthesized*/ fun B2(/*0*/ function: (kotlin.String!, kotlin.String!) -> kotlin.Unit): B2 +public/*package*/ /*synthesized*/ fun B3(/*0*/ function: (kotlin.String!, kotlin.String!) -> kotlin.Unit): B3 + +public/*package*/ interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: T, /*1*/ org.jetbrains.annotations.Nullable() y: T?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface B1 : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface B2 : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public/*package*/ interface B3 : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ fun foo(/*0*/ org.jetbrains.annotations.Nullable() x: kotlin.String?, /*1*/ org.jetbrains.annotations.NotNull() y: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface C1 : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface C2 : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String?, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface C3 : B1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ org.jetbrains.annotations.NotNull() x: kotlin.String, /*1*/ org.jetbrains.annotations.Nullable() y: kotlin.String?): kotlin.Unit + internal abstract fun foo(/*0*/ x: kotlin.String?, /*1*/ y: kotlin.String?): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 39c8d2abb34..1fc9afd337e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -10463,6 +10463,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("saveAnnotationAfterSubstitution.kt") + public void testSaveAnnotationAfterSubstitution() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt"); + doTest(fileName); + } + @TestMetadata("supertypeDifferentParameterNullability.kt") public void testSupertypeDifferentParameterNullability() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/supertypeDifferentParameterNullability.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt index d6627b229fb..03a1cc364d5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/Annotations.kt @@ -69,6 +69,8 @@ class FilteredAnnotations( class CompositeAnnotations( private val delegates: List ) : Annotations { + constructor(vararg delegates: Annotations): this(delegates.toList()) + override fun isEmpty() = delegates.all { it.isEmpty() } override fun findAnnotation(fqName: FqName) = delegates.asSequence().map { it.findAnnotation(fqName) }.filterNotNull().firstOrNull() diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java index dad4ac43afb..55bcc9e499a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; +import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations; import org.jetbrains.kotlin.resolve.calls.inference.InferencePackage; import org.jetbrains.kotlin.resolve.scopes.SubstitutingScope; import org.jetbrains.kotlin.types.typeUtil.TypeUtilPackage; @@ -221,6 +222,14 @@ public class TypeSubstitutor { substitutedType = TypeUtils.makeNullableIfNeeded(replacement.getType(), type.isMarkedNullable()); } + // substitutionType.annotations = replacement.annotations ++ type.annotations + if (!type.getAnnotations().isEmpty()) { + substitutedType = TypeUtilPackage.replaceAnnotations( + substitutedType, + new CompositeAnnotations(substitutedType.getAnnotations(), type.getAnnotations()) + ); + } + Variance resultingProjectionKind = varianceConflict == VarianceConflictType.NO_CONFLICT ? combine(originalProjectionKind, replacement.getProjectionKind()) : originalProjectionKind; diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt index 69655659bf0..fcd3e47d85e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedReceiverParameterInspection.kt @@ -95,7 +95,7 @@ public class UnusedReceiverParameterInspection : AbstractKotlinInspection() { return JetBundle.message("unused.receiver.parameter.remove") } - override fun applyFix(project: Project, descriptor: ProblemDescriptor?) { + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { declaration.setReceiverTypeReference(null) } diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt index 73670008380..4aa5f387255 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UnusedSymbolInspection.kt @@ -112,7 +112,7 @@ public class UnusedSymbolInspection : AbstractKotlinInspection() { override fun getFamilyName() = "Safe delete" - override fun applyFix(project: Project, descriptor: ProblemDescriptor?) { + override fun applyFix(project: Project, descriptor: ProblemDescriptor) { if (!FileModificationService.getInstance().prepareFileForWrite(declaration.getContainingFile())) return SafeDeleteHandler.invoke(project, arrayOf(declaration), false) } From d19cb747be3b3e6ea077df4fedd53feae6602b51 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 14 Jul 2015 14:21:20 +0300 Subject: [PATCH 263/450] Emit not-null assertions for enhanced types --- .../org/jetbrains/kotlin/codegen/AsmUtil.java | 8 +- .../kotlin/codegen/ExpressionCodegen.java | 9 +- .../kotlin/codegen/FunctionCodegen.java | 9 +- .../jetbrains/kotlin/jvm/RuntimeAssertions.kt | 116 ++++++++++++++++++ .../kotlin/jvm/bindingContextSlices.kt | 26 ++++ .../load/kotlin/KotlinJvmCheckerProvider.kt | 3 +- .../notNullAssertions/AssertionChecker.kt | 4 +- .../GenerateNotNullAssertionsTest.java | 3 +- .../kotlin/load/java/JvmAnnotationNames.java | 4 + .../java/typeEnhacement/typeEnhancement.kt | 78 +++++++++--- .../outs/stepIntoSpecificKotlinClasses.out | 4 +- 11 files changed, 231 insertions(+), 33 deletions(-) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index 42b4e4ff79d..537d52aca79 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.load.java.JavaVisibilities; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.load.java.JvmAnnotationNames; import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor; +import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; @@ -45,7 +46,6 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName; import org.jetbrains.kotlin.resolve.jvm.JvmPackage; import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin; -import org.jetbrains.kotlin.types.Approximation; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypesPackage; import org.jetbrains.org.objectweb.asm.*; @@ -637,10 +637,10 @@ public class AsmUtil { public static StackValue genNotNullAssertions( @NotNull GenerationState state, @NotNull final StackValue stackValue, - @Nullable final Approximation.Info approximationInfo + @Nullable final RuntimeAssertionInfo runtimeAssertionInfo ) { if (!state.isCallAssertionsEnabled()) return stackValue; - if (approximationInfo == null || !TypesPackage.assertNotNull(approximationInfo)) return stackValue; + if (runtimeAssertionInfo == null || !runtimeAssertionInfo.getNeedNotNullAssertion()) return stackValue; return new StackValue(stackValue.type) { @@ -649,7 +649,7 @@ public class AsmUtil { stackValue.put(type, v); if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { v.dup(); - v.visitLdcInsn(approximationInfo.getMessage()); + v.visitLdcInsn(runtimeAssertionInfo.getMessage()); v.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull", "(Ljava/lang/Object;Ljava/lang/String;)V", false); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index f9466586266..462dfbf20d7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -49,10 +49,12 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor; import org.jetbrains.kotlin.diagnostics.DiagnosticUtils; import org.jetbrains.kotlin.diagnostics.Errors; +import org.jetbrains.kotlin.jvm.bindingContextSlices.BindingContextSlicesPackage; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor; +import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.renderer.DescriptorRenderer; @@ -75,7 +77,6 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.scopes.receivers.*; -import org.jetbrains.kotlin.types.Approximation; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; @@ -280,12 +281,12 @@ public class ExpressionCodegen extends JetVisitor implem StackValue stackValue = selector.accept(visitor, receiver); - Approximation.Info approximationInfo = null; + RuntimeAssertionInfo runtimeAssertionInfo = null; if (selector instanceof JetExpression) { - approximationInfo = bindingContext.get(BindingContext.EXPRESSION_RESULT_APPROXIMATION, (JetExpression) selector); + runtimeAssertionInfo = bindingContext.get(BindingContextSlicesPackage.getRUNTIME_ASSERTION_INFO(), (JetExpression) selector); } - return genNotNullAssertions(state, stackValue, approximationInfo); + return genNotNullAssertions(state, stackValue, runtimeAssertionInfo); } catch (ProcessCanceledException e) { throw e; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index cd7016c3f68..64bfd7e0ba8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeDeclarationsPackage; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.psi.JetNamedFunction; @@ -51,8 +52,6 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; -import org.jetbrains.kotlin.types.Approximation; -import org.jetbrains.kotlin.types.TypesPackage; import org.jetbrains.org.objectweb.asm.AnnotationVisitor; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.MethodVisitor; @@ -834,10 +833,10 @@ public class FunctionCodegen { StackValue stackValue = AsmUtil.genNotNullAssertions( state, StackValue.onStack(delegateToMethod.getReturnType()), - TypesPackage.getApproximationTo( - delegatedTo.getReturnType(), + RuntimeAssertionInfo.create( delegateFunction.getReturnType(), - new Approximation.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)") + delegatedTo.getReturnType(), + new RuntimeAssertionInfo.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)") ) ); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt new file mode 100644 index 00000000000..c42d9a6bf48 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/RuntimeAssertions.kt @@ -0,0 +1,116 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jvm + +import com.intellij.openapi.util.text.StringUtil +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor +import org.jetbrains.kotlin.load.java.JvmAnnotationNames +import org.jetbrains.kotlin.jvm.bindingContextSlices.RUNTIME_ASSERTION_INFO +import org.jetbrains.kotlin.psi.JetExpression +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker +import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.types.upperIfFlexible +import kotlin.platform.platformStatic + +public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, public val message: String) { + public interface DataFlowExtras { + class OnlyMessage(message: String) : DataFlowExtras { + override val canBeNull: Boolean get() = true + override val possibleTypes: Set get() = setOf() + override val presentableText: String = message + } + + val canBeNull: Boolean + val possibleTypes: Set + val presentableText: String + } + + companion object { + platformStatic public fun create( + expectedType: JetType, + expressionType: JetType, + dataFlowExtras: DataFlowExtras + ): RuntimeAssertionInfo? { + fun assertNotNull(): Boolean { + if (expectedType.isError() || expressionType.isError()) return false + + // T : Any, T! = T..T? + // Let T$ will be copy of T! with enhanced nullability. + // Cases when nullability assertion needed: T! -> T, T$ -> T + + // Expected type either T?, T! or T$ + if (TypeUtils.isNullableType(expectedType) || expectedType.hasEnhancedNullability()) return false + + // Expression type is not nullable and not enhanced (neither T?, T! or T$) + val isExpressionTypeNullable = TypeUtils.isNullableType(expressionType) + if (!isExpressionTypeNullable && !expressionType.hasEnhancedNullability()) return false + + // Smart-cast T! or T? + if (!dataFlowExtras.canBeNull && isExpressionTypeNullable) return false + + return true + } + + return if (assertNotNull()) + RuntimeAssertionInfo(needNotNullAssertion = true, message = dataFlowExtras.presentableText) + else + null + } + + private fun JetType.hasEnhancedNullability() + = getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null + } +} + +public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker { + override fun checkType(expression: JetExpression, expressionType: JetType, c: ResolutionContext<*>) { + if (TypeUtils.noExpectedType(c.expectedType)) return + + val assertionInfo = RuntimeAssertionInfo.create( + c.expectedType, + expressionType, + object : RuntimeAssertionInfo.DataFlowExtras { + override val canBeNull: Boolean + get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull() + override val possibleTypes: Set + get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue) + override val presentableText: String + get() = StringUtil.trimMiddle(expression.getText(), 50) + + private val dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, expressionType, c) + } + ) + + if (assertionInfo != null) { + c.trace.record(RUNTIME_ASSERTION_INFO, expression, assertionInfo) + } + } + + override fun checkReceiver( + receiverParameter: ReceiverParameterDescriptor, + receiverArgument: ReceiverValue, + safeAccess: Boolean, + c: CallResolutionContext<*> + ) { } +} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt new file mode 100644 index 00000000000..00d32c8a0fa --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/jvm/bindingContextSlices.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.jvm.bindingContextSlices + +import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo +import org.jetbrains.kotlin.psi.JetExpression +import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice +import org.jetbrains.kotlin.util.slicedMap.RewritePolicy +import org.jetbrains.kotlin.util.slicedMap.WritableSlice +import org.jetbrains.kotlin.utils.DO_NOTHING + +public val RUNTIME_ASSERTION_INFO: WritableSlice = BasicWritableSlice(RewritePolicy.DO_NOTHING) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt index a8b0f8f4625..4b61deb32b2 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmCheckerProvider.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.cfg.WhenChecker import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.diagnostics.DiagnosticSink import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.jvm.RuntimeAssertionsTypeChecker import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNotNull import org.jetbrains.kotlin.load.java.lazy.types.isMarkedNullable @@ -63,7 +64,7 @@ public class KotlinJvmCheckerProvider(private val module: ModuleDescriptor) : Ad JavaAnnotationMethodCallChecker(), TraitDefaultMethodCallChecker(), ReflectionAPICallChecker(module)), - additionalTypeCheckers = listOf(JavaNullabilityWarningsChecker()), + additionalTypeCheckers = listOf(JavaNullabilityWarningsChecker(), RuntimeAssertionsTypeChecker), additionalSymbolUsageValidators = listOf() ) diff --git a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt index 17523ca17c2..d3643218d1d 100644 --- a/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt +++ b/compiler/testData/codegen/notNullAssertions/AssertionChecker.kt @@ -45,10 +45,10 @@ fun checkAssertions(illegalStateExpected: Boolean) { check("plus") { A() + A() } // field - // check("NULL") { A().NULL } + check("NULL") { A().NULL } // static field - // check("STATIC_NULL") { A.STATIC_NULL } + check("STATIC_NULL") { A.STATIC_NULL } // postfix expression // TODO: diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java index 9f698b8c185..d30c89bca3f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/GenerateNotNullAssertionsTest.java @@ -126,6 +126,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase { loadFile("notNullAssertions/arrayListGet.kt"); String text = generateToText(); + assertTrue(text.contains("checkExpressionValueIsNotNull")); assertTrue(text.contains("checkParameterIsNotNull")); } @@ -136,7 +137,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase { loadFile("notNullAssertions/javaMultipleSubstitutions.kt"); String text = generateToText(); - assertEquals(0, StringUtil.getOccurrenceCount(text, "checkExpressionValueIsNotNull")); + assertEquals(3, StringUtil.getOccurrenceCount(text, "checkExpressionValueIsNotNull")); assertEquals(3, StringUtil.getOccurrenceCount(text, "checkParameterIsNotNull")); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index a6c887c1762..c3ff64321d4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -46,6 +46,10 @@ public final class JvmAnnotationNames { public static final FqName PURELY_IMPLEMENTS_ANNOTATION = new FqName("kotlin.jvm.PurelyImplements"); + // Just for internal use: there is no such real classes in bytecode + public static final FqName ENHANCED_NULLABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedNullability"); + public static final FqName ENHANCED_MUTABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedMutability"); + public static class KotlinClass { public static final JvmClassName CLASS_NAME = JvmClassName.byInternalName("kotlin/jvm/internal/KotlinClass"); public static final ClassId KIND_CLASS_ID = diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt index 332b72e9a05..b1d2eb30f36 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/typeEnhacement/typeEnhancement.kt @@ -18,12 +18,19 @@ package org.jetbrains.kotlin.load.java.typeEnhacement import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.java.typeEnhacement.JavaTypeQualifiers import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.MUTABLE import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.READ_ONLY import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NULL import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.platform.JavaToKotlinClassMap +import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant import org.jetbrains.kotlin.types.* // The index in the lambda is the position of the type component: @@ -68,7 +75,7 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i ?: return Result(this, 1) val effectiveQualifiers = qualifiers(index) - val enhancedClassifier = originalClass.enhanceMutability(effectiveQualifiers, position) + val (enhancedClassifier, enhancedMutabilityAnnotations) = originalClass.enhanceMutability(effectiveQualifiers, position) var globalArgIndex = index + 1 val enhancedArguments = getArguments().mapIndexed { @@ -87,10 +94,17 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i } } - val enhancedType = JetTypeImpl( + val (enhancedNullability, enhancedNullabilityAnnotations) = this.getEnhancedNullability(effectiveQualifiers, position) + val newAnnotations = listOf( getAnnotations(), + enhancedMutabilityAnnotations, + enhancedNullabilityAnnotations + ).filterNotNull().compositeAnnotationsOrSingle() + + val enhancedType = JetTypeImpl( + newAnnotations, enhancedClassifier.getTypeConstructor(), - this.getEnhancedNullability(effectiveQualifiers, position), + enhancedNullability, enhancedArguments, if (enhancedClassifier is ClassDescriptor) enhancedClassifier.getMemberScope(enhancedArguments) @@ -99,36 +113,72 @@ private fun JetType.enhanceInflexible(qualifiers: (Int) -> JavaTypeQualifiers, i return Result(enhancedType, globalArgIndex - index) } +private fun List.compositeAnnotationsOrSingle() = when (size()) { + 0 -> error("At least one Annotations object expected") + 1 -> single() + else -> CompositeAnnotations(this) +} + private fun TypeComponentPosition.shouldEnhance() = this != TypeComponentPosition.INFLEXIBLE -private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): ClassifierDescriptor { - if (!position.shouldEnhance()) return this - if (this !is ClassDescriptor) return this // mutability is not applicable for type parameters +private data class EnhancementResult(val result: T, val enhancementAnnotations: Annotations?) +private fun T.noChange() = EnhancementResult(this, null) +private fun T.enhancedNullability() = EnhancementResult(this, ENHANCED_NULLABILITY_ANNOTATIONS) +private fun T.enhancedMutability() = EnhancementResult(this, ENHANCED_MUTABILITY_ANNOTATIONS) + +private fun ClassifierDescriptor.enhanceMutability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult { + if (!position.shouldEnhance()) return this.noChange() + if (this !is ClassDescriptor) return this.noChange() // mutability is not applicable for type parameters val mapping = JavaToKotlinClassMap.INSTANCE when (qualifiers.mutability) { READ_ONLY -> { if (position == TypeComponentPosition.FLEXIBLE_LOWER && mapping.isMutable(this)) { - return mapping.convertMutableToReadOnly(this) + return mapping.convertMutableToReadOnly(this).enhancedMutability() } } MUTABLE -> { if (position == TypeComponentPosition.FLEXIBLE_UPPER && mapping.isReadOnly(this) ) { - return mapping.convertReadOnlyToMutable(this) + return mapping.convertReadOnlyToMutable(this).enhancedMutability() } } } - return this + return this.noChange() } -private fun JetType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): Boolean { - if (!position.shouldEnhance()) return this.isMarkedNullable() +private fun JetType.getEnhancedNullability(qualifiers: JavaTypeQualifiers, position: TypeComponentPosition): EnhancementResult { + if (!position.shouldEnhance()) return this.isMarkedNullable().noChange() return when (qualifiers.nullability) { - NULLABLE -> true - NOT_NULL -> false - else -> this.isMarkedNullable() + NULLABLE -> true.enhancedNullability() + NOT_NULL -> false.enhancedNullability() + else -> this.isMarkedNullable().noChange() } } + +private val ENHANCED_NULLABILITY_ANNOTATIONS = EnhancedTypeAnnotations(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) +private val ENHANCED_MUTABILITY_ANNOTATIONS = EnhancedTypeAnnotations(JvmAnnotationNames.ENHANCED_MUTABILITY_ANNOTATION) + +private class EnhancedTypeAnnotations(private val fqNameToMatch: FqName) : Annotations { + override fun isEmpty() = false + + override fun findAnnotation(fqName: FqName) = when (fqName) { + fqNameToMatch -> EnhancedTypeAnnotationDescriptor + else -> null + } + + override fun findExternalAnnotation(fqName: FqName) = null + + // Note, that this class may break Annotations contract (!isEmpty && iterator.isEmpty()) + // It's a hack that we need unless we have stable "user data" in JetType + override fun iterator(): Iterator = emptyList().iterator() +} + +private object EnhancedTypeAnnotationDescriptor : AnnotationDescriptor { + private fun throwError() = error("No methods should be called on this descriptor. Only it's presence matters") + override fun getType() = throwError() + override fun getAllValueArguments() = throwError() + override fun toString() = "[EnhancedType]" +} diff --git a/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out index 94468ad37ce..bdd1cc9bd58 100644 --- a/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out +++ b/idea/testData/debugger/tinyApp/outs/stepIntoSpecificKotlinClasses.out @@ -4,9 +4,9 @@ Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socke stepIntoSpecificKotlinClasses.kt:8 MyJavaClass.java:12 stepIntoSpecificKotlinClasses.kt:8 +Intrinsics.!EXT! +stepIntoSpecificKotlinClasses.kt:8 stepIntoSpecificKotlinClasses.kt:9 -stepIntoSpecificKotlinClasses.kt:10 -Thread.!EXT! Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 From e82adc9d90e5e0b65bf9cb2fd854b542ad1ff58e Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 13 Jul 2015 20:06:07 +0300 Subject: [PATCH 264/450] Drop unused Approximation type capabilities --- .../resolve/AdditionalCheckerProvider.kt | 2 +- .../kotlin/resolve/BindingContext.java | 2 - .../calls/checkers/TypeApproximator.kt | 61 ------------------- .../jetbrains/kotlin/types/flexibleTypes.kt | 51 +--------------- 4 files changed, 3 insertions(+), 113 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/TypeApproximator.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AdditionalCheckerProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AdditionalCheckerProvider.kt index a92008ebdf0..e66791d2c5e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AdditionalCheckerProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AdditionalCheckerProvider.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator private val DEFAULT_DECLARATION_CHECKERS = listOf(DataClassAnnotationChecker()) private val DEFAULT_CALL_CHECKERS = listOf(CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker()) -private val DEFAULT_TYPE_CHECKERS = listOf(TypeApproximator()) +private val DEFAULT_TYPE_CHECKERS = emptyList() private val DEFAULT_VALIDATORS = listOf(DeprecatedSymbolValidator()) public abstract class AdditionalCheckerProvider( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java index efd27e7c827..952e2938faf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java @@ -36,7 +36,6 @@ import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier; -import org.jetbrains.kotlin.types.Approximation; import org.jetbrains.kotlin.types.DeferredType; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.expressions.CaptureKind; @@ -97,7 +96,6 @@ public interface BindingContext { WritableSlice EXPRESSION_TYPE_INFO = new BasicWritableSlice(DO_NOTHING); WritableSlice EXPECTED_EXPRESSION_TYPE = new BasicWritableSlice(DO_NOTHING); WritableSlice EXPECTED_RETURN_TYPE = new BasicWritableSlice(DO_NOTHING); - WritableSlice EXPRESSION_RESULT_APPROXIMATION = new BasicWritableSlice(DO_NOTHING); WritableSlice DATAFLOW_INFO_AFTER_CONDITION = Slices.createSimpleSlice(); /** diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/TypeApproximator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/TypeApproximator.kt deleted file mode 100644 index f95f420b617..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/TypeApproximator.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.calls.checkers - -import org.jetbrains.kotlin.psi.JetExpression -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext - -import org.jetbrains.kotlin.types.TypeUtils.noExpectedType -import org.jetbrains.kotlin.types.getApproximationTo -import org.jetbrains.kotlin.types.Approximation -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory -import com.intellij.openapi.util.text.StringUtil -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor -import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext - -public class TypeApproximator : AdditionalTypeChecker { - override fun checkType(expression: JetExpression, expressionType: JetType, c: ResolutionContext<*>) { - if (noExpectedType(c.expectedType)) return - - val approximationInfo = expressionType.getApproximationTo( - c.expectedType, - object : Approximation.DataFlowExtras { - override val canBeNull: Boolean - get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull() - override val possibleTypes: Set - get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue) - override val presentableText: String - get() = StringUtil.trimMiddle(expression.getText(), 50) - - private val dataFlowValue = DataFlowValueFactory.createDataFlowValue(expression, expressionType, c) - } - ) - if (approximationInfo != null) { - c.trace.record(BindingContext.EXPRESSION_RESULT_APPROXIMATION, expression, approximationInfo) - } - } - - override fun checkReceiver( - receiverParameter: ReceiverParameterDescriptor, - receiverArgument: ReceiverValue, - safeAccess: Boolean, - c: CallResolutionContext<*> - ) { } -} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt index 779346885a8..28834dd1aa8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt @@ -105,38 +105,6 @@ public trait NullAwareness : TypeCapability { public fun computeIsNullable(): Boolean } -public trait Approximation : TypeCapability { - public class Info(val from: JetType, val to: JetType, val message: String) - public trait DataFlowExtras { - object EMPTY : DataFlowExtras { - override val canBeNull: Boolean get() = true - override val possibleTypes: Set get() = setOf() - override val presentableText: String = "" - } - - class OnlyMessage(message: String) : DataFlowExtras { - override val canBeNull: Boolean get() = true - override val possibleTypes: Set get() = setOf() - override val presentableText: String = message - } - - val canBeNull: Boolean - val possibleTypes: Set - val presentableText: String - } - - public fun approximateToExpectedType(expectedType: JetType, dataFlowExtras: DataFlowExtras): Info? -} - -fun Approximation.Info.assertNotNull(): Boolean { - return from.upperIfFlexible().isMarkedNullable() && !TypeUtils.isNullableType(to) -} - -public fun JetType.getApproximationTo( - expectedType: JetType, - extras: Approximation.DataFlowExtras = Approximation.DataFlowExtras.EMPTY -): Approximation.Info? = this.getCapability(javaClass())?.approximateToExpectedType(expectedType, extras) - trait FlexibleTypeDelegation : TypeCapability { public val delegateType: JetType } @@ -145,14 +113,13 @@ public open class DelegatingFlexibleType protected constructor( override val lowerBound: JetType, override val upperBound: JetType, override val extraCapabilities: FlexibleTypeCapabilities -) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation, Approximation { +) : DelegatingType(), NullAwareness, Flexibility, FlexibleTypeDelegation { companion object { internal val capabilityClasses = hashSetOf( javaClass(), javaClass(), javaClass(), - javaClass(), - javaClass() + javaClass() ) platformStatic fun create(lowerBound: JetType, upperBound: JetType, extraCapabilities: FlexibleTypeCapabilities): JetType { @@ -193,20 +160,6 @@ public open class DelegatingFlexibleType protected constructor( override fun isMarkedNullable(): Boolean = getCapability(javaClass())!!.computeIsNullable() - override fun approximateToExpectedType(expectedType: JetType, dataFlowExtras: Approximation.DataFlowExtras): Approximation.Info? { - // val foo: Any? = foo() : Foo! - if (JetTypeChecker.DEFAULT.isSubtypeOf(upperBound, expectedType)) return null - - // if (foo : Foo! != null) { - // val bar: Any = foo - // } - if (!dataFlowExtras.canBeNull && JetTypeChecker.DEFAULT.isSubtypeOf(TypeUtils.makeNotNullable(upperBound), expectedType)) return null - - // TODO: maybe check possibleTypes to avoid extra approximations - - return Approximation.Info(this, expectedType, dataFlowExtras.presentableText) - } - override val delegateType: JetType = lowerBound override fun getDelegate() = getCapability(javaClass())!!.delegateType From d34d54ba4794b516c6e50be8c453098579dd5506 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Tue, 14 Jul 2015 13:17:42 +0200 Subject: [PATCH 265/450] nicer looking action to create a new Kotlin file #KT-8445 Fixed --- .../src/org/jetbrains/kotlin/idea/JetBundle.properties | 2 +- .../jetbrains/kotlin/idea/actions/NewKotlinFileAction.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties index caad43ddb91..e80b9aaff18 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/JetBundle.properties @@ -47,7 +47,7 @@ introduce.non.null.assertion=Add non-null asserted (!!) call remove.unnecessary.non.null.assertion=Remove unnecessary non-null assertion (!!) change.to.backing.field=Change reference to backing field implement.members=Implement members -new.kotlin.file.action=Kotlin File +new.kotlin.file.action=Kotlin File/Class import.fix=Import imports.chooser.title=Imports rename.parameter.to.match.overridden.method=Rename parameter to match overridden method diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java index 2028eeaa738..245d908ab8d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java +++ b/idea/src/org/jetbrains/kotlin/idea/actions/NewKotlinFileAction.java @@ -39,7 +39,7 @@ import java.util.Map; public class NewKotlinFileAction extends CreateFileFromTemplateAction implements DumbAware { public NewKotlinFileAction() { - super(JetBundle.message("new.kotlin.file.action"), "Creates new Kotlin file", JetFileType.INSTANCE.getIcon()); + super(JetBundle.message("new.kotlin.file.action"), "Creates new Kotlin file or class", JetFileType.INSTANCE.getIcon()); } @Override @@ -55,8 +55,8 @@ public class NewKotlinFileAction extends CreateFileFromTemplateAction implements @Override protected void buildDialog(Project project, PsiDirectory directory, CreateFileFromTemplateDialog.Builder builder) { builder - .setTitle(JetBundle.message("new.kotlin.file.action")) - .addKind("Kotlin file", JetFileType.INSTANCE.getIcon(), "Kotlin File") + .setTitle("New Kotlin File/Class") + .addKind("File", JetFileType.INSTANCE.getIcon(), "Kotlin File") .addKind("Class", JetIcons.CLASS, "Kotlin Class") .addKind("Interface", JetIcons.TRAIT, "Kotlin Interface") .addKind("Enum class", JetIcons.ENUM, "Kotlin Enum") From 5f8a652a3837dc567d8541304f754b87ffee6ae3 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 19:55:54 +0300 Subject: [PATCH 266/450] KT-4592 Parameter info shows signatures of inaccessible methods #KT-4592 Fixed --- .../kotlin/resolve/JetVisibilityChecker.java | 32 ------------------- .../JetFunctionParameterInfoHandler.java | 10 +++--- .../functionParameterInfo/NotAccessible.kt | 11 +++++++ .../FunctionParameterInfoTestGenerated.java | 6 ++++ 4 files changed, 23 insertions(+), 36 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/JetVisibilityChecker.java create mode 100644 idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/JetVisibilityChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/JetVisibilityChecker.java deleted file mode 100644 index aa3d597f9a7..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/JetVisibilityChecker.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; - -public class JetVisibilityChecker { - /** - * @param locationOwner owner of the call site - * @param subject the descriptor whose visibility is being checked - * @return true iff subject is visible locationOwner - */ - public static boolean isVisible(@NotNull DeclarationDescriptor locationOwner, @NotNull DeclarationDescriptor subject) { - // TODO : stub implementation - return true; - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java index 89606052d28..c0ce8301b09 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade; import org.jetbrains.kotlin.idea.caches.resolve.ResolvePackage; import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper; +import org.jetbrains.kotlin.idea.core.CorePackage; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; @@ -45,7 +46,6 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; -import org.jetbrains.kotlin.resolve.JetVisibilityChecker; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude; import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter; @@ -373,7 +373,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith return null; } - JetSimpleNameExpression callNameExpression = getCallSimpleNameExpression(argumentList); + final JetSimpleNameExpression callNameExpression = getCallSimpleNameExpression(argumentList); if (callNameExpression == null) { return null; } @@ -384,7 +384,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith } ResolutionFacade resolutionFacade = ResolvePackage.getResolutionFacade(callNameExpression.getContainingJetFile()); - BindingContext bindingContext = resolutionFacade.analyze(callNameExpression, BodyResolveMode.FULL); + final BindingContext bindingContext = resolutionFacade.analyze(callNameExpression, BodyResolveMode.FULL); ModuleDescriptor moduleDescriptor = resolutionFacade.findModuleDescriptor(callNameExpression); JetScope scope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, callNameExpression); @@ -398,7 +398,9 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith Function1 visibilityFilter = new Function1() { @Override public Boolean invoke(DeclarationDescriptor descriptor) { - return placeDescriptor == null || JetVisibilityChecker.isVisible(placeDescriptor, descriptor); + if (placeDescriptor == null) return true; + if (!(descriptor instanceof DeclarationDescriptorWithVisibility)) return true; + return CorePackage.isVisible((DeclarationDescriptorWithVisibility) descriptor, placeDescriptor, bindingContext, callNameExpression); } }; diff --git a/idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt b/idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt new file mode 100644 index 00000000000..d479deb45d2 --- /dev/null +++ b/idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt @@ -0,0 +1,11 @@ +class C { + fun foo(){} + protected fun foo(p: Int){} +} + +fun f(c: C) { + c.foo(1) +} +/* +Text: (), Disabled: true, Strikeout: false, Green: true +*/ \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/FunctionParameterInfoTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/FunctionParameterInfoTestGenerated.java index e23191fe321..4df942d70a3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/FunctionParameterInfoTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/FunctionParameterInfoTestGenerated.java @@ -77,6 +77,12 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete doTest(fileName); } + @TestMetadata("NotAccessible.kt") + public void testNotAccessible() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotAccessible.kt"); + doTest(fileName); + } + @TestMetadata("NotGreen.kt") public void testNotGreen() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NotGreen.kt"); From 96b79eebe7b923aa81fc808db9482f40d02c12df Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 10 Jul 2015 19:15:56 +0300 Subject: [PATCH 267/450] asSequence returns empty sequence singleton for empty arrays and strings. #KT-8450 Fixed --- libraries/stdlib/src/generated/_Sequences.kt | 10 ++++++++++ .../kotlin-stdlib-gen/src/templates/Sequence.kt | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index d2e1b314b20..6e99878fc17 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -14,6 +14,7 @@ import java.util.Collections // TODO: it's temporary while we have java.util.Col * Returns a sequence from the given collection. */ public fun Array.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -25,6 +26,7 @@ public fun Array.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun BooleanArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -36,6 +38,7 @@ public fun BooleanArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun ByteArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -47,6 +50,7 @@ public fun ByteArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun CharArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -58,6 +62,7 @@ public fun CharArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun DoubleArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -69,6 +74,7 @@ public fun DoubleArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun FloatArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -80,6 +86,7 @@ public fun FloatArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun IntArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -91,6 +98,7 @@ public fun IntArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun LongArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -102,6 +110,7 @@ public fun LongArray.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun ShortArray.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() @@ -142,6 +151,7 @@ public fun Sequence.asSequence(): Sequence { * Returns a sequence from the given collection. */ public fun String.asSequence(): Sequence { + if (isEmpty()) return emptySequence() return object : Sequence { override fun iterator(): Iterator { return this@asSequence.iterator() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt index 8f25dbb53cb..6fb929dc583 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt @@ -26,7 +26,6 @@ fun sequences(): List { } templates add f("asSequence()") { include(Maps) - exclude(Sequences) doc { "Returns a sequence from the given collection." } returns("Sequence") body { @@ -39,6 +38,17 @@ fun sequences(): List { """ } + body(ArraysOfObjects, ArraysOfPrimitives, Strings) { + """ + if (isEmpty()) return emptySequence() + return object : Sequence { + override fun iterator(): Iterator { + return this@asSequence.iterator() + } + } + """ + } + body(Sequences) { """ return this From e080753dc2686459c5786fcdb9d55453ad14c85c Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 6 Jul 2015 20:31:43 +0300 Subject: [PATCH 268/450] Provide toMap and putAll for Arrays and Sequences of key-value pairs. #KT-4166 Fixed --- .../stdlib/src/kotlin/collections/Maps.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 2a694cc2aea..099b350a108 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -222,6 +222,15 @@ public fun MutableMap.putAll(values: Iterable>): Unit { } } +/** + * Puts all the elements of the given sequence into this [MutableMap] with the first component in the pair being the key and the second the value. + */ +public fun MutableMap.putAll(values: Sequence>): Unit { + for ((key, value) in values) { + put(key, value) + } +} + /** * Returns a new map with entries having the keys of this map and the values obtained by applying the `transform` * function to each entry in this [Map]. @@ -336,6 +345,29 @@ public fun MutableMap.plusAssign(map: Map) { * Returns a new map containing all key-value pairs from the given collection of pairs. */ public fun Iterable>.toMap(): Map { + val result = LinkedHashMap(collectionSizeOrNull()?.let { mapCapacity(it) } ?: 16) + for (element in this) { + result.put(element.first, element.second) + } + return result +} + +/** + * Returns a new map containing all key-value pairs from the given array of pairs. + */ +public fun Array>.toMap(): Map { + val result = LinkedHashMap(mapCapacity(size())) + for (element in this) { + result.put(element.first, element.second) + } + return result +} + +/** + * Returns a new map containing all key-value pairs from the given sequence of pairs. + */ + +public fun Sequence>.toMap(): Map { val result = LinkedHashMap() for (element in this) { result.put(element.first, element.second) From d1a12aa2a7de5d1774bd78c82a9fc8e6c357a77a Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 9 Jul 2015 21:24:33 +0300 Subject: [PATCH 269/450] plus, plusAssign, minus, minusAssign for all possible parameter types for Maps. #KT-6594 Fixed --- .../stdlib/src/kotlin/collections/Maps.kt | 133 +++++++++++--- libraries/stdlib/test/collections/MapTest.kt | 170 ++++++++---------- 2 files changed, 184 insertions(+), 119 deletions(-) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index 099b350a108..4e2fbee23a7 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -320,27 +320,6 @@ public inline fun Map.filterNot(predicate: (Map.Entry) -> Boo return filterNotTo(LinkedHashMap(), predicate) } -/** - * Appends or replaces the given [pair] in this mutable map. - */ -public fun MutableMap.plusAssign(pair: Pair) { - put(pair.first, pair.second) -} - -/** - * Appends or replaces all pairs from the given collection of [pairs] in this mutable map. - */ -public fun MutableMap.plusAssign(pairs: Iterable>) { - putAll(pairs) -} - -/** - * Appends or replaces all entries from the given [map] in this mutable map. - */ -public fun MutableMap.plusAssign(map: Map) { - putAll(map) -} - /** * Returns a new map containing all key-value pairs from the given collection of pairs. */ @@ -398,6 +377,24 @@ public fun Map.plus(pairs: Iterable>): Map { return newMap } +/** + * Creates a new read-only map by replacing or adding entries to this map from a given array of key-value [pairs]. + */ +public fun Map.plus(pairs: Array>): Map { + val newMap = this.toLinkedMap() + newMap.putAll(*pairs) + return newMap +} + +/** + * Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value [pairs]. + */ +public fun Map.plus(pairs: Sequence>): Map { + val newMap = this.toLinkedMap() + newMap.putAll(pairs) + return newMap +} + /** * Creates a new read-only map by replacing or adding entries to this map from another [map]. */ @@ -407,21 +404,101 @@ public fun Map.plus(map: Map): Map { return newMap } +/** + * Appends or replaces the given [pair] in this mutable map. + */ +public fun MutableMap.plusAssign(pair: Pair) { + put(pair.first, pair.second) +} + +/** + * Appends or replaces all pairs from the given collection of [pairs] in this mutable map. + */ +public fun MutableMap.plusAssign(pairs: Iterable>) { + putAll(pairs) +} + +/** + * Appends or replaces all pairs from the given array of [pairs] in this mutable map. + */ +public fun MutableMap.plusAssign(pairs: Array>) { + putAll(*pairs) +} + +/** + * Appends or replaces all pairs from the given sequence of [pairs] in this mutable map. + */ +public fun MutableMap.plusAssign(pairs: Sequence>) { + putAll(pairs) +} + +/** + * Appends or replaces all entries from the given [map] in this mutable map. + */ +public fun MutableMap.plusAssign(map: Map) { + putAll(map) +} + /** * Creates a new read-only map by removing a [key] from this map. */ public fun Map.minus(key: K): Map { - return this.filterKeys { key != it } + val result = LinkedHashMap(this) + result.minusAssign(key) + return result } /** * Creates a new read-only map by removing a collection of [keys] from this map. */ public fun Map.minus(keys: Iterable): Map { - val result = LinkedHashMap() - result.putAll(this) - for (entry in keys) { - result.remove(entry) - } + val result = LinkedHashMap(this) + result.minusAssign(keys) return result -} \ No newline at end of file +} + +/** + * Creates a new read-only map by removing a array of [keys] from this map. + */ +public fun Map.minus(keys: Array): Map { + val result = LinkedHashMap(this) + result.minusAssign(keys) + return result +} + +/** + * Creates a new read-only map by removing a sequence of [keys] from this map. + */ +public fun Map.minus(keys: Sequence): Map { + val result = LinkedHashMap(this) + result.minusAssign(keys) + return result +} + +/** + * Removes the given [key] from this mutable map. + */ +public fun MutableMap.minusAssign(key: K) { + remove(key) +} + +/** + * Removes all the given [keys] from this mutable map. + */ +public fun MutableMap.minusAssign(keys: Iterable) { + for (key in keys) remove(key) +} + +/** + * Removes all the given [keys] from this mutable map. + */ +public fun MutableMap.minusAssign(keys: Array) { + for (key in keys) remove(key) +} + +/** + * Removes all the given [keys] from this mutable map. + */ +public fun MutableMap.minusAssign(keys: Sequence) { + for (key in keys) remove(key) +} diff --git a/libraries/stdlib/test/collections/MapTest.kt b/libraries/stdlib/test/collections/MapTest.kt index 2a2e1c72f90..6eeec4ed7e4 100644 --- a/libraries/stdlib/test/collections/MapTest.kt +++ b/libraries/stdlib/test/collections/MapTest.kt @@ -268,120 +268,108 @@ class MapTest { assertEquals(3, filteredByValue["b"]) } - test fun plusAssign() { - val extended = hashMapOf(Pair("b", 3)) - extended += ("c" to 2) - assertEquals(2, extended.size()) - assertEquals(2, extended["c"]) - assertEquals(3, extended["b"]) + fun testPlusAssign(doPlusAssign: (MutableMap) -> Unit) { + val map = hashMapOf("a" to 1, "b" to 2) + doPlusAssign(map) + assertEquals(3, map.size()) + assertEquals(1, map["a"]) + assertEquals(4, map["b"]) + assertEquals(3, map["c"]) } - test fun plusAssignList() { - val extended = hashMapOf(Pair("b", 3)) - extended += listOf("C" to 3, "D" to 4) + test fun plusAssign() = testPlusAssign { + it += "b" to 4 + it += "c" to 3 + } + + test fun plusAssignList() = testPlusAssign { it += listOf("c" to 3, "b" to 4) } + + test fun plusAssignArray() = testPlusAssign { it += arrayOf("c" to 3, "b" to 4) } + + test fun plusAssignSequence() = testPlusAssign { it += sequenceOf("c" to 3, "b" to 4) } + + test fun plusAssignMap() = testPlusAssign { it += mapOf("c" to 3, "b" to 4) } + + fun testPlus(doPlus: (Map) -> Map) { + val original = mapOf("A" to 1, "B" to 2) + val extended = doPlus(original) assertEquals(3, extended.size()) + assertEquals(1, extended["A"]) + assertEquals(4, extended["B"]) assertEquals(3, extended["C"]) - assertEquals(4, extended["D"]) } - test fun plusAssignMap() { - val extended = hashMapOf(Pair("b", 3)) - extended += mapOf("C" to 3, "D" to 4) - assertEquals(3, extended.size()) - assertEquals(3, extended["C"]) - assertEquals(4, extended["D"]) - } + test fun plus() = testPlus { it + ("C" to 3) + ("B" to 4) } - test fun plus() { + test fun plusList() = testPlus { it + listOf("C" to 3, "B" to 4) } + + test fun plusArray() = testPlus { it + arrayOf("C" to 3, "B" to 4) } + + test fun plusSequence() = testPlus { it + sequenceOf("C" to 3, "B" to 4) } + + test fun plusMap() = testPlus { it + mapOf("C" to 3, "B" to 4) } + + + fun testMinus(doMinus: (Map) -> Map) { val original = mapOf("A" to 1, "B" to 2) - val extended = original + ("C" to 3) - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 2) - assertEquals(extended["C"], 3) + val shortened = doMinus(original) + assertEquals("A" to 1, shortened.entrySet().single().toPair()) } - test fun plusList() { - val original = mapOf("A" to 1, "B" to 2) - val extended = original + listOf("C" to 3, "D" to 4) - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 2) - assertEquals(extended["C"], 3) - assertEquals(extended["D"], 4) + test fun minus() = testMinus { it - "B" - "C" } + + test fun minusList() = testMinus { it - listOf("B", "C") } + + test fun minusArray() = testMinus { it - arrayOf("B", "C") } + + test fun minusSequence() = testMinus { it - sequenceOf("B", "C") } + + test fun minusSet() = testMinus { it - setOf("B", "C") } + + + + fun testMinusAssign(doMinusAssign: (MutableMap) -> Unit) { + val original = hashMapOf("A" to 1, "B" to 2) + doMinusAssign(original) + assertEquals("A" to 1, original.entrySet().single().toPair()) } - test fun plusMap() { - val original = mapOf("A" to 1, "B" to 2) - val extended = original + mapOf("C" to 3, "D" to 4) - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 2) - assertEquals(extended["C"], 3) - assertEquals(extended["D"], 4) + test fun minusAssign() = testMinusAssign { + it -= "B" + it -= "C" } - test fun plusListOverload() { + test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") } + + test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") } + + test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") } + + + fun testIdempotent(operation: (Map) -> Map) { val original = mapOf("A" to 1, "B" to 2) - val extended = original + listOf("B" to 3, "C" to 4) - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 3) - assertEquals(extended["C"], 4) + assertEquals(original, operation(original)) } - test fun plusEmptyList() { - val original = mapOf("A" to 1, "B" to 2) - val extended = original + listOf() - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 2) + fun testIdempotentAssign(operation: (MutableMap) -> Unit) { + val original = hashMapOf("A" to 1, "B" to 2) + val result = HashMap(original) + operation(result) + assertEquals(original, result) } - test fun plusEmptySet() { - val original = mapOf("A" to 1, "B" to 2) - val extended = original + setOf() - assertEquals(extended["A"], 1) - assertEquals(extended["B"], 2) - } - test fun minus() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - "B" - assertEquals(shortened["A"], 1) - assertFalse(shortened.contains("B")) - } + test fun plusEmptyList() = testIdempotent { it + listOf() } + test fun minusEmptyList() = testIdempotent { it - listOf() } - test fun minusNotElem() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - "C" - assertEquals(shortened["A"], 1) - assertEquals(shortened["B"], 2) - } + test fun plusEmptySet() = testIdempotent { it + setOf() } + test fun minusEmptySet() = testIdempotent { it - setOf() } - test fun minusList() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - listOf("B", "C") - assertEquals(shortened["A"], 1) - assertFalse(shortened.contains("B")) - assertFalse(shortened.contains("C")) - } + test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() } + test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() } - test fun minusListNotElem() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - listOf("C", "D") - assertEquals(shortened["A"], 1) - assertEquals(shortened["B"], 2) - } + test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() } + test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() } - test fun minusSet() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - setOf("B", "C") - assertEquals(shortened["A"], 1) - assertFalse(shortened.contains("B")) - assertFalse(shortened.contains("C")) - } - - test fun minusEmptySet() { - val original = mapOf("A" to 1, "B" to 2) - val shortened = original - setOf() - assertEquals(shortened["A"], 1) - assertEquals(shortened["B"], 2) - } } From 10c376975a994d1e8c998d67b2332af00d1f0e25 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 5 Jul 2015 17:26:08 +0300 Subject: [PATCH 270/450] Stdlib generators: refactor and eliminate warnings, add families of Sets and InvariantArrays, allow to specify custom signature for particular families. --- .../src/generators/GenerateStandardLib.kt | 4 +- .../src/templates/Comparables.kt | 8 +-- .../kotlin-stdlib-gen/src/templates/Engine.kt | 69 ++++++++++++------- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt index 09e58ca95a2..692ecc0087c 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt @@ -17,7 +17,7 @@ private val COMMON_AUTOGENERATED_WARNING: String = """// * at runtime. */ fun main(args: Array) { - require(args.size == 1, "Expecting Kotlin project home path as an argument") + require(args.size() == 1, "Expecting Kotlin project home path as an argument") val outDir = File(File(args[0]), "libraries/stdlib/src/generated") require(outDir.exists(), "${outDir.getPath()} doesn't exist!") @@ -31,8 +31,6 @@ fun main(args: Array) { generateDownTos(File(outDir, "_DownTo.kt"), "package kotlin") } -fun String.flat() = this.replaceAll(" ", "") - fun List.writeTo(file: File, builder: GenericFunction.() -> String) { println("Generating file: ${file.getPath()}") val its = FileWriter(file) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt index fda97e8d062..f6a3b8eb67e 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt @@ -7,7 +7,7 @@ fun comparables(): List { templates add f("coerceAtLeast(minimumValue: SELF)") { only(Primitives, Generic) - only(*numericPrimitives) + only(numericPrimitives) returns("SELF") typeParam("T: Comparable") doc { @@ -27,7 +27,7 @@ fun comparables(): List { templates add f("coerceAtMost(maximumValue: SELF)") { only(Primitives, Generic) - only(*numericPrimitives) + only(numericPrimitives) returns("SELF") typeParam("T: Comparable") doc { @@ -46,7 +46,7 @@ fun comparables(): List { templates add f("coerceIn(range: TRange)") { only(Primitives, Generic) - only(*numericPrimitives) + only(numericPrimitives) returns("SELF") typeParam("T: Comparable") doc { @@ -66,7 +66,7 @@ fun comparables(): List { templates add f("coerceIn(minimumValue: SELF?, maximumValue: SELF?)") { only(Primitives, Generic) - only(*numericPrimitives) + only(numericPrimitives) returns("SELF") typeParam("T: Comparable") doc { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt index d271af9f2a5..a27564d565e 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt @@ -12,26 +12,40 @@ enum class Family { Collections, Lists, Maps, + Sets, ArraysOfObjects, ArraysOfPrimitives, + InvariantArraysOfObjects, Strings, RangesOfPrimitives, ProgressionsOfPrimitives, Primitives, Generic; - val isPrimitiveSpecialization: Boolean by Delegates.lazy { this in listOf(ArraysOfPrimitives, RangesOfPrimitives, ProgressionsOfPrimitives, Primitives) } + val isPrimitiveSpecialization: Boolean by lazy { this in primitiveSpecializations } + + companion object { + val primitiveSpecializations = setOf(ArraysOfPrimitives, RangesOfPrimitives, ProgressionsOfPrimitives, Primitives) + val defaultFamilies = setOf(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Strings) + } } -enum class PrimitiveType(val name: String) { - Boolean("Boolean"), - Byte("Byte"), - Char("Char"), - Short("Short"), - Int("Int"), - Long("Long"), - Float("Float"), - Double("Double") +enum class PrimitiveType { + Boolean, + Byte, + Char, + Short, + Int, + Long, + Float, + Double; + + val name: String get() = this.name() + + companion object { + val defaultPrimitives = PrimitiveType.values().toSet() + val numericPrimitives = setOf(PrimitiveType.Int, PrimitiveType.Long, PrimitiveType.Byte, PrimitiveType.Short, PrimitiveType.Double, PrimitiveType.Float) + } } @@ -63,17 +77,18 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp open class PrimitiveProperty() : SpecializedProperty() - val defaultFamilies = array(Iterables, Sequences, ArraysOfObjects, ArraysOfPrimitives, Strings) - val defaultPrimitives = PrimitiveType.values() - val numericPrimitives = array(PrimitiveType.Int, PrimitiveType.Long, PrimitiveType.Byte, PrimitiveType.Short, PrimitiveType.Double, PrimitiveType.Float) + val defaultFamilies = Family.defaultFamilies + val defaultPrimitives = PrimitiveType.defaultPrimitives + val numericPrimitives = PrimitiveType.numericPrimitives var toNullableT: Boolean = false var receiverAsterisk = false - val buildFamilies = LinkedHashSet(defaultFamilies.toList()) - val buildPrimitives = LinkedHashSet(defaultPrimitives.toList()) + val buildFamilies = LinkedHashSet(defaultFamilies) + val buildPrimitives = LinkedHashSet(defaultPrimitives) + val customSignature = FamilyProperty() val deprecate = FamilyProperty() val deprecateReplacement = FamilyProperty() val doc = FamilyProperty() @@ -112,8 +127,12 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp } fun only(vararg primitives: PrimitiveType) { + only(primitives.asList()) + } + + fun only(primitives: Collection) { buildPrimitives.clear() - buildPrimitives.addAll(primitives.toList()) + buildPrimitives.addAll(primitives) } fun include(vararg families: Family) { @@ -156,15 +175,16 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp Collections -> "Collection<$isAsteriskOrT>" Lists -> "List<$isAsteriskOrT>" Maps -> "Map" + Sets -> "Set<$isAsteriskOrT>" Sequences -> "Sequence<$isAsteriskOrT>" - ArraysOfObjects -> "Array<$isAsteriskOrT>" + InvariantArraysOfObjects -> "Array" + ArraysOfObjects -> "Array<${isAsteriskOrT.replace("T", "out T")}>" Strings -> "String" ArraysOfPrimitives -> primitive?.let { it.name() + "Array" } ?: throw IllegalArgumentException("Primitive array should specify primitive type") RangesOfPrimitives -> primitive?.let { it.name() + "Range" } ?: throw IllegalArgumentException("Primitive range should specify primitive type") ProgressionsOfPrimitives -> primitive?.let { it.name() + "Progression" } ?: throw IllegalArgumentException("Primitive progression should specify primitive type") Primitives -> primitive?.let { it.name } ?: throw IllegalArgumentException("Primitive should specify primitive type") Generic -> "T" - else -> throw IllegalStateException("Invalid family") } @@ -175,7 +195,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp while (t.hasMoreTokens()) { val token = t.nextToken() answer.append(when (token) { - "SELF" -> if (receiver == "Array") "Array" else receiver + "SELF" -> receiver "PRIMITIVE" -> primitive?.name() ?: token "SUM" -> { when (primitive) { @@ -244,7 +264,8 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp return types } else if (primitive == null && f != Strings) { - val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).filterNot { it == ' ' }.takeWhile { it != '>' }.split(",") + val implicitTypeParameters = receiver.dropWhile { it != '<' }.drop(1).takeWhile { it != '>' }.split(",") + .map { it.removePrefix("out").removePrefix("in").trim() } for (implicit in implicitTypeParameters.reverse()) { if (implicit != "*" && !types.any { it.startsWith(implicit) || it.startsWith("reified " + implicit) }) { types.add(0, implicit) @@ -293,14 +314,10 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp builder.append(types.join(separator = ", ", prefix = "<", postfix = "> ").renderType()) } - val receiverType = (when (receiver) { - "Array" -> if (toNullableT) "Array" else "Array" - else -> if (toNullableT) receiver.replace("T>", "T?>") else receiver - }).renderType() - + val receiverType = (if (toNullableT) receiver.replace("T>", "T?>") else receiver).renderType() builder.append(receiverType) - builder.append(".${signature.renderType()}: ${returnType.renderType()}") + builder.append(".${(customSignature[f] ?: signature).renderType()}: ${returnType.renderType()}") if (keyword == "fun") builder.append(" {") val body = (customPrimitiveBodies[f to primitive] ?: body[f] ?: throw RuntimeException("No body specified for $signature for ${f to primitive}")).trim('\n') From 0a320a13e5a9c8d5647d32efe9395b5184c1d5a7 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 6 Jul 2015 19:22:33 +0300 Subject: [PATCH 271/450] Stdlib generators: change constants for Long: ZERO, ONE, -ONE. --- libraries/stdlib/src/generated/_Numeric.kt | 8 ++++---- libraries/stdlib/src/generated/_Ranges.kt | 2 +- libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/src/generated/_Numeric.kt b/libraries/stdlib/src/generated/_Numeric.kt index df318f6ca04..d5c21a19a87 100644 --- a/libraries/stdlib/src/generated/_Numeric.kt +++ b/libraries/stdlib/src/generated/_Numeric.kt @@ -421,7 +421,7 @@ public fun IntArray.sum(): Int { platformName("sumOfLong") public fun Iterable.sum(): Long { val iterator = iterator() - var sum: Long = 0 + var sum: Long = 0L while (iterator.hasNext()) { sum += iterator.next() } @@ -434,7 +434,7 @@ public fun Iterable.sum(): Long { platformName("sumOfLong") public fun Sequence.sum(): Long { val iterator = iterator() - var sum: Long = 0 + var sum: Long = 0L while (iterator.hasNext()) { sum += iterator.next() } @@ -447,7 +447,7 @@ public fun Sequence.sum(): Long { platformName("sumOfLong") public fun Array.sum(): Long { val iterator = iterator() - var sum: Long = 0 + var sum: Long = 0L while (iterator.hasNext()) { sum += iterator.next() } @@ -459,7 +459,7 @@ public fun Array.sum(): Long { */ public fun LongArray.sum(): Long { val iterator = iterator() - var sum: Long = 0 + var sum: Long = 0L while (iterator.hasNext()) { sum += iterator.next() } diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index 0b283ce0a43..5d68386518e 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -98,7 +98,7 @@ public fun IntRange.reversed(): IntProgression { * Returns a progression that goes over this range in reverse direction. */ public fun LongRange.reversed(): LongProgression { - return LongProgression(end, start, -1.toLong()) + return LongProgression(end, start, -1L) } /** diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt index a27564d565e..f53107a214d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Engine.kt @@ -206,18 +206,19 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp "ZERO" -> when (primitive) { PrimitiveType.Double -> "0.0" PrimitiveType.Float -> "0.0f" + PrimitiveType.Long -> "0L" else -> "0" } "ONE" -> when (primitive) { PrimitiveType.Double -> "1.0" PrimitiveType.Float -> "1.0f" - PrimitiveType.Long -> "1.toLong()" + PrimitiveType.Long -> "1L" else -> "1" } "-ONE" -> when (primitive) { PrimitiveType.Double -> "-1.0" PrimitiveType.Float -> "-1.0f" - PrimitiveType.Long -> "-1.toLong()" + PrimitiveType.Long -> "-1L" else -> "-1" } "TCollection" -> { From 4de5dd9aeb3cae8507026b0cd8d149ce76173e7b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 8 Jul 2015 20:32:37 +0300 Subject: [PATCH 272/450] Drop deprecated FunctionalList, FunctionalQueue. Remove dependency on FunctionalList from tests. --- .../imports/DependencyOnStdLib.expected.kt | 4 +- .../imports/DependencyOnStdLib.expected.names | 2 +- .../copyPaste/imports/DependencyOnStdLib.kt | 4 +- .../insertImportForArg.kt | 2 +- .../insertImportForArg.kt.after | 6 +- .../src/kotlin/concurrent/FunctionalList.kt | 57 ------------------- .../src/kotlin/concurrent/FunctionalQueue.kt | 31 ---------- libraries/stdlib/test/concurrent/FListTest.kt | 16 ------ 8 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt delete mode 100644 libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt delete mode 100644 libraries/stdlib/test/concurrent/FListTest.kt diff --git a/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.kt b/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.kt index 5f2a0f5472c..89767829ef2 100644 --- a/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.kt +++ b/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.kt @@ -1,5 +1,5 @@ package to -import kotlin.concurrent.FunctionalList +import kotlin.properties.ObservableProperty -fun f(l: FunctionalList) {} \ No newline at end of file +fun f(l: ObservableProperty) {} \ No newline at end of file diff --git a/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.names b/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.names index 1e28860500b..2a89ec4170a 100644 --- a/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.names +++ b/idea/testData/copyPaste/imports/DependencyOnStdLib.expected.names @@ -1,2 +1,2 @@ kotlin.Int -kotlin.concurrent.FunctionalList +kotlin.properties.ObservableProperty diff --git a/idea/testData/copyPaste/imports/DependencyOnStdLib.kt b/idea/testData/copyPaste/imports/DependencyOnStdLib.kt index 4c5c5306087..73104657ebc 100644 --- a/idea/testData/copyPaste/imports/DependencyOnStdLib.kt +++ b/idea/testData/copyPaste/imports/DependencyOnStdLib.kt @@ -2,6 +2,6 @@ package g -import kotlin.concurrent.FunctionalList +import kotlin.properties.ObservableProperty -fun f(l: FunctionalList) {} \ No newline at end of file +fun f(l: ObservableProperty) {} \ No newline at end of file diff --git a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt index 10e3f0aff50..ab3c5d372c9 100644 --- a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt +++ b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt @@ -1,4 +1,4 @@ -fun foo(c: kotlin.support.AbstractIterator>) { +fun foo(c: kotlin.support.AbstractIterator>) { bar(c) } diff --git a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after index 1e09c2b3b66..2e636643e12 100644 --- a/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after +++ b/idea/testData/intentions/insertExplicitTypeArguments/insertImportForArg.kt.after @@ -1,8 +1,8 @@ -import kotlin.concurrent.FunctionalList +import kotlin.properties.ObservableProperty import kotlin.support.AbstractIterator -fun foo(c: kotlin.support.AbstractIterator>) { - bar>>(c) +fun foo(c: kotlin.support.AbstractIterator>) { + bar>>(c) } fun bar(t: T): T = t diff --git a/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt b/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt deleted file mode 100644 index e54a6e9e583..00000000000 --- a/libraries/stdlib/src/kotlin/concurrent/FunctionalList.kt +++ /dev/null @@ -1,57 +0,0 @@ -package kotlin.concurrent - -deprecated("This class is unfinished work. It will be removed from the standard library and replaced by a separate persistent collections library") -public abstract class FunctionalList(public val size: Int) { - public abstract val head: T - public abstract val tail: FunctionalList - - public val empty: Boolean - get() = size == 0 - - public fun add(element: T): FunctionalList = FunctionalList.Standard(element, this) - - public fun reversed(): FunctionalList { - if(empty) - return this - - var cur = tail - var new = of(head) - - while(!cur.empty) { - new = new.add(cur.head) - cur = cur.tail - } - return new - } - - public fun iterator() : Iterator = object: Iterator { - var cur = this@FunctionalList - - public override fun next(): T { - if(cur.empty) - throw java.util.NoSuchElementException() - - val head = cur.head - cur = cur.tail - return head - } - - override fun hasNext(): Boolean = !cur.empty - } - - private class Empty() : FunctionalList(0) { - override val head: T - get() = throw java.util.NoSuchElementException() - override val tail: FunctionalList - get() = throw java.util.NoSuchElementException() - } - - private class Standard(override val head: T, override val tail: FunctionalList) : FunctionalList(tail.size + 1) - - companion object { - public fun emptyList(): FunctionalList = Empty() - - public fun of(element: T): FunctionalList = FunctionalList.Standard(element, emptyList()) - } -} - diff --git a/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt b/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt deleted file mode 100644 index 5e51e1cbe26..00000000000 --- a/libraries/stdlib/src/kotlin/concurrent/FunctionalQueue.kt +++ /dev/null @@ -1,31 +0,0 @@ -package kotlin.concurrent - -import java.util.concurrent.Executor - -deprecated("This class is unfinished work. It will be removed from the standard library and replaced by a separate persistent collections library") -public class FunctionalQueue ( - private val input: FunctionalList = FunctionalList.emptyList(), - private val output: FunctionalList = FunctionalList.emptyList() -) { - - public val size: Int - get() = input.size + output.size - - public val empty: Boolean - get() = size == 0 - - public fun add(element: T): FunctionalQueue = FunctionalQueue(input add element, output) - - public fun addFirst(element: T): FunctionalQueue = FunctionalQueue(input, output add element) - - public fun removeFirst(): Pair> = - if (output.empty) { - if (input.empty) - throw java.util.NoSuchElementException() - else - FunctionalQueue(FunctionalList.emptyList(), input.reversed()).removeFirst() - } - else { - Pair(output.head, FunctionalQueue(input, output.tail)) - } -} diff --git a/libraries/stdlib/test/concurrent/FListTest.kt b/libraries/stdlib/test/concurrent/FListTest.kt deleted file mode 100644 index fbc89746f6a..00000000000 --- a/libraries/stdlib/test/concurrent/FListTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package test.concurrent - -import kotlin.concurrent.* -import junit.framework.* - -class FListTest() : TestCase() { - fun testEmpty() { - val empty = FunctionalQueue () - Assert.assertTrue(empty.empty) - } - - fun testNonEmpty() { -// val empty = FunctionalList.emptyList () -// assertTrue(!(empty + 10).empty) - } -} From 8b325e8a307fd560902b6b79cf856ade3a0c345c Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 3 Jul 2015 19:09:52 +0300 Subject: [PATCH 273/450] Make ByteArray.inputStream a method, not a property. #KT-8360 Fixed --- libraries/stdlib/src/kotlin/collections/ArraysJVM.kt | 10 ++++++++-- libraries/stdlib/test/OldStdlibTest.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt index 729e9dddb36..0a5b2103b0b 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt @@ -52,12 +52,18 @@ import kotlin.jvm.internal.Intrinsic */ @Intrinsic("kotlin.arrays.array") public fun booleanArrayOf(vararg content : Boolean) : BooleanArray = content +// TODO: Move inputStream to kotlin.io +/** + * Creates an input stream for reading data from this byte array. + */ +deprecated("Use inputStream() method instead.", ReplaceWith("this.inputStream()")) +public val ByteArray.inputStream : ByteArrayInputStream + get() = inputStream() /** * Creates an input stream for reading data from this byte array. */ -public val ByteArray.inputStream : ByteArrayInputStream - get() = ByteArrayInputStream(this) +public fun ByteArray.inputStream(): ByteArrayInputStream = ByteArrayInputStream(this) /** * Creates an input stream for reading data from the specified portion of this byte array. diff --git a/libraries/stdlib/test/OldStdlibTest.kt b/libraries/stdlib/test/OldStdlibTest.kt index ea2a88713ad..60b911d99fa 100644 --- a/libraries/stdlib/test/OldStdlibTest.kt +++ b/libraries/stdlib/test/OldStdlibTest.kt @@ -27,7 +27,7 @@ class OldStdlibTest() { x [index] = index.toByte() } - for(b in x.inputStream) { + for(b in x.inputStream()) { println(b) } } From c19785252cf37287bda7a763d308e22dc360dc10 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 15 Jul 2015 16:14:01 +0300 Subject: [PATCH 274/450] Sealed classes now are decompiled correctly + test #EA-70762 Fixed --- .../decompiler/stubBuilder/clsStubBuilding.kt | 3 +- .../decompiler/stubBuilder/Sealed/Sealed.kt | 6 ++++ .../decompiler/stubBuilder/Sealed/Sealed.txt | 33 +++++++++++++++++++ .../ClsStubBuilderTestGenerated.java | 6 ++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 idea/testData/decompiler/stubBuilder/Sealed/Sealed.kt create mode 100644 idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index 39716526e45..b66cc21dac1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -116,7 +116,8 @@ enum class FlagsToModifiers { ProtoBuf.Modality.ABSTRACT -> JetTokens.ABSTRACT_KEYWORD ProtoBuf.Modality.FINAL -> JetTokens.FINAL_KEYWORD ProtoBuf.Modality.OPEN -> JetTokens.OPEN_KEYWORD - else -> throw IllegalStateException("Unexpected modality: $modality") + ProtoBuf.Modality.SEALED -> JetTokens.SEALED_KEYWORD + null -> throw IllegalStateException("Unexpected modality: null") } } }, diff --git a/idea/testData/decompiler/stubBuilder/Sealed/Sealed.kt b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.kt new file mode 100644 index 00000000000..53be5967af5 --- /dev/null +++ b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.kt @@ -0,0 +1,6 @@ +package test + +sealed class Sealed { + class Nested: Sealed() + object Top: Sealed() +} diff --git a/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt new file mode 100644 index 00000000000..389c3ed96da --- /dev/null +++ b/idea/testData/decompiler/stubBuilder/Sealed/Sealed.txt @@ -0,0 +1,33 @@ +PsiJetFileStubImpl[package=test] + PACKAGE_DIRECTIVE: + REFERENCE_EXPRESSION:[referencedName=test] + IMPORT_LIST: + CLASS:[fqName=test.Sealed, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=Sealed, superNames=[]] + MODIFIER_LIST:[internal sealed] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[private] + VALUE_PARAMETER_LIST: + CLASS_BODY: + CLASS:[fqName=test.Sealed.Nested, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Nested, superNames=[Sealed]] + MODIFIER_LIST:[internal final] + PRIMARY_CONSTRUCTOR: + MODIFIER_LIST:[public] + VALUE_PARAMETER_LIST: + DELEGATION_SPECIFIER_LIST: + DELEGATOR_SUPER_CLASS: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=Sealed] + CLASS_BODY: + OBJECT_DECLARATION:[fqName=test.Sealed.Top, isCompanion=false, isLocal=false, isObjectLiteral=false, isTopLevel=false, name=Top, superNames=[Sealed]] + MODIFIER_LIST:[internal] + DELEGATION_SPECIFIER_LIST: + DELEGATOR_SUPER_CLASS: + TYPE_REFERENCE: + USER_TYPE:[isAbsoluteInRootPackage=false] + USER_TYPE:[isAbsoluteInRootPackage=false] + REFERENCE_EXPRESSION:[referencedName=test] + REFERENCE_EXPRESSION:[referencedName=Sealed] + CLASS_BODY: diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java index 269eb227ffb..d46059314e0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java @@ -125,6 +125,12 @@ public class ClsStubBuilderTestGenerated extends AbstractClsStubBuilderTest { doTest(fileName); } + @TestMetadata("Sealed") + public void testSealed() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/Sealed/"); + doTest(fileName); + } + @TestMetadata("SecondaryConstructors") public void testSecondaryConstructors() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/SecondaryConstructors/"); From 44dffa7bbc610cd8ee65bc5b69a9b43efddfe291 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 29 Jun 2015 19:26:20 +0300 Subject: [PATCH 275/450] Minor: remove a couple of usages of KotlinBuiltIns.getInstance() --- .../codegen/CollectionStubMethodGenerator.kt | 30 ++++++++++--------- .../codegen/binding/CodegenBinding.java | 5 ++-- .../lazy/descriptors/LazyJavaMemberScope.kt | 5 ++-- .../impl/AbstractTypeParameterDescriptor.java | 7 +++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt index 4b466be340e..542ea8cdd9c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt @@ -18,23 +18,25 @@ package org.jetbrains.kotlin.codegen import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.* -import org.jetbrains.kotlin.descriptors.impl.* -import org.jetbrains.org.objectweb.asm.Opcodes.* -import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin -import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.types.* -import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.impl.MutableClassDescriptor +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.OverrideResolver import org.jetbrains.kotlin.resolve.OverridingUtil -import java.util.LinkedHashSet -import org.jetbrains.kotlin.name.Name -import java.util.ArrayList -import org.jetbrains.kotlin.types.checker.JetTypeChecker -import java.util.HashSet +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns +import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_ABSTRACT +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC +import org.jetbrains.org.objectweb.asm.Opcodes.ACC_SYNTHETIC +import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter +import java.util.ArrayList +import java.util.HashSet +import java.util.LinkedHashSet /** * Generates exception-throwing stubs for methods from mutable collection classes not implemented in Kotlin classes which inherit only from @@ -127,7 +129,7 @@ class CollectionStubMethodGenerator( private fun findRelevantSuperCollectionClasses(): Collection { fun pair(readOnlyClass: ClassDescriptor, mutableClass: ClassDescriptor) = CollectionClassPair(readOnlyClass, mutableClass) - val collectionClasses = with(KotlinBuiltIns.getInstance()) { + val collectionClasses = with(descriptor.builtIns) { listOf( pair(getCollection(), getMutableCollection()), pair(getSet(), getMutableSet()), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java index bfbcb51e979..ebac3428ae2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenBinding.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen.binding; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.JvmCodegenUtil; import org.jetbrains.kotlin.codegen.SamType; import org.jetbrains.kotlin.codegen.state.GenerationState; @@ -32,6 +31,7 @@ import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingTrace; +import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice; import org.jetbrains.kotlin.util.slicedMap.Slices; @@ -207,7 +207,8 @@ public class CodegenBinding { String simpleName = asmType.getInternalName().substring(asmType.getInternalName().lastIndexOf('/') + 1); ClassDescriptorImpl classDescriptor = new ClassDescriptorImpl(descriptor, Name.special(""), Modality.FINAL, - Collections.singleton(KotlinBuiltIns.getInstance().getAnyType()), toSourceElement(script)); + Collections.singleton(DescriptorUtilPackage.getBuiltIns(descriptor).getAnyType()), + toSourceElement(script)); classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.emptySet(), null); recordClosure(trace, classDescriptor, null, asmType); diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 30b7914a38a..93e435d526c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.load.java.lazy.descriptors -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl @@ -180,7 +179,7 @@ public abstract class LazyJavaMemberScope( val paramType = javaParameter.getType() as? JavaArrayType ?: throw AssertionError("Vararg parameter should be an array: $javaParameter") val outType = c.typeResolver.transformArrayType(paramType, typeUsage, true) - outType to KotlinBuiltIns.getInstance().getArrayElementType(outType) + outType to c.module.builtIns.getArrayElementType(outType) } else { c.typeResolver.transformJavaType(javaParameter.getType(), typeUsage) to null @@ -188,7 +187,7 @@ public abstract class LazyJavaMemberScope( val name = if (function.getName().asString() == "equals" && jValueParameters.size() == 1 && - KotlinBuiltIns.getInstance().getNullableAnyType() == outType) { + c.module.builtIns.getNullableAnyType() == outType) { // This is a hack to prevent numerous warnings on Kotlin classes that inherit Java classes: if you override "equals" in such // class without this hack, you'll be warned that in the superclass the name is "p0" (regardless of the fact that it's // "other" in Any) diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java index 0726e92893f..6a094e436d2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/AbstractTypeParameterDescriptor.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.descriptors.impl; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.ReadOnly; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.kotlin.descriptors.SourceElement; @@ -36,6 +35,8 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker; import java.util.Collections; import java.util.Set; +import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getBuiltIns; + public abstract class AbstractTypeParameterDescriptor extends DeclarationDescriptorNonRootImpl implements TypeParameterDescriptor { private final Variance variance; private final boolean reified; @@ -135,7 +136,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip Set upperBounds = getUpperBounds(); assert !upperBounds.isEmpty() : "Upper bound list is empty in " + getName(); JetType upperBoundsAsType = TypeUtils.intersect(JetTypeChecker.DEFAULT, upperBounds); - return upperBoundsAsType != null ? upperBoundsAsType : KotlinBuiltIns.getInstance().getNothingType(); + return upperBoundsAsType != null ? upperBoundsAsType : getBuiltIns(this).getNothingType(); } @NotNull @@ -153,7 +154,7 @@ public abstract class AbstractTypeParameterDescriptor extends DeclarationDescrip @NotNull @Override public Set getLowerBounds() { - return Collections.singleton(KotlinBuiltIns.getInstance().getNothingType()); + return Collections.singleton(getBuiltIns(this).getNothingType()); } @NotNull From 7fef1c46134fddd7deba6c88ea996f9bc084acb1 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 29 Jun 2015 20:33:20 +0300 Subject: [PATCH 276/450] Minor: inject builtIns to CallCompleter --- .../src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 9bda02e0631..bcf7feb5529 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -45,7 +45,8 @@ import java.util.ArrayList public class CallCompleter( val argumentTypeResolver: ArgumentTypeResolver, - val candidateResolver: CandidateResolver + val candidateResolver: CandidateResolver, + val builtIns: KotlinBuiltIns ) { fun completeCall( context: BasicCallResolutionContext, @@ -154,7 +155,7 @@ public class CallCompleter( if (returnType != null && expectedType === TypeUtils.UNIT_EXPECTED_TYPE) { updateSystemIfSuccessful { system -> - system.addSupertypeConstraint(KotlinBuiltIns.getInstance().getUnitType(), returnType, EXPECTED_TYPE_POSITION.position()) + system.addSupertypeConstraint(builtIns.getUnitType(), returnType, EXPECTED_TYPE_POSITION.position()) system.getStatus().isSuccessful() } } From a6180611f49b84b9079460dea5f9e3149f82bede Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 30 Jun 2015 15:39:55 +0300 Subject: [PATCH 277/450] Convert compile constant classes to kotlin: rename files --- .../constants/{AnnotationValue.java => AnnotationValue.kt} | 0 .../kotlin/resolve/constants/{ArrayValue.java => ArrayValue.kt} | 0 .../resolve/constants/{BooleanValue.java => BooleanValue.kt} | 0 .../kotlin/resolve/constants/{ByteValue.java => ByteValue.kt} | 0 .../kotlin/resolve/constants/{CharValue.java => CharValue.kt} | 0 .../{CompileTimeConstant.java => CompileTimeConstant.kt} | 0 .../kotlin/resolve/constants/{DoubleValue.java => DoubleValue.kt} | 0 .../kotlin/resolve/constants/{EnumValue.java => EnumValue.kt} | 0 .../kotlin/resolve/constants/{ErrorValue.java => ErrorValue.kt} | 0 .../kotlin/resolve/constants/{FloatValue.java => FloatValue.kt} | 0 .../kotlin/resolve/constants/{IntValue.java => IntValue.kt} | 0 .../{IntegerValueConstant.java => IntegerValueConstant.kt} | 0 ...{IntegerValueTypeConstant.java => IntegerValueTypeConstant.kt} | 0 ...erValueTypeConstructor.java => IntegerValueTypeConstructor.kt} | 0 .../kotlin/resolve/constants/{LongValue.java => LongValue.kt} | 0 .../kotlin/resolve/constants/{NullValue.java => NullValue.kt} | 0 .../kotlin/resolve/constants/{ShortValue.java => ShortValue.kt} | 0 .../kotlin/resolve/constants/{StringValue.java => StringValue.kt} | 0 18 files changed, 0 insertions(+), 0 deletions(-) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{AnnotationValue.java => AnnotationValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{ArrayValue.java => ArrayValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{BooleanValue.java => BooleanValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{ByteValue.java => ByteValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{CharValue.java => CharValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{CompileTimeConstant.java => CompileTimeConstant.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{DoubleValue.java => DoubleValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{EnumValue.java => EnumValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{ErrorValue.java => ErrorValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{FloatValue.java => FloatValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{IntValue.java => IntValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{IntegerValueConstant.java => IntegerValueConstant.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{IntegerValueTypeConstant.java => IntegerValueTypeConstant.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{IntegerValueTypeConstructor.java => IntegerValueTypeConstructor.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{LongValue.java => LongValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{NullValue.java => NullValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{ShortValue.java => ShortValue.kt} (100%) rename core/descriptors/src/org/jetbrains/kotlin/resolve/constants/{StringValue.java => StringValue.kt} (100%) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt similarity index 100% rename from core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.java rename to core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt From 0369de86c7124c7a959641e47900168c423bc76a Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 30 Jun 2015 15:57:54 +0300 Subject: [PATCH 278/450] Convert compile constant classes to kotlin: j2k --- .../kotlin/resolve/AnnotationResolver.java | 1 - .../kotlin/resolve/AnnotationTargetChecker.kt | 2 +- .../kotlin/resolve/AnnotationUtil.kt | 2 +- .../evaluate/ConstantExpressionEvaluator.kt | 12 +-- .../serialization/AnnotationSerializer.kt | 24 ++--- .../AbstractEvaluateExpressionTest.kt | 2 +- .../kotlin/renderer/DescriptorRendererImpl.kt | 6 +- .../resolve/constants/AnnotationValue.kt | 42 +++------ .../kotlin/resolve/constants/ArrayValue.kt | 85 ++++++----------- .../kotlin/resolve/constants/BooleanValue.kt | 32 +++---- .../kotlin/resolve/constants/ByteValue.kt | 31 +++---- .../kotlin/resolve/constants/CharValue.kt | 67 ++++++-------- .../resolve/constants/CompileTimeConstant.kt | 76 +++++++-------- .../kotlin/resolve/constants/DoubleValue.kt | 31 +++---- .../kotlin/resolve/constants/EnumValue.kt | 69 +++++--------- .../kotlin/resolve/constants/ErrorValue.kt | 66 +++++-------- .../kotlin/resolve/constants/FloatValue.kt | 31 +++---- .../kotlin/resolve/constants/IntValue.kt | 55 +++++------ .../resolve/constants/IntegerValueConstant.kt | 9 +- .../constants/IntegerValueTypeConstant.kt | 81 +++++++--------- .../constants/IntegerValueTypeConstructor.kt | 92 ++++++++----------- .../kotlin/resolve/constants/KClassValue.kt | 7 +- .../kotlin/resolve/constants/LongValue.kt | 31 +++---- .../kotlin/resolve/constants/NullValue.kt | 33 +++---- .../kotlin/resolve/constants/ShortValue.kt | 31 +++---- .../kotlin/resolve/constants/StringValue.kt | 55 +++++------ .../ConvertToStringTemplateIntention.kt | 2 +- .../quickfix/DeprecatedSymbolUsageFixBase.kt | 2 +- .../js/resolve/diagnostics/JsCallChecker.kt | 2 +- 29 files changed, 377 insertions(+), 602 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 792730b3a45..06567399a62 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -63,7 +63,6 @@ import java.util.List; import java.util.Map; import static org.jetbrains.kotlin.diagnostics.Errors.NOT_AN_ANNOTATION_CLASS; -import static org.jetbrains.kotlin.resolve.BindingContext.ANNOTATION_DESCRIPTOR_TO_PSI_ELEMENT; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class AnnotationResolver { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt index 307be5f064d..6878b9d8088 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt @@ -99,7 +99,7 @@ public object AnnotationTargetChecker { ?: return DEFAULT_TARGET_LIST val valueArguments = targetEntryDescriptor.getAllValueArguments() val valueArgument = valueArguments.entrySet().firstOrNull()?.getValue() as? ArrayValue ?: return DEFAULT_TARGET_LIST - return valueArgument.getValue().filterIsInstance().map { it.getValue().getName().asString() } + return valueArgument.value.filterIsInstance().map { it.value.getName().asString() } } private fun checkAnnotationEntry(entry: JetAnnotationEntry, actualTargets: List, trace: BindingTrace) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt index 390c2556b0a..94fbbebc1e6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt @@ -59,5 +59,5 @@ private fun CallableDescriptor.isPlatformStaticIn(predicate: (DeclarationDescrip public fun AnnotationDescriptor.argumentValue(parameterName: String): Any? { return getAllValueArguments().entrySet() .singleOrNull { it.key.getName().asString() == parameterName } - ?.value?.getValue() + ?.value?.value } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 0110b9b7b4d..0b947d2ade8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -151,7 +151,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT else { if (!constant.canBeUsedInAnnotations()) canBeUsedInAnnotation = false if (constant.usesVariableAsConstant()) usesVariableAsConstant = true - sb.append(constant.getValue()) + sb.append(constant.value) } } return if (!interupted) @@ -180,8 +180,8 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val rightConstant = evaluate(rightExpression, booleanType) if (rightConstant == null) return null - val leftValue = leftConstant.getValue() - val rightValue = rightConstant.getValue() + val leftValue = leftConstant.value + val rightValue = rightConstant.value if (leftValue !is Boolean || rightValue !is Boolean) return null val result = when(operationToken) { @@ -341,7 +341,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (compileTimeConstant is IntegerValueTypeConstant) compileTimeConstant.getValue(expectedType ?: TypeUtils.NO_EXPECTED_TYPE) else - compileTimeConstant.getValue() + compileTimeConstant.value return createCompileTimeConstant(value, expectedType, isPure = false, canBeUsedInAnnotation = isPropertyCompileTimeConstant(callableDescriptor), usesVariableAsConstant = true) @@ -462,7 +462,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return OperationArgument(evaluationResultWithNewType, compileTimeType, expression) } - val evaluationResult = evaluatedConstant.getValue() + val evaluationResult = evaluatedConstant.value if (evaluationResult == null) return null return OperationArgument(evaluationResult, compileTimeType, expression) @@ -580,7 +580,7 @@ private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? { is CharValue, is DoubleValue, is FloatValue, is BooleanValue, - is NullValue -> StringValue("${value.getValue()}", value.canBeUsedInAnnotations(), value.usesVariableAsConstant()) + is NullValue -> StringValue("${value.value}", value.canBeUsedInAnnotations(), value.usesVariableAsConstant()) else -> null } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 0a23ec43013..6e6d7416e23 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -52,39 +52,39 @@ public object AnnotationSerializer { constant.accept(object : AnnotationArgumentVisitor { override fun visitAnnotationValue(value: AnnotationValue, data: Unit) { setType(Type.ANNOTATION) - setAnnotation(serializeAnnotation(value.getValue(), nameTable)) + setAnnotation(serializeAnnotation(value.value, nameTable)) } override fun visitArrayValue(value: ArrayValue, data: Unit) { setType(Type.ARRAY) - for (element in value.getValue()) { + for (element in value.value) { addArrayElement(valueProto(element, KotlinBuiltIns.getInstance().getArrayElementType(type), nameTable).build()) } } override fun visitBooleanValue(value: BooleanValue, data: Unit) { setType(Type.BOOLEAN) - setIntValue(if (value.getValue()!!) 1 else 0) + setIntValue(if (value.value) 1 else 0) } override fun visitByteValue(value: ByteValue, data: Unit) { setType(Type.BYTE) - setIntValue(value.getValue()!!.toLong()) + setIntValue(value.value.toLong()) } override fun visitCharValue(value: CharValue, data: Unit) { setType(Type.CHAR) - setIntValue(value.getValue()!!.toLong()) + setIntValue(value.value.toLong()) } override fun visitDoubleValue(value: DoubleValue, data: Unit) { setType(Type.DOUBLE) - setDoubleValue(value.getValue()!!) + setDoubleValue(value.value) } override fun visitEnumValue(value: EnumValue, data: Unit) { setType(Type.ENUM) - val enumEntry = value.getValue() + val enumEntry = value.value setClassId(nameTable.getFqNameIndex(enumEntry.getContainingDeclaration() as ClassDescriptor)) setEnumValueId(nameTable.getSimpleNameIndex(enumEntry.getName())) } @@ -95,12 +95,12 @@ public object AnnotationSerializer { override fun visitFloatValue(value: FloatValue, data: Unit) { setType(Type.FLOAT) - setFloatValue(value.getValue()!!) + setFloatValue(value.value) } override fun visitIntValue(value: IntValue, data: Unit) { setType(Type.INT) - setIntValue(value.getValue()!!.toLong()) + setIntValue(value.value.toLong()) } override fun visitKClassValue(value: KClassValue?, data: Unit?) { @@ -110,7 +110,7 @@ public object AnnotationSerializer { override fun visitLongValue(value: LongValue, data: Unit) { setType(Type.LONG) - setIntValue(value.getValue()!!) + setIntValue(value.value) } override fun visitNullValue(value: NullValue, data: Unit) { @@ -135,12 +135,12 @@ public object AnnotationSerializer { override fun visitShortValue(value: ShortValue, data: Unit) { setType(Type.SHORT) - setIntValue(value.getValue()!!.toLong()) + setIntValue(value.value.toLong()) } override fun visitStringValue(value: StringValue, data: Unit) { setType(Type.STRING) - setStringValue(nameTable.getStringIndex(value.getValue()!!)) + setStringValue(nameTable.getStringIndex(value.value)) } }, Unit) diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt index 36ff026c07e..21b3da3518c 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt @@ -36,7 +36,7 @@ public abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescrip property, context -> val compileTimeConstant = property.getCompileTimeInitializer() if (compileTimeConstant is StringValue) { - "\\\"${compileTimeConstant.getValue()}\\\"" + "\\\"${compileTimeConstant.value}\\\"" } else { "$compileTimeConstant" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index dd48739459f..24970e499a8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -386,9 +386,9 @@ internal class DescriptorRendererImpl( private fun renderConstant(value: CompileTimeConstant<*>): String { return when (value) { - is ArrayValue -> value.getValue().map { renderConstant(it) }.joinToString(", ", "{", "}") - is AnnotationValue -> renderAnnotation(value.getValue()) - is KClassValue -> renderType(value.getValue()) + "::class" + is ArrayValue -> value.value.map { renderConstant(it) }.joinToString(", ", "{", "}") + is AnnotationValue -> renderAnnotation(value.value) + is KClassValue -> renderType(value.value) + "::class" else -> value.toString() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt index 551fc128936..f56c108ba1d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt @@ -14,41 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.types.JetType -public class AnnotationValue extends CompileTimeConstant { - - public AnnotationValue(@NotNull AnnotationDescriptor value) { - super(value, true, false, false); +public class AnnotationValue(value: AnnotationDescriptor) : CompileTimeConstant(value, true, false, false) { + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return value.getType() } - @NotNull - @Override - public AnnotationDescriptor getValue() { - AnnotationDescriptor value = super.getValue(); - assert value != null : "Guaranteed by constructor"; - return value; + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitAnnotationValue(this, data) } - @Override - @NotNull - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return value.getType(); - } - - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitAnnotationValue(this, data); - } - - @Override - public String toString() { - return value.toString(); + override fun toString(): String { + return value.toString() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index afae9e14363..fe16daf7fc9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -14,83 +14,58 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -import java.util.List; +public class ArrayValue(value: List>, private val type: JetType, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant>>(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { -public class ArrayValue extends CompileTimeConstant>> { - - private final JetType type; - - public ArrayValue(@NotNull List> value, - @NotNull JetType type, - boolean canBeUsedInAnnotations, - boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, false, usesVariableAsConstant); - assert KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type) - : "Type should be an array, but was " + type + ": " + value; - this.type = type; + init { + assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } } - @NotNull - @Override - public List> getValue() { - List> value = super.getValue(); - assert value != null : "Guaranteed by constructor"; - return value; + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return type } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return type; + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitArrayValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitArrayValue(this, data); + override fun toString(): String { + return value.toString() } - @Override - public String toString() { - return value.toString(); - } + override fun equals(o: Any?): Boolean { + if (this === o) return true + if (o == null || javaClass != o.javaClass) return false - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ArrayValue that = (ArrayValue) o; + val that = o as? ArrayValue ?: return false if (value == null) { - return that.value == null; + return that.value == null } - int i = 0; - for (Object thisObject : value) { - if (!thisObject.equals(that.value.get(i))) { - return false; + var i = 0 + for (thisObject in value) { + if (thisObject != that.value.get(i)) { + return false } - i++; + i++ } - return true; + return true } - @Override - public int hashCode() { - int hashCode = 0; - if (value == null) return hashCode; - for (Object o : value) { - hashCode += o.hashCode(); + override fun hashCode(): Int { + var hashCode = 0 + if (value == null) return hashCode + for (o in value) { + hashCode += o.hashCode() } - return hashCode; + return hashCode } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt index ce55cd6e45b..410b580b059 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt @@ -14,33 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class BooleanValue extends CompileTimeConstant { +public class BooleanValue(value: Boolean, canBeUseInAnnotation: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUseInAnnotation, false, usesVariableAsConstant) { - public BooleanValue(boolean value, boolean canBeUseInAnnotation, boolean usesVariableAsConstant) { - super(value, canBeUseInAnnotation, false, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getBooleanType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getBooleanType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitBooleanValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitBooleanValue(this, data); + override fun toString(): String { + return "$value" } - - @Override - public String toString() { - return String.valueOf(value); - } - } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt index 26d036e42e8..7cb040452bb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt @@ -14,32 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class ByteValue extends IntegerValueConstant { +public class ByteValue(value: Byte, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVaraiableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVaraiableAsConstant) { - public ByteValue(byte value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVaraiableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVaraiableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getByteType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getByteType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitByteValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitByteValue(this, data); - } - - @Override - public String toString() { - return value + ".toByte()"; + override fun toString(): String { + return "$value.toByte()" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt index 1ae5504827d..9bdf3e62a7d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt @@ -14,55 +14,44 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class CharValue extends IntegerValueConstant { +public class CharValue(value: Char, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - public CharValue(char value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getCharType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getCharType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitCharValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitCharValue(this, data); - } + override fun toString() = "\\u%04X ('%s')".format(value.toInt(), getPrintablePart(value)) - @Override - public String toString() { - return String.format("\\u%04X ('%s')", (int) value, getPrintablePart(value)); - } - - private static String getPrintablePart(char c) { - switch (c) { - case '\b': - return "\\b"; - case '\t': - return "\\t"; - case '\n': - return "\\n"; - case '\f': - return "\\f"; - case '\r': - return "\\r"; - default: - return isPrintableUnicode(c) ? Character.toString(c) : "?"; + private fun getPrintablePart(c: Char): String { + when (c) { + '\b' -> return "\\b" + '\t' -> return "\\t" + '\n' -> return "\\n" + //TODO_R: can't escape form feed in Kotlin + 12.toChar() -> return "\\f" + '\r' -> return "\\r" + else -> return if (isPrintableUnicode(c)) Character.toString(c) else "?" } } - private static boolean isPrintableUnicode(char c) { - int t = Character.getType(c); - return t != Character.UNASSIGNED && t != Character.LINE_SEPARATOR && t != Character.PARAGRAPH_SEPARATOR && - t != Character.CONTROL && t != Character.FORMAT && t != Character.PRIVATE_USE && t != Character.SURROGATE; + private fun isPrintableUnicode(c: Char): Boolean { + val t = Character.getType(c).toByte() + return t != Character.UNASSIGNED && + t != Character.LINE_SEPARATOR && + t != Character.PARAGRAPH_SEPARATOR && + t != Character.CONTROL && + t != Character.FORMAT && + t != Character.PRIVATE_USE && + t != Character.SURROGATE } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index f51c8ef0e5f..05732ace9fa 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -14,57 +14,45 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public abstract class CompileTimeConstant { - protected final T value; - private final int flags; +public abstract class CompileTimeConstant protected constructor(public open val value: T, canBeUsedInAnnotations: Boolean, isPure: Boolean, usesVariableAsConstant: Boolean) { + private val flags: Int - /* + init { + flags = (if (isPure) IS_PURE_MASK else 0) or (if (canBeUsedInAnnotations) CAN_BE_USED_IN_ANNOTATIONS_MASK else 0) or (if (usesVariableAsConstant) USES_VARIABLE_AS_CONSTANT_MASK else 0) + } + + public fun canBeUsedInAnnotations(): Boolean { + return (flags and CAN_BE_USED_IN_ANNOTATIONS_MASK) != 0 + } + + public fun isPure(): Boolean { + return (flags and IS_PURE_MASK) != 0 + } + + public fun usesVariableAsConstant(): Boolean { + return (flags and USES_VARIABLE_AS_CONSTANT_MASK) != 0 + } + + public abstract fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType + + public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R + + companion object { + + /* * if is pure is false then constant type cannot be changed * ex1. val a: Long = 1.toInt() (TYPE_MISMATCH error, 1.toInt() isn't pure) * ex2. val b: Int = a (TYPE_MISMATCH error, a isn't pure) * */ - private static final int IS_PURE_MASK = 1; - private static final int CAN_BE_USED_IN_ANNOTATIONS_MASK = 1 << 1; - private static final int USES_VARIABLE_AS_CONSTANT_MASK = 1 << 2; - - protected CompileTimeConstant(T value, - boolean canBeUsedInAnnotations, - boolean isPure, - boolean usesVariableAsConstant) { - this.value = value; - flags = (isPure ? IS_PURE_MASK : 0) | - (canBeUsedInAnnotations ? CAN_BE_USED_IN_ANNOTATIONS_MASK : 0) | - (usesVariableAsConstant ? USES_VARIABLE_AS_CONSTANT_MASK : 0); + private val IS_PURE_MASK = 1 + private val CAN_BE_USED_IN_ANNOTATIONS_MASK = 1 shl 1 + private val USES_VARIABLE_AS_CONSTANT_MASK = 1 shl 2 } - - public boolean canBeUsedInAnnotations() { - return (flags & CAN_BE_USED_IN_ANNOTATIONS_MASK) != 0; - } - - public boolean isPure() { - return (flags & IS_PURE_MASK) != 0; - } - - public boolean usesVariableAsConstant() { - return (flags & USES_VARIABLE_AS_CONSTANT_MASK) != 0; - } - - @Nullable - public T getValue() { - return value; - } - - @NotNull - public abstract JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns); - - public abstract R accept(AnnotationArgumentVisitor visitor, D data); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt index f6a13def8ec..3cc03222e55 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt @@ -14,32 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class DoubleValue extends CompileTimeConstant { +public class DoubleValue(value: Double, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - public DoubleValue(double value, boolean canBeUsedInAnnotations, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, false, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getDoubleType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getDoubleType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitDoubleValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitDoubleValue(this, data); - } - - @Override - public String toString() { - return value + ".toDouble()"; + override fun toString(): String { + return "$value.toDouble()" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt index 05a092cf9bc..ccca617b354 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt @@ -14,64 +14,43 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.utils.sure -import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getClassObjectType; +public class EnumValue(value: ClassDescriptor, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, true, false, usesVariableAsConstant) { -public class EnumValue extends CompileTimeConstant { - - public EnumValue(@NotNull ClassDescriptor value, boolean usesVariableAsConstant) { - super(value, true, false, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return getType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return getType(); + private fun getType(): JetType { + val type = value.classObjectType + return type.sure { "Enum entry must have a class object type: " + value } } - @NotNull - private JetType getType() { - JetType type = getClassObjectType(value); - assert type != null : "Enum entry must have a class object type: " + value; - return type; + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitEnumValue(this, data) } - @NotNull - @Override - public ClassDescriptor getValue() { - ClassDescriptor value = super.getValue(); - assert value != null : "Guaranteed by constructor"; - return value; + override fun toString(): String { + return "${getType()}.${value.getName()}" } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitEnumValue(this, data); + override fun equals(o: Any?): Boolean { + if (this === o) return true + if (o == null || javaClass != o.javaClass) return false + + return value == (o as? EnumValue)?.value } - @Override - public String toString() { - return getType() + "." + value.getName(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - return value.equals(((EnumValue) o).value); - } - - @Override - public int hashCode() { - return value.hashCode(); + override fun hashCode(): Int { + return value.hashCode() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt index 980988ef74f..5d0444504e7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt @@ -14,56 +14,40 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.ErrorUtils; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.ErrorUtils +import org.jetbrains.kotlin.types.JetType -public abstract class ErrorValue extends CompileTimeConstant { +public abstract class ErrorValue : CompileTimeConstant(Unit, true, false, false) { - public ErrorValue() { - super(null, true, false, false); - } - - @Override - @Deprecated // Should not be called, for this is not a real value, but a indication of an error - public Void getValue() { - throw new UnsupportedOperationException(); - } - - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitErrorValue(this, data); - } - - @NotNull - public static ErrorValue create(@NotNull String message) { - return new ErrorValueWithMessage(message); - } - - public static class ErrorValueWithMessage extends ErrorValue { - private final String message; - - public ErrorValueWithMessage(@NotNull String message) { - this.message = message; + deprecated("") // Should not be called, for this is not a real value, but a indication of an error + override val value: Unit + get() { + throw UnsupportedOperationException() } - public String getMessage() { - return message; + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitErrorValue(this, data) + } + + public class ErrorValueWithMessage(public val message: String) : ErrorValue() { + + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return ErrorUtils.createErrorType(message) } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return ErrorUtils.createErrorType(message); + override fun toString(): String { + return message } + } - @Override - public String toString() { - return getMessage(); + companion object { + + public fun create(message: String): ErrorValue { + return ErrorValueWithMessage(message) } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt index b541ecf0246..7da1f85633d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt @@ -14,32 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class FloatValue extends CompileTimeConstant { +public class FloatValue(value: Float, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - public FloatValue(float value, boolean canBeUsedInAnnotations, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, false, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getFloatType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getFloatType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitFloatValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitFloatValue(this, data); - } - - @Override - public String toString() { - return value + ".toFloat()"; + override fun toString(): String { + return "$value.toFloat()" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt index cb390098600..5e2ca89cafe 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt @@ -14,49 +14,38 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class IntValue extends IntegerValueConstant { +public class IntValue(value: Int, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - public IntValue(int value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getIntType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getIntType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitIntValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitIntValue(this, data); + override fun toString(): String { + return value.toString() } - @Override - public String toString() { - return value.toString(); + override fun equals(o: Any?): Boolean { + if (this === o) return true + if (o == null || javaClass != o.javaClass) return false + + val intValue = o as? IntValue ?: return false + + if (value !== intValue.value) return false + + return true } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - IntValue intValue = (IntValue) o; - - if (value != intValue.value) return false; - - return true; - } - - @Override - public int hashCode() { - return value; + override fun hashCode(): Int { + return value } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt index 7c3b9de2e65..220a174d3ab 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt @@ -14,11 +14,6 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -public abstract class IntegerValueConstant extends CompileTimeConstant { - - protected IntegerValueConstant(T value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVariableAsConstant); - } -} +public abstract class IntegerValueConstant protected constructor(value: T, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt index 682a70b9265..04778e7a327 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt @@ -14,74 +14,59 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.descriptors.annotations.Annotations; -import org.jetbrains.kotlin.types.*; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.types.* -import java.util.Collections; +import java.util.Collections -public class IntegerValueTypeConstant extends IntegerValueConstant { +public class IntegerValueTypeConstant(value: Number, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, true, usesVariableAsConstant) { - private final IntegerValueTypeConstructor typeConstructor; + private val typeConstructor: IntegerValueTypeConstructor - public IntegerValueTypeConstant(@NotNull Number value, boolean canBeUsedInAnnotations, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, true, usesVariableAsConstant); - this.typeConstructor = new IntegerValueTypeConstructor(value.longValue()); + init { + this.typeConstructor = IntegerValueTypeConstructor(value.toLong()) } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return new JetTypeImpl( - Annotations.EMPTY, typeConstructor, - false, Collections.emptyList(), - ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return JetTypeImpl(Annotations.EMPTY, typeConstructor, false, emptyList(), ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)) } - @Nullable - @Override - @Deprecated - public Number getValue() { - throw new UnsupportedOperationException("Use IntegerValueTypeConstant.getValue(expectedType) instead"); + deprecated("") + override val value: Number + get() = throw UnsupportedOperationException("Use IntegerValueTypeConstant.getValue(expectedType) instead") + + public fun getType(expectedType: JetType): JetType { + return TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) } - @NotNull - public JetType getType(@NotNull JetType expectedType) { - return TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType); - } + public fun getValue(expectedType: JetType): Number { + val numberValue = typeConstructor.getValue() + val builtIns = KotlinBuiltIns.getInstance() - @NotNull - public Number getValue(@NotNull JetType expectedType) { - Number numberValue = typeConstructor.getValue(); - KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance(); - - JetType valueType = getType(expectedType); - if (valueType.equals(builtIns.getIntType())) { - return numberValue.intValue(); + val valueType = getType(expectedType) + if (valueType == builtIns.getIntType()) { + return numberValue.toInt() } - else if (valueType.equals(builtIns.getByteType())) { - return numberValue.byteValue(); + else if (valueType == builtIns.getByteType()) { + return numberValue.toByte() } - else if (valueType.equals(builtIns.getShortType())) { - return numberValue.shortValue(); + else if (valueType == builtIns.getShortType()) { + return numberValue.toShort() } else { - return numberValue.longValue(); + return numberValue.toLong() } } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitNumberTypeValue(this, data); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitNumberTypeValue(this, data) } - @Override - public String toString() { - return typeConstructor.toString(); + override fun toString(): String { + return typeConstructor.toString() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt index aaec9522e06..93a736afdb4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt @@ -14,83 +14,65 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.ClassifierDescriptor; -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; -import org.jetbrains.kotlin.descriptors.annotations.Annotations; -import org.jetbrains.kotlin.types.JetType; -import org.jetbrains.kotlin.types.TypeConstructor; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassifierDescriptor +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeConstructor -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.ArrayList +import java.util.Collections -public class IntegerValueTypeConstructor implements TypeConstructor { - private final long value; - private final Collection supertypes = new ArrayList(4); +public class IntegerValueTypeConstructor(private val value: Long) : TypeConstructor { + private val supertypes = ArrayList(4) - public IntegerValueTypeConstructor(long value) { - // order of types matters - // 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type - // for expected type 'Any' result type 'Int' should be returned - this.value = value; - checkBoundsAndAddSuperType(value, (long) Integer.MIN_VALUE, (long) Integer.MAX_VALUE, KotlinBuiltIns.getInstance().getIntType()); - checkBoundsAndAddSuperType(value, (long) Byte.MIN_VALUE, (long) Byte.MAX_VALUE, KotlinBuiltIns.getInstance().getByteType()); - checkBoundsAndAddSuperType(value, (long) Short.MIN_VALUE, (long) Short.MAX_VALUE, KotlinBuiltIns.getInstance().getShortType()); - supertypes.add(KotlinBuiltIns.getInstance().getLongType()); - } + init { + checkBoundsAndAddSuperType(value, Integer.MIN_VALUE.toLong(), Integer.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getIntType()) + checkBoundsAndAddSuperType(value, java.lang.Byte.MIN_VALUE.toLong(), java.lang.Byte.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getByteType()) + checkBoundsAndAddSuperType(value, java.lang.Short.MIN_VALUE.toLong(), java.lang.Short.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getShortType()) + supertypes.add(KotlinBuiltIns.getInstance().getLongType()) + }// order of types matters + // 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type + // for expected type 'Any' result type 'Int' should be returned - private void checkBoundsAndAddSuperType(long value, long minValue, long maxValue, JetType kotlinType) { + private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: JetType) { if (value >= minValue && value <= maxValue) { - supertypes.add(kotlinType); + supertypes.add(kotlinType) } } - @NotNull - @Override - public Collection getSupertypes() { - return supertypes; + override fun getSupertypes(): Collection { + return supertypes } - @NotNull - @Override - public List getParameters() { - return Collections.emptyList(); + override fun getParameters(): List { + return emptyList() } - @Override - public boolean isFinal() { - return false; + override fun isFinal(): Boolean { + return false } - @Override - public boolean isDenotable() { - return false; + override fun isDenotable(): Boolean { + return false } - @Nullable - @Override - public ClassifierDescriptor getDeclarationDescriptor() { - return null; + override fun getDeclarationDescriptor(): ClassifierDescriptor? { + return null } - @NotNull - @Override - public Annotations getAnnotations() { - return Annotations.EMPTY; + override fun getAnnotations(): Annotations { + return Annotations.EMPTY } - public Long getValue() { - return value; + public fun getValue(): Long { + return value } - @Override - public String toString() { - return "IntegerValueType(" + value + ")"; + override fun toString(): String { + return "IntegerValueType(" + value + ")" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt index 563f1b680bb..ec518f99fbd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt @@ -21,9 +21,10 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class KClassValue(type: JetType) : CompileTimeConstant(type, true, false, false) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = value - override fun getValue(): JetType = value.getArguments().single().getType() +public class KClassValue(private val type: JetType) : CompileTimeConstant(type, true, false, false) { + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = type + override val value: JetType + get() = type.getArguments().single().getType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitKClassValue(this, data) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt index 448dd6fab72..b0f803bf7e2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt @@ -14,32 +14,23 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class LongValue extends IntegerValueConstant { +public class LongValue(value: Long, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - public LongValue(long value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getLongType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getLongType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitLongValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitLongValue(this, data); - } - - @Override - public String toString() { - return value + ".toLong()"; + override fun toString(): String { + return "$value.toLong()" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt index a4ec8773aa7..35fccaf9a49 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt @@ -14,34 +14,27 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class NullValue extends CompileTimeConstant { +public class NullValue private constructor() : CompileTimeConstant(null, false, false, false) { - public static final NullValue NULL = new NullValue(); - - private NullValue() { - super(null, false, false, false); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getNullableNothingType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getNullableNothingType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitNullValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitNullValue(this, data); + override fun toString(): String { + return "null" } - @Override - public String toString() { - return "null"; + companion object { + public val NULL: NullValue = NullValue() } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt index b32fcc2ceb1..45294ca2d27 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt @@ -14,33 +14,24 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class ShortValue extends IntegerValueConstant { +public class ShortValue(value: Short, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - public ShortValue(short value, boolean canBeUsedInAnnotations, boolean pure, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, pure, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getShortType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getShortType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitShortValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitShortValue(this, data); - } - - @Override - public String toString() { - return value + ".toShort()"; + override fun toString(): String { + return "$value.toShort()" } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt index d3367beb420..e1cb3feac4f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt @@ -14,49 +14,38 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.constants; +package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType -public class StringValue extends CompileTimeConstant { +public class StringValue(value: String, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - public StringValue(String value, boolean canBeUsedInAnnotations, boolean usesVariableAsConstant) { - super(value, canBeUsedInAnnotations, false, usesVariableAsConstant); + override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { + return kotlinBuiltIns.getStringType() } - @NotNull - @Override - public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) { - return kotlinBuiltIns.getStringType(); + override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { + return visitor.visitStringValue(this, data) } - @Override - public R accept(AnnotationArgumentVisitor visitor, D data) { - return visitor.visitStringValue(this, data); + override fun toString(): String { + return "\"" + value + "\"" } - @Override - public String toString() { - return "\"" + value + "\""; + override fun equals(o: Any?): Boolean { + if (this === o) return true + if (o == null || javaClass != o.javaClass) return false + + val that = o as? StringValue ?: return false + + if (if (value != null) value != that.value else that.value != null) return false + + return true } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - StringValue that = (StringValue) o; - - if (value != null ? !value.equals(that.value) : that.value != null) return false; - - return true; - } - - @Override - public int hashCode() { - return value != null ? value.hashCode() : 0; + override fun hashCode(): Int { + return if (value != null) value.hashCode() else 0 } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt index 52f70e28e34..01afc5eb16e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt @@ -95,7 +95,7 @@ public class ConvertToStringTemplateIntention : JetSelfTargetingOffsetIndependen constant.getValue(type).toString() } else { - constant?.getValue().toString() + constant?.value.toString() } } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index 23f76759d79..1be97fe23b2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -112,7 +112,7 @@ public abstract class DeprecatedSymbolUsageFixBase( if (pattern.isEmpty()) return null val importValues = replaceWithValue.argumentValue("imports"/*TODO: kotlin.ReplaceWith::imports.name*/) as? List<*> ?: return null if (importValues.any { it !is StringValue }) return null - val imports = importValues.map { (it as StringValue).getValue()!! } + val imports = importValues.map { (it as StringValue).value } // should not be available for descriptors with optional parameters if we cannot fetch default values for them (currently for library with no sources) if (descriptor is CallableDescriptor && diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt index 9a4cf2dd0d5..de5fabeb1e3 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt @@ -84,7 +84,7 @@ public class JsCallChecker : CallChecker { return } - val code = evaluationResult.getValue() as String + val code = evaluationResult.value as String val errorReporter = JsCodeErrorReporter(argument, code, context.trace) try { From ae88dd3f1f836dfe70b6cd6d046e6619bb0b825b Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 2 Jul 2015 19:58:08 +0300 Subject: [PATCH 279/450] Convert compile constant classes to kotlin: prettify --- .../evaluate/ConstantExpressionEvaluator.kt | 2 +- .../LazyJavaAnnotationDescriptor.kt | 2 +- .../resolve/constants/AnnotationValue.kt | 12 +--- .../kotlin/resolve/constants/ArrayValue.kt | 56 ++++++------------- .../kotlin/resolve/constants/BooleanValue.kt | 19 +++---- .../kotlin/resolve/constants/ByteValue.kt | 19 +++---- .../kotlin/resolve/constants/CharValue.kt | 15 ++--- .../resolve/constants/CompileTimeConstant.kt | 2 + .../kotlin/resolve/constants/ConstantUtils.kt | 2 +- .../kotlin/resolve/constants/DoubleValue.kt | 18 +++--- .../kotlin/resolve/constants/EnumValue.kt | 44 ++++++--------- .../kotlin/resolve/constants/ErrorValue.kt | 19 ++----- .../kotlin/resolve/constants/FloatValue.kt | 18 +++--- .../kotlin/resolve/constants/IntValue.kt | 43 ++++++-------- .../resolve/constants/IntegerValueConstant.kt | 7 ++- .../constants/IntegerValueTypeConstant.kt | 29 +++++----- .../constants/IntegerValueTypeConstructor.kt | 39 ++++--------- .../kotlin/resolve/constants/LongValue.kt | 19 +++---- .../kotlin/resolve/constants/NullValue.kt | 18 ++---- .../kotlin/resolve/constants/ShortValue.kt | 20 +++---- .../kotlin/resolve/constants/StringValue.kt | 42 ++++++-------- 21 files changed, 175 insertions(+), 270 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 0b947d2ade8..de81d30ac63 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -106,7 +106,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (text == null) return null val nodeElementType = expression.getNode().getElementType() - if (nodeElementType == JetNodeTypes.NULL) return NullValue.NULL + if (nodeElementType == JetNodeTypes.NULL) return NullValue val result: Any? = when (nodeElementType) { JetNodeTypes.INTEGER_CONSTANT -> parseLong(text) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 09027521512..38b0a20fcbf 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -123,7 +123,7 @@ class LazyJavaAnnotationDescriptor( if (valueParameter == null) return null val values = elements.map { - argument -> resolveAnnotationArgument(argument) ?: NullValue.NULL + argument -> resolveAnnotationArgument(argument) ?: NullValue } return ArrayValue(values, valueParameter.getType(), true, values.any { it.usesVariableAsConstant() }) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt index f56c108ba1d..0fcc18648ed 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt @@ -22,15 +22,9 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.types.JetType public class AnnotationValue(value: AnnotationDescriptor) : CompileTimeConstant(value, true, false, false) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return value.getType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = value.getType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitAnnotationValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitAnnotationValue(this, data) - override fun toString(): String { - return value.toString() - } + override fun toString() = value.toString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index fe16daf7fc9..44ee6d3f965 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -19,53 +19,29 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType +import java.util.* -public class ArrayValue(value: List>, private val type: JetType, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant>>(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { +public class ArrayValue( + value: List>, + private val type: JetType, + canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean +) : CompileTimeConstant>>(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { init { assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } } - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return type + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = type + + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitArrayValue(this, data) + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + return value == (other as ArrayValue).value } - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitArrayValue(this, data) - } - - override fun toString(): String { - return value.toString() - } - - override fun equals(o: Any?): Boolean { - if (this === o) return true - if (o == null || javaClass != o.javaClass) return false - - val that = o as? ArrayValue ?: return false - - if (value == null) { - return that.value == null - } - - var i = 0 - for (thisObject in value) { - if (thisObject != that.value.get(i)) { - return false - } - i++ - } - - return true - } - - override fun hashCode(): Int { - var hashCode = 0 - if (value == null) return hashCode - for (o in value) { - hashCode += o.hashCode() - } - return hashCode - } + override fun hashCode() = value.hashCode() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt index 410b580b059..aa691a535f5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt @@ -20,17 +20,12 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class BooleanValue(value: Boolean, canBeUseInAnnotation: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUseInAnnotation, false, usesVariableAsConstant) { +public class BooleanValue( + value: Boolean, + canBeUseInAnnotation: Boolean, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, canBeUseInAnnotation, false, usesVariableAsConstant) { + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getBooleanType() - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getBooleanType() - } - - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitBooleanValue(this, data) - } - - override fun toString(): String { - return "$value" - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitBooleanValue(this, data) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt index 7cb040452bb..973ec0af255 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt @@ -20,17 +20,16 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class ByteValue(value: Byte, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVaraiableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVaraiableAsConstant) { +public class ByteValue( + value: Byte, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVaraiableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVaraiableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getByteType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getByteType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitByteValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitByteValue(this, data) - override fun toString(): String { - return "$value.toByte()" - } + override fun toString(): String = "$value.toByte()" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt index 9bdf3e62a7d..fb9a93adda1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt @@ -20,15 +20,16 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class CharValue(value: Char, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { +public class CharValue( + value: Char, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVariableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getCharType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getCharType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitCharValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitCharValue(this, data) override fun toString() = "\\u%04X ('%s')".format(value.toInt(), getPrintablePart(value)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index 05732ace9fa..d7c8c477387 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -43,6 +43,8 @@ public abstract class CompileTimeConstant protected constructor(public open v public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R + override fun toString() = value.toString() + companion object { /* diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt index 0dff6a49e5f..a82205ecf24 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt @@ -43,7 +43,7 @@ public fun createCompileTimeConstant( is Double -> DoubleValue(value, canBeUsedInAnnotation, usesVariableAsConstant) is Boolean -> BooleanValue(value, canBeUsedInAnnotation, usesVariableAsConstant) is String -> StringValue(value, canBeUsedInAnnotation, usesVariableAsConstant) - null -> NullValue.NULL + null -> NullValue else -> null } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt index 3cc03222e55..351861c4c86 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt @@ -20,17 +20,15 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class DoubleValue(value: Double, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { +public class DoubleValue( + value: Double, + canBeUsedInAnnotations: Boolean, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getDoubleType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getDoubleType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitDoubleValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitDoubleValue(this, data) - override fun toString(): String { - return "$value.toDouble()" - } + override fun toString() = "$value.toDouble()" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt index ccca617b354..2afd293da3c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt @@ -23,34 +23,26 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.sure -public class EnumValue(value: ClassDescriptor, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, true, false, usesVariableAsConstant) { +public class EnumValue( + value: ClassDescriptor, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, true, false, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return getType() + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = getType() + + private fun getType() = value.classObjectType.sure { "Enum entry must have a class object type: " + value } + + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitEnumValue(this, data) + + override fun toString() = "${getType()}.${value.getName()}" + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + return value == (other as EnumValue).value } - private fun getType(): JetType { - val type = value.classObjectType - return type.sure { "Enum entry must have a class object type: " + value } - } - - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitEnumValue(this, data) - } - - override fun toString(): String { - return "${getType()}.${value.getName()}" - } - - override fun equals(o: Any?): Boolean { - if (this === o) return true - if (o == null || javaClass != o.javaClass) return false - - return value == (o as? EnumValue)?.value - } - - override fun hashCode(): Int { - return value.hashCode() - } + override fun hashCode() = value.hashCode() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt index 5d0444504e7..74164f3019d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt @@ -23,29 +23,20 @@ import org.jetbrains.kotlin.types.JetType public abstract class ErrorValue : CompileTimeConstant(Unit, true, false, false) { - deprecated("") // Should not be called, for this is not a real value, but a indication of an error + deprecated("Should not be called, for this is not a real value, but a indication of an error") override val value: Unit - get() { - throw UnsupportedOperationException() - } + get() = throw UnsupportedOperationException() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitErrorValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitErrorValue(this, data) public class ErrorValueWithMessage(public val message: String) : ErrorValue() { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return ErrorUtils.createErrorType(message) - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = ErrorUtils.createErrorType(message) - override fun toString(): String { - return message - } + override fun toString() = message } companion object { - public fun create(message: String): ErrorValue { return ErrorValueWithMessage(message) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt index 7da1f85633d..ba1e4f037c6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt @@ -20,17 +20,15 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class FloatValue(value: Float, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { +public class FloatValue( + value: Float, + canBeUsedInAnnotations: Boolean, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getFloatType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getFloatType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitFloatValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitFloatValue(this, data) - override fun toString(): String { - return "$value.toFloat()" - } + override fun toString() = "$value.toFloat()" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt index 5e2ca89cafe..bb3333e70de 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt @@ -20,32 +20,25 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class IntValue(value: Int, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { +public class IntValue( + value: Int, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVariableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getIntType() + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getIntType() + + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitIntValue(this, data) + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + val intValue = other as IntValue + + return value == intValue.value } - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitIntValue(this, data) - } - - override fun toString(): String { - return value.toString() - } - - override fun equals(o: Any?): Boolean { - if (this === o) return true - if (o == null || javaClass != o.javaClass) return false - - val intValue = o as? IntValue ?: return false - - if (value !== intValue.value) return false - - return true - } - - override fun hashCode(): Int { - return value - } + override fun hashCode() = value } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt index 220a174d3ab..3c71270741f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt @@ -16,4 +16,9 @@ package org.jetbrains.kotlin.resolve.constants -public abstract class IntegerValueConstant protected constructor(value: T, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) +public abstract class IntegerValueConstant protected constructor( + value: T, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt index 04778e7a327..65744390727 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt @@ -23,25 +23,26 @@ import org.jetbrains.kotlin.types.* import java.util.Collections -public class IntegerValueTypeConstant(value: Number, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, true, usesVariableAsConstant) { +public class IntegerValueTypeConstant( + value: Number, + canBeUsedInAnnotations: Boolean, + usesVariableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, true, usesVariableAsConstant) { - private val typeConstructor: IntegerValueTypeConstructor - - init { - this.typeConstructor = IntegerValueTypeConstructor(value.toLong()) - } + private val typeConstructor = IntegerValueTypeConstructor(value.toLong()) override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return JetTypeImpl(Annotations.EMPTY, typeConstructor, false, emptyList(), ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true)) + return JetTypeImpl( + Annotations.EMPTY, typeConstructor, false, emptyList() + , ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) + ) } deprecated("") override val value: Number get() = throw UnsupportedOperationException("Use IntegerValueTypeConstant.getValue(expectedType) instead") - public fun getType(expectedType: JetType): JetType { - return TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) - } + public fun getType(expectedType: JetType): JetType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) public fun getValue(expectedType: JetType): Number { val numberValue = typeConstructor.getValue() @@ -62,11 +63,7 @@ public class IntegerValueTypeConstant(value: Number, canBeUsedInAnnotations: Boo } } - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitNumberTypeValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitNumberTypeValue(this, data) - override fun toString(): String { - return typeConstructor.toString() - } + override fun toString() = typeConstructor.toString() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt index 93a736afdb4..92e9458bc7b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstructor.kt @@ -30,13 +30,14 @@ public class IntegerValueTypeConstructor(private val value: Long) : TypeConstruc private val supertypes = ArrayList(4) init { + // order of types matters + // 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type + // for expected type 'Any' result type 'Int' should be returned checkBoundsAndAddSuperType(value, Integer.MIN_VALUE.toLong(), Integer.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getIntType()) checkBoundsAndAddSuperType(value, java.lang.Byte.MIN_VALUE.toLong(), java.lang.Byte.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getByteType()) checkBoundsAndAddSuperType(value, java.lang.Short.MIN_VALUE.toLong(), java.lang.Short.MAX_VALUE.toLong(), KotlinBuiltIns.getInstance().getShortType()) supertypes.add(KotlinBuiltIns.getInstance().getLongType()) - }// order of types matters - // 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type - // for expected type 'Any' result type 'Int' should be returned + } private fun checkBoundsAndAddSuperType(value: Long, minValue: Long, maxValue: Long, kotlinType: JetType) { if (value >= minValue && value <= maxValue) { @@ -44,35 +45,19 @@ public class IntegerValueTypeConstructor(private val value: Long) : TypeConstruc } } - override fun getSupertypes(): Collection { - return supertypes - } + override fun getSupertypes(): Collection = supertypes - override fun getParameters(): List { - return emptyList() - } + override fun getParameters(): List = emptyList() - override fun isFinal(): Boolean { - return false - } + override fun isFinal() = false - override fun isDenotable(): Boolean { - return false - } + override fun isDenotable() = false - override fun getDeclarationDescriptor(): ClassifierDescriptor? { - return null - } + override fun getDeclarationDescriptor() = null - override fun getAnnotations(): Annotations { - return Annotations.EMPTY - } + override fun getAnnotations() = Annotations.EMPTY - public fun getValue(): Long { - return value - } + public fun getValue(): Long = value - override fun toString(): String { - return "IntegerValueType(" + value + ")" - } + override fun toString() = "IntegerValueType(" + value + ")" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt index b0f803bf7e2..c442492f435 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt @@ -20,17 +20,16 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class LongValue(value: Long, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { +public class LongValue( + value: Long, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVariableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getLongType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getLongType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitLongValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitLongValue(this, data) - override fun toString(): String { - return "$value.toLong()" - } + override fun toString() = "$value.toLong()" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt index 35fccaf9a49..8c28e6ca910 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt @@ -20,21 +20,11 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class NullValue private constructor() : CompileTimeConstant(null, false, false, false) { +public object NullValue : CompileTimeConstant(null, false, false, false) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getNullableNothingType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getNullableNothingType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitNullValue(this, data) - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitNullValue(this, data) - override fun toString(): String { - return "null" - } - - companion object { - public val NULL: NullValue = NullValue() - } + override fun toString() = "null" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt index 45294ca2d27..f1d71050be2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt @@ -20,18 +20,16 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class ShortValue(value: Short, canBeUsedInAnnotations: Boolean, pure: Boolean, usesVariableAsConstant: Boolean) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { +public class ShortValue( + value: Short, + canBeUsedInAnnotations: Boolean, + pure: Boolean, + usesVariableAsConstant: Boolean +) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getShortType() - } + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getShortType() - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitShortValue(this, data) - } - - override fun toString(): String { - return "$value.toShort()" - } + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitShortValue(this, data) + override fun toString() = "$value.toShort()" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt index e1cb3feac4f..f8467927cd8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt @@ -20,32 +20,24 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class StringValue(value: String, canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { +public class StringValue( + value: String, + canBeUsedInAnnotations: Boolean, + usesVariableAsConstant: Boolean +) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return kotlinBuiltIns.getStringType() + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getStringType() + + override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitStringValue(this, data) + + override fun toString() = "\"$value\"" + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other == null || javaClass != other.javaClass) return false + + return value != (other as StringValue).value } - override fun accept(visitor: AnnotationArgumentVisitor, data: D): R { - return visitor.visitStringValue(this, data) - } - - override fun toString(): String { - return "\"" + value + "\"" - } - - override fun equals(o: Any?): Boolean { - if (this === o) return true - if (o == null || javaClass != o.javaClass) return false - - val that = o as? StringValue ?: return false - - if (if (value != null) value != that.value else that.value != null) return false - - return true - } - - override fun hashCode(): Int { - return if (value != null) value.hashCode() else 0 - } + override fun hashCode() = value.hashCode() } From f97767e15952e3a6e550a24d9d205ecc4c5ee338 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 3 Jul 2015 14:20:39 +0300 Subject: [PATCH 280/450] Drop ArrayValue redundant constructor parameter --- .../org/jetbrains/kotlin/resolve/AnnotationResolver.java | 2 +- .../constants/evaluate/ConstantExpressionEvaluator.kt | 2 +- .../java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt | 2 +- .../kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt | 2 +- .../org/jetbrains/kotlin/resolve/constants/ArrayValue.kt | 4 ++-- .../serialization/deserialization/AnnotationDeserializer.kt | 6 ++++-- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 06567399a62..bae071d01f3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -249,7 +249,7 @@ public class AnnotationResolver { if (parameterDescriptor.declaresDefaultValue() && constants.isEmpty()) return null; - return new ArrayValue(constants, parameterDescriptor.getType(), true, usesVariableAsConstant); + return new ArrayValue(constants, parameterDescriptor.getType(), usesVariableAsConstant); } else { // we should actually get only one element, but just in case of getting many, we take the last one diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index de81d30ac63..994956bf95b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -387,7 +387,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val varargType = resultingDescriptor.getValueParameters().first().getVarargElementType()!! val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) } - return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, true, arguments.any() { it.usesVariableAsConstant() }) + return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, arguments.any() { it.usesVariableAsConstant() }) } // Ann() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 38b0a20fcbf..bb7c81b8a04 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -125,7 +125,7 @@ class LazyJavaAnnotationDescriptor( val values = elements.map { argument -> resolveAnnotationArgument(argument) ?: NullValue } - return ArrayValue(values, valueParameter.getType(), true, values.any { it.usesVariableAsConstant() }) + return ArrayValue(values, valueParameter.getType(), values.any { it.usesVariableAsConstant() }) } private fun resolveFromEnumValue(element: JavaField?): CompileTimeConstant<*>? { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index 78504d9db8b..0a8c0c9984e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -107,7 +107,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( val parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass) if (parameter != null) { elements.trimToSize() - arguments[parameter] = ArrayValue(elements, parameter.getType(), true, false) + arguments[parameter] = ArrayValue(elements, parameter.getType(), false) } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index 44ee6d3f965..137f84f1012 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -24,8 +24,8 @@ import java.util.* public class ArrayValue( value: List>, private val type: JetType, - canBeUsedInAnnotations: Boolean, usesVariableAsConstant: Boolean -) : CompileTimeConstant>>(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { + usesVariableAsConstant: Boolean +) : CompileTimeConstant>>(value, true, false, usesVariableAsConstant) { init { assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index d4930a87147..25faaeb8d90 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -110,9 +110,11 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { val expectedElementType = builtIns.getArrayElementType(if (expectedIsArray) expectedType else actualArrayType) ArrayValue( - arrayElements.map { resolveValue(expectedElementType, it, nameResolver) }, + arrayElements.map { + resolveValue(expectedElementType, it, nameResolver) + }, actualArrayType, - true, true + true ) } else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)") From b0a45207109ac9991ad00697df109322fc2d7ef3 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 3 Jul 2015 16:04:41 +0300 Subject: [PATCH 281/450] Refactor compile constants to reduce boolean parameter hell --- .../JavaPropertyInitializerEvaluatorImpl.java | 11 +- .../evaluate/ConstantExpressionEvaluator.kt | 100 ++++++++++-------- .../serialization/AnnotationSerializer.kt | 9 +- .../LazyJavaAnnotationDescriptor.kt | 6 +- ...aryClassAnnotationAndConstantLoaderImpl.kt | 14 +-- .../resolve/constants/AnnotationValue.kt | 3 +- .../kotlin/resolve/constants/ArrayValue.kt | 13 ++- .../kotlin/resolve/constants/BooleanValue.kt | 7 +- .../kotlin/resolve/constants/ByteValue.kt | 6 +- .../kotlin/resolve/constants/CharValue.kt | 6 +- .../resolve/constants/CompileTimeConstant.kt | 53 +++++----- .../kotlin/resolve/constants/ConstantUtils.kt | 61 ++++++----- .../kotlin/resolve/constants/DoubleValue.kt | 7 +- .../kotlin/resolve/constants/EnumValue.kt | 5 +- .../kotlin/resolve/constants/ErrorValue.kt | 2 +- .../kotlin/resolve/constants/FloatValue.kt | 6 +- .../kotlin/resolve/constants/IntValue.kt | 6 +- .../resolve/constants/IntegerValueConstant.kt | 6 +- .../constants/IntegerValueTypeConstant.kt | 7 +- .../kotlin/resolve/constants/KClassValue.kt | 4 +- .../kotlin/resolve/constants/LongValue.kt | 6 +- .../kotlin/resolve/constants/NullValue.kt | 2 +- .../kotlin/resolve/constants/ShortValue.kt | 6 +- .../kotlin/resolve/constants/StringValue.kt | 6 +- .../deserialization/AnnotationDeserializer.kt | 23 ++-- 25 files changed, 195 insertions(+), 180 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java index 09f05f5d778..582a69a9e9f 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java @@ -37,10 +37,13 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial if (evaluatedExpression != null) { return ConstantsPackage.createCompileTimeConstant( evaluatedExpression, - ConstantExpressionEvaluator.isPropertyCompileTimeConstant(descriptor), - false, - true, - descriptor.getType()); + new CompileTimeConstant.Parameters.Impl( + ConstantExpressionEvaluator.isPropertyCompileTimeConstant(descriptor), + false, + true + ), + descriptor.getType() + ); } return null; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 994956bf95b..015a4fcdff6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -96,9 +96,9 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return createStringConstant(this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType())) } - override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = StringValue(entry.getText(), true, false) + override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = StringValue(entry.getText(), CompileTimeConstant.Parameters.Impl(true, false, false)) - override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = StringValue(entry.getUnescapedValue(), true, false) + override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = StringValue(entry.getUnescapedValue(), CompileTimeConstant.Parameters.Impl(true, false, false)) } override fun visitConstantExpression(expression: JetConstantExpression, expectedType: JetType?): CompileTimeConstant<*>? { @@ -118,7 +118,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (result == null) return null fun isLongWithSuffix() = nodeElementType == JetNodeTypes.INTEGER_CONSTANT && hasLongSuffix(text) - return createCompileTimeConstant(result, expectedType, !isLongWithSuffix(), true, false) + return createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(true, !isLongWithSuffix(), false)) } override fun visitParenthesizedExpression(expression: JetParenthesizedExpression, expectedType: JetType?): CompileTimeConstant<*>? { @@ -155,9 +155,15 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } } return if (!interupted) - createCompileTimeConstant(sb.toString(), expectedType, - isPure = true, canBeUsedInAnnotation = canBeUsedInAnnotation, - usesVariableAsConstant = usesVariableAsConstant) + createConstant( + sb.toString(), + expectedType, + CompileTimeConstant.Parameters.Impl( + isPure = true, + canBeUsedInAnnotation = canBeUsedInAnnotation, + usesVariableAsConstant = usesVariableAsConstant + ) + ) else null } @@ -190,7 +196,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT else -> throw IllegalArgumentException("Unknown boolean operation token ${operationToken}") } val usesVariableAsConstant = leftConstant.usesVariableAsConstant() || rightConstant.usesVariableAsConstant() - return createCompileTimeConstant(result, expectedType, true, true, usesVariableAsConstant) + return createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(true, true, usesVariableAsConstant)) } else { return evaluateCall(expression.getOperationReference(), leftExpression, expectedType) @@ -214,11 +220,14 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) val usesVariableAsConstant = usesVariableAsConstant(argumentForReceiver.expression) val isNumberConversionMethod = resultingDescriptorName in OperatorConventions.NUMBER_CONVERSIONS - return createCompileTimeConstant(result, - expectedType, - !isNumberConversionMethod && isArgumentPure, - canBeUsedInAnnotation, - usesVariableAsConstant) + return createConstant( + result, + expectedType, + CompileTimeConstant.Parameters.Impl( + canBeUsedInAnnotation, + !isNumberConversionMethod && isArgumentPure, + usesVariableAsConstant) + ) } else if (argumentsEntrySet.size() == 1) { val (parameter, argument) = argumentsEntrySet.first() @@ -237,12 +246,12 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val areArgumentsPure = isPureConstant(argumentForReceiver.expression) && isPureConstant(argumentForParameter.expression) val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression) val usesVariableAsConstant = usesVariableAsConstant(argumentForReceiver.expression) || usesVariableAsConstant(argumentForParameter.expression) - val c = EvaluatorContext(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) + val parameters = CompileTimeConstant.Parameters.Impl(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) return when(resultingDescriptorName) { - OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, c) - OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, c) + OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, parameters) + OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, parameters) else -> { - createCompileTimeConstant(result, expectedType, areArgumentsPure, canBeUsedInAnnotation, usesVariableAsConstant) + createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(areArgumentsPure, canBeUsedInAnnotation, usesVariableAsConstant)) } } } @@ -327,7 +336,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT override fun visitSimpleNameExpression(expression: JetSimpleNameExpression, expectedType: JetType?): CompileTimeConstant<*>? { val enumDescriptor = trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, expression); if (enumDescriptor != null && DescriptorUtils.isEnumEntry(enumDescriptor)) { - return EnumValue(enumDescriptor as ClassDescriptor, false); + return EnumValue(enumDescriptor as ClassDescriptor) } val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) @@ -342,9 +351,15 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT compileTimeConstant.getValue(expectedType ?: TypeUtils.NO_EXPECTED_TYPE) else compileTimeConstant.value - return createCompileTimeConstant(value, expectedType, isPure = false, - canBeUsedInAnnotation = isPropertyCompileTimeConstant(callableDescriptor), - usesVariableAsConstant = true) + return createConstant( + value, + expectedType, + CompileTimeConstant.Parameters.Impl( + canBeUsedInAnnotation = isPropertyCompileTimeConstant(callableDescriptor), + isPure = false, + usesVariableAsConstant = true + ) + ) } } return null @@ -468,18 +483,17 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return OperationArgument(evaluationResult, compileTimeType, expression) } - fun createCompileTimeConstant(value: Any?, - expectedType: JetType?, - isPure: Boolean = true, - canBeUsedInAnnotation: Boolean = true, - usesVariableAsConstant: Boolean = false): CompileTimeConstant<*>? { - val c = EvaluatorContext(canBeUsedInAnnotation, isPure, usesVariableAsConstant) - return createCompileTimeConstant(value, c, if (isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) + fun createConstant( + value: Any?, + expectedType: JetType?, + parameters: CompileTimeConstant.Parameters + ): CompileTimeConstant<*>? { + return createCompileTimeConstant(value, parameters, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) } } public fun IntegerValueTypeConstant.createCompileTimeConstantWithType(expectedType: JetType): CompileTimeConstant<*>? - = createCompileTimeConstant(this.getValue(expectedType), EvaluatorContext(this.canBeUsedInAnnotations(), true)) + = createCompileTimeConstant(this.getValue(expectedType), CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false)) private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L') @@ -536,16 +550,16 @@ private fun parseBoolean(text: String): Boolean { } -private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, c: EvaluatorContext): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, parameters: CompileTimeConstant.Parameters): CompileTimeConstant<*>? { if (result is Boolean) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for equals operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() return when (operationToken) { - JetTokens.EQEQ -> BooleanValue(result, c.canBeUsedInAnnotation, c.usesVariableAsConstant) - JetTokens.EXCLEQ -> BooleanValue(!result, c.canBeUsedInAnnotation, c.usesVariableAsConstant) + JetTokens.EQEQ -> BooleanValue(result, parameters) + JetTokens.EXCLEQ -> BooleanValue(!result, parameters) JetTokens.IDENTIFIER -> { assert (operationReference.getReferencedNameAsName() == OperatorConventions.EQUALS, "This method should be called only for equals operations") - return BooleanValue(result, c.canBeUsedInAnnotation, c.usesVariableAsConstant) + return BooleanValue(result, parameters) } else -> throw IllegalStateException("Unknown equals operation token: $operationToken ${operationReference.getText()}") } @@ -553,18 +567,18 @@ private fun createCompileTimeConstantForEquals(result: Any?, operationReference: return null } -private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, c: EvaluatorContext): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, parameters: CompileTimeConstant.Parameters): CompileTimeConstant<*>? { if (result is Int) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for compareTo operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() return when (operationToken) { - JetTokens.LT -> BooleanValue(result < 0, c.canBeUsedInAnnotation, c.usesVariableAsConstant) - JetTokens.LTEQ -> BooleanValue(result <= 0, c.canBeUsedInAnnotation, c.usesVariableAsConstant) - JetTokens.GT -> BooleanValue(result > 0, c.canBeUsedInAnnotation, c.usesVariableAsConstant) - JetTokens.GTEQ -> BooleanValue(result >= 0, c.canBeUsedInAnnotation, c.usesVariableAsConstant) + JetTokens.LT -> BooleanValue(result < 0, parameters) + JetTokens.LTEQ -> BooleanValue(result <= 0, parameters) + JetTokens.GT -> BooleanValue(result > 0, parameters) + JetTokens.GTEQ -> BooleanValue(result >= 0, parameters) JetTokens.IDENTIFIER -> { assert (operationReference.getReferencedNameAsName() == OperatorConventions.COMPARE_TO, "This method should be called only for compareTo operations") - return IntValue(result, c.canBeUsedInAnnotation, c.isPure, c.usesVariableAsConstant) + return IntValue(result, parameters) } else -> throw IllegalStateException("Unknown compareTo operation token: $operationToken") } @@ -574,21 +588,17 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? { return when (value) { - is IntegerValueTypeConstant -> StringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString(), value.canBeUsedInAnnotations(), value.usesVariableAsConstant()) + is IntegerValueTypeConstant -> StringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString(), value.parameters) is StringValue -> value is IntValue, is ByteValue, is ShortValue, is LongValue, is CharValue, is DoubleValue, is FloatValue, is BooleanValue, - is NullValue -> StringValue("${value.value}", value.canBeUsedInAnnotations(), value.usesVariableAsConstant()) + is NullValue -> StringValue("${value.value}", value.parameters) else -> null } } -private fun createCompileTimeConstant(value: Any?, c: EvaluatorContext, expectedType: JetType? = null): CompileTimeConstant<*>? { - return createCompileTimeConstant(value, c.canBeUsedInAnnotation, c.isPure, c.usesVariableAsConstant, expectedType) -} - fun isIntegerType(value: Any?) = value is Byte || value is Short || value is Int || value is Long private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): JetType? { @@ -618,8 +628,6 @@ private fun getCompileTimeType(c: JetType): CompileTimeType? { } } -private class EvaluatorContext(val canBeUsedInAnnotation: Boolean, val isPure: Boolean, val usesVariableAsConstant: Boolean = false) - private class CompileTimeType private val BYTE = CompileTimeType() diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 6e6d7416e23..b936d81084e 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -121,11 +121,12 @@ public object AnnotationSerializer { // TODO: IntegerValueTypeConstant should not occur in annotation arguments val number = constant.getValue(type) val specificConstant = with(KotlinBuiltIns.getInstance()) { + val parameters = CompileTimeConstant.Parameters.ThrowException when (type) { - getLongType() -> LongValue(number.toLong(), true, true, true) - getIntType() -> IntValue(number.toInt(), true, true, true) - getShortType() -> ShortValue(number.toShort(), true, true, true) - getByteType() -> ByteValue(number.toByte(), true, true, true) + getLongType() -> LongValue(number.toLong(), parameters) + getIntType() -> IntValue(number.toInt(), parameters) + getShortType() -> ShortValue(number.toShort(), parameters) + getByteType() -> ByteValue(number.toByte(), parameters) else -> throw IllegalStateException("Integer constant $constant has non-integer type $type") } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index bb7c81b8a04..d8ab3ebcbf0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -100,7 +100,7 @@ class LazyJavaAnnotationDescriptor( private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): CompileTimeConstant<*>? { return when (argument) { - is JavaLiteralAnnotationArgument -> createCompileTimeConstant(argument.value, true, false, false, null) + is JavaLiteralAnnotationArgument -> createCompileTimeConstant(argument.value, CompileTimeConstant.Parameters.Impl(true, false, false)) is JavaEnumValueAnnotationArgument -> resolveFromEnumValue(argument.resolve()) is JavaArrayAnnotationArgument -> resolveFromArray(argument.name ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements()) is JavaAnnotationAsAnnotationArgument -> resolveFromAnnotation(argument.getAnnotation()) @@ -125,7 +125,7 @@ class LazyJavaAnnotationDescriptor( val values = elements.map { argument -> resolveAnnotationArgument(argument) ?: NullValue } - return ArrayValue(values, valueParameter.getType(), values.any { it.usesVariableAsConstant() }) + return ArrayValue(values, valueParameter.getType(), CompileTimeConstant.Parameters.Impl(true, false, values.any { it.usesVariableAsConstant() })) } private fun resolveFromEnumValue(element: JavaField?): CompileTimeConstant<*>? { @@ -140,7 +140,7 @@ class LazyJavaAnnotationDescriptor( val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(element.getName()) if (classifier !is ClassDescriptor) return null - return EnumValue(classifier, false) + return EnumValue(classifier) } private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index 0a8c0c9984e..17beab314dd 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -66,8 +66,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( } val compileTimeConstant = createCompileTimeConstant( - normalizedValue, canBeUsedInAnnotation = true, isPureIntConstant = true, - usesVariableAsConstant = true, expectedType = null + normalizedValue, CompileTimeConstant.Parameters.ThrowException ) return compileTimeConstant } @@ -107,7 +106,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( val parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass) if (parameter != null) { elements.trimToSize() - arguments[parameter] = ArrayValue(elements, parameter.getType(), false) + arguments[parameter] = ArrayValue(elements, parameter.getType(), CompileTimeConstant.Parameters.ThrowException) } } } @@ -130,7 +129,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name) if (classifier is ClassDescriptor) { - return EnumValue(classifier, false) + return EnumValue(classifier) } } return ErrorValue.create("Unresolved enum entry: $enumClassId.$name") @@ -141,9 +140,10 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( } private fun createConstant(name: Name?, value: Any?): CompileTimeConstant<*> { - return createCompileTimeConstant(value, canBeUsedInAnnotation = true, isPureIntConstant = false, - usesVariableAsConstant = false, expectedType = null) - ?: ErrorValue.create("Unsupported annotation argument: $name") + return createCompileTimeConstant( + value, + CompileTimeConstant.Parameters.ThrowException + ) ?: ErrorValue.create("Unsupported annotation argument: $name") } private fun setArgumentValueByName(name: Name, argumentValue: CompileTimeConstant<*>) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt index 0fcc18648ed..8dcd6304934 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt @@ -21,7 +21,8 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.types.JetType -public class AnnotationValue(value: AnnotationDescriptor) : CompileTimeConstant(value, true, false, false) { +public class AnnotationValue(value: AnnotationDescriptor) : + CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = value.getType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitAnnotationValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index 137f84f1012..46ae183fb7b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -24,8 +24,17 @@ import java.util.* public class ArrayValue( value: List>, private val type: JetType, - usesVariableAsConstant: Boolean -) : CompileTimeConstant>>(value, true, false, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant>>(value, parameters) { + + public constructor( + value: List>, + type: JetType, + usesVariableAsConstant: Boolean + ) : this(value, type, CompileTimeConstant.Parameters.Impl(true, false, usesVariableAsConstant)) + + override fun canBeUsedInAnnotations() = true + override fun isPure() = false init { assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt index aa691a535f5..d703db17024 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt @@ -22,9 +22,10 @@ import org.jetbrains.kotlin.types.JetType public class BooleanValue( value: Boolean, - canBeUseInAnnotation: Boolean, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, canBeUseInAnnotation, false, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant(value, parameters) { + override fun isPure(): Boolean = false + override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getBooleanType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitBooleanValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt index 973ec0af255..a9d73f2b598 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt @@ -22,10 +22,8 @@ import org.jetbrains.kotlin.types.JetType public class ByteValue( value: Byte, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVaraiableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVaraiableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getByteType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt index fb9a93adda1..f5285f8ea97 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt @@ -22,10 +22,8 @@ import org.jetbrains.kotlin.types.JetType public class CharValue( value: Char, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVariableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getCharType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index d7c8c477387..a9d752f6c41 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -20,24 +20,15 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public abstract class CompileTimeConstant protected constructor(public open val value: T, canBeUsedInAnnotations: Boolean, isPure: Boolean, usesVariableAsConstant: Boolean) { - private val flags: Int +public abstract class CompileTimeConstant protected constructor( + public open val value: T, + public val parameters: CompileTimeConstant.Parameters +) { + public open fun canBeUsedInAnnotations(): Boolean = parameters.canBeUsedInAnnotation - init { - flags = (if (isPure) IS_PURE_MASK else 0) or (if (canBeUsedInAnnotations) CAN_BE_USED_IN_ANNOTATIONS_MASK else 0) or (if (usesVariableAsConstant) USES_VARIABLE_AS_CONSTANT_MASK else 0) - } + public open fun isPure(): Boolean = parameters.isPure - public fun canBeUsedInAnnotations(): Boolean { - return (flags and CAN_BE_USED_IN_ANNOTATIONS_MASK) != 0 - } - - public fun isPure(): Boolean { - return (flags and IS_PURE_MASK) != 0 - } - - public fun usesVariableAsConstant(): Boolean { - return (flags and USES_VARIABLE_AS_CONSTANT_MASK) != 0 - } + public open fun usesVariableAsConstant(): Boolean = parameters.usesVariableAsConstant public abstract fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType @@ -45,16 +36,24 @@ public abstract class CompileTimeConstant protected constructor(public open v override fun toString() = value.toString() - companion object { + public interface Parameters { + public open val canBeUsedInAnnotation: Boolean + public open val isPure: Boolean + public open val usesVariableAsConstant: Boolean - /* - * if is pure is false then constant type cannot be changed - * ex1. val a: Long = 1.toInt() (TYPE_MISMATCH error, 1.toInt() isn't pure) - * ex2. val b: Int = a (TYPE_MISMATCH error, a isn't pure) - * - */ - private val IS_PURE_MASK = 1 - private val CAN_BE_USED_IN_ANNOTATIONS_MASK = 1 shl 1 - private val USES_VARIABLE_AS_CONSTANT_MASK = 1 shl 2 + public class Impl( + override val canBeUsedInAnnotation: Boolean, + override val isPure: Boolean, + override val usesVariableAsConstant: Boolean + ) : Parameters + + public object ThrowException : Parameters { + override val canBeUsedInAnnotation: Boolean + get() = error("Should not be called") + override val isPure: Boolean + get() = error("Should not be called") + override val usesVariableAsConstant: Boolean + get() = error("Should not be called") + } } -} +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt index a82205ecf24..7273006d1fc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt @@ -22,27 +22,25 @@ import org.jetbrains.kotlin.types.TypeUtils public fun createCompileTimeConstant( value: Any?, - canBeUsedInAnnotation: Boolean, - isPureIntConstant: Boolean, - usesVariableAsConstant: Boolean = false, + parameters: CompileTimeConstant.Parameters, expectedType: JetType? = null ): CompileTimeConstant<*>? { // TODO: primitive arrays if (expectedType == null) { when(value) { - is Byte -> return ByteValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - is Short -> return ShortValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - is Int -> return IntValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - is Long -> return LongValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) + is Byte -> return ByteValue(value, parameters) + is Short -> return ShortValue(value, parameters) + is Int -> return IntValue(value, parameters) + is Long -> return LongValue(value, parameters) } } return when(value) { - is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant, expectedType) - is Char -> CharValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - is Float -> FloatValue(value, canBeUsedInAnnotation, usesVariableAsConstant) - is Double -> DoubleValue(value, canBeUsedInAnnotation, usesVariableAsConstant) - is Boolean -> BooleanValue(value, canBeUsedInAnnotation, usesVariableAsConstant) - is String -> StringValue(value, canBeUsedInAnnotation, usesVariableAsConstant) + is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), parameters, expectedType) + is Char -> CharValue(value, parameters) + is Float -> FloatValue(value, parameters) + is Double -> DoubleValue(value, parameters) + is Boolean -> BooleanValue(value, parameters) + is String -> StringValue(value, parameters) null -> NullValue else -> null } @@ -50,32 +48,37 @@ public fun createCompileTimeConstant( private fun getIntegerValue( value: Long, - canBeUsedInAnnotation: Boolean, - isPureIntConstant: Boolean, - usesVariableAsConstant: Boolean, + parameters: CompileTimeConstant.Parameters, expectedType: JetType ): CompileTimeConstant<*>? { fun defaultIntegerValue(value: Long) = when (value) { - value.toInt().toLong() -> IntValue(value.toInt(), canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - else -> LongValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) + value.toInt().toLong() -> IntValue(value.toInt(), parameters) + else -> LongValue(value, parameters) } if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { - return IntegerValueTypeConstant(value, canBeUsedInAnnotation, usesVariableAsConstant) + return IntegerValueTypeConstant(value, parameters) } val notNullExpected = TypeUtils.makeNotNullable(expectedType) return when { - KotlinBuiltIns.isLong(notNullExpected) -> LongValue(value, canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - KotlinBuiltIns.isShort(notNullExpected) -> when (value) { - value.toShort().toLong() -> ShortValue(value.toShort(), canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - else -> defaultIntegerValue(value) - } - KotlinBuiltIns.isByte(notNullExpected) -> when (value) { - value.toByte().toLong() -> ByteValue(value.toByte(), canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) - else -> defaultIntegerValue(value) - } - KotlinBuiltIns.isChar(notNullExpected) -> IntValue(value.toInt(), canBeUsedInAnnotation, isPureIntConstant, usesVariableAsConstant) + KotlinBuiltIns.isLong(notNullExpected) -> LongValue(value, parameters) + + KotlinBuiltIns.isShort(notNullExpected) -> + if (value == value.toShort().toLong()) + ShortValue(value.toShort(), parameters) + else + defaultIntegerValue(value) + + KotlinBuiltIns.isByte(notNullExpected) -> + if (value == value.toByte().toLong()) + ByteValue(value.toByte(), parameters) + else + defaultIntegerValue(value) + + KotlinBuiltIns.isChar(notNullExpected) -> + IntValue(value.toInt(), parameters) + else -> defaultIntegerValue(value) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt index 351861c4c86..111ea9acad3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt @@ -22,9 +22,10 @@ import org.jetbrains.kotlin.types.JetType public class DoubleValue( value: Double, - canBeUsedInAnnotations: Boolean, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant(value, parameters) { + + override fun isPure() = false override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getDoubleType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt index 2afd293da3c..fe734397589 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt @@ -24,9 +24,8 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.sure public class EnumValue( - value: ClassDescriptor, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, true, false, usesVariableAsConstant) { + value: ClassDescriptor +) : CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = getType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt index 74164f3019d..e73a0802c42 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType -public abstract class ErrorValue : CompileTimeConstant(Unit, true, false, false) { +public abstract class ErrorValue : CompileTimeConstant(Unit, CompileTimeConstant.Parameters.Impl(true, false, false)) { deprecated("Should not be called, for this is not a real value, but a indication of an error") override val value: Unit diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt index ba1e4f037c6..c78672653ea 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt @@ -22,9 +22,9 @@ import org.jetbrains.kotlin.types.JetType public class FloatValue( value: Float, - canBeUsedInAnnotations: Boolean, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant(value, parameters) { + override fun isPure() = false override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getFloatType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt index bb3333e70de..ec2bbce627b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt @@ -22,10 +22,8 @@ import org.jetbrains.kotlin.types.JetType public class IntValue( value: Int, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVariableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getIntType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt index 3c71270741f..e6501aee9e2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt @@ -18,7 +18,5 @@ package org.jetbrains.kotlin.resolve.constants public abstract class IntegerValueConstant protected constructor( value: T, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant(value, parameters) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt index 65744390727..f487be511b3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt @@ -25,9 +25,10 @@ import java.util.Collections public class IntegerValueTypeConstant( value: Number, - canBeUsedInAnnotations: Boolean, - usesVariableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, true, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { + + override fun isPure() = true private val typeConstructor = IntegerValueTypeConstructor(value.toLong()) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt index ec518f99fbd..9a6a867198e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType - -public class KClassValue(private val type: JetType) : CompileTimeConstant(type, true, false, false) { +public class KClassValue(private val type: JetType) : + CompileTimeConstant(type, CompileTimeConstant.Parameters.Impl(true, false, false)) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = type override val value: JetType get() = type.getArguments().single().getType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt index c442492f435..fe443987362 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt @@ -22,10 +22,8 @@ import org.jetbrains.kotlin.types.JetType public class LongValue( value: Long, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVariableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getLongType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt index 8c28e6ca910..5554fc8167a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public object NullValue : CompileTimeConstant(null, false, false, false) { +public object NullValue : CompileTimeConstant(null, CompileTimeConstant.Parameters.Impl(false, false, false)) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getNullableNothingType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt index f1d71050be2..917fcb77f1f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt @@ -22,10 +22,8 @@ import org.jetbrains.kotlin.types.JetType public class ShortValue( value: Short, - canBeUsedInAnnotations: Boolean, - pure: Boolean, - usesVariableAsConstant: Boolean -) : IntegerValueConstant(value, canBeUsedInAnnotations, pure, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : IntegerValueConstant(value, parameters) { override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getShortType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt index f8467927cd8..26c9b2c5286 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt @@ -22,9 +22,9 @@ import org.jetbrains.kotlin.types.JetType public class StringValue( value: String, - canBeUsedInAnnotations: Boolean, - usesVariableAsConstant: Boolean -) : CompileTimeConstant(value, canBeUsedInAnnotations, false, usesVariableAsConstant) { + parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant(value, parameters) { + override fun isPure() = false override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getStringType() diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 25faaeb8d90..b42e01b7e1b 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -68,17 +68,18 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { value: Value, nameResolver: NameResolver ): CompileTimeConstant<*> { + val parameters = CompileTimeConstant.Parameters.ThrowException val result = when (value.getType()) { - Type.BYTE -> ByteValue(value.getIntValue().toByte(), true, true, true) - Type.CHAR -> CharValue(value.getIntValue().toChar(), true, true, true) - Type.SHORT -> ShortValue(value.getIntValue().toShort(), true, true, true) - Type.INT -> IntValue(value.getIntValue().toInt(), true, true, true) - Type.LONG -> LongValue(value.getIntValue(), true, true, true) - Type.FLOAT -> FloatValue(value.getFloatValue(), true, true) - Type.DOUBLE -> DoubleValue(value.getDoubleValue(), true, true) - Type.BOOLEAN -> BooleanValue(value.getIntValue() != 0L, true, true) + Type.BYTE -> ByteValue(value.getIntValue().toByte(), parameters) + Type.CHAR -> CharValue(value.getIntValue().toChar(), parameters) + Type.SHORT -> ShortValue(value.getIntValue().toShort(), parameters) + Type.INT -> IntValue(value.getIntValue().toInt(), parameters) + Type.LONG -> LongValue(value.getIntValue(), parameters) + Type.FLOAT -> FloatValue(value.getFloatValue(), parameters) + Type.DOUBLE -> DoubleValue(value.getDoubleValue(), parameters) + Type.BOOLEAN -> BooleanValue(value.getIntValue() != 0L, parameters) Type.STRING -> { - StringValue(nameResolver.getString(value.getStringValue()), true, true) + StringValue(nameResolver.getString(value.getStringValue()), parameters) } Type.CLASS -> { // TODO: support class literals @@ -114,7 +115,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { resolveValue(expectedElementType, it, nameResolver) }, actualArrayType, - true + parameters ) } else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)") @@ -135,7 +136,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName) if (enumEntry is ClassDescriptor) { - return EnumValue(enumEntry, true) + return EnumValue(enumEntry) } } return ErrorValue.create("Unresolved enum entry: $enumClassId.$enumEntryName") From ea1a85e78cbbe527c92c0e378a36b86d66dd0cac Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Mon, 6 Jul 2015 20:37:50 +0300 Subject: [PATCH 282/450] Introduce CompileTimeConstantFactory --- .../JavaPropertyInitializerEvaluatorImpl.java | 10 +- .../evaluate/ConstantExpressionEvaluator.kt | 88 +++++++------ .../serialization/AnnotationSerializer.kt | 12 +- .../LazyJavaAnnotationDescriptor.kt | 23 ++-- ...aryClassAnnotationAndConstantLoaderImpl.kt | 18 +-- .../constants/CompileTimeConstantFactory.kt | 122 ++++++++++++++++++ .../kotlin/resolve/constants/ConstantUtils.kt | 84 ------------ .../deserialization/AnnotationDeserializer.kt | 32 ++--- 8 files changed, 214 insertions(+), 175 deletions(-) create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt delete mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java index 582a69a9e9f..e5f1117ea46 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.PropertyDescriptor; import org.jetbrains.kotlin.load.java.structure.JavaField; import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.ConstantsPackage; +import org.jetbrains.kotlin.resolve.constants.CompileTimeConstantFactory; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitializerEvaluator { @@ -35,15 +35,13 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial PsiExpression initializer = ((JavaFieldImpl) field).getInitializer(); Object evaluatedExpression = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false); if (evaluatedExpression != null) { - return ConstantsPackage.createCompileTimeConstant( - evaluatedExpression, + CompileTimeConstantFactory factory = new CompileTimeConstantFactory( new CompileTimeConstant.Parameters.Impl( ConstantExpressionEvaluator.isPropertyCompileTimeConstant(descriptor), false, true - ), - descriptor.getType() - ); + )); + return factory.createCompileTimeConstant(evaluatedExpression, descriptor.getType()); } return null; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 015a4fcdff6..c3c318dc2ab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -17,26 +17,27 @@ package org.jetbrains.kotlin.resolve.constants.evaluate import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.kotlin.JetNodeTypes +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.* +import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument +import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.constants.* import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.expressions.OperatorConventions -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument -import org.jetbrains.kotlin.JetNodeTypes -import org.jetbrains.kotlin.diagnostics.DiagnosticUtils +import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.math.BigInteger -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages -import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall -import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import kotlin.platform.platformStatic public class ConstantExpressionEvaluator private constructor(val trace: BindingTrace) : JetVisitor, JetType>() { @@ -85,6 +86,8 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } private val stringExpressionEvaluator = object : JetVisitor() { + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false)) + fun evaluate(entry: JetStringTemplateEntry): StringValue? { return entry.accept(this, null) } @@ -96,14 +99,13 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return createStringConstant(this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType())) } - override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = StringValue(entry.getText(), CompileTimeConstant.Parameters.Impl(true, false, false)) + override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getText()) - override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = StringValue(entry.getUnescapedValue(), CompileTimeConstant.Parameters.Impl(true, false, false)) + override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getUnescapedValue()) } override fun visitConstantExpression(expression: JetConstantExpression, expectedType: JetType?): CompileTimeConstant<*>? { - val text = expression.getText() - if (text == null) return null + val text = expression.getText() ?: return null val nodeElementType = expression.getNode().getElementType() if (nodeElementType == JetNodeTypes.NULL) return NullValue @@ -114,8 +116,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT JetNodeTypes.BOOLEAN_CONSTANT -> parseBoolean(text) JetNodeTypes.CHARACTER_CONSTANT -> CompileTimeConstantChecker.parseChar(expression) else -> throw IllegalArgumentException("Unsupported constant: " + expression) - } - if (result == null) return null + } ?: return null fun isLongWithSuffix() = nodeElementType == JetNodeTypes.INTEGER_CONSTANT && hasLongSuffix(text) return createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(true, !isLongWithSuffix(), false)) @@ -164,11 +165,11 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT usesVariableAsConstant = usesVariableAsConstant ) ) - else null + else null } override fun visitBinaryWithTypeRHSExpression(expression: JetBinaryExpressionWithTypeRHS, expectedType: JetType?): CompileTimeConstant<*>? = - evaluate(expression.getLeft(), expectedType) + evaluate(expression.getLeft(), expectedType) override fun visitBinaryExpression(expression: JetBinaryExpression, expectedType: JetType?): CompileTimeConstant<*>? { val leftExpression = expression.getLeft() @@ -190,7 +191,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val rightValue = rightConstant.value if (leftValue !is Boolean || rightValue !is Boolean) return null - val result = when(operationToken) { + val result = when (operationToken) { JetTokens.ANDAND -> leftValue && rightValue JetTokens.OROR -> leftValue || rightValue else -> throw IllegalArgumentException("Unknown boolean operation token ${operationToken}") @@ -237,6 +238,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) { val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())!! trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression)) + //TODO_R: return ErrorValue.create("Division by zero") } @@ -247,11 +249,12 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression) val usesVariableAsConstant = usesVariableAsConstant(argumentForReceiver.expression) || usesVariableAsConstant(argumentForParameter.expression) val parameters = CompileTimeConstant.Parameters.Impl(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) - return when(resultingDescriptorName) { - OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, parameters) - OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, parameters) + val factory = CompileTimeConstantFactory(parameters) + return when (resultingDescriptorName) { + OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory) + OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory) else -> { - createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(areArgumentsPure, canBeUsedInAnnotation, usesVariableAsConstant)) + createConstant(result, expectedType, parameters) } } } @@ -296,7 +299,8 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val (function, checker) = functions val actualResult = try { function(receiver.value, parameter.value) - } catch (e: Exception) { + } + catch (e: Exception) { null } if (checker == emptyBinaryFun) { @@ -402,6 +406,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val varargType = resultingDescriptor.getValueParameters().first().getVarargElementType()!! val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) } + return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, arguments.any() { it.usesVariableAsConstant() }) } @@ -488,12 +493,12 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT expectedType: JetType?, parameters: CompileTimeConstant.Parameters ): CompileTimeConstant<*>? { - return createCompileTimeConstant(value, parameters, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) + return CompileTimeConstantFactory(parameters).createCompileTimeConstant(value, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) } } public fun IntegerValueTypeConstant.createCompileTimeConstantWithType(expectedType: JetType): CompileTimeConstant<*>? - = createCompileTimeConstant(this.getValue(expectedType), CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false)) + = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false)).createCompileTimeConstant(this.getValue(expectedType)) private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L') @@ -550,35 +555,36 @@ private fun parseBoolean(text: String): Boolean { } -private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, parameters: CompileTimeConstant.Parameters): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, factory: CompileTimeConstantFactory): CompileTimeConstant<*>? { if (result is Boolean) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for equals operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() - return when (operationToken) { - JetTokens.EQEQ -> BooleanValue(result, parameters) - JetTokens.EXCLEQ -> BooleanValue(!result, parameters) + val value: Boolean = when (operationToken) { + JetTokens.EQEQ -> result + JetTokens.EXCLEQ -> !result JetTokens.IDENTIFIER -> { assert (operationReference.getReferencedNameAsName() == OperatorConventions.EQUALS, "This method should be called only for equals operations") - return BooleanValue(result, parameters) + result } else -> throw IllegalStateException("Unknown equals operation token: $operationToken ${operationReference.getText()}") } + return factory.createBooleanValue(value) } return null } -private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, parameters: CompileTimeConstant.Parameters): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, factory: CompileTimeConstantFactory): CompileTimeConstant<*>? { if (result is Int) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for compareTo operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() return when (operationToken) { - JetTokens.LT -> BooleanValue(result < 0, parameters) - JetTokens.LTEQ -> BooleanValue(result <= 0, parameters) - JetTokens.GT -> BooleanValue(result > 0, parameters) - JetTokens.GTEQ -> BooleanValue(result >= 0, parameters) + JetTokens.LT -> factory.createBooleanValue(result < 0) + JetTokens.LTEQ -> factory.createBooleanValue(result <= 0) + JetTokens.GT -> factory.createBooleanValue(result > 0) + JetTokens.GTEQ -> factory.createBooleanValue(result >= 0) JetTokens.IDENTIFIER -> { assert (operationReference.getReferencedNameAsName() == OperatorConventions.COMPARE_TO, "This method should be called only for compareTo operations") - return IntValue(result, parameters) + return factory.createIntValue(result) } else -> throw IllegalStateException("Unknown compareTo operation token: $operationToken") } @@ -588,13 +594,13 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? { return when (value) { - is IntegerValueTypeConstant -> StringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString(), value.parameters) + is IntegerValueTypeConstant -> CompileTimeConstantFactory(value.parameters).createStringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString()) is StringValue -> value is IntValue, is ByteValue, is ShortValue, is LongValue, is CharValue, is DoubleValue, is FloatValue, is BooleanValue, - is NullValue -> StringValue("${value.value}", value.parameters) + is NullValue -> CompileTimeConstantFactory(value.parameters).createStringValue("${value.value}") else -> null } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index b936d81084e..72e006e402d 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -27,6 +27,9 @@ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType public object AnnotationSerializer { + + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) + public fun serializeAnnotation(annotation: AnnotationDescriptor, stringTable: StringTable): ProtoBuf.Annotation { return with(ProtoBuf.Annotation.newBuilder()) { val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as? ClassDescriptor @@ -121,12 +124,11 @@ public object AnnotationSerializer { // TODO: IntegerValueTypeConstant should not occur in annotation arguments val number = constant.getValue(type) val specificConstant = with(KotlinBuiltIns.getInstance()) { - val parameters = CompileTimeConstant.Parameters.ThrowException when (type) { - getLongType() -> LongValue(number.toLong(), parameters) - getIntType() -> IntValue(number.toInt(), parameters) - getShortType() -> ShortValue(number.toShort(), parameters) - getByteType() -> ByteValue(number.toByte(), parameters) + getLongType() -> factory.createLongValue(number.toLong()) + getIntType() -> factory.createIntValue(number.toInt()) + getShortType() -> factory.createShortValue(number.toShort()) + getByteType() -> factory.createByteValue(number.toByte()) else -> throw IllegalStateException("Integer constant $constant has non-integer type $type") } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index d8ab3ebcbf0..9aea20d079d 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -64,6 +64,8 @@ class LazyJavaAnnotationDescriptor( annotationClass?.getDefaultType() ?: ErrorUtils.createErrorType(fqName.asString()) } + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false)) + override fun getType(): JetType = type() private val allValueArguments = c.storageManager.createLazyValue { @@ -100,7 +102,7 @@ class LazyJavaAnnotationDescriptor( private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): CompileTimeConstant<*>? { return when (argument) { - is JavaLiteralAnnotationArgument -> createCompileTimeConstant(argument.value, CompileTimeConstant.Parameters.Impl(true, false, false)) + is JavaLiteralAnnotationArgument -> factory.createCompileTimeConstant(argument.value) is JavaEnumValueAnnotationArgument -> resolveFromEnumValue(argument.resolve()) is JavaArrayAnnotationArgument -> resolveFromArray(argument.name ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements()) is JavaAnnotationAsAnnotationArgument -> resolveFromAnnotation(argument.getAnnotation()) @@ -110,22 +112,20 @@ class LazyJavaAnnotationDescriptor( } private fun resolveFromAnnotation(javaAnnotation: JavaAnnotation): CompileTimeConstant<*>? { - val descriptor = c.resolveAnnotation(javaAnnotation) - if (descriptor == null) return null + val descriptor = c.resolveAnnotation(javaAnnotation) ?: return null - return AnnotationValue(descriptor) + return factory.createAnnotationValue(descriptor) } private fun resolveFromArray(argumentName: Name, elements: List): CompileTimeConstant<*>? { if (getType().isError()) return null - val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) - if (valueParameter == null) return null + val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) ?: return null val values = elements.map { - argument -> resolveAnnotationArgument(argument) ?: NullValue + argument -> resolveAnnotationArgument(argument) ?: factory.createNullValue() } - return ArrayValue(values, valueParameter.getType(), CompileTimeConstant.Parameters.Impl(true, false, values.any { it.usesVariableAsConstant() })) + return factory.createArrayValue(values, valueParameter.getType()) } private fun resolveFromEnumValue(element: JavaField?): CompileTimeConstant<*>? { @@ -134,13 +134,12 @@ class LazyJavaAnnotationDescriptor( val containingJavaClass = element.getContainingClass() //TODO: (module refactoring) moduleClassResolver should be used here - val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) - if (enumClass == null) return null + val enumClass = c.javaClassResolver.resolveClass(containingJavaClass) ?: return null val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(element.getName()) if (classifier !is ClassDescriptor) return null - return EnumValue(classifier) + return factory.createEnumValue(classifier) } private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? { @@ -160,7 +159,7 @@ class LazyJavaAnnotationDescriptor( override fun computeMemberScope() = jlClass.getMemberScope(arguments) } - return KClassValue(javaClassObjectType) + return factory.createKClassValue(javaClassObjectType) } override fun toString(): String { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index 17beab314dd..efa26f4f311 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -46,6 +46,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( storageManager, kotlinClassFinder, errorReporter ) { private val annotationDeserializer = AnnotationDeserializer(module) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) override fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor = annotationDeserializer.deserializeAnnotation(proto, nameResolver) @@ -65,10 +66,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( initializer } - val compileTimeConstant = createCompileTimeConstant( - normalizedValue, CompileTimeConstant.Parameters.ThrowException - ) - return compileTimeConstant + return factory.createCompileTimeConstant(normalizedValue) } override fun loadAnnotation( @@ -106,7 +104,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( val parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass) if (parameter != null) { elements.trimToSize() - arguments[parameter] = ArrayValue(elements, parameter.getType(), CompileTimeConstant.Parameters.ThrowException) + arguments[parameter] = factory.createArrayValue(elements, parameter.getType()) } } } @@ -129,10 +127,10 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name) if (classifier is ClassDescriptor) { - return EnumValue(classifier) + return factory.createEnumValue(classifier) } } - return ErrorValue.create("Unresolved enum entry: $enumClassId.$name") + return factory.createErrorValue("Unresolved enum entry: $enumClassId.$name") } override fun visitEnd() { @@ -140,10 +138,8 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( } private fun createConstant(name: Name?, value: Any?): CompileTimeConstant<*> { - return createCompileTimeConstant( - value, - CompileTimeConstant.Parameters.ThrowException - ) ?: ErrorValue.create("Unsupported annotation argument: $name") + return factory.createCompileTimeConstant(value) ?: + factory.createErrorValue("Unsupported annotation argument: $name") } private fun setArgumentValueByName(name: Name, argumentValue: CompileTimeConstant<*>) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt new file mode 100644 index 00000000000..5709bc40784 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt @@ -0,0 +1,122 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.constants + +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeUtils + +public class CompileTimeConstantFactory(private val parameters: CompileTimeConstant.Parameters) { + fun createLongValue(value: Long) = LongValue(value, parameters) + + fun createIntValue(value: Int) = IntValue(value, parameters) + + fun createErrorValue(message: String) = ErrorValue.create(message) + + fun createShortValue(value: Short) = ShortValue(value, parameters) + + fun createByteValue(value: Byte) = ByteValue(value, parameters) + + fun createDoubleValue(value: Double) = DoubleValue(value, parameters) + + fun createFloatValue(value: Float) = FloatValue(value, parameters) + + fun createBooleanValue(value: Boolean) = BooleanValue(value, parameters) + + fun createCharValue(value: Char) = CharValue(value, parameters) + + fun createStringValue(value: String) = StringValue(value, parameters) + + fun createNullValue() = NullValue + + fun createEnumValue(enumEntryClass: ClassDescriptor): EnumValue = EnumValue(enumEntryClass) + + fun createArrayValue( + value: List>, + type: JetType + ) = ArrayValue(value, type, parameters) + + fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value) + + fun createKClassValue(type: JetType) = KClassValue(type) + + fun createNumberTypeValue(value: Number) = IntegerValueTypeConstant(value, parameters) + + + fun createCompileTimeConstant( + value: Any?, + expectedType: JetType? = null + ): CompileTimeConstant<*>? { + // TODO: primitive arrays + if (expectedType == null) { + when (value) { + is Byte -> return createByteValue(value) + is Short -> return createShortValue(value) + is Int -> return createIntValue(value) + is Long -> return createLongValue(value) + } + } + return when (value) { + is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), expectedType) + is Char -> createCharValue(value) + is Float -> createFloatValue(value) + is Double -> createDoubleValue(value) + is Boolean -> createBooleanValue(value) + is String -> createStringValue(value) + null -> createNullValue() + else -> null + } + } + + private fun getIntegerValue( + value: Long, + expectedType: JetType + ): CompileTimeConstant<*>? { + fun defaultIntegerValue(value: Long) = when (value) { + value.toInt().toLong() -> createIntValue(value.toInt()) + else -> createLongValue(value) + } + + if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { + return createNumberTypeValue(value) + } + + val notNullExpected = TypeUtils.makeNotNullable(expectedType) + return when { + KotlinBuiltIns.isLong(notNullExpected) -> createLongValue(value) + + KotlinBuiltIns.isShort(notNullExpected) -> + if (value == value.toShort().toLong()) + createShortValue(value.toShort()) + else + defaultIntegerValue(value) + + KotlinBuiltIns.isByte(notNullExpected) -> + if (value == value.toByte().toLong()) + createByteValue(value.toByte()) + else + defaultIntegerValue(value) + + KotlinBuiltIns.isChar(notNullExpected) -> + createIntValue(value.toInt()) + + else -> defaultIntegerValue(value) + } + } +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt deleted file mode 100644 index 7273006d1fc..00000000000 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantUtils.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.constants - -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.types.TypeUtils - -public fun createCompileTimeConstant( - value: Any?, - parameters: CompileTimeConstant.Parameters, - expectedType: JetType? = null -): CompileTimeConstant<*>? { - // TODO: primitive arrays - if (expectedType == null) { - when(value) { - is Byte -> return ByteValue(value, parameters) - is Short -> return ShortValue(value, parameters) - is Int -> return IntValue(value, parameters) - is Long -> return LongValue(value, parameters) - } - } - return when(value) { - is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), parameters, expectedType) - is Char -> CharValue(value, parameters) - is Float -> FloatValue(value, parameters) - is Double -> DoubleValue(value, parameters) - is Boolean -> BooleanValue(value, parameters) - is String -> StringValue(value, parameters) - null -> NullValue - else -> null - } -} - -private fun getIntegerValue( - value: Long, - parameters: CompileTimeConstant.Parameters, - expectedType: JetType -): CompileTimeConstant<*>? { - fun defaultIntegerValue(value: Long) = when (value) { - value.toInt().toLong() -> IntValue(value.toInt(), parameters) - else -> LongValue(value, parameters) - } - - if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { - return IntegerValueTypeConstant(value, parameters) - } - - val notNullExpected = TypeUtils.makeNotNullable(expectedType) - return when { - KotlinBuiltIns.isLong(notNullExpected) -> LongValue(value, parameters) - - KotlinBuiltIns.isShort(notNullExpected) -> - if (value == value.toShort().toLong()) - ShortValue(value.toShort(), parameters) - else - defaultIntegerValue(value) - - KotlinBuiltIns.isByte(notNullExpected) -> - if (value == value.toByte().toLong()) - ByteValue(value.toByte(), parameters) - else - defaultIntegerValue(value) - - KotlinBuiltIns.isChar(notNullExpected) -> - IntValue(value.toInt(), parameters) - - else -> defaultIntegerValue(value) - } -} diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index b42e01b7e1b..69f858a0ffe 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -39,6 +39,8 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { private val builtIns: KotlinBuiltIns get() = module.builtIns + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) + public fun deserializeAnnotation(proto: Annotation, nameResolver: NameResolver): AnnotationDescriptor { val annotationClass = resolveClass(nameResolver.getClassId(proto.getId())) @@ -68,18 +70,17 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { value: Value, nameResolver: NameResolver ): CompileTimeConstant<*> { - val parameters = CompileTimeConstant.Parameters.ThrowException val result = when (value.getType()) { - Type.BYTE -> ByteValue(value.getIntValue().toByte(), parameters) - Type.CHAR -> CharValue(value.getIntValue().toChar(), parameters) - Type.SHORT -> ShortValue(value.getIntValue().toShort(), parameters) - Type.INT -> IntValue(value.getIntValue().toInt(), parameters) - Type.LONG -> LongValue(value.getIntValue(), parameters) - Type.FLOAT -> FloatValue(value.getFloatValue(), parameters) - Type.DOUBLE -> DoubleValue(value.getDoubleValue(), parameters) - Type.BOOLEAN -> BooleanValue(value.getIntValue() != 0L, parameters) + Type.BYTE -> factory.createByteValue(value.getIntValue().toByte()) + Type.CHAR -> factory.createCharValue(value.getIntValue().toChar()) + Type.SHORT -> factory.createShortValue(value.getIntValue().toShort()) + Type.INT -> factory.createIntValue(value.getIntValue().toInt()) + Type.LONG -> factory.createLongValue(value.getIntValue()) + Type.FLOAT -> factory.createFloatValue(value.getFloatValue()) + Type.DOUBLE -> factory.createDoubleValue(value.getDoubleValue()) + Type.BOOLEAN -> factory.createBooleanValue(value.getIntValue() != 0L) Type.STRING -> { - StringValue(nameResolver.getString(value.getStringValue()), parameters) + factory.createStringValue(nameResolver.getString(value.getStringValue())) } Type.CLASS -> { // TODO: support class literals @@ -110,12 +111,11 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { val expectedElementType = builtIns.getArrayElementType(if (expectedIsArray) expectedType else actualArrayType) - ArrayValue( + factory.createArrayValue( arrayElements.map { resolveValue(expectedElementType, it, nameResolver) }, - actualArrayType, - parameters + actualArrayType ) } else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)") @@ -126,7 +126,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { } else { // This means that an annotation class has been changed incompatibly without recompiling clients - return ErrorValue.create("Unexpected argument value") + return factory.createErrorValue("Unexpected argument value") } } @@ -136,10 +136,10 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName) if (enumEntry is ClassDescriptor) { - return EnumValue(enumEntry) + return factory.createEnumValue(enumEntry) } } - return ErrorValue.create("Unresolved enum entry: $enumClassId.$enumEntryName") + return factory.createErrorValue("Unresolved enum entry: $enumClassId.$enumEntryName") } private fun resolveArrayElementType(value: Value, nameResolver: NameResolver): JetType = From 5dc5d77e603ffc15a18e243bd58da690783f97ad Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 7 Jul 2015 13:34:32 +0300 Subject: [PATCH 283/450] Inject builtins in constants --- .../kotlin/codegen/AnnotationCodegen.java | 4 +-- .../codegen/JvmSerializerExtension.java | 4 ++- .../builtins/BuiltInsSerializer.kt | 2 +- .../JavaPropertyInitializerEvaluatorImpl.java | 3 ++- .../resolve/calls/CallExpressionResolver.java | 6 ++--- .../constants/CompileTimeConstantChecker.java | 4 +-- .../evaluate/ConstantExpressionEvaluator.kt | 16 ++++++------ .../BasicExpressionTypingVisitor.java | 6 ++--- .../expressions/ExpressionTypingUtils.java | 5 ++-- .../serialization/AnnotationSerializer.kt | 5 ++-- .../builtins/BuiltInsSerializerExtension.kt | 21 ++++++++-------- .../LazyJavaAnnotationDescriptor.kt | 2 +- ...aryClassAnnotationAndConstantLoaderImpl.kt | 2 +- .../resolve/constants/AnnotationValue.kt | 3 ++- .../kotlin/resolve/constants/ArrayValue.kt | 4 +-- .../kotlin/resolve/constants/BooleanValue.kt | 5 ++-- .../kotlin/resolve/constants/ByteValue.kt | 5 ++-- .../kotlin/resolve/constants/CharValue.kt | 5 ++-- .../resolve/constants/CompileTimeConstant.kt | 2 +- .../constants/CompileTimeConstantFactory.kt | 25 +++++++++++-------- .../kotlin/resolve/constants/DoubleValue.kt | 5 ++-- .../kotlin/resolve/constants/EnumValue.kt | 7 +++--- .../kotlin/resolve/constants/ErrorValue.kt | 2 +- .../kotlin/resolve/constants/FloatValue.kt | 5 ++-- .../kotlin/resolve/constants/IntValue.kt | 5 ++-- .../constants/IntegerValueTypeConstant.kt | 10 +++----- .../kotlin/resolve/constants/KClassValue.kt | 3 +-- .../kotlin/resolve/constants/LongValue.kt | 5 ++-- .../kotlin/resolve/constants/NullValue.kt | 6 +++-- .../kotlin/resolve/constants/ShortValue.kt | 5 ++-- .../kotlin/resolve/constants/StringValue.kt | 5 ++-- .../deserialization/AnnotationDeserializer.kt | 4 +-- .../js/KotlinJavascriptSerializerExtension.kt | 16 +++++++----- 33 files changed, 111 insertions(+), 96 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index a5c3f95a6e3..fbfe87901d8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -274,7 +274,7 @@ public abstract class AnnotationCodegen { @Override public Void visitEnumValue(EnumValue value, Void data) { String propertyName = value.getValue().getName().asString(); - annotationVisitor.visitEnum(name, typeMapper.mapType(value.getType(KotlinBuiltIns.getInstance())).getDescriptor(), propertyName); + annotationVisitor.visitEnum(name, typeMapper.mapType(value.getType()).getDescriptor(), propertyName); return null; } @@ -282,7 +282,7 @@ public abstract class AnnotationCodegen { public Void visitArrayValue(ArrayValue value, Void data) { AnnotationVisitor visitor = annotationVisitor.visitArray(name); for (CompileTimeConstant argument : value.getValue()) { - genCompileTimeValue(null, argument, value.getType(KotlinBuiltIns.getInstance()), visitor); + genCompileTimeValue(null, argument, value.getType(), visitor); } visitor.visitEnd(); return null; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java index 994399eb8ed..5c30d9271c2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; @@ -45,6 +46,7 @@ import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*; public class JvmSerializerExtension extends SerializerExtension { private final JvmSerializationBindings bindings; private final JetTypeMapper typeMapper; + private final AnnotationSerializer annotationSerializer = new AnnotationSerializer(KotlinBuiltIns.getInstance()); public JvmSerializerExtension(@NotNull JvmSerializationBindings bindings, @NotNull JetTypeMapper typeMapper) { this.bindings = bindings; @@ -77,7 +79,7 @@ public class JvmSerializerExtension extends SerializerExtension { public void serializeType(@NotNull JetType type, @NotNull ProtoBuf.Type.Builder proto, @NotNull StringTable stringTable) { // TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead for (AnnotationDescriptor annotation : type.getAnnotations()) { - proto.addExtension(JvmProtoBuf.typeAnnotation, AnnotationSerializer.INSTANCE$.serializeAnnotation(annotation, stringTable)); + proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)); } } diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt index c5d7686567b..49b048795e6 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt @@ -113,7 +113,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) { // TODO: perform some kind of validation? At the moment not possible because DescriptorValidator is in compiler-tests // DescriptorValidator.validate(packageView) - val serializer = DescriptorSerializer.createTopLevel(BuiltInsSerializerExtension) + val serializer = DescriptorSerializer.createTopLevel(BuiltInsSerializerExtension(module)) val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS)) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java index e5f1117ea46..22870fd170e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstantFactory; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; +import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitializerEvaluator { @Nullable @@ -40,7 +41,7 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial ConstantExpressionEvaluator.isPropertyCompileTimeConstant(descriptor), false, true - )); + ), DescriptorUtilPackage.getBuiltIns(descriptor)); return factory.createCompileTimeConstant(evaluatedExpression, descriptor.getType()); } return null; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index 51cad1c463d..a598cb915d3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -61,11 +61,9 @@ import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class CallExpressionResolver { private final CallResolver callResolver; - private final KotlinBuiltIns builtIns; - public CallExpressionResolver(@NotNull CallResolver callResolver, @NotNull KotlinBuiltIns builtIns) { + public CallExpressionResolver(@NotNull CallResolver callResolver) { this.callResolver = callResolver; - this.builtIns = builtIns; } private ExpressionTypingServices expressionTypingServices; @@ -372,7 +370,7 @@ public class CallExpressionResolver { CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, context.trace, context.expectedType); if (value instanceof IntegerValueConstant && ((IntegerValueConstant) value).isPure()) { - return ExpressionTypingUtils.createCompileTimeConstantTypeInfo(value, expression, context, builtIns); + return ExpressionTypingUtils.createCompileTimeConstantTypeInfo(value, expression, context); } JetTypeInfo typeInfo; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java index 77839c93515..907beccac42 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java @@ -89,7 +89,7 @@ public class CompileTimeConstantChecker { } if (!noExpectedTypeOrError(expectedType)) { - JetType valueType = value.getType(builtIns); + JetType valueType = value.getType(); if (!JetTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "integer", expectedType)); } @@ -106,7 +106,7 @@ public class CompileTimeConstantChecker { return reportError(FLOAT_LITERAL_OUT_OF_RANGE.on(expression)); } if (!noExpectedTypeOrError(expectedType)) { - JetType valueType = value.getType(builtIns); + JetType valueType = value.getType(); if (!JetTypeChecker.DEFAULT.isSubtypeOf(valueType, expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "floating-point", expectedType)); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index c3c318dc2ab..05f234d0810 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -42,6 +42,8 @@ import kotlin.platform.platformStatic public class ConstantExpressionEvaluator private constructor(val trace: BindingTrace) : JetVisitor, JetType>() { + private val builtIns = KotlinBuiltIns.getInstance() + companion object { platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { val evaluator = ConstantExpressionEvaluator(trace) @@ -86,7 +88,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } private val stringExpressionEvaluator = object : JetVisitor() { - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false)) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false), builtIns) fun evaluate(entry: JetStringTemplateEntry): StringValue? { return entry.accept(this, null) @@ -108,7 +110,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val text = expression.getText() ?: return null val nodeElementType = expression.getNode().getElementType() - if (nodeElementType == JetNodeTypes.NULL) return NullValue + if (nodeElementType == JetNodeTypes.NULL) return NullValue(builtIns) val result: Any? = when (nodeElementType) { JetNodeTypes.INTEGER_CONSTANT -> parseLong(text) @@ -249,7 +251,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression) val usesVariableAsConstant = usesVariableAsConstant(argumentForReceiver.expression) || usesVariableAsConstant(argumentForParameter.expression) val parameters = CompileTimeConstant.Parameters.Impl(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) - val factory = CompileTimeConstantFactory(parameters) + val factory = CompileTimeConstantFactory(parameters, builtIns) return when (resultingDescriptorName) { OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory) OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory) @@ -493,12 +495,12 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT expectedType: JetType?, parameters: CompileTimeConstant.Parameters ): CompileTimeConstant<*>? { - return CompileTimeConstantFactory(parameters).createCompileTimeConstant(value, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) + return CompileTimeConstantFactory(parameters, builtIns).createCompileTimeConstant(value, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) } } public fun IntegerValueTypeConstant.createCompileTimeConstantWithType(expectedType: JetType): CompileTimeConstant<*>? - = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false)).createCompileTimeConstant(this.getValue(expectedType)) + = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false), KotlinBuiltIns.getInstance()).createCompileTimeConstant(this.getValue(expectedType)) private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L') @@ -594,13 +596,13 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? { return when (value) { - is IntegerValueTypeConstant -> CompileTimeConstantFactory(value.parameters).createStringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString()) + is IntegerValueTypeConstant -> CompileTimeConstantFactory(value.parameters, KotlinBuiltIns.getInstance()).createStringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString()) is StringValue -> value is IntValue, is ByteValue, is ShortValue, is LongValue, is CharValue, is DoubleValue, is FloatValue, is BooleanValue, - is NullValue -> CompileTimeConstantFactory(value.parameters).createStringValue("${value.value}") + is NullValue -> CompileTimeConstantFactory(value.parameters, KotlinBuiltIns.getInstance()).createStringValue("${value.value}") else -> null } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index f7c0eb0bcda..4be38adea30 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -133,7 +133,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } assert value != null : "CompileTimeConstant should be evaluated for constant expression or an error should be recorded " + expression.getText(); - return createCompileTimeConstantTypeInfo(value, expression, context, components.builtIns); + return createCompileTimeConstantTypeInfo(value, expression, context); } @NotNull @@ -942,7 +942,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType); if (value != null) { - return createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType, components.builtIns); + return createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType); } return DataFlowUtils.checkType(typeInfo.replaceType(result), @@ -1138,7 +1138,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { expression, contextWithExpectedType.trace, contextWithExpectedType.expectedType ); if (value != null) { - return createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType, components.builtIns); + return createCompileTimeConstantTypeInfo(value, expression, contextWithExpectedType); } return DataFlowUtils.checkType(result, expression, contextWithExpectedType); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java index d4ec9b5440b..0e38b188d83 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java @@ -246,10 +246,9 @@ public class ExpressionTypingUtils { public static JetTypeInfo createCompileTimeConstantTypeInfo( @NotNull CompileTimeConstant value, @NotNull JetExpression expression, - @NotNull ExpressionTypingContext context, - @NotNull KotlinBuiltIns kotlinBuiltIns + @NotNull ExpressionTypingContext context ) { - JetType expressionType = value.getType(kotlinBuiltIns); + JetType expressionType = value.getType(); if (value instanceof IntegerValueTypeConstant && context.contextDependency == INDEPENDENT) { expressionType = ((IntegerValueTypeConstant) value).getType(context.expectedType); ArgumentTypeResolver.updateNumberType(expressionType, expression, context); diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 72e006e402d..1091c6b491c 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.serialization import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.resolve.constants.* @@ -26,9 +27,9 @@ import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.Typ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType -public object AnnotationSerializer { +public class AnnotationSerializer(builtIns: KotlinBuiltIns) { - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, builtIns) public fun serializeAnnotation(annotation: AnnotationDescriptor, stringTable: StringTable): ProtoBuf.Annotation { return with(ProtoBuf.Annotation.newBuilder()) { diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt index b5b4de0c193..73f22d9608e 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt @@ -17,11 +17,7 @@ package org.jetbrains.kotlin.serialization.builtins import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor -import org.jetbrains.kotlin.descriptors.PropertyDescriptor -import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.resolve.constants.NullValue import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter @@ -31,10 +27,13 @@ import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.SerializerExtension import org.jetbrains.kotlin.serialization.StringTable -public object BuiltInsSerializerExtension : SerializerExtension() { +public class BuiltInsSerializerExtension(module: ModuleDescriptor) : SerializerExtension() { + + private val annotationSerializer = AnnotationSerializer(module.builtIns) + override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) { for (annotation in descriptor.getAnnotations()) { - proto.addExtension(BuiltInsProtoBuf.classAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(BuiltInsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } } @@ -58,13 +57,13 @@ public object BuiltInsSerializerExtension : SerializerExtension() { stringTable: StringTable ) { for (annotation in callable.getAnnotations()) { - proto.addExtension(BuiltInsProtoBuf.callableAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(BuiltInsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } val propertyDescriptor = callable as? PropertyDescriptor ?: return val compileTimeConstant = propertyDescriptor.getCompileTimeInitializer() if (compileTimeConstant != null && compileTimeConstant !is NullValue) { - val type = compileTimeConstant.getType(propertyDescriptor.builtIns) - proto.setExtension(BuiltInsProtoBuf.compileTimeValue, AnnotationSerializer.valueProto(compileTimeConstant, type, stringTable).build()) + val valueProto = annotationSerializer.valueProto(compileTimeConstant, compileTimeConstant.type, stringTable) + proto.setExtension(BuiltInsProtoBuf.compileTimeValue, valueProto.build()) } } @@ -74,7 +73,7 @@ public object BuiltInsSerializerExtension : SerializerExtension() { stringTable: StringTable ) { for (annotation in descriptor.getAnnotations()) { - proto.addExtension(BuiltInsProtoBuf.parameterAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(BuiltInsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } } } \ No newline at end of file diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 9aea20d079d..e1f54ca3f05 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -64,7 +64,7 @@ class LazyJavaAnnotationDescriptor( annotationClass?.getDefaultType() ?: ErrorUtils.createErrorType(fqName.asString()) } - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false)) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false), c.module.builtIns) override fun getType(): JetType = type() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index efa26f4f311..e856d4291d0 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -46,7 +46,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( storageManager, kotlinClassFinder, errorReporter ) { private val annotationDeserializer = AnnotationDeserializer(module) - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, module.builtIns) override fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor = annotationDeserializer.deserializeAnnotation(proto, nameResolver) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt index 8dcd6304934..8ea1dc4dc19 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt @@ -23,7 +23,8 @@ import org.jetbrains.kotlin.types.JetType public class AnnotationValue(value: AnnotationDescriptor) : CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = value.getType() + override val type: JetType + get() = value.getType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitAnnotationValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index 46ae183fb7b..8c95657718b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -23,7 +23,7 @@ import java.util.* public class ArrayValue( value: List>, - private val type: JetType, + override val type: JetType, parameters: CompileTimeConstant.Parameters ) : CompileTimeConstant>>(value, parameters) { @@ -40,8 +40,6 @@ public class ArrayValue( assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } } - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = type - override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitArrayValue(this, data) override fun equals(other: Any?): Boolean { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt index d703db17024..44dd0386c75 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt @@ -22,11 +22,12 @@ import org.jetbrains.kotlin.types.JetType public class BooleanValue( value: Boolean, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : CompileTimeConstant(value, parameters) { override fun isPure(): Boolean = false - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getBooleanType() + override val type = builtIns.getBooleanType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitBooleanValue(this, data) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt index a9d73f2b598..2b230fbc5fa 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt @@ -22,10 +22,11 @@ import org.jetbrains.kotlin.types.JetType public class ByteValue( value: Byte, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : IntegerValueConstant(value, parameters) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getByteType() + override val type = builtIns.getByteType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitByteValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt index f5285f8ea97..a14dd4ac4ab 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt @@ -22,10 +22,11 @@ import org.jetbrains.kotlin.types.JetType public class CharValue( value: Char, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : IntegerValueConstant(value, parameters) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getCharType() + override val type = builtIns.getCharType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitCharValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index a9d752f6c41..cb76122cdfd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -30,7 +30,7 @@ public abstract class CompileTimeConstant protected constructor( public open fun usesVariableAsConstant(): Boolean = parameters.usesVariableAsConstant - public abstract fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType + public abstract val type: JetType public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt index 5709bc40784..2283ad75233 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt @@ -22,28 +22,31 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils -public class CompileTimeConstantFactory(private val parameters: CompileTimeConstant.Parameters) { - fun createLongValue(value: Long) = LongValue(value, parameters) +public class CompileTimeConstantFactory( + private val parameters: CompileTimeConstant.Parameters, + private val builtins: KotlinBuiltIns +) { + fun createLongValue(value: Long) = LongValue(value, parameters, builtins) - fun createIntValue(value: Int) = IntValue(value, parameters) + fun createIntValue(value: Int) = IntValue(value, parameters, builtins) fun createErrorValue(message: String) = ErrorValue.create(message) - fun createShortValue(value: Short) = ShortValue(value, parameters) + fun createShortValue(value: Short) = ShortValue(value, parameters, builtins) - fun createByteValue(value: Byte) = ByteValue(value, parameters) + fun createByteValue(value: Byte) = ByteValue(value, parameters, builtins) - fun createDoubleValue(value: Double) = DoubleValue(value, parameters) + fun createDoubleValue(value: Double) = DoubleValue(value, parameters, builtins) - fun createFloatValue(value: Float) = FloatValue(value, parameters) + fun createFloatValue(value: Float) = FloatValue(value, parameters, builtins) - fun createBooleanValue(value: Boolean) = BooleanValue(value, parameters) + fun createBooleanValue(value: Boolean) = BooleanValue(value, parameters, builtins) - fun createCharValue(value: Char) = CharValue(value, parameters) + fun createCharValue(value: Char) = CharValue(value, parameters, builtins) - fun createStringValue(value: String) = StringValue(value, parameters) + fun createStringValue(value: String) = StringValue(value, parameters, builtins) - fun createNullValue() = NullValue + fun createNullValue() = NullValue(builtins) fun createEnumValue(enumEntryClass: ClassDescriptor): EnumValue = EnumValue(enumEntryClass) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt index 111ea9acad3..1dcb99816bc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt @@ -22,12 +22,13 @@ import org.jetbrains.kotlin.types.JetType public class DoubleValue( value: Double, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : CompileTimeConstant(value, parameters) { override fun isPure() = false - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getDoubleType() + override val type = builtIns.getDoubleType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitDoubleValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt index fe734397589..7c7b6197178 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt @@ -27,13 +27,12 @@ public class EnumValue( value: ClassDescriptor ) : CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = getType() - - private fun getType() = value.classObjectType.sure { "Enum entry must have a class object type: " + value } + override val type: JetType + get() = value.classObjectType.sure { "Enum entry must have a class object type: " + value } override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitEnumValue(this, data) - override fun toString() = "${getType()}.${value.getName()}" + override fun toString() = "$type.${value.getName()}" override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt index e73a0802c42..4a0564c6a42 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt @@ -31,7 +31,7 @@ public abstract class ErrorValue : CompileTimeConstant(Unit, CompileTimeCo public class ErrorValueWithMessage(public val message: String) : ErrorValue() { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = ErrorUtils.createErrorType(message) + override val type = ErrorUtils.createErrorType(message) override fun toString() = message } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt index c78672653ea..bb1e069e44c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt @@ -22,11 +22,12 @@ import org.jetbrains.kotlin.types.JetType public class FloatValue( value: Float, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : CompileTimeConstant(value, parameters) { override fun isPure() = false - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getFloatType() + override val type = builtIns.getFloatType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitFloatValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt index ec2bbce627b..0649089b15d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt @@ -22,10 +22,11 @@ import org.jetbrains.kotlin.types.JetType public class IntValue( value: Int, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : IntegerValueConstant(value, parameters) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getIntType() + override val type = builtIns.getIntType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitIntValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt index f487be511b3..054b47dc49e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt @@ -32,12 +32,10 @@ public class IntegerValueTypeConstant( private val typeConstructor = IntegerValueTypeConstructor(value.toLong()) - override fun getType(kotlinBuiltIns: KotlinBuiltIns): JetType { - return JetTypeImpl( - Annotations.EMPTY, typeConstructor, false, emptyList() - , ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) - ) - } + override val type = JetTypeImpl( + Annotations.EMPTY, typeConstructor, false, emptyList() + , ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) + ) deprecated("") override val value: Number diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt index 9a6a867198e..a3eedd4e0b8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt @@ -20,9 +20,8 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public class KClassValue(private val type: JetType) : +public class KClassValue(override val type: JetType) : CompileTimeConstant(type, CompileTimeConstant.Parameters.Impl(true, false, false)) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = type override val value: JetType get() = type.getArguments().single().getType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt index fe443987362..24811e33a6e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt @@ -22,10 +22,11 @@ import org.jetbrains.kotlin.types.JetType public class LongValue( value: Long, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : IntegerValueConstant(value, parameters) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getLongType() + override val type = builtIns.getLongType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitLongValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt index 5554fc8167a..7676cdcdca7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt @@ -20,9 +20,11 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -public object NullValue : CompileTimeConstant(null, CompileTimeConstant.Parameters.Impl(false, false, false)) { +public class NullValue( + builtIns: KotlinBuiltIns +) : CompileTimeConstant(null, CompileTimeConstant.Parameters.Impl(false, false, false)) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getNullableNothingType() + override val type = builtIns.getNullableNothingType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitNullValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt index 917fcb77f1f..45b6c88a745 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt @@ -22,10 +22,11 @@ import org.jetbrains.kotlin.types.JetType public class ShortValue( value: Short, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : IntegerValueConstant(value, parameters) { - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getShortType() + override val type = builtIns.getShortType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitShortValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt index 26c9b2c5286..530e310f9d1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt @@ -22,11 +22,12 @@ import org.jetbrains.kotlin.types.JetType public class StringValue( value: String, - parameters: CompileTimeConstant.Parameters + parameters: CompileTimeConstant.Parameters, + builtIns: KotlinBuiltIns ) : CompileTimeConstant(value, parameters) { override fun isPure() = false - override fun getType(kotlinBuiltIns: KotlinBuiltIns) = kotlinBuiltIns.getStringType() + override val type = builtIns.getStringType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitStringValue(this, data) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 69f858a0ffe..3773495ecc1 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -39,7 +39,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { private val builtIns: KotlinBuiltIns get() = module.builtIns - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException) + private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, builtIns) public fun deserializeAnnotation(proto: Annotation, nameResolver: NameResolver): AnnotationDescriptor { val annotationClass = resolveClass(nameResolver.getClassId(proto.getId())) @@ -121,7 +121,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { else -> error("Unsupported annotation argument type: ${value.getType()} (expected $expectedType)") } - if (result.getType(builtIns) isSubtypeOf expectedType) { + if (result.type isSubtypeOf expectedType) { return result } else { diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index 90d5eec26a9..e680b560895 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.serialization.js +import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor @@ -29,9 +30,12 @@ import org.jetbrains.kotlin.serialization.StringTable import org.jetbrains.kotlin.types.JetType public object KotlinJavascriptSerializerExtension : SerializerExtension() { + + private val annotationSerializer = AnnotationSerializer(KotlinBuiltIns.getInstance()) + override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) { for (annotation in descriptor.getAnnotations()) { - proto.addExtension(JsProtoBuf.classAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(JsProtoBuf.classAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } } @@ -41,13 +45,13 @@ public object KotlinJavascriptSerializerExtension : SerializerExtension() { stringTable: StringTable ) { for (annotation in callable.getAnnotations()) { - proto.addExtension(JsProtoBuf.callableAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(JsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } val propertyDescriptor = callable as? PropertyDescriptor ?: return val compileTimeConstant = propertyDescriptor.getCompileTimeInitializer() if (compileTimeConstant != null && compileTimeConstant !is NullValue) { - val type = compileTimeConstant.getType(propertyDescriptor.builtIns) - proto.setExtension(JsProtoBuf.compileTimeValue, AnnotationSerializer.valueProto(compileTimeConstant, type, stringTable).build()) + val type = compileTimeConstant.type + proto.setExtension(JsProtoBuf.compileTimeValue, annotationSerializer.valueProto(compileTimeConstant, type, stringTable).build()) } } @@ -57,13 +61,13 @@ public object KotlinJavascriptSerializerExtension : SerializerExtension() { stringTable: StringTable ) { for (annotation in descriptor.getAnnotations()) { - proto.addExtension(JsProtoBuf.parameterAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(JsProtoBuf.parameterAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } } override fun serializeType(type: JetType, proto: ProtoBuf.Type.Builder, stringTable: StringTable) { for (annotation in type.getAnnotations()) { - proto.addExtension(JsProtoBuf.typeAnnotation, AnnotationSerializer.serializeAnnotation(annotation, stringTable)) + proto.addExtension(JsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } } } From 155f00578d5e467036238feaabb9dc843e731fd6 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 7 Jul 2015 14:45:18 +0300 Subject: [PATCH 284/450] Builtins are passed into builtins module Fixes circular dependency --- .../jetbrains/kotlin/builtins/KotlinBuiltIns.java | 2 +- .../kotlin/descriptors/impl/ModuleDescriptorImpl.kt | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 4f4141383e9..42e178b124f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -111,7 +111,7 @@ public class KotlinBuiltIns { private KotlinBuiltIns() { LockBasedStorageManager storageManager = new LockBasedStorageManager(); builtInsModule = new ModuleDescriptorImpl( - Name.special(""), storageManager, ModuleParameters.Empty.INSTANCE$ + Name.special(""), storageManager, ModuleParameters.Empty.INSTANCE$, this ); PackageFragmentProvider packageFragmentProvider = BuiltinsPackage.createBuiltInPackageFragmentProvider( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt index 6a337c85acc..d33fd496b39 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ModuleDescriptorImpl.kt @@ -32,7 +32,8 @@ import kotlin.properties.Delegates public class ModuleDescriptorImpl( moduleName: Name, private val storageManager: StorageManager, - private val moduleParameters: ModuleParameters + private val moduleParameters: ModuleParameters, + override val builtIns: KotlinBuiltIns ) : DeclarationDescriptorImpl(Annotations.EMPTY, moduleName), ModuleDescriptor, ModuleParameters by moduleParameters { init { if (!moduleName.isSpecial()) { @@ -40,6 +41,12 @@ public class ModuleDescriptorImpl( } } + public constructor( + moduleName: Name, + storageManager: StorageManager, + moduleParameters: ModuleParameters + ) : this(moduleName, storageManager, moduleParameters, KotlinBuiltIns.getInstance()) + private var dependencies: ModuleDependencies? = null private var packageFragmentProviderForModuleContent: PackageFragmentProvider? = null @@ -102,9 +109,6 @@ public class ModuleDescriptorImpl( assert(friend != this) { "Attempt to make module $id a friend to itself" } friendModules.add(friend) } - - override val builtIns: KotlinBuiltIns - get() = KotlinBuiltIns.getInstance() } public interface ModuleDependencies { From c313887641e7a5b381b8508cab3b7b8debc2f86a Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 7 Jul 2015 14:56:19 +0300 Subject: [PATCH 285/450] Split CompileTimeConstant into two entities 1. ConstantValue * just holds some value and its type * implementations for concrete constants 2. CompileTimeConstant * is only produced by ConstantExpressionEvaluator * has additional flags (canBeUsedInAnnotation etc) * has two implementations TypedCompileTimeConstant containing a constant value and IntegerValueConstant which does not have exact type * can be converted to ConstantValue Adjustt usages to use ConstantValue if flags are not needed Add tests for some uncovered cases --- .../kotlin/codegen/AnnotationCodegen.java | 32 +-- .../kotlin/codegen/ExpressionCodegen.java | 20 +- .../kotlin/codegen/FunctionCodegen.java | 8 +- .../kotlin/codegen/MemberCodegen.java | 31 +-- .../kotlin/codegen/PropertyCodegen.java | 6 +- .../binding/CodegenAnnotatingVisitor.java | 8 +- .../kotlin/codegen/state/JetTypeMapper.java | 6 +- .../codegen/when/EnumSwitchCodegen.java | 4 +- .../when/IntegralConstantsSwitchCodegen.java | 4 +- .../codegen/when/StringSwitchCodegen.java | 4 +- .../kotlin/codegen/when/SwitchCodegen.java | 8 +- .../codegen/when/SwitchCodegenUtil.java | 26 +-- .../JavaPropertyInitializerEvaluatorImpl.java | 56 ----- .../JavaPropertyInitializerEvaluatorImpl.kt | 50 ++++ .../kotlin/resolve/AnnotationResolver.java | 35 ++- .../kotlin/resolve/BodyResolver.java | 4 +- .../resolve/CompileTimeConstantUtils.java | 12 +- .../kotlin/resolve/DescriptorResolver.java | 14 +- .../kotlin/resolve/ModifiersChecker.java | 8 +- .../resolve/calls/CallExpressionResolver.java | 3 +- .../util/FakeCallableDescriptorForObject.kt | 3 +- .../constants/CompileTimeConstantChecker.java | 8 +- .../evaluate/ConstantExpressionEvaluator.kt | 221 ++++++++++-------- .../DiagnosticsWithSuppression.java | 6 +- .../kotlin/resolve/inline/InlineUtil.java | 8 +- .../lazy/descriptors/LazyAnnotations.kt | 6 +- .../BasicExpressionTypingVisitor.java | 15 +- .../types/expressions/DataFlowUtils.java | 11 +- .../expressions/ExpressionTypingUtils.java | 19 +- .../serialization/AnnotationSerializer.kt | 21 +- .../serialization/DescriptorSerializer.java | 4 +- .../javaPropertyAsAnnotationParameter.java | 2 + .../javaPropertyAsAnnotationParameter.kt | 8 +- .../tests/annotations/AnnotatedResultType.txt | 2 +- .../tests/annotations/AnnotationOnObject.txt | 2 +- .../tests/annotations/BasicAnnotations.txt | 4 +- .../tests/annotations/ConstructorCall.txt | 4 +- .../annotations/RecursivelyAnnotated.txt | 2 +- .../RecursivelyAnnotatedParameter.txt | 4 +- .../RecursivelyAnnotatedParameterType.txt | 4 +- .../RecursivelyAnnotatedParameterWithAt.txt | 4 +- ...cursivelyIncorrectlyAnnotatedParameter.txt | 4 +- .../WrongAnnotationArgsOnObject.txt | 2 +- .../tests/annotations/atAnnotationResolve.txt | 6 +- .../primaryConstructorMissingKeyword.txt | 2 +- .../namedArguments/allowForJavaAnnotation.txt | 2 +- .../ctrsAnnotationResolve.txt | 2 +- .../annotations/annotationClassMethodCall.txt | 2 +- .../array.txt | 2 +- .../vararg.txt | 2 +- .../annotationParameters/valueArray.txt | 14 +- .../valueArrayAndOtherDefault.txt | 10 +- .../javaAnnotationWithVarargArgument.txt | 2 +- .../kotlinAnnotationWithVarargArgument.txt | 2 +- .../annotationAsArgument.txt | 4 +- .../argAndOtherDefault.txt | 2 +- .../argWithDefaultAndOther.txt | 4 +- .../valueAndOtherDefault.txt | 4 +- .../valueWithDefaultAndOther.txt | 6 +- .../kotlinAnnotation.txt | 6 +- .../prohibitPositionedArgument/withValue.txt | 8 +- .../withoutValue.txt | 6 +- .../usesVariableAsConstant/OtherTypes.kt | 10 +- .../resolveAnnotations/parameters/byte.kt | 2 +- .../parameters/expressions/char.kt | 2 +- .../parameters/expressions/divide.kt | 2 +- .../parameters/expressions/infixCallBinary.kt | 2 +- .../parameters/expressions/intrincics.kt | 2 +- .../parameters/expressions/long.kt | 2 +- .../parameters/expressions/maxValueByte.kt | 2 +- .../parameters/expressions/maxValueInt.kt | 2 +- .../parameters/expressions/miltiply.kt | 2 +- .../parameters/expressions/minus.kt | 2 +- .../parameters/expressions/mod.kt | 2 +- .../parameters/expressions/paranthesized.kt | 2 +- .../parameters/expressions/plus.kt | 2 +- .../expressions/simpleCallBinary.kt | 2 +- .../parameters/expressions/unaryMinus.kt | 2 +- .../parameters/expressions/unaryPlus.kt | 2 +- .../resolveAnnotations/parameters/int.kt | 2 +- .../resolveAnnotations/parameters/long.kt | 2 +- .../resolveAnnotations/parameters/short.kt | 2 +- .../jvm/compiler/ExpectedLoadErrorsUtil.java | 4 +- .../AnnotationDescriptorResolveTest.java | 8 +- .../AbstractEvaluateExpressionTest.kt | 29 +-- .../LazyJavaAnnotationDescriptor.kt | 19 +- .../descriptors/LazyJavaClassDescriptor.kt | 2 +- .../JavaPropertyInitializerEvaluator.java | 42 ---- .../JavaPropertyInitializerEvaluator.kt | 32 +++ ...aryClassAnnotationAndConstantLoaderImpl.kt | 24 +- .../load/kotlin/reflect/RuntimeModuleData.kt | 2 +- .../BuiltInsAnnotationAndConstantLoader.kt | 6 +- .../kotlin/builtins/KotlinBuiltIns.java | 4 +- .../descriptors/VariableDescriptor.java | 4 +- .../AnnotationArgumentVisitor.java | 2 - .../annotations/AnnotationDescriptor.java | 4 +- .../annotations/AnnotationDescriptorImpl.java | 8 +- .../DefaultAnnotationArgumentVisitor.java | 7 +- .../impl/VariableDescriptorImpl.java | 8 +- .../kotlin/renderer/DescriptorRendererImpl.kt | 24 +- .../resolve/constants/AnnotationValue.kt | 4 +- .../kotlin/resolve/constants/ArrayValue.kt | 18 +- .../kotlin/resolve/constants/BooleanValue.kt | 6 +- .../kotlin/resolve/constants/ByteValue.kt | 4 +- .../kotlin/resolve/constants/CharValue.kt | 6 +- .../resolve/constants/CompileTimeConstant.kt | 99 +++++--- .../constants/CompileTimeConstantFactory.kt | 125 ---------- .../kotlin/resolve/constants/ConstantValue.kt | 29 +++ .../resolve/constants/ConstantValueFactory.kt | 95 ++++++++ .../kotlin/resolve/constants/DoubleValue.kt | 7 +- .../kotlin/resolve/constants/EnumValue.kt | 3 +- .../kotlin/resolve/constants/ErrorValue.kt | 4 +- .../kotlin/resolve/constants/FloatValue.kt | 6 +- .../kotlin/resolve/constants/IntValue.kt | 4 +- .../resolve/constants/IntegerValueConstant.kt | 5 +- .../constants/IntegerValueTypeConstant.kt | 68 ------ .../kotlin/resolve/constants/KClassValue.kt | 3 +- .../kotlin/resolve/constants/LongValue.kt | 4 +- .../kotlin/resolve/constants/NullValue.kt | 3 +- .../kotlin/resolve/constants/ShortValue.kt | 4 +- .../kotlin/resolve/constants/StringValue.kt | 6 +- .../deserialization/AnnotationDeserializer.kt | 30 +-- .../deserialization/MemberDeserializer.kt | 16 +- .../serialization/deserialization/context.kt | 4 +- .../DeserializerForDecompilerBase.kt | 4 +- .../ConvertToStringTemplateIntention.kt | 9 +- .../js/resolve/diagnostics/JsCallChecker.kt | 23 +- .../js/translate/utils/AnnotationsUtils.java | 4 +- ...inJavascriptAnnotationAndConstantLoader.kt | 6 +- .../js/KotlinJavascriptSerializerExtension.kt | 9 +- .../expression/ExpressionVisitor.java | 10 +- .../operation/UnaryOperationTranslator.java | 1 - .../reference/CallExpressionTranslator.java | 2 +- .../js/translate/utils/BindingUtils.java | 11 +- 134 files changed, 791 insertions(+), 907 deletions(-) delete mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt delete mode 100644 core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.java create mode 100644 core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt delete mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValue.kt create mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt delete mode 100644 core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index fbfe87901d8..2f176994840 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -187,9 +187,9 @@ public abstract class AnnotationCodegen { return !type.isMarkedNullable() && classifier instanceof TypeParameterDescriptor && TypeUtils.hasNullableSuperType(type); } - public void generateAnnotationDefaultValue(@NotNull CompileTimeConstant value, @NotNull JetType expectedType) { + public void generateAnnotationDefaultValue(@NotNull ConstantValue value, @NotNull JetType expectedType) { AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant - genCompileTimeValue(null, value, expectedType, visitor); + genCompileTimeValue(null, value, visitor); visitor.visitEnd(); } @@ -212,17 +212,16 @@ public abstract class AnnotationCodegen { } private void genAnnotationArguments(AnnotationDescriptor annotationDescriptor, AnnotationVisitor annotationVisitor) { - for (Map.Entry> entry : annotationDescriptor.getAllValueArguments().entrySet()) { + for (Map.Entry> entry : annotationDescriptor.getAllValueArguments().entrySet()) { ValueParameterDescriptor descriptor = entry.getKey(); String name = descriptor.getName().asString(); - genCompileTimeValue(name, entry.getValue(), descriptor.getType(), annotationVisitor); + genCompileTimeValue(name, entry.getValue(), annotationVisitor); } } private void genCompileTimeValue( @Nullable final String name, - @NotNull CompileTimeConstant value, - @NotNull final JetType expectedType, + @NotNull ConstantValue value, @NotNull final AnnotationVisitor annotationVisitor ) { AnnotationArgumentVisitor argumentVisitor = new AnnotationArgumentVisitor() { @@ -281,8 +280,8 @@ public abstract class AnnotationCodegen { @Override public Void visitArrayValue(ArrayValue value, Void data) { AnnotationVisitor visitor = annotationVisitor.visitArray(name); - for (CompileTimeConstant argument : value.getValue()) { - genCompileTimeValue(null, argument, value.getType(), visitor); + for (ConstantValue argument : value.getValue()) { + genCompileTimeValue(null, argument, visitor); } visitor.visitEnd(); return null; @@ -303,14 +302,7 @@ public abstract class AnnotationCodegen { return null; } - @Override - public Void visitNumberTypeValue(IntegerValueTypeConstant value, Void data) { - Object numberType = value.getValue(expectedType); - annotationVisitor.visit(name, numberType); - return null; - } - - private Void visitSimpleValue(CompileTimeConstant value) { + private Void visitSimpleValue(ConstantValue value) { annotationVisitor.visit(name, value.getValue()); return null; } @@ -325,7 +317,7 @@ public abstract class AnnotationCodegen { return visitUnsupportedValue(value); } - private Void visitUnsupportedValue(CompileTimeConstant value) { + private Void visitUnsupportedValue(ConstantValue value) { throw new IllegalStateException("Don't know how to compile annotation value " + value); } }; @@ -349,7 +341,7 @@ public abstract class AnnotationCodegen { private RetentionPolicy getRetentionPolicy(@NotNull Annotated descriptor) { AnnotationDescriptor kotlinAnnotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.annotation); if (kotlinAnnotation != null) { - for (Map.Entry> argument: kotlinAnnotation.getAllValueArguments().entrySet()) { + for (Map.Entry> argument: kotlinAnnotation.getAllValueArguments().entrySet()) { if ("retention".equals(argument.getKey().getName().asString()) && argument.getValue() instanceof EnumValue) { ClassDescriptor enumEntry = ((EnumValue) argument.getValue()).getValue(); JetType classObjectType = getClassObjectType(enumEntry); @@ -366,9 +358,9 @@ public abstract class AnnotationCodegen { } AnnotationDescriptor retentionAnnotation = descriptor.getAnnotations().findAnnotation(new FqName(Retention.class.getName())); if (retentionAnnotation != null) { - Collection> valueArguments = retentionAnnotation.getAllValueArguments().values(); + Collection> valueArguments = retentionAnnotation.getAllValueArguments().values(); if (!valueArguments.isEmpty()) { - CompileTimeConstant compileTimeConstant = valueArguments.iterator().next(); + ConstantValue compileTimeConstant = valueArguments.iterator().next(); if (compileTimeConstant instanceof EnumValue) { ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue(); JetType classObjectType = getClassObjectType(enumEntry); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 462dfbf20d7..0596f41ee19 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -49,12 +49,12 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.impl.ScriptCodeDescriptor; import org.jetbrains.kotlin.diagnostics.DiagnosticUtils; import org.jetbrains.kotlin.diagnostics.Errors; +import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.jvm.bindingContextSlices.BindingContextSlicesPackage; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.load.java.JvmAbi; import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor; import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor; -import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.renderer.DescriptorRenderer; @@ -68,9 +68,8 @@ import org.jetbrains.kotlin.resolve.calls.model.*; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.resolve.constants.evaluate.EvaluatePackage; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; import org.jetbrains.kotlin.resolve.inline.InlineUtil; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; @@ -1292,20 +1291,19 @@ public class ExpressionCodegen extends JetVisitor implem @Override public StackValue visitConstantExpression(@NotNull JetConstantExpression expression, StackValue receiver) { - CompileTimeConstant compileTimeValue = getCompileTimeConstant(expression, bindingContext); + ConstantValue compileTimeValue = getCompileTimeConstant(expression, bindingContext); assert compileTimeValue != null; return StackValue.constant(compileTimeValue.getValue(), expressionType(expression)); } @Nullable - public static CompileTimeConstant getCompileTimeConstant(@NotNull JetExpression expression, @NotNull BindingContext bindingContext) { + public static ConstantValue getCompileTimeConstant(@NotNull JetExpression expression, @NotNull BindingContext bindingContext) { CompileTimeConstant compileTimeValue = ConstantExpressionEvaluator.getConstant(expression, bindingContext); - if (compileTimeValue instanceof IntegerValueTypeConstant) { - JetType expectedType = bindingContext.getType(expression); - assert expectedType != null : "Expression is not type checked: " + expression.getText(); - return EvaluatePackage.createCompileTimeConstantWithType((IntegerValueTypeConstant) compileTimeValue, expectedType); + if (compileTimeValue == null) { + return null; } - return compileTimeValue; + JetType expectedType = bindingContext.getType(expression); + return compileTimeValue.toConstantValue(expectedType); } @Override @@ -3012,7 +3010,7 @@ public class ExpressionCodegen extends JetVisitor implem } private boolean isIntZero(JetExpression expr, Type exprType) { - CompileTimeConstant exprValue = getCompileTimeConstant(expr, bindingContext); + ConstantValue exprValue = getCompileTimeConstant(expr, bindingContext); return isIntPrimitive(exprType) && exprValue != null && Integer.valueOf(0).equals(exprValue.getValue()); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 64bfd7e0ba8..8c673bf33e4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; import org.jetbrains.kotlin.resolve.constants.ArrayValue; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.KClassValue; import org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage; import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin; @@ -538,7 +538,7 @@ public class FunctionCodegen { AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws")); if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY; - Collection> values = annotation.getAllValueArguments().values(); + Collection> values = annotation.getAllValueArguments().values(); if (values.isEmpty()) return ArrayUtil.EMPTY_STRING_ARRAY; Object value = values.iterator().next(); @@ -547,9 +547,9 @@ public class FunctionCodegen { List strings = ContainerUtil.mapNotNull( arrayValue.getValue(), - new Function, String>() { + new Function, String>() { @Override - public String fun(CompileTimeConstant constant) { + public String fun(ConstantValue constant) { if (constant instanceof KClassValue) { KClassValue classValue = (KClassValue) constant; ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(classValue.getValue()); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index c4a779ffd2d..a8c687c69b1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -39,8 +39,7 @@ import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.TemporaryBindingTrace; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; import org.jetbrains.kotlin.storage.LockBasedStorageManager; @@ -379,26 +378,28 @@ public abstract class MemberCodegen initializerValue; - if (property.isVar() && initializer != null) { - BindingTrace tempTrace = TemporaryBindingTrace.create(state.getBindingTrace(), "property initializer"); - initializerValue = ConstantExpressionEvaluator.evaluate(initializer, tempTrace, propertyDescriptor.getType()); - } - else { - initializerValue = propertyDescriptor.getCompileTimeInitializer(); - } + ConstantValue initializerValue = computeInitializerValue(property, propertyDescriptor, initializer); // we must write constant values for fields in light classes, // because Java's completion for annotation arguments uses this information if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES; //TODO: OPTIMIZATION: don't initialize static final fields - - Object value = initializerValue instanceof IntegerValueTypeConstant - ? ((IntegerValueTypeConstant) initializerValue).getValue(propertyDescriptor.getType()) - : initializerValue.getValue(); JetType jetType = getPropertyOrDelegateType(property, propertyDescriptor); Type type = typeMapper.mapType(jetType); - return !skipDefaultValue(propertyDescriptor, value, type); + return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type); + } + + @Nullable + private ConstantValue computeInitializerValue( + @NotNull JetProperty property, + @NotNull PropertyDescriptor propertyDescriptor, + @Nullable JetExpression initializer + ) { + if (property.isVar() && initializer != null) { + BindingTrace tempTrace = TemporaryBindingTrace.create(state.getBindingTrace(), "property initializer"); + return ConstantExpressionEvaluator.evaluateToConstantValue(initializer, tempTrace, propertyDescriptor.getType()); + } + return propertyDescriptor.getCompileTimeInitializer(); } @NotNull diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java index 5454cff725c..828ce88f00b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyCodegen.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor; import org.jetbrains.kotlin.types.ErrorUtils; @@ -180,7 +180,7 @@ public class PropertyCodegen { if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { JetExpression defaultValue = p.getDefaultValue(); if (defaultValue != null) { - CompileTimeConstant constant = ExpressionCodegen.getCompileTimeConstant(defaultValue, bindingContext); + ConstantValue constant = ExpressionCodegen.getCompileTimeConstant(defaultValue, bindingContext); assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText(); AnnotationCodegen annotationCodegen = AnnotationCodegen.forAnnotationDefaultValue(mv, typeMapper); annotationCodegen.generateAnnotationDefaultValue(constant, descriptor.getType()); @@ -311,7 +311,7 @@ public class PropertyCodegen { Object value = null; if (shouldWriteFieldInitializer(propertyDescriptor)) { - CompileTimeConstant initializer = propertyDescriptor.getCompileTimeInitializer(); + ConstantValue initializer = propertyDescriptor.getCompileTimeInitializer(); if (initializer != null) { value = initializer.getValue(); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java index 69855dca290..1e8413c8131 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/binding/CodegenAnnotatingVisitor.java @@ -45,7 +45,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.EnumValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.resolve.scopes.JetScope; @@ -537,7 +537,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { WhenByEnumsMapping mapping = new WhenByEnumsMapping(classDescriptor, currentClassName, fieldNumber); - for (CompileTimeConstant constant : SwitchCodegenUtil.getAllConstants(expression, bindingContext)) { + for (ConstantValue constant : SwitchCodegenUtil.getAllConstants(expression, bindingContext)) { if (constant instanceof NullValue) continue; assert constant instanceof EnumValue : "expression in when should be EnumValue"; @@ -554,9 +554,9 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { SwitchCodegenUtil.checkAllItemsAreConstantsSatisfying( expression, bindingContext, - new Function1() { + new Function1, Boolean>() { @Override - public Boolean invoke(@NotNull CompileTimeConstant constant) { + public Boolean invoke(@NotNull ConstantValue constant) { return constant instanceof EnumValue || constant instanceof NullValue; } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java index db4519777cb..9c947619152 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/JetTypeMapper.java @@ -54,7 +54,7 @@ import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage; import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.StringValue; import org.jetbrains.kotlin.resolve.jvm.AsmTypes; import org.jetbrains.kotlin.resolve.jvm.JvmClassName; @@ -721,10 +721,10 @@ public class JetTypeMapper { AnnotationDescriptor platformNameAnnotation = descriptor.getAnnotations().findAnnotation(new FqName("kotlin.platform.platformName")); if (platformNameAnnotation == null) return null; - Map> arguments = platformNameAnnotation.getAllValueArguments(); + Map> arguments = platformNameAnnotation.getAllValueArguments(); if (arguments.isEmpty()) return null; - CompileTimeConstant name = arguments.values().iterator().next(); + ConstantValue name = arguments.values().iterator().next(); if (!(name instanceof StringValue)) return null; return ((StringValue) name).getValue(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/EnumSwitchCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/EnumSwitchCodegen.java index 3b092f7e141..7eab364b1f8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/EnumSwitchCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/EnumSwitchCodegen.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.when; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.codegen.ExpressionCodegen; import org.jetbrains.kotlin.psi.JetWhenExpression; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.EnumValue; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.Type; @@ -58,7 +58,7 @@ public class EnumSwitchCodegen extends SwitchCodegen { } @Override - protected void processConstant(@NotNull CompileTimeConstant constant, @NotNull Label entryLabel) { + protected void processConstant(@NotNull ConstantValue constant, @NotNull Label entryLabel) { assert constant instanceof EnumValue : "guaranteed by usage contract"; putTransitionOnce(mapping.getIndexByEntry((EnumValue) constant), entryLabel); } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/IntegralConstantsSwitchCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/IntegralConstantsSwitchCodegen.java index 3463d689343..8915ac68485 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/IntegralConstantsSwitchCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/IntegralConstantsSwitchCodegen.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.when; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.codegen.ExpressionCodegen; import org.jetbrains.kotlin.psi.JetWhenExpression; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.org.objectweb.asm.Label; public class IntegralConstantsSwitchCodegen extends SwitchCodegen { @@ -32,7 +32,7 @@ public class IntegralConstantsSwitchCodegen extends SwitchCodegen { } @Override - protected void processConstant(@NotNull CompileTimeConstant constant, @NotNull Label entryLabel) { + protected void processConstant(@NotNull ConstantValue constant, @NotNull Label entryLabel) { assert constant.getValue() != null : "constant value should not be null"; int value = (constant.getValue() instanceof Number) ? ((Number) constant.getValue()).intValue() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/StringSwitchCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/StringSwitchCodegen.java index f3a1058bab3..e689eefdaa7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/StringSwitchCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/StringSwitchCodegen.java @@ -21,7 +21,7 @@ import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.codegen.ExpressionCodegen; import org.jetbrains.kotlin.psi.JetWhenExpression; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.StringValue; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.Type; @@ -47,7 +47,7 @@ public class StringSwitchCodegen extends SwitchCodegen { @Override protected void processConstant( - @NotNull CompileTimeConstant constant, @NotNull Label entryLabel + @NotNull ConstantValue constant, @NotNull Label entryLabel ) { assert constant instanceof StringValue : "guaranteed by usage contract"; int hashCode = constant.hashCode(); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java index c65505ce41e..026107f6297 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegen.java @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.codegen.FrameMap; import org.jetbrains.kotlin.psi.JetWhenEntry; import org.jetbrains.kotlin.psi.JetWhenExpression; import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeUtils; @@ -96,7 +96,7 @@ abstract public class SwitchCodegen { for (JetWhenEntry entry : expression.getEntries()) { Label entryLabel = new Label(); - for (CompileTimeConstant constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) { + for (ConstantValue constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) { if (constant instanceof NullValue) continue; processConstant(constant, entryLabel); } @@ -110,7 +110,7 @@ abstract public class SwitchCodegen { } abstract protected void processConstant( - @NotNull CompileTimeConstant constant, + @NotNull ConstantValue constant, @NotNull Label entryLabel ); @@ -154,7 +154,7 @@ abstract public class SwitchCodegen { private int findNullEntryIndex(@NotNull JetWhenExpression expression) { int entryIndex = 0; for (JetWhenEntry entry : expression.getEntries()) { - for (CompileTimeConstant constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) { + for (ConstantValue constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) { if (constant instanceof NullValue) { return entryIndex; } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegenUtil.java index de79f42bd81..9e2a7db30d8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/when/SwitchCodegenUtil.java @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.ExpressionCodegen; import org.jetbrains.kotlin.codegen.binding.CodegenBinding; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.IntegerValueConstant; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.resolve.constants.StringValue; @@ -36,7 +36,7 @@ public class SwitchCodegenUtil { public static boolean checkAllItemsAreConstantsSatisfying( @NotNull JetWhenExpression expression, @NotNull BindingContext bindingContext, - Function1 predicate + Function1, Boolean> predicate ) { for (JetWhenEntry entry : expression.getEntries()) { for (JetWhenCondition condition : entry.getConditions()) { @@ -49,7 +49,7 @@ public class SwitchCodegenUtil { if (patternExpression == null) return false; - CompileTimeConstant constant = ExpressionCodegen.getCompileTimeConstant(patternExpression, bindingContext); + ConstantValue constant = ExpressionCodegen.getCompileTimeConstant(patternExpression, bindingContext); if (constant == null || !predicate.invoke(constant)) { return false; } @@ -60,11 +60,11 @@ public class SwitchCodegenUtil { } @NotNull - public static Iterable getAllConstants( + public static Iterable> getAllConstants( @NotNull JetWhenExpression expression, @NotNull BindingContext bindingContext ) { - List result = new ArrayList(); + List> result = new ArrayList>(); for (JetWhenEntry entry : expression.getEntries()) { addConstantsFromEntry(result, entry, bindingContext); @@ -74,7 +74,7 @@ public class SwitchCodegenUtil { } private static void addConstantsFromEntry( - @NotNull List result, + @NotNull List> result, @NotNull JetWhenEntry entry, @NotNull BindingContext bindingContext ) { @@ -89,11 +89,11 @@ public class SwitchCodegenUtil { } @NotNull - public static Iterable getConstantsFromEntry( + public static Iterable> getConstantsFromEntry( @NotNull JetWhenEntry entry, @NotNull BindingContext bindingContext ) { - List result = new ArrayList(); + List> result = new ArrayList>(); addConstantsFromEntry(result, entry, bindingContext); return result; } @@ -132,7 +132,7 @@ public class SwitchCodegenUtil { @NotNull JetWhenExpression expression, @NotNull BindingContext bindingContext ) { - for (CompileTimeConstant constant : getAllConstants(expression, bindingContext)) { + for (ConstantValue constant : getAllConstants(expression, bindingContext)) { if (constant != null && !(constant instanceof NullValue)) return true; } @@ -150,10 +150,10 @@ public class SwitchCodegenUtil { return false; } - return checkAllItemsAreConstantsSatisfying(expression, bindingContext, new Function1() { + return checkAllItemsAreConstantsSatisfying(expression, bindingContext, new Function1, Boolean>() { @Override public Boolean invoke( - @NotNull CompileTimeConstant constant + @NotNull ConstantValue constant ) { return constant instanceof IntegerValueConstant; } @@ -170,10 +170,10 @@ public class SwitchCodegenUtil { return false; } - return checkAllItemsAreConstantsSatisfying(expression, bindingContext, new Function1() { + return checkAllItemsAreConstantsSatisfying(expression, bindingContext, new Function1, Boolean>() { @Override public Boolean invoke( - @NotNull CompileTimeConstant constant + @NotNull ConstantValue constant ) { return constant instanceof StringValue || constant instanceof NullValue; } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java deleted file mode 100644 index 22870fd170e..00000000000 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.load.java.structure.impl; - -import com.intellij.psi.PsiExpression; -import com.intellij.psi.impl.JavaConstantExpressionEvaluator; -import com.intellij.psi.util.PsiUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.PropertyDescriptor; -import org.jetbrains.kotlin.load.java.structure.JavaField; -import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstantFactory; -import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage; - -public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitializerEvaluator { - @Nullable - @Override - public CompileTimeConstant getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) { - PsiExpression initializer = ((JavaFieldImpl) field).getInitializer(); - Object evaluatedExpression = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false); - if (evaluatedExpression != null) { - CompileTimeConstantFactory factory = new CompileTimeConstantFactory( - new CompileTimeConstant.Parameters.Impl( - ConstantExpressionEvaluator.isPropertyCompileTimeConstant(descriptor), - false, - true - ), DescriptorUtilPackage.getBuiltIns(descriptor)); - return factory.createCompileTimeConstant(evaluatedExpression, descriptor.getType()); - } - return null; - } - - @Override - public boolean isNotNullCompileTimeConstant(@NotNull JavaField field) { - // PsiUtil.isCompileTimeConstant returns false for null-initialized fields, - // see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression() - return PsiUtil.isCompileTimeConstant(((JavaFieldImpl) field).getPsi()); - } -} diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt new file mode 100644 index 00000000000..50229ad1676 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.kt @@ -0,0 +1,50 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.structure.impl + +import com.intellij.psi.impl.JavaConstantExpressionEvaluator +import com.intellij.psi.util.PsiUtil +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.load.java.structure.JavaField +import org.jetbrains.kotlin.load.java.structure.JavaPropertyInitializerEvaluator +import org.jetbrains.kotlin.resolve.constants.ConstantValue +import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns + +public class JavaPropertyInitializerEvaluatorImpl : JavaPropertyInitializerEvaluator { + override fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor): ConstantValue<*>? { + val initializer = (field as JavaFieldImpl).getInitializer() + val evaluated = JavaConstantExpressionEvaluator.computeConstantExpression(initializer, false) ?: return null + val factory = ConstantValueFactory(descriptor.builtIns) + when (evaluated) { + //Note: evaluated expression may be of class that does not match field type in some cases + // tested for Int, left other checks just in case + is Byte, is Short, is Int, is Long -> { + return factory.createIntegerConstantValue((evaluated as Number).toLong(), descriptor.getType()) + } + else -> { + return factory.createConstantValue(evaluated) + } + } + } + + override fun isNotNullCompileTimeConstant(field: JavaField): Boolean { + // PsiUtil.isCompileTimeConstant returns false for null-initialized fields, + // see com.intellij.psi.util.IsConstantExpressionVisitor.visitLiteralExpression() + return PsiUtil.isCompileTimeConstant((field as JavaFieldImpl).getPsi()) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index bae071d01f3..0ad61eb1e58 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; import org.jetbrains.kotlin.resolve.constants.ArrayValue; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; @@ -210,16 +211,16 @@ public class AnnotationResolver { } @NotNull - public static Map> resolveAnnotationArguments( + public static Map> resolveAnnotationArguments( @NotNull ResolvedCall resolvedCall, @NotNull BindingTrace trace ) { - Map> arguments = new HashMap>(); + Map> arguments = new HashMap>(); for (Map.Entry descriptorToArgument : resolvedCall.getValueArguments().entrySet()) { ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey(); ResolvedValueArgument resolvedArgument = descriptorToArgument.getValue(); - CompileTimeConstant value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument); + ConstantValue value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument); if (value != null) { arguments.put(parameterDescriptor, value); } @@ -228,32 +229,30 @@ public class AnnotationResolver { } @Nullable - public static CompileTimeConstant getAnnotationArgumentValue( + public static ConstantValue getAnnotationArgumentValue( BindingTrace trace, ValueParameterDescriptor parameterDescriptor, ResolvedValueArgument resolvedArgument ) { JetType varargElementType = parameterDescriptor.getVarargElementType(); boolean argumentsAsVararg = varargElementType != null && !hasSpread(resolvedArgument); - List> constants = resolveValueArguments( - resolvedArgument, argumentsAsVararg ? varargElementType : parameterDescriptor.getType(), trace); + final JetType constantType = argumentsAsVararg ? varargElementType : parameterDescriptor.getType(); + List> compileTimeConstants = resolveValueArguments(resolvedArgument, constantType, trace); + List> constants = KotlinPackage.map(compileTimeConstants, new Function1, ConstantValue>() { + @Override + public ConstantValue invoke(CompileTimeConstant constant) { + return constant.toConstantValue(constantType); + } + }); if (argumentsAsVararg) { + if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null; - boolean usesVariableAsConstant = KotlinPackage.any(constants, new Function1, Boolean>() { - @Override - public Boolean invoke(CompileTimeConstant constant) { - return constant.usesVariableAsConstant(); - } - }); - - if (parameterDescriptor.declaresDefaultValue() && constants.isEmpty()) return null; - - return new ArrayValue(constants, parameterDescriptor.getType(), usesVariableAsConstant); + return new ArrayValue(constants, parameterDescriptor.getType()); } else { // we should actually get only one element, but just in case of getting many, we take the last one - return !constants.isEmpty() ? KotlinPackage.last(constants) : null; + return KotlinPackage.lastOrNull(constants); } } @@ -280,7 +279,7 @@ public class AnnotationResolver { } CompileTimeConstant constant = ConstantExpressionEvaluator.getConstant(argumentExpression, trace.getBindingContext()); - if (constant != null && constant.canBeUsedInAnnotations()) { + if (constant != null && constant.getCanBeUsedInAnnotations()) { return; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index f08e868dff1..475dde783db 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -33,7 +33,6 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.scopes.*; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; @@ -735,8 +734,7 @@ public class BodyResolver { JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer( propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace); JetType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE; - CompileTimeConstant compileTimeInitializer = propertyDescriptor.getCompileTimeInitializer(); - if (compileTimeInitializer == null) { + if (propertyDescriptor.getCompileTimeInitializer() == null) { expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer, outerDataFlowInfo, trace); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java index b660ef8ffbb..bd8c2912b9f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CompileTimeConstantUtils.java @@ -31,6 +31,8 @@ import org.jetbrains.kotlin.psi.JetTypeReference; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.BooleanValue; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; +import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeProjection; @@ -113,7 +115,7 @@ public class CompileTimeConstantUtils { annotatedDescriptor.getAnnotations().findAnnotation(new FqName("kotlin.jvm.internal.Intrinsic")); if (intrinsicAnnotation == null) return null; - Collection> values = intrinsicAnnotation.getAllValueArguments().values(); + Collection> values = intrinsicAnnotation.getAllValueArguments().values(); if (values.isEmpty()) return null; Object value = values.iterator().next().getValue(); @@ -132,9 +134,13 @@ public class CompileTimeConstantUtils { if (expression == null) return false; CompileTimeConstant compileTimeConstant = ConstantExpressionEvaluator.evaluate(expression, trace, KotlinBuiltIns.getInstance().getBooleanType()); - if (!(compileTimeConstant instanceof BooleanValue) || compileTimeConstant.usesVariableAsConstant()) return false; + if (!(compileTimeConstant instanceof TypedCompileTimeConstant) || compileTimeConstant.getUsesVariableAsConstant()) return false; - Boolean value = ((BooleanValue) compileTimeConstant).getValue(); + ConstantValue constantValue = ((TypedCompileTimeConstant) compileTimeConstant).getConstantValue(); + + if (!(constantValue instanceof BooleanValue)) return false; + + Boolean value = ((BooleanValue) constantValue).getValue(); return expectedValue == null || expectedValue.equals(value); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 6dbac5fab2d..ca3dc003652 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -37,10 +37,8 @@ import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.resolve.constants.evaluate.EvaluatePackage; import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsPackage; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.scopes.JetScope; @@ -868,17 +866,13 @@ public class DescriptorResolver { if (!variable.hasInitializer()) return; variableDescriptor.setCompileTimeInitializer( - storageManager.createRecursionTolerantNullableLazyValue(new Function0>() { + storageManager.createRecursionTolerantNullableLazyValue(new Function0>() { @Nullable @Override - public CompileTimeConstant invoke() { + public ConstantValue invoke() { JetExpression initializer = variable.getInitializer(); JetType initializerType = expressionTypingServices.safeGetType(scope, initializer, variableType, dataFlowInfo, trace); - CompileTimeConstant constant = ConstantExpressionEvaluator.evaluate(initializer, trace, initializerType); - if (constant instanceof IntegerValueTypeConstant) { - return EvaluatePackage.createCompileTimeConstantWithType((IntegerValueTypeConstant) constant, initializerType); - } - return constant; + return ConstantExpressionEvaluator.evaluateToConstantValue(initializer, trace, initializerType); } }, null) ); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java index 1a4f6c9e987..1fe0859d64e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java @@ -26,13 +26,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.kotlin.diagnostics.*; +import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.lexer.JetModifierKeywordToken; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.StringValue; import java.util.*; @@ -302,9 +302,9 @@ public class ModifiersChecker { } String value = null; - Collection> values = annotation.getAllValueArguments().values(); + Collection> values = annotation.getAllValueArguments().values(); if (!values.isEmpty()) { - CompileTimeConstant name = values.iterator().next(); + ConstantValue name = values.iterator().next(); if (name instanceof StringValue) { value = ((StringValue) name).getValue(); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index a598cb915d3..a2fc4c7b3c5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -39,7 +39,6 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.IntegerValueConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.scopes.receivers.*; import org.jetbrains.kotlin.types.ErrorUtils; @@ -369,7 +368,7 @@ public class CallExpressionResolver { } CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, context.trace, context.expectedType); - if (value instanceof IntegerValueConstant && ((IntegerValueConstant) value).isPure()) { + if (value != null && value.getIsPure()) { return ExpressionTypingUtils.createCompileTimeConstantTypeInfo(value, expression, context); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt index ac78cd3b963..8ba9e0bc3a7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/FakeCallableDescriptorForObject.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.resolve.calls.util import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassObjectType @@ -59,7 +58,7 @@ public class FakeCallableDescriptorForObject( override fun getOriginal(): CallableDescriptor = this - override fun getCompileTimeInitializer(): CompileTimeConstant? = null + override fun getCompileTimeInitializer() = null override fun getSource(): SourceElement = classDescriptor.getSource() } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java index 907beccac42..5699547eae1 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantChecker.java @@ -51,7 +51,7 @@ public class CompileTimeConstantChecker { // return true if there is an error public boolean checkConstantExpressionType( - @Nullable CompileTimeConstant compileTimeConstant, + @Nullable ConstantValue compileTimeConstant, @NotNull JetConstantExpression expression, @NotNull JetType expectedType ) { @@ -76,7 +76,7 @@ public class CompileTimeConstantChecker { } private boolean checkIntegerValue( - @Nullable CompileTimeConstant value, + @Nullable ConstantValue value, @NotNull JetType expectedType, @NotNull JetConstantExpression expression ) { @@ -98,7 +98,7 @@ public class CompileTimeConstantChecker { } private boolean checkFloatValue( - @Nullable CompileTimeConstant value, + @Nullable ConstantValue value, @NotNull JetType expectedType, @NotNull JetConstantExpression expression ) { @@ -125,7 +125,7 @@ public class CompileTimeConstantChecker { return false; } - private boolean checkCharValue(CompileTimeConstant constant, JetType expectedType, JetConstantExpression expression) { + private boolean checkCharValue(ConstantValue constant, JetType expectedType, JetConstantExpression expression) { if (!noExpectedTypeOrError(expectedType) && !JetTypeChecker.DEFAULT.isSubtypeOf(builtIns.getCharType(), expectedType)) { return reportError(CONSTANT_EXPECTED_TYPE_MISMATCH.on(expression, "character", expectedType)); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 05f234d0810..0c51f3846b5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -41,31 +41,26 @@ import java.math.BigInteger import kotlin.platform.platformStatic public class ConstantExpressionEvaluator private constructor(val trace: BindingTrace) : JetVisitor, JetType>() { - - private val builtIns = KotlinBuiltIns.getInstance() + private val factory = ConstantValueFactory(KotlinBuiltIns.getInstance()) companion object { platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { val evaluator = ConstantExpressionEvaluator(trace) - val constant = evaluator.evaluate(expression, expectedType) - return if (constant !is ErrorValue) constant else null + val constant = evaluator.evaluate(expression, expectedType) ?: return null + return if (!constant.isError) constant else null } - platformStatic public fun isPropertyCompileTimeConstant(descriptor: VariableDescriptor): Boolean { - if (descriptor.isVar()) { - return false - } - if (DescriptorUtils.isObject(descriptor.getContainingDeclaration()) || - DescriptorUtils.isStaticDeclaration(descriptor)) { - val returnType = descriptor.getType() - return KotlinBuiltIns.isPrimitiveType(returnType) || KotlinBuiltIns.isString(returnType) - } - return false + platformStatic public fun evaluateToConstantValue( + expression: JetExpression, + trace: BindingTrace, + expectedType: JetType + ): ConstantValue<*>? { + return evaluate(expression, trace, expectedType)?.toConstantValue(expectedType) } platformStatic public fun getConstant(expression: JetExpression, bindingContext: BindingContext): CompileTimeConstant<*>? { - val constant = getPossiblyErrorConstant(expression, bindingContext) - return if (constant !is ErrorValue) constant else null + val constant = getPossiblyErrorConstant(expression, bindingContext) ?: return null + return if (!constant.isError) constant else null } platformStatic private fun getPossiblyErrorConstant(expression: JetExpression, bindingContext: BindingContext): CompileTimeConstant<*>? { @@ -87,30 +82,38 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return null } - private val stringExpressionEvaluator = object : JetVisitor() { - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false), builtIns) + private val stringExpressionEvaluator = object : JetVisitor, Nothing>() { + private fun createStringConstant(compileTimeConstant: CompileTimeConstant<*>): TypedCompileTimeConstant? { + val constantValue = compileTimeConstant.toConstantValue(TypeUtils.NO_EXPECTED_TYPE) + return when (constantValue) { + is ErrorValue, is EnumValue -> return null + is NullValue -> factory.createStringValue("null") + else -> factory.createStringValue(constantValue.value.toString()) + }.wrap(compileTimeConstant.parameters) + } - fun evaluate(entry: JetStringTemplateEntry): StringValue? { + fun evaluate(entry: JetStringTemplateEntry): TypedCompileTimeConstant? { return entry.accept(this, null) } - override fun visitStringTemplateEntryWithExpression(entry: JetStringTemplateEntryWithExpression, data: Nothing?): StringValue? { - val expression = entry.getExpression() - if (expression == null) return null + override fun visitStringTemplateEntryWithExpression(entry: JetStringTemplateEntryWithExpression, data: Nothing?): TypedCompileTimeConstant? { + val expression = entry.getExpression() ?: return null - return createStringConstant(this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType())) + return this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType())?.let { + createStringConstant(it) + } } - override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getText()) + override fun visitLiteralStringTemplateEntry(entry: JetLiteralStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getText()).wrap() - override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getUnescapedValue()) + override fun visitEscapeStringTemplateEntry(entry: JetEscapeStringTemplateEntry, data: Nothing?) = factory.createStringValue(entry.getUnescapedValue()).wrap() } override fun visitConstantExpression(expression: JetConstantExpression, expectedType: JetType?): CompileTimeConstant<*>? { val text = expression.getText() ?: return null val nodeElementType = expression.getNode().getElementType() - if (nodeElementType == JetNodeTypes.NULL) return NullValue(builtIns) + if (nodeElementType == JetNodeTypes.NULL) return factory.createNullValue().wrap() val result: Any? = when (nodeElementType) { JetNodeTypes.INTEGER_CONSTANT -> parseLong(text) @@ -121,7 +124,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } ?: return null fun isLongWithSuffix() = nodeElementType == JetNodeTypes.INTEGER_CONSTANT && hasLongSuffix(text) - return createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(true, !isLongWithSuffix(), false)) + return createConstant(result, expectedType, CompileTimeConstant.Parameters(true, !isLongWithSuffix(), false)) } override fun visitParenthesizedExpression(expression: JetParenthesizedExpression, expectedType: JetType?): CompileTimeConstant<*>? { @@ -152,17 +155,17 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT break } else { - if (!constant.canBeUsedInAnnotations()) canBeUsedInAnnotation = false - if (constant.usesVariableAsConstant()) usesVariableAsConstant = true - sb.append(constant.value) + if (!constant.canBeUsedInAnnotations) canBeUsedInAnnotation = false + if (constant.usesVariableAsConstant) usesVariableAsConstant = true + sb.append(constant.constantValue.value) } } return if (!interupted) createConstant( sb.toString(), expectedType, - CompileTimeConstant.Parameters.Impl( - isPure = true, + CompileTimeConstant.Parameters( + isPure = false, canBeUsedInAnnotation = canBeUsedInAnnotation, usesVariableAsConstant = usesVariableAsConstant ) @@ -174,8 +177,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT evaluate(expression.getLeft(), expectedType) override fun visitBinaryExpression(expression: JetBinaryExpression, expectedType: JetType?): CompileTimeConstant<*>? { - val leftExpression = expression.getLeft() - if (leftExpression == null) return null + val leftExpression = expression.getLeft() ?: return null val operationToken = expression.getOperationToken() if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationToken)) { @@ -183,14 +185,12 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val leftConstant = evaluate(leftExpression, booleanType) if (leftConstant == null) return null - val rightExpression = expression.getRight() - if (rightExpression == null) return null + val rightExpression = expression.getRight() ?: return null - val rightConstant = evaluate(rightExpression, booleanType) - if (rightConstant == null) return null + val rightConstant = evaluate(rightExpression, booleanType) ?: return null - val leftValue = leftConstant.value - val rightValue = rightConstant.value + val leftValue = leftConstant.getValue(booleanType) + val rightValue = rightConstant.getValue(booleanType) if (leftValue !is Boolean || rightValue !is Boolean) return null val result = when (operationToken) { @@ -198,8 +198,14 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT JetTokens.OROR -> leftValue || rightValue else -> throw IllegalArgumentException("Unknown boolean operation token ${operationToken}") } - val usesVariableAsConstant = leftConstant.usesVariableAsConstant() || rightConstant.usesVariableAsConstant() - return createConstant(result, expectedType, CompileTimeConstant.Parameters.Impl(true, true, usesVariableAsConstant)) + return createConstant( + result, expectedType, + CompileTimeConstant.Parameters( + canBeUsedInAnnotation = true, + isPure = false, + usesVariableAsConstant = leftConstant.usesVariableAsConstant || rightConstant.usesVariableAsConstant + ) + ) } else { return evaluateCall(expression.getOperationReference(), leftExpression, expectedType) @@ -226,7 +232,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return createConstant( result, expectedType, - CompileTimeConstant.Parameters.Impl( + CompileTimeConstant.Parameters( canBeUsedInAnnotation, !isNumberConversionMethod && isArgumentPure, usesVariableAsConstant) @@ -240,8 +246,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT if (isDivisionByZero(resultingDescriptorName.asString(), argumentForParameter.value)) { val parentExpression: JetExpression = PsiTreeUtil.getParentOfType(receiverExpression, javaClass())!! trace.report(Errors.DIVISION_BY_ZERO.on(parentExpression)) - //TODO_R: - return ErrorValue.create("Division by zero") + return factory.createErrorValue("Division by zero").wrap() } val result = evaluateBinaryAndCheck(argumentForReceiver, argumentForParameter, resultingDescriptorName.asString(), callExpression) @@ -250,11 +255,10 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val areArgumentsPure = isPureConstant(argumentForReceiver.expression) && isPureConstant(argumentForParameter.expression) val canBeUsedInAnnotation = canBeUsedInAnnotation(argumentForReceiver.expression) && canBeUsedInAnnotation(argumentForParameter.expression) val usesVariableAsConstant = usesVariableAsConstant(argumentForReceiver.expression) || usesVariableAsConstant(argumentForParameter.expression) - val parameters = CompileTimeConstant.Parameters.Impl(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) - val factory = CompileTimeConstantFactory(parameters, builtIns) + val parameters = CompileTimeConstant.Parameters(canBeUsedInAnnotation, areArgumentsPure, usesVariableAsConstant) return when (resultingDescriptorName) { - OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory) - OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory) + OperatorConventions.COMPARE_TO -> createCompileTimeConstantForCompareTo(result, callExpression, factory)?.wrap(parameters) + OperatorConventions.EQUALS -> createCompileTimeConstantForEquals(result, callExpression, factory)?.wrap(parameters) else -> { createConstant(result, expectedType, parameters) } @@ -264,17 +268,11 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return null } - private fun usesVariableAsConstant(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.usesVariableAsConstant() ?: false + private fun usesVariableAsConstant(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.usesVariableAsConstant ?: false - private fun canBeUsedInAnnotation(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.canBeUsedInAnnotations() ?: false + private fun canBeUsedInAnnotation(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.canBeUsedInAnnotations ?: false - private fun isPureConstant(expression: JetExpression): Boolean { - val compileTimeConstant = getConstant(expression, trace.getBindingContext()) - if (compileTimeConstant is IntegerValueConstant) { - return compileTimeConstant.isPure() - } - return false - } + private fun isPureConstant(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.isPure ?: false private fun evaluateUnaryAndCheck(receiver: OperationArgument, name: String, callExpression: JetExpression): Any? { val functions = unaryOperations[UnaryOperationKey(receiver.ctcType, name)] @@ -342,25 +340,19 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT override fun visitSimpleNameExpression(expression: JetSimpleNameExpression, expectedType: JetType?): CompileTimeConstant<*>? { val enumDescriptor = trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, expression); if (enumDescriptor != null && DescriptorUtils.isEnumEntry(enumDescriptor)) { - return EnumValue(enumDescriptor as ClassDescriptor) + return factory.createEnumValue(enumDescriptor as ClassDescriptor).wrap() } val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) if (resolvedCall != null) { val callableDescriptor = resolvedCall.getResultingDescriptor() if (callableDescriptor is VariableDescriptor) { - val compileTimeConstant = callableDescriptor.getCompileTimeInitializer() - if (compileTimeConstant == null) return null + val variableInitializer = callableDescriptor.getCompileTimeInitializer() ?: return null - val value: Any? = - if (compileTimeConstant is IntegerValueTypeConstant) - compileTimeConstant.getValue(expectedType ?: TypeUtils.NO_EXPECTED_TYPE) - else - compileTimeConstant.value return createConstant( - value, + variableInitializer.value, expectedType, - CompileTimeConstant.Parameters.Impl( + CompileTimeConstant.Parameters( canBeUsedInAnnotation = isPropertyCompileTimeConstant(callableDescriptor), isPure = false, usesVariableAsConstant = true @@ -371,6 +363,18 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return null } + private fun isPropertyCompileTimeConstant(descriptor: VariableDescriptor): Boolean { + if (descriptor.isVar()) { + return false + } + if (DescriptorUtils.isObject(descriptor.getContainingDeclaration()) || + DescriptorUtils.isStaticDeclaration(descriptor)) { + val returnType = descriptor.getType() + return KotlinBuiltIns.isPrimitiveType(returnType) || KotlinBuiltIns.isString(returnType) + } + return false + } + override fun visitQualifiedExpression(expression: JetQualifiedExpression, expectedType: JetType?): CompileTimeConstant<*>? { val selectorExpression = expression.getSelectorExpression() // 1.toInt(); 1.plus(1); @@ -409,7 +413,10 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) } - return ArrayValue(arguments, resultingDescriptor.getReturnType()!!, arguments.any() { it.usesVariableAsConstant() }) + return ArrayValue(arguments.map { it.toConstantValue(varargType) }, resultingDescriptor.getReturnType()!!). + wrap( + usesVariableAsConstant = arguments.any { it.usesVariableAsConstant } + ) } // Ann() @@ -420,7 +427,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT classDescriptor.getDefaultType(), AnnotationResolver.resolveAnnotationArguments(call, trace) ) - return AnnotationValue(descriptor) + return AnnotationValue(descriptor).wrap() } } @@ -430,7 +437,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT override fun visitClassLiteralExpression(expression: JetClassLiteralExpression, expectedType: JetType?): CompileTimeConstant<*>? { val jetType = trace.getType(expression)!! if (jetType.isError()) return null - return KClassValue(jetType) + return KClassValue(jetType).wrap() } private fun resolveArguments(valueArguments: List, expectedType: JetType): List> { @@ -476,32 +483,54 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } private fun createOperationArgument(expression: JetExpression, expressionType: JetType, compileTimeType: CompileTimeType<*>): OperationArgument? { - val evaluatedConstant = evaluate(expression, trace, expressionType) - if (evaluatedConstant == null) return null - - if (evaluatedConstant is IntegerValueTypeConstant) { - val evaluationResultWithNewType = evaluatedConstant.getValue(expressionType) - return OperationArgument(evaluationResultWithNewType, compileTimeType, expression) - } - - val evaluationResult = evaluatedConstant.value - if (evaluationResult == null) return null - + val compileTimeConstant = evaluate(expression, trace, expressionType) ?: return null + val evaluationResult = compileTimeConstant.getValue(expressionType) ?: return null return OperationArgument(evaluationResult, compileTimeType, expression) } - fun createConstant( + private fun createConstant( value: Any?, expectedType: JetType?, parameters: CompileTimeConstant.Parameters ): CompileTimeConstant<*>? { - return CompileTimeConstantFactory(parameters, builtIns).createCompileTimeConstant(value, if (parameters.isPure) expectedType ?: TypeUtils.NO_EXPECTED_TYPE else null) + return if (parameters.isPure) { + return createCompileTimeConstant(value, parameters, expectedType ?: TypeUtils.NO_EXPECTED_TYPE) + } + else { + factory.createConstantValue(value)?.wrap(parameters) + } + } + + private fun createCompileTimeConstant( + value: Any?, + parameters: CompileTimeConstant.Parameters, + expectedType: JetType + ): CompileTimeConstant<*>? { + return when (value) { + is Byte, is Short, is Int, is Long -> createIntegerCompileTimeConstant((value as Number).toLong(), parameters, expectedType) + else -> factory.createConstantValue(value)?.wrap(parameters) + } + } + + private fun createIntegerCompileTimeConstant( + value: Long, + parameters: CompileTimeConstant.Parameters, + expectedType: JetType + ): CompileTimeConstant<*>? { + if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { + return IntegerValueTypeConstant(value, parameters) + } + val integerValue = factory.createIntegerConstantValue(value, expectedType) + if (integerValue != null) { + return integerValue.wrap(parameters) + } + return when (value) { + value.toInt().toLong() -> factory.createIntValue(value.toInt()) + else -> factory.createLongValue(value) + }.wrap(parameters) } } -public fun IntegerValueTypeConstant.createCompileTimeConstantWithType(expectedType: JetType): CompileTimeConstant<*>? - = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(this.canBeUsedInAnnotations(), true, false), KotlinBuiltIns.getInstance()).createCompileTimeConstant(this.getValue(expectedType)) - private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L') public fun parseLong(text: String): Long? { @@ -557,7 +586,7 @@ private fun parseBoolean(text: String): Boolean { } -private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, factory: CompileTimeConstantFactory): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForEquals(result: Any?, operationReference: JetExpression, factory: ConstantValueFactory): ConstantValue<*>? { if (result is Boolean) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for equals operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() @@ -575,7 +604,7 @@ private fun createCompileTimeConstantForEquals(result: Any?, operationReference: return null } -private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, factory: CompileTimeConstantFactory): CompileTimeConstant<*>? { +private fun createCompileTimeConstantForCompareTo(result: Any?, operationReference: JetExpression, factory: ConstantValueFactory): ConstantValue<*>? { if (result is Int) { assert(operationReference is JetSimpleNameExpression, "This method should be called only for compareTo operations") val operationToken = (operationReference as JetSimpleNameExpression).getReferencedNameElementType() @@ -594,19 +623,6 @@ private fun createCompileTimeConstantForCompareTo(result: Any?, operationReferen return null } -private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? { - return when (value) { - is IntegerValueTypeConstant -> CompileTimeConstantFactory(value.parameters, KotlinBuiltIns.getInstance()).createStringValue(value.getValue(TypeUtils.NO_EXPECTED_TYPE).toString()) - is StringValue -> value - is IntValue, is ByteValue, is ShortValue, is LongValue, - is CharValue, - is DoubleValue, is FloatValue, - is BooleanValue, - is NullValue -> CompileTimeConstantFactory(value.parameters, KotlinBuiltIns.getInstance()).createStringValue("${value.value}") - else -> null - } -} - fun isIntegerType(value: Any?) = value is Byte || value is Short || value is Int || value is Long private fun getReceiverExpressionType(resolvedCall: ResolvedCall<*>): JetType? { @@ -668,4 +684,3 @@ private fun unaryOperation( private data class BinaryOperationKey(val f: CompileTimeType, val s: CompileTimeType, val functionName: String) private data class UnaryOperationKey(val f: CompileTimeType, val functionName: String) - diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/diagnostics/DiagnosticsWithSuppression.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/diagnostics/DiagnosticsWithSuppression.java index 85a01b8899d..7482867dd13 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/diagnostics/DiagnosticsWithSuppression.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/diagnostics/DiagnosticsWithSuppression.java @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.diagnostics.Severity; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.constants.ArrayValue; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.StringValue; import org.jetbrains.kotlin.util.ExtensionProvider; @@ -214,9 +214,9 @@ public class DiagnosticsWithSuppression implements Diagnostics { if (!KotlinBuiltIns.isSuppressAnnotation(annotationDescriptor)) continue; // We only add strings and skip other values to facilitate recovery in presence of erroneous code - for (CompileTimeConstant arrayValue : annotationDescriptor.getAllValueArguments().values()) { + for (ConstantValue arrayValue : annotationDescriptor.getAllValueArguments().values()) { if ((arrayValue instanceof ArrayValue)) { - for (CompileTimeConstant value : ((ArrayValue) arrayValue).getValue()) { + for (ConstantValue value : ((ArrayValue) arrayValue).getValue()) { if (value instanceof StringValue) { builder.add(String.valueOf(((StringValue) value).getValue()).toLowerCase()); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java index 983deaf5047..afcd4037800 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ArgumentMapping; import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.ArrayValue; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.EnumValue; import static kotlin.KotlinPackage.firstOrNull; @@ -53,7 +53,7 @@ public class InlineUtil { if (annotation == null) { return InlineStrategy.NOT_INLINE; } - CompileTimeConstant argument = firstOrNull(annotation.getAllValueArguments().values()); + ConstantValue argument = firstOrNull(annotation.getAllValueArguments().values()); if (argument == null) { return InlineStrategy.AS_FUNCTION; } @@ -72,9 +72,9 @@ public class InlineUtil { private static boolean hasInlineOption(@NotNull ValueParameterDescriptor descriptor, @NotNull InlineOption option) { AnnotationDescriptor annotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.inlineOptions); if (annotation != null) { - CompileTimeConstant argument = firstOrNull(annotation.getAllValueArguments().values()); + ConstantValue argument = firstOrNull(annotation.getAllValueArguments().values()); if (argument instanceof ArrayValue) { - for (CompileTimeConstant value : ((ArrayValue) argument).getValue()) { + for (ConstantValue value : ((ArrayValue) argument).getValue()) { if (value instanceof EnumValue && ((EnumValue) value).getValue().getName().asString().equals(option.name())) { return true; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt index 3cb342e5418..48868f41499 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.resolve.AnnotationResolver import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.lazy.LazyEntity import org.jetbrains.kotlin.resolve.scopes.JetScope @@ -109,7 +109,7 @@ public class LazyAnnotationDescriptor( override fun getAllValueArguments() = valueArguments() - private fun computeValueArguments(): Map> { + private fun computeValueArguments(): Map> { val resolutionResults = c.annotationResolver.resolveAnnotationCall(annotationEntry, c.scope, c.trace) AnnotationResolver.checkAnnotationType(annotationEntry, c.trace, resolutionResults) @@ -121,7 +121,7 @@ public class LazyAnnotationDescriptor( if (resolvedArgument == null) null else AnnotationResolver.getAnnotationArgumentValue(c.trace, valueParameter, resolvedArgument) } - .filterValues { it != null } as Map> + .filterValues { it != null } as Map> } override fun forceResolveAllContents() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 4be38adea30..06383a6cec7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -55,9 +55,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind; import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate; import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstantChecker; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.*; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.WritableScopeImpl; @@ -121,19 +119,20 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { @Override public JetTypeInfo visitConstantExpression(@NotNull JetConstantExpression expression, ExpressionTypingContext context) { - CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, context.trace, context.expectedType); + CompileTimeConstant compileTimeConstant = ConstantExpressionEvaluator.evaluate(expression, context.trace, context.expectedType); - if (!(value instanceof IntegerValueTypeConstant)) { + if (!(compileTimeConstant instanceof IntegerValueTypeConstant)) { CompileTimeConstantChecker compileTimeConstantChecker = context.getCompileTimeConstantChecker(); - boolean hasError = compileTimeConstantChecker.checkConstantExpressionType(value, expression, context.expectedType); + ConstantValue constantValue = compileTimeConstant != null ? ((TypedCompileTimeConstant) compileTimeConstant).getConstantValue() : null; + boolean hasError = compileTimeConstantChecker.checkConstantExpressionType(constantValue, expression, context.expectedType); if (hasError) { IElementType elementType = expression.getNode().getElementType(); return TypeInfoFactoryPackage.createTypeInfo(getDefaultType(elementType), context); } } - assert value != null : "CompileTimeConstant should be evaluated for constant expression or an error should be recorded " + expression.getText(); - return createCompileTimeConstantTypeInfo(value, expression, context); + assert compileTimeConstant != null : "CompileTimeConstant should be evaluated for constant expression or an error should be recorded " + expression.getText(); + return createCompileTimeConstantTypeInfo(compileTimeConstant, expression, context); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowUtils.java index f297b7e2d6d..c189ca513b3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DataFlowUtils.java @@ -31,11 +31,9 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory; import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstantChecker; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; -import org.jetbrains.kotlin.resolve.constants.evaluate.EvaluatePackage; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.TypesPackage; @@ -176,12 +174,9 @@ public class DataFlowUtils { } if (expression instanceof JetConstantExpression) { - CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, c.trace, c.expectedType); - if (value instanceof IntegerValueTypeConstant) { - value = EvaluatePackage.createCompileTimeConstantWithType((IntegerValueTypeConstant) value, c.expectedType); - } + ConstantValue constantValue = ConstantExpressionEvaluator.evaluateToConstantValue(expression, c.trace, c.expectedType); boolean error = new CompileTimeConstantChecker(c.trace, true) - .checkConstantExpressionType(value, (JetConstantExpression) expression, c.expectedType); + .checkConstantExpressionType(constantValue, (JetConstantExpression) expression, c.expectedType); if (hasError != null) hasError.set(error); return expressionType; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java index 0e38b188d83..58e9ba815af 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java @@ -22,7 +22,6 @@ import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; @@ -33,6 +32,7 @@ import org.jetbrains.kotlin.resolve.*; import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; +import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant; import org.jetbrains.kotlin.resolve.scopes.WritableScope; import org.jetbrains.kotlin.resolve.scopes.WritableScopeImpl; import org.jetbrains.kotlin.resolve.scopes.receivers.ClassReceiver; @@ -248,10 +248,19 @@ public class ExpressionTypingUtils { @NotNull JetExpression expression, @NotNull ExpressionTypingContext context ) { - JetType expressionType = value.getType(); - if (value instanceof IntegerValueTypeConstant && context.contextDependency == INDEPENDENT) { - expressionType = ((IntegerValueTypeConstant) value).getType(context.expectedType); - ArgumentTypeResolver.updateNumberType(expressionType, expression, context); + JetType expressionType; + if (value instanceof IntegerValueTypeConstant) { + IntegerValueTypeConstant integerValueTypeConstant = (IntegerValueTypeConstant) value; + if (context.contextDependency == INDEPENDENT) { + expressionType = integerValueTypeConstant.getType(context.expectedType); + ArgumentTypeResolver.updateNumberType(expressionType, expression, context); + } + else { + expressionType = integerValueTypeConstant.getUnknownIntegerType(); + } + } + else { + expressionType = ((TypedCompileTimeConstant) value).getType(); } return TypeInfoFactoryPackage.createCheckedTypeInfo(expressionType, context, expression); diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index 1091c6b491c..e47482a3466 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.serialization import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.resolve.constants.* @@ -29,8 +28,6 @@ import org.jetbrains.kotlin.types.JetType public class AnnotationSerializer(builtIns: KotlinBuiltIns) { - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, builtIns) - public fun serializeAnnotation(annotation: AnnotationDescriptor, stringTable: StringTable): ProtoBuf.Annotation { return with(ProtoBuf.Annotation.newBuilder()) { val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as? ClassDescriptor @@ -52,7 +49,7 @@ public class AnnotationSerializer(builtIns: KotlinBuiltIns) { } } - fun valueProto(constant: CompileTimeConstant<*>, type: JetType, nameTable: StringTable): Value.Builder = with(Value.newBuilder()) { + fun valueProto(constant: ConstantValue<*>, type: JetType, nameTable: StringTable): Value.Builder = with(Value.newBuilder()) { constant.accept(object : AnnotationArgumentVisitor { override fun visitAnnotationValue(value: AnnotationValue, data: Unit) { setType(Type.ANNOTATION) @@ -121,22 +118,6 @@ public class AnnotationSerializer(builtIns: KotlinBuiltIns) { throw UnsupportedOperationException("Null should not appear in annotation arguments") } - override fun visitNumberTypeValue(constant: IntegerValueTypeConstant, data: Unit) { - // TODO: IntegerValueTypeConstant should not occur in annotation arguments - val number = constant.getValue(type) - val specificConstant = with(KotlinBuiltIns.getInstance()) { - when (type) { - getLongType() -> factory.createLongValue(number.toLong()) - getIntType() -> factory.createIntValue(number.toInt()) - getShortType() -> factory.createShortValue(number.toShort()) - getByteType() -> factory.createByteValue(number.toByte()) - else -> throw IllegalStateException("Integer constant $constant has non-integer type $type") - } - } - - specificConstant.accept(this, data) - } - override fun visitShortValue(value: ShortValue, data: Unit) { setType(Type.SHORT) setIntValue(value.value.toLong()) diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java index c48b5449257..d1d0cdede90 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotated; import org.jetbrains.kotlin.resolve.DescriptorFactory; import org.jetbrains.kotlin.resolve.MemberComparator; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.types.*; @@ -188,7 +188,7 @@ public class DescriptorSerializer { } } - CompileTimeConstant compileTimeConstant = propertyDescriptor.getCompileTimeInitializer(); + ConstantValue compileTimeConstant = propertyDescriptor.getCompileTimeInitializer(); hasConstant = !(compileTimeConstant == null || compileTimeConstant instanceof NullValue); } diff --git a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java index 9e0b81576c2..2c5840ad27f 100644 --- a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java +++ b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java @@ -8,4 +8,6 @@ class Foo { public static final boolean bool = true; public static final char c = 'c'; public static final String str = "str"; + public static final int charAsInt = '3'; + public static final char intAsChar = 3; } \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt index aa6d75c3acb..cb542bcd213 100644 --- a/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt +++ b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt @@ -1,4 +1,4 @@ -Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass +Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str, Foo.charAsInt, Foo.intAsChar) class MyClass fun box(): String { val ann = javaClass().getAnnotation(javaClass()) @@ -12,6 +12,8 @@ fun box(): String { if (!ann.bool) return "fail: annotation parameter i should be true, but was ${ann.i}" if (ann.c != 'c') return "fail: annotation parameter i should be c, but was ${ann.i}" if (ann.str != "str") return "fail: annotation parameter i should be str, but was ${ann.i}" + if (ann.i2 != '3'.toInt()) return "fail: annotation parameter i2 should be ${'3'.toInt()}, but was ${ann.i}" + if (ann.c2 != 3.toChar()) return "fail: annotation parameter c2 should be 3, but was ${ann.i}" return "OK" } @@ -24,5 +26,7 @@ annotation(retention = AnnotationRetention.RUNTIME) class Ann( val b: Byte, val bool: Boolean, val c: Char, - val str: String + val str: String, + val i2: Int, + val c2: Char ) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt index aa0615c7e0b..76c1bb536a0 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotatedResultType.txt @@ -1,6 +1,6 @@ package -internal fun foo(): @[My(x = IntegerValueType(42))] kotlin.Int +internal fun foo(): @[My(x = 42)] kotlin.Int kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class My : kotlin.Annotation { public constructor My(/*0*/ x: kotlin.Int) diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt index 3ffe8307356..58c743b8ff7 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationOnObject.txt @@ -12,7 +12,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - test.A(a = IntegerValueType(12), c = "Hello") internal object SomeObject { + test.A(a = 12, c = "Hello") internal object SomeObject { private constructor SomeObject() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt index a1080dfccfa..d22174c1d06 100644 --- a/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/BasicAnnotations.txt @@ -2,10 +2,10 @@ package my() internal fun foo(): kotlin.Unit my1() internal fun foo2(): kotlin.Unit -my1(i = IntegerValueType(2)) internal fun foo3(): kotlin.Unit +my1(i = 2) internal fun foo3(): kotlin.Unit my2() internal fun foo4(): kotlin.Unit my2() internal fun foo41(): kotlin.Unit -my2(i = IntegerValueType(2)) internal fun foo42(): kotlin.Unit +my2(i = 2) internal fun foo42(): kotlin.Unit kotlin.annotation.annotation() internal final class my : kotlin.Annotation { public constructor my() diff --git a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt index 6762022a638..282baf803a7 100644 --- a/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt +++ b/compiler/testData/diagnostics/tests/annotations/ConstructorCall.txt @@ -1,7 +1,7 @@ package -Ann2(a = Ann1(a = IntegerValueType(1))) internal val a: kotlin.Int = 1 -Ann2(a = Ann1(a = IntegerValueType(1))) internal val c: kotlin.Int = 2 +Ann2(a = Ann1(a = 1)) internal val a: kotlin.Int = 1 +Ann2(a = Ann1(a = 1)) internal val c: kotlin.Int = 2 internal fun bar(/*0*/ a: Ann = ...): kotlin.Unit internal fun foo(): kotlin.Unit internal fun javaClass(): java.lang.Class diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt index 3ce20f4bfb6..4fbbf722b26 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotated.txt @@ -1,6 +1,6 @@ package -RecursivelyAnnotated(x = IntegerValueType(1)) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { +RecursivelyAnnotated(x = 1) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { public constructor RecursivelyAnnotated(/*0*/ x: kotlin.Int) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt index aa410c44299..39cd83556cd 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameter.txt @@ -1,8 +1,8 @@ package kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { - public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) - RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int + public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int) + RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt index 111ffbf2d28..a5994d556c1 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterType.txt @@ -1,8 +1,8 @@ package kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { - public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int) - internal final val x: @[RecursivelyAnnotated(x = IntegerValueType(1))] kotlin.Int + public constructor RecursivelyAnnotated(/*0*/ x: @[RecursivelyAnnotated(x = 1)] kotlin.Int) + internal final val x: @[RecursivelyAnnotated(x = 1)] kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt index aa410c44299..39cd83556cd 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedParameterWithAt.txt @@ -1,8 +1,8 @@ package kotlin.annotation.annotation() internal final class RecursivelyAnnotated : kotlin.Annotation { - public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) - RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int + public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int) + RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.txt b/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.txt index ad23ca551a4..2bc4d2a30c0 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.txt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.txt @@ -1,8 +1,8 @@ package internal final class RecursivelyAnnotated { - public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = IntegerValueType(1)) x: kotlin.Int) - RecursivelyAnnotated(x = IntegerValueType(1)) internal final val x: kotlin.Int + public constructor RecursivelyAnnotated(/*0*/ RecursivelyAnnotated(x = 1) x: kotlin.Int) + RecursivelyAnnotated(x = 1) internal final val x: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt index 4593d4f7324..5c3b870ce33 100644 --- a/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt +++ b/compiler/testData/diagnostics/tests/annotations/WrongAnnotationArgsOnObject.txt @@ -11,7 +11,7 @@ package test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - test.BadAnnotation(s = IntegerValueType(1)) internal object SomeObject { + test.BadAnnotation(s = 1) internal object SomeObject { private constructor SomeObject() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt index 195d72eac5c..8304ffac487 100644 --- a/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/annotations/atAnnotationResolve.txt @@ -1,11 +1,11 @@ package -Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueType(3)) private final class A { +Ann(x = 1) Ann(x = 2) Ann(x = 3) private final class A { Ann() public constructor A() Ann() internal final val x: kotlin.Int = 1 - internal final fun bar(/*0*/ x: @[Ann(x = IntegerValueType(1)) Ann(x = IntegerValueType(2)) Ann(x = IntegerValueType(3))] kotlin.Int): kotlin.Unit + internal final fun bar(/*0*/ x: @[Ann(x = 1) Ann(x = 2) Ann(x = 3)] kotlin.Int): kotlin.Unit public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - Ann(x = IntegerValueType(5)) internal final fun foo(): kotlin.Unit + Ann(x = 5) internal final fun foo(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt index b10e1ac4536..08b73867132 100644 --- a/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt +++ b/compiler/testData/diagnostics/tests/modifiers/primaryConstructorMissingKeyword.txt @@ -9,7 +9,7 @@ internal final class A { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String internal final inner class B { - Ann(x = IntegerValueType(2)) public constructor B(/*0*/ y: kotlin.Int) + Ann(x = 2) public constructor B(/*0*/ y: kotlin.Int) internal final val y: kotlin.Int public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt b/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt index 72c58383a23..ef1414b9a56 100644 --- a/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt +++ b/compiler/testData/diagnostics/tests/namedArguments/allowForJavaAnnotation.txt @@ -1,6 +1,6 @@ package -A(x = IntegerValueType(1), y = "2") internal fun test(): kotlin.Unit +A(x = 1, y = "2") internal fun test(): kotlin.Unit public final class A : kotlin.Annotation { public constructor A(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String) diff --git a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt index 1a3899fe003..d2331f93dbd 100644 --- a/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt +++ b/compiler/testData/diagnostics/tests/secondaryConstructors/ctrsAnnotationResolve.txt @@ -3,7 +3,7 @@ package internal final class A { Ann1() public constructor A() Ann2() public constructor A(/*0*/ x1: kotlin.Int) - Ann2(x = IntegerValueType(2)) public constructor A(/*0*/ x1: kotlin.Int, /*1*/ x2: kotlin.Int) + Ann2(x = 2) public constructor A(/*0*/ x1: kotlin.Int, /*1*/ x2: kotlin.Int) public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt index 5d763d51ae8..abd04a4380c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationClassMethodCall.txt @@ -14,7 +14,7 @@ public final class A : kotlin.Annotation { public abstract fun value(): kotlin.String } -A(arg = IntegerValueType(1), value = "a") internal final class MyClass { +A(arg = 1, value = "a") internal final class MyClass { public constructor MyClass() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt index bc95994fb3f..559b318378d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.txt @@ -29,7 +29,7 @@ Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i = {{1}}) internal final public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -AnnAnn(i = {Ann(i = {IntegerValueType(1)})}) AnnAnn(i = {}) internal final class TestAnn { +AnnAnn(i = {Ann(i = {1})}) AnnAnn(i = {}) internal final class TestAnn { public constructor TestAnn() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt index f1a137aefb6..6621e28bf33 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.txt @@ -29,7 +29,7 @@ Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i = {}) Ann(i = {1}) Ann(i public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -AnnAnn(i = {Ann(i = {IntegerValueType(1)})}) AnnAnn(i = {}) internal final class TestAnn { +AnnAnn(i = {Ann(i = {1})}) AnnAnn(i = {}) internal final class TestAnn { public constructor TestAnn() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt index 032f49996fc..a69cf471c73 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArray.txt @@ -1,12 +1,12 @@ package -A(value = {"1", "2", "3"}, y = IntegerValueType(1)) internal fun test1(): kotlin.Unit -A(value = {"4"}, y = IntegerValueType(2)) internal fun test2(): kotlin.Unit -A(value = {{"5", "6"}, "7"}, y = IntegerValueType(3)) internal fun test3(): kotlin.Unit -A(value = {"1", "2", "3"}, x = kotlin.String::class, y = IntegerValueType(4)) internal fun test4(): kotlin.Unit -A(value = {"4"}, y = IntegerValueType(5)) internal fun test5(): kotlin.Unit -A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = IntegerValueType(6)) internal fun test6(): kotlin.Unit -A(value = {}, y = IntegerValueType(7)) internal fun test7(): kotlin.Unit +A(value = {"1", "2", "3"}, y = 1) internal fun test1(): kotlin.Unit +A(value = {"4"}, y = 2) internal fun test2(): kotlin.Unit +A(value = {{"5", "6"}, "7"}, y = 3) internal fun test3(): kotlin.Unit +A(value = {"1", "2", "3"}, x = kotlin.String::class, y = 4) internal fun test4(): kotlin.Unit +A(value = {"4"}, y = 5) internal fun test5(): kotlin.Unit +A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = 6) internal fun test6(): kotlin.Unit +A(value = {}, y = 7) internal fun test7(): kotlin.Unit A(value = {"8", "9", "10"}) internal fun test8(): kotlin.Unit public final class A : kotlin.Annotation { diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt index 56f9dfb46d6..607954a26f4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameters/valueArrayAndOtherDefault.txt @@ -1,16 +1,16 @@ package A(value = {"1", "2", "3"}) internal fun test1(): kotlin.Unit -A(value = {"5", "6"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test10(): kotlin.Unit -A(value = {"5", "6", "7"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test11(): kotlin.Unit +A(value = {"5", "6"}, x = kotlin.Any::class, y = 3) internal fun test10(): kotlin.Unit +A(value = {"5", "6", "7"}, x = kotlin.Any::class, y = 3) internal fun test11(): kotlin.Unit A(value = {"4"}) internal fun test2(): kotlin.Unit A(value = {{"5", "6"}, "7"}) internal fun test3(): kotlin.Unit A(value = {"1", "2", "3"}, x = kotlin.String::class) internal fun test4(): kotlin.Unit -A(value = {"4"}, y = IntegerValueType(2)) internal fun test5(): kotlin.Unit -A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test6(): kotlin.Unit +A(value = {"4"}, y = 2) internal fun test5(): kotlin.Unit +A(value = {{"5", "6"}, "7"}, x = kotlin.Any::class, y = 3) internal fun test6(): kotlin.Unit A(value = {}) internal fun test7(): kotlin.Unit A(value = {}) internal fun test8(): kotlin.Unit -A(value = {}, x = kotlin.Any::class, y = IntegerValueType(3)) internal fun test9(): kotlin.Unit +A(value = {}, x = kotlin.Any::class, y = 3) internal fun test9(): kotlin.Unit public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/, /*1*/ x: kotlin.reflect.KClass<*> = ..., /*2*/ y: kotlin.Int = ...) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt index fd257b84b8c..dac73b98869 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/javaAnnotationWithVarargArgument.txt @@ -1,6 +1,6 @@ package -A(value = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit +A(value = {1, "b"}) internal fun test(): kotlin.Unit public final class A : kotlin.Annotation { public constructor A(/*0*/ vararg value: kotlin.String /*kotlin.Array*/) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt index ac5ed31f939..5974a3c30b3 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationWithVarargParameter/kotlinAnnotationWithVarargArgument.txt @@ -1,6 +1,6 @@ package -B(args = {IntegerValueType(1), "b"}) internal fun test(): kotlin.Unit +B(args = {1, "b"}) internal fun test(): kotlin.Unit kotlin.annotation.annotation() internal final class B : kotlin.Annotation { public constructor B(/*0*/ vararg args: kotlin.String /*kotlin.Array*/) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt index a6254ef6253..2c4ea8df39b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/annotationAsArgument.txt @@ -24,14 +24,14 @@ public final class B : kotlin.Annotation { public abstract fun y(): kotlin.Int } -A(arg = kotlin.String::class, b = B(y = IntegerValueType(1))) internal final class MyClass1 { +A(arg = kotlin.String::class, b = B(y = 1)) internal final class MyClass1 { public constructor MyClass1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(b = B(y = IntegerValueType(3))) internal final class MyClass2 { +A(b = B(y = 3)) internal final class MyClass2 { public constructor MyClass2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt index c2c0e772a6d..3395985b2b7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argAndOtherDefault.txt @@ -18,7 +18,7 @@ A(arg = kotlin.String::class) internal final class MyClass1 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(arg = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass2 { +A(arg = kotlin.String::class, x = 2) internal final class MyClass2 { public constructor MyClass2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt index 0ad8f243afb..117f5e6ccb0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/argWithDefaultAndOther.txt @@ -11,14 +11,14 @@ public final class A : kotlin.Annotation { public abstract fun x(): kotlin.Int } -A(arg = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass2 { +A(arg = kotlin.String::class, x = 4) internal final class MyClass2 { public constructor MyClass2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(x = IntegerValueType(5)) internal final class MyClass3 { +A(x = 5) internal final class MyClass3 { public constructor MyClass3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt index 783990fc9f0..bb937f10a14 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueAndOtherDefault.txt @@ -25,14 +25,14 @@ A(value = kotlin.String::class) internal final class MyClass2 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(value = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass3 { +A(value = kotlin.String::class, x = 2) internal final class MyClass3 { public constructor MyClass3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(value = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass4 { +A(value = kotlin.String::class, x = 4) internal final class MyClass4 { public constructor MyClass4() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt index 15eb1a6a038..d46c0049dc5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/javaAnnotationsWithKClassParameter/valueWithDefaultAndOther.txt @@ -11,21 +11,21 @@ public final class A : kotlin.Annotation { public abstract fun x(): kotlin.Int } -A(value = kotlin.String::class, x = IntegerValueType(2)) internal final class MyClass1 { +A(value = kotlin.String::class, x = 2) internal final class MyClass1 { public constructor MyClass1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(value = kotlin.String::class, x = IntegerValueType(4)) internal final class MyClass2 { +A(value = kotlin.String::class, x = 4) internal final class MyClass2 { public constructor MyClass2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -A(x = IntegerValueType(5)) internal final class MyClass3 { +A(x = 5) internal final class MyClass3 { public constructor MyClass3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt index 2ad42368826..f5aeeece4c0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/kotlinAnnotation.txt @@ -1,8 +1,8 @@ package -Ann(value = "a", x = IntegerValueType(1), y = 1.0.toDouble()) internal fun foo1(): kotlin.Unit -Ann(value = "b", x = IntegerValueType(2), y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit -Ann(value = "c", x = IntegerValueType(3), y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit +Ann(value = "a", x = 1, y = 1.0.toDouble()) internal fun foo1(): kotlin.Unit +Ann(value = "b", x = 2, y = 2.0.toDouble()) internal fun foo2(): kotlin.Unit +Ann(value = "c", x = 3, y = 2.0.toDouble()) internal fun foo3(): kotlin.Unit kotlin.annotation.annotation() internal final class Ann : kotlin.Annotation { public constructor Ann(/*0*/ x: kotlin.Int, /*1*/ value: kotlin.String, /*2*/ y: kotlin.Double) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt index 964ccf60e5e..74b23d2864c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withValue.txt @@ -1,9 +1,9 @@ package -A(a = IntegerValueType(1), b = 1.0.toDouble(), value = "v1", x = false) internal fun foo1(): kotlin.Unit -A(a = IntegerValueType(2), b = 2.0.toDouble(), value = "v2", x = true) internal fun foo2(): kotlin.Unit -A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo3(): kotlin.Unit -A(a = IntegerValueType(4), b = 3.0.toDouble(), value = "v2", x = true) internal fun foo4(): kotlin.Unit +A(a = 1, b = 1.0.toDouble(), value = "v1", x = false) internal fun foo1(): kotlin.Unit +A(a = 2, b = 2.0.toDouble(), value = "v2", x = true) internal fun foo2(): kotlin.Unit +A(a = 4, b = 3.0.toDouble(), value = "v2", x = true) internal fun foo3(): kotlin.Unit +A(a = 4, b = 3.0.toDouble(), value = "v2", x = true) internal fun foo4(): kotlin.Unit public final class A : kotlin.Annotation { public constructor A(/*0*/ value: kotlin.String, /*1*/ a: kotlin.Int, /*2*/ b: kotlin.Double, /*3*/ x: kotlin.Boolean) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt index af89ce48848..1eaa96222ef 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/prohibitPositionedArgument/withoutValue.txt @@ -1,8 +1,8 @@ package -A(a = IntegerValueType(1), b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit -A(a = IntegerValueType(2), b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit -A(a = IntegerValueType(4), b = 3.0.toDouble(), x = true) internal fun foo3(): kotlin.Unit +A(a = 1, b = 1.0.toDouble(), x = false) internal fun foo1(): kotlin.Unit +A(a = 2, b = 2.0.toDouble(), x = true) internal fun foo2(): kotlin.Unit +A(a = 4, b = 3.0.toDouble(), x = true) internal fun foo3(): kotlin.Unit public final class A : kotlin.Annotation { public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double, /*2*/ x: kotlin.Boolean) diff --git a/compiler/testData/evaluate/usesVariableAsConstant/OtherTypes.kt b/compiler/testData/evaluate/usesVariableAsConstant/OtherTypes.kt index eed8758f371..a4e735bf812 100644 --- a/compiler/testData/evaluate/usesVariableAsConstant/OtherTypes.kt +++ b/compiler/testData/evaluate/usesVariableAsConstant/OtherTypes.kt @@ -6,11 +6,17 @@ fun foo(): Boolean = true val x = 1 -// val prop1: null +// val prop1: false val prop1 = MyEnum.A // val prop2: null val prop2 = foo() // val prop3: true -val prop3 = "$x" \ No newline at end of file +val prop3 = "$x" + +// val prop4: false +val prop4 = intArrayOf(1, 2, 3) + +// val prop5: true +val prop5 = intArrayOf(1, 2, x, x) \ No newline at end of file diff --git a/compiler/testData/resolveAnnotations/parameters/byte.kt b/compiler/testData/resolveAnnotations/parameters/byte.kt index 975bd272817..b953532f881 100644 --- a/compiler/testData/resolveAnnotations/parameters/byte.kt +++ b/compiler/testData/resolveAnnotations/parameters/byte.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1, 1.toByte(), 128.toByte(), 128) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toByte(), b3 = -128.toByte(), b4 = IntegerValueType(128)) \ No newline at end of file +// EXPECTED: Ann(b1 = 1.toByte(), b2 = 1.toByte(), b3 = -128.toByte(), b4 = 128) \ No newline at end of file diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/char.kt b/compiler/testData/resolveAnnotations/parameters/expressions/char.kt index 2be63e20012..004b0288ea9 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/char.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/char.kt @@ -4,4 +4,4 @@ annotation class Ann(val c1: Char) Ann('a' - 'a') class MyClass -// EXPECTED: Ann(c1 = IntegerValueType(0)) +// EXPECTED: Ann(c1 = 0) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/divide.kt b/compiler/testData/resolveAnnotations/parameters/expressions/divide.kt index 5a146c2e77f..f5e60dd97e1 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/divide.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/divide.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1 / 1, 1 / 1, 1 / 1, 1 / 1) class MyClass -// EXPECTED: Ann(b = IntegerValueType(1), i = IntegerValueType(1), l = IntegerValueType(1), s = IntegerValueType(1)) +// EXPECTED: Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt b/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt index 6d36415f438..0d67ae790da 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/infixCallBinary.kt @@ -10,4 +10,4 @@ annotation class Ann( Ann(1 plus 1, 1 minus 1, 1 times 1, 1 div 1, 1 mod 1) class MyClass -// EXPECTED: Ann(p1 = IntegerValueType(2), p2 = IntegerValueType(0), p3 = IntegerValueType(1), p4 = IntegerValueType(1), p5 = IntegerValueType(0)) +// EXPECTED: Ann(p1 = 2, p2 = 0, p3 = 1, p4 = 1, p5 = 0) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt b/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt index 57df6738438..eac70c9d80f 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/intrincics.kt @@ -10,4 +10,4 @@ annotation class Ann(p1: Int, Ann(1 or 1, 1 and 1, 1 xor 1, 1 shl 1, 1 shr 1, 1 ushr 1) class MyClass -// EXPECTED: Ann(p1 = IntegerValueType(1), p2 = IntegerValueType(1), p3 = IntegerValueType(0), p4 = IntegerValueType(2), p5 = IntegerValueType(0), p6 = IntegerValueType(0)) +// EXPECTED: Ann(p1 = 1, p2 = 1.toShort(), p3 = 0.toByte(), p4 = 2, p5 = 0, p6 = 0) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/long.kt b/compiler/testData/resolveAnnotations/parameters/expressions/long.kt index fd46cfc7617..1363d922c3a 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/long.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/long.kt @@ -8,4 +8,4 @@ annotation class Ann( Ann(1 + 1, java.lang.Long.MAX_VALUE + 1 - 1, java.lang.Long.MAX_VALUE - 1) class MyClass -// EXPECTED: Ann(l1 = IntegerValueType(2), l2 = 9223372036854775807.toLong(), l3 = 9223372036854775806.toLong()) +// EXPECTED: Ann(l1 = 2.toLong(), l2 = 9223372036854775807.toLong(), l3 = 9223372036854775806.toLong()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/maxValueByte.kt b/compiler/testData/resolveAnnotations/parameters/expressions/maxValueByte.kt index 699ed948087..9127af4c873 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/maxValueByte.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/maxValueByte.kt @@ -16,4 +16,4 @@ Ann( p5 = 1.toByte() + 1.toByte() ) class MyClass -// EXPECTED: Ann(p1 = 128, p2 = IntegerValueType(2), p3 = 128, p4 = 2, p5 = 2) +// EXPECTED: Ann(p1 = 128, p2 = 2.toByte(), p3 = 128, p4 = 2, p5 = 2) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/maxValueInt.kt b/compiler/testData/resolveAnnotations/parameters/expressions/maxValueInt.kt index 9d558c9aef3..ad28cc95479 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/maxValueInt.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/maxValueInt.kt @@ -16,4 +16,4 @@ Ann( p5 = 1.toInt() + 1.toInt() ) class MyClass -// EXPECTED: Ann(p1 = -2147483648, p2 = IntegerValueType(2), p3 = -2147483648, p4 = 2, p5 = 2) +// EXPECTED: Ann(p1 = -2147483648, p2 = 2, p3 = -2147483648, p4 = 2, p5 = 2) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/miltiply.kt b/compiler/testData/resolveAnnotations/parameters/expressions/miltiply.kt index 18e45eb61ff..6974a5e5986 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/miltiply.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/miltiply.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1 * 1, 1 * 1, 1 * 1, 1 * 1) class MyClass -// EXPECTED: Ann(b = IntegerValueType(1), i = IntegerValueType(1), l = IntegerValueType(1), s = IntegerValueType(1)) +// EXPECTED: Ann(b = 1.toByte(), i = 1, l = 1.toLong(), s = 1.toShort()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/minus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/minus.kt index 71fd2ae8bc3..f3e7cb53f57 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/minus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/minus.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1 - 1, 1 - 1, 1 - 1, 1 - 1) class MyClass -// EXPECTED: Ann(b = IntegerValueType(0), i = IntegerValueType(0), l = IntegerValueType(0), s = IntegerValueType(0)) +// EXPECTED: Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/mod.kt b/compiler/testData/resolveAnnotations/parameters/expressions/mod.kt index 1df17b2e9f1..0754ffe3dc1 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/mod.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/mod.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1 % 1, 1 % 1, 1 % 1, 1 % 1) class MyClass -// EXPECTED: Ann(b = IntegerValueType(0), i = IntegerValueType(0), l = IntegerValueType(0), s = IntegerValueType(0)) +// EXPECTED: Ann(b = 0.toByte(), i = 0, l = 0.toLong(), s = 0.toShort()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/paranthesized.kt b/compiler/testData/resolveAnnotations/parameters/expressions/paranthesized.kt index bc997c607cb..42bd629f2db 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/paranthesized.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/paranthesized.kt @@ -4,4 +4,4 @@ annotation class Ann(i: Int) Ann((1 + 2) * 2) class MyClass -// EXPECTED: Ann(i = IntegerValueType(6)) +// EXPECTED: Ann(i = 6) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/plus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/plus.kt index 9c8042b543a..36d84f9b39d 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/plus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/plus.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1 + 1, 1 + 1, 1 + 1, 1 + 1) class MyClass -// EXPECTED: Ann(b = IntegerValueType(2), i = IntegerValueType(2), l = IntegerValueType(2), s = IntegerValueType(2)) +// EXPECTED: Ann(b = 2.toByte(), i = 2, l = 2.toLong(), s = 2.toShort()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/simpleCallBinary.kt b/compiler/testData/resolveAnnotations/parameters/expressions/simpleCallBinary.kt index ccd45c47ed1..5e474748142 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/simpleCallBinary.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/simpleCallBinary.kt @@ -10,4 +10,4 @@ annotation class Ann( Ann(1.plus(1), 1.minus(1), 1.times(1), 1.div(1), 1.mod(1)) class MyClass -// EXPECTED: Ann(p1 = IntegerValueType(2), p2 = IntegerValueType(0), p3 = IntegerValueType(1), p4 = IntegerValueType(1), p5 = IntegerValueType(0)) +// EXPECTED: Ann(p1 = 2, p2 = 0, p3 = 1, p4 = 1, p5 = 0) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt index d2203adca7b..f7f7c911aac 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/unaryMinus.kt @@ -11,4 +11,4 @@ annotation class Ann( Ann(-1, -1, -1, -1, -1.0, -1.0.toFloat()) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(-1), b2 = IntegerValueType(-1), b3 = IntegerValueType(-1), b4 = IntegerValueType(-1), b5 = -1.0.toDouble(), b6 = -1.0.toFloat()) +// EXPECTED: Ann(b1 = -1.toByte(), b2 = -1.toShort(), b3 = -1, b4 = -1.toLong(), b5 = -1.0.toDouble(), b6 = -1.0.toFloat()) diff --git a/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt b/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt index 5d519646817..8d9a91b50af 100644 --- a/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt +++ b/compiler/testData/resolveAnnotations/parameters/expressions/unaryPlus.kt @@ -11,4 +11,4 @@ annotation class Ann( Ann(+1, +1, +1, +1, +1.0, +1.0.toFloat()) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = IntegerValueType(1), b3 = IntegerValueType(1), b4 = IntegerValueType(1), b5 = 1.0.toDouble(), b6 = 1.0.toFloat()) +// EXPECTED: Ann(b1 = 1.toByte(), b2 = 1.toShort(), b3 = 1, b4 = 1.toLong(), b5 = 1.0.toDouble(), b6 = 1.0.toFloat()) diff --git a/compiler/testData/resolveAnnotations/parameters/int.kt b/compiler/testData/resolveAnnotations/parameters/int.kt index f66cf48ab35..f02f77b3c02 100644 --- a/compiler/testData/resolveAnnotations/parameters/int.kt +++ b/compiler/testData/resolveAnnotations/parameters/int.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1, 1.toInt(), 2147483648.toInt(), 2147483648) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1, b3 = -2147483648, b4 = IntegerValueType(2147483648)) \ No newline at end of file +// EXPECTED: Ann(b1 = 1, b2 = 1, b3 = -2147483648, b4 = 2147483648.toLong()) \ No newline at end of file diff --git a/compiler/testData/resolveAnnotations/parameters/long.kt b/compiler/testData/resolveAnnotations/parameters/long.kt index a5e737289e6..06c689d50ef 100644 --- a/compiler/testData/resolveAnnotations/parameters/long.kt +++ b/compiler/testData/resolveAnnotations/parameters/long.kt @@ -7,4 +7,4 @@ annotation class Ann( Ann(1, 1.toLong()) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toLong()) \ No newline at end of file +// EXPECTED: Ann(b1 = 1.toLong(), b2 = 1.toLong()) \ No newline at end of file diff --git a/compiler/testData/resolveAnnotations/parameters/short.kt b/compiler/testData/resolveAnnotations/parameters/short.kt index bdd892a457a..9192a5bbcb2 100644 --- a/compiler/testData/resolveAnnotations/parameters/short.kt +++ b/compiler/testData/resolveAnnotations/parameters/short.kt @@ -9,4 +9,4 @@ annotation class Ann( Ann(1, 1.toShort(), 32768.toShort(), 32768) class MyClass -// EXPECTED: Ann(b1 = IntegerValueType(1), b2 = 1.toShort(), b3 = -32768.toShort(), b4 = IntegerValueType(32768)) \ No newline at end of file +// EXPECTED: Ann(b1 = 1.toShort(), b2 = 1.toShort(), b3 = -32768.toShort(), b4 = 32768) \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java index b982e1a93e2..77b4dc3a3f9 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ExpectedLoadErrorsUtil.java @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.load.java.JavaBindingContext; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.renderer.DescriptorRenderer; import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.scopes.JetScope; import java.util.*; @@ -84,7 +84,7 @@ public class ExpectedLoadErrorsUtil { if (annotation == null) return null; // we expect exactly one annotation argument - CompileTimeConstant argument = annotation.getAllValueArguments().values().iterator().next(); + ConstantValue argument = annotation.getAllValueArguments().values().iterator().next(); String error = (String) argument.getValue(); //noinspection ConstantConditions diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationDescriptorResolveTest.java b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationDescriptorResolveTest.java index 5cef40c425d..58202a730fe 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationDescriptorResolveTest.java +++ b/compiler/tests/org/jetbrains/kotlin/resolve/annotation/AnnotationDescriptorResolveTest.java @@ -21,7 +21,7 @@ import java.io.IOException; public class AnnotationDescriptorResolveTest extends AbstractAnnotationDescriptorResolveTest { public void testIntAnnotation() throws IOException { String content = getContent("AnnInt(1)"); - String expectedAnnotation = "AnnInt(a = IntegerValueType(1))"; + String expectedAnnotation = "AnnInt(a = 1)"; doTest(content, expectedAnnotation); } @@ -51,13 +51,13 @@ public class AnnotationDescriptorResolveTest extends AbstractAnnotationDescripto public void testIntArrayAnnotation() throws IOException { String content = getContent("AnnIntArray(intArray(1, 2))"); - String expectedAnnotation = "AnnIntArray(a = {IntegerValueType(1), IntegerValueType(2)})"; + String expectedAnnotation = "AnnIntArray(a = {1, 2})"; doTest(content, expectedAnnotation); } public void testIntArrayVarargAnnotation() throws IOException { String content = getContent("AnnIntVararg(1, 2)"); - String expectedAnnotation = "AnnIntVararg(a = {IntegerValueType(1), IntegerValueType(2)})"; + String expectedAnnotation = "AnnIntVararg(a = {1, 2})"; doTest(content, expectedAnnotation); } @@ -81,7 +81,7 @@ public class AnnotationDescriptorResolveTest extends AbstractAnnotationDescripto public void testAnnotationAnnotation() throws Exception { String content = getContent("AnnAnn(AnnInt(1))"); - String expectedAnnotation = "AnnAnn(a = AnnInt(a = IntegerValueType(1)))"; + String expectedAnnotation = "AnnAnn(a = AnnInt(a = 1))"; doTest(content, expectedAnnotation); } diff --git a/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt b/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt index 21b3da3518c..7f53fbfad86 100644 --- a/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/resolve/constants/evaluate/AbstractEvaluateExpressionTest.kt @@ -18,9 +18,12 @@ package org.jetbrains.kotlin.resolve.constants.evaluate import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.descriptors.VariableDescriptor +import org.jetbrains.kotlin.psi.JetProperty import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.DelegatingBindingTrace +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.annotation.AbstractAnnotationDescriptorResolveTest -import org.jetbrains.kotlin.resolve.constants.IntegerValueConstant +import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.test.InTextDirectivesUtils import org.jetbrains.kotlin.test.JetTestUtils @@ -47,12 +50,7 @@ public abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescrip fun doIsPureTest(path: String) { doTest(path) { property, context -> - val compileTimeConstant = property.getCompileTimeInitializer() - if (compileTimeConstant is IntegerValueConstant) { - compileTimeConstant.isPure().toString() - } else { - "null" - } + evaluateInitializer(context, property)?.isPure.toString() } } @@ -60,15 +58,20 @@ public abstract class AbstractEvaluateExpressionTest : AbstractAnnotationDescrip fun doUsesVariableAsConstantTest(path: String) { doTest(path) { property, context -> - val compileTimeConstant = property.getCompileTimeInitializer() - if (compileTimeConstant == null) { - "null" - } else { - compileTimeConstant.usesVariableAsConstant().toString() - } + evaluateInitializer(context, property)?.usesVariableAsConstant.toString() } } + private fun evaluateInitializer(context: BindingContext, property: VariableDescriptor): CompileTimeConstant<*>? { + val propertyDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(property) as JetProperty + val compileTimeConstant = ConstantExpressionEvaluator.evaluate( + propertyDeclaration.getInitializer()!!, + DelegatingBindingTrace(context, "trace for evaluating compile time constant"), + property.getType() + ) + return compileTimeConstant + } + private fun doTest(path: String, getValueToTest: (VariableDescriptor, BindingContext) -> String) { val myFile = File(path) val fileText = FileUtil.loadFile(myFile, true) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index e1f54ca3f05..7be9187d8cb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -30,7 +30,8 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.renderer.DescriptorRenderer -import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.resolve.constants.ConstantValue +import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES import org.jetbrains.kotlin.types.* @@ -64,7 +65,7 @@ class LazyJavaAnnotationDescriptor( annotationClass?.getDefaultType() ?: ErrorUtils.createErrorType(fqName.asString()) } - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.Impl(true, false, false), c.module.builtIns) + private val factory = ConstantValueFactory(c.module.builtIns) override fun getType(): JetType = type() @@ -74,7 +75,7 @@ class LazyJavaAnnotationDescriptor( override fun getAllValueArguments() = allValueArguments() - private fun computeValueArguments(): Map> { + private fun computeValueArguments(): Map> { val constructors = getAnnotationClass().getConstructors() if (constructors.isEmpty()) return mapOf() @@ -100,9 +101,9 @@ class LazyJavaAnnotationDescriptor( private fun getAnnotationClass() = getType().getConstructor().getDeclarationDescriptor() as ClassDescriptor - private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): CompileTimeConstant<*>? { + private fun resolveAnnotationArgument(argument: JavaAnnotationArgument?): ConstantValue<*>? { return when (argument) { - is JavaLiteralAnnotationArgument -> factory.createCompileTimeConstant(argument.value) + is JavaLiteralAnnotationArgument -> factory.createConstantValue(argument.value) is JavaEnumValueAnnotationArgument -> resolveFromEnumValue(argument.resolve()) is JavaArrayAnnotationArgument -> resolveFromArray(argument.name ?: DEFAULT_ANNOTATION_MEMBER_NAME, argument.getElements()) is JavaAnnotationAsAnnotationArgument -> resolveFromAnnotation(argument.getAnnotation()) @@ -111,13 +112,13 @@ class LazyJavaAnnotationDescriptor( } } - private fun resolveFromAnnotation(javaAnnotation: JavaAnnotation): CompileTimeConstant<*>? { + private fun resolveFromAnnotation(javaAnnotation: JavaAnnotation): ConstantValue<*>? { val descriptor = c.resolveAnnotation(javaAnnotation) ?: return null return factory.createAnnotationValue(descriptor) } - private fun resolveFromArray(argumentName: Name, elements: List): CompileTimeConstant<*>? { + private fun resolveFromArray(argumentName: Name, elements: List): ConstantValue<*>? { if (getType().isError()) return null val valueParameter = DescriptorResolverUtils.getAnnotationParameterByName(argumentName, getAnnotationClass()) ?: return null @@ -128,7 +129,7 @@ class LazyJavaAnnotationDescriptor( return factory.createArrayValue(values, valueParameter.getType()) } - private fun resolveFromEnumValue(element: JavaField?): CompileTimeConstant<*>? { + private fun resolveFromEnumValue(element: JavaField?): ConstantValue<*>? { if (element == null || !element.isEnumEntry()) return null val containingJavaClass = element.getContainingClass() @@ -142,7 +143,7 @@ class LazyJavaAnnotationDescriptor( return factory.createEnumValue(classifier) } - private fun resolveFromJavaClassObjectType(javaType: JavaType): CompileTimeConstant<*>? { + private fun resolveFromJavaClassObjectType(javaType: JavaType): ConstantValue<*>? { // Class type is never nullable in 'Foo.class' in Java val type = TypeUtils.makeNotNullable(c.typeResolver.transformJavaType( javaType, diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 8dab34fbd9c..a14dcc2e89c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -181,7 +181,7 @@ class LazyJavaClassDescriptor( getAnnotations(). findAnnotation(JvmAnnotationNames.PURELY_IMPLEMENTS_ANNOTATION) ?: return null - val fqNameString = (annotation.getAllValueArguments().values().singleOrNull() as? StringValue)?.getValue() ?: return null + val fqNameString = (annotation.getAllValueArguments().values().singleOrNull() as? StringValue)?.value ?: return null if (!isValidJavaFqName(fqNameString)) return null return FqName(fqNameString) diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.java deleted file mode 100644 index 712bcb5c2a4..00000000000 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.load.java.structure; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.PropertyDescriptor; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; - -public interface JavaPropertyInitializerEvaluator { - JavaPropertyInitializerEvaluator DO_NOTHING = new JavaPropertyInitializerEvaluator() { - @Nullable - @Override - public CompileTimeConstant getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor) { - return null; - } - - @Override - public boolean isNotNullCompileTimeConstant(@NotNull JavaField field) { - return false; - } - }; - - @Nullable - CompileTimeConstant getInitializerConstant(@NotNull JavaField field, @NotNull PropertyDescriptor descriptor); - - boolean isNotNullCompileTimeConstant(@NotNull JavaField field); -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt new file mode 100644 index 00000000000..44f2be2af9d --- /dev/null +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/structure/JavaPropertyInitializerEvaluator.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.load.java.structure + +import org.jetbrains.kotlin.descriptors.PropertyDescriptor +import org.jetbrains.kotlin.resolve.constants.ConstantValue + +public interface JavaPropertyInitializerEvaluator { + public fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor): ConstantValue<*>? + + public fun isNotNullCompileTimeConstant(field: JavaField): Boolean + + public object DoNothing : JavaPropertyInitializerEvaluator { + override fun getInitializerConstant(field: JavaField, descriptor: PropertyDescriptor) = null + + override fun isNotNullCompileTimeConstant(field: JavaField) = false + } +} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt index e856d4291d0..a867de852c4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/BinaryClassAnnotationAndConstantLoaderImpl.kt @@ -26,7 +26,9 @@ import org.jetbrains.kotlin.load.java.components.DescriptorResolverUtils import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass.AnnotationArrayArgumentVisitor import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.resolve.constants.AnnotationValue +import org.jetbrains.kotlin.resolve.constants.ConstantValue +import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.AnnotationDeserializer import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter @@ -42,16 +44,16 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( storageManager: StorageManager, kotlinClassFinder: KotlinClassFinder, errorReporter: ErrorReporter -) : AbstractBinaryClassAnnotationAndConstantLoader>( +) : AbstractBinaryClassAnnotationAndConstantLoader>( storageManager, kotlinClassFinder, errorReporter ) { private val annotationDeserializer = AnnotationDeserializer(module) - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, module.builtIns) + private val factory = ConstantValueFactory(module.builtIns) override fun loadTypeAnnotation(proto: ProtoBuf.Annotation, nameResolver: NameResolver): AnnotationDescriptor = annotationDeserializer.deserializeAnnotation(proto, nameResolver) - override fun loadConstant(desc: String, initializer: Any): CompileTimeConstant<*>? { + override fun loadConstant(desc: String, initializer: Any): ConstantValue<*>? { val normalizedValue: Any = if (desc in "ZBCS") { val intValue = initializer as Int when (desc) { @@ -66,7 +68,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( initializer } - return factory.createCompileTimeConstant(normalizedValue) + return factory.createConstantValue(normalizedValue) } override fun loadAnnotation( @@ -76,7 +78,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( val annotationClass = resolveClass(annotationClassId) return object : KotlinJvmBinaryClass.AnnotationArgumentVisitor { - private val arguments = HashMap>() + private val arguments = HashMap>() override fun visit(name: Name?, value: Any?) { if (name != null) { @@ -90,7 +92,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( override fun visitArray(name: Name): AnnotationArrayArgumentVisitor? { return object : KotlinJvmBinaryClass.AnnotationArrayArgumentVisitor { - private val elements = ArrayList>() + private val elements = ArrayList>() override fun visit(value: Any?) { elements.add(createConstant(name, value)) @@ -122,7 +124,7 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( } // NOTE: see analogous code in AnnotationDeserializer - private fun enumEntryValue(enumClassId: ClassId, name: Name): CompileTimeConstant<*> { + private fun enumEntryValue(enumClassId: ClassId, name: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val classifier = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(name) @@ -137,12 +139,12 @@ public class BinaryClassAnnotationAndConstantLoaderImpl( result.add(AnnotationDescriptorImpl(annotationClass.getDefaultType(), arguments)) } - private fun createConstant(name: Name?, value: Any?): CompileTimeConstant<*> { - return factory.createCompileTimeConstant(value) ?: + private fun createConstant(name: Name?, value: Any?): ConstantValue<*> { + return factory.createConstantValue(value) ?: factory.createErrorValue("Unsupported annotation argument: $name") } - private fun setArgumentValueByName(name: Name, argumentValue: CompileTimeConstant<*>) { + private fun setArgumentValueByName(name: Name, argumentValue: ConstantValue<*>) { val parameter = DescriptorResolverUtils.getAnnotationParameterByName(name, annotationClass) if (parameter != null) { arguments[parameter] = argumentValue diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt index b581f3b1c5c..49bbc961aaf 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/kotlin/reflect/RuntimeModuleData.kt @@ -50,7 +50,7 @@ public class RuntimeModuleData private constructor(public val module: ModuleDesc val globalJavaResolverContext = GlobalJavaResolverContext( storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver, ExternalAnnotationResolver.EMPTY, ExternalSignatureResolver.DO_NOTHING, RuntimeErrorReporter, JavaResolverCache.EMPTY, - JavaPropertyInitializerEvaluator.DO_NOTHING, SamConversionResolver, RuntimeSourceElementFactory, singleModuleClassResolver + JavaPropertyInitializerEvaluator.DoNothing, SamConversionResolver, RuntimeSourceElementFactory, singleModuleClassResolver ) val lazyJavaPackageFragmentProvider = LazyJavaPackageFragmentProvider(globalJavaResolverContext, module, ReflectionTypes(module)) val javaDescriptorResolver = JavaDescriptorResolver(lazyJavaPackageFragmentProvider, module) diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt index 25a8f685cd1..dbf23ac2dc0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltInsAnnotationAndConstantLoader.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.builtins import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.types.JetType class BuiltInsAnnotationAndConstantLoader( module: ModuleDescriptor -) : AnnotationAndConstantLoader> { +) : AnnotationAndConstantLoader> { private val deserializer = AnnotationDeserializer(module) override fun loadClassAnnotations( @@ -68,7 +68,7 @@ class BuiltInsAnnotationAndConstantLoader( proto: ProtoBuf.Callable, nameResolver: NameResolver, expectedType: JetType - ): CompileTimeConstant<*>? { + ): ConstantValue<*>? { val value = proto.getExtension(BuiltInsProtoBuf.compileTimeValue) return deserializer.resolveValue(expectedType, value, nameResolver) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 42e178b124f..5b519332cdd 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.storage.LockBasedStorageManager; import org.jetbrains.kotlin.types.*; @@ -659,7 +659,7 @@ public class KotlinBuiltIns { @NotNull public AnnotationDescriptor createExtensionAnnotation() { return new AnnotationDescriptorImpl(getBuiltInClassByName("extension").getDefaultType(), - Collections.>emptyMap()); + Collections.>emptyMap()); } private static boolean isTypeAnnotatedWithExtension(@NotNull JetType type) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java index cfe8ebb6056..0cc1b7c6080 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/VariableDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeSubstitutor; @@ -36,5 +36,5 @@ public interface VariableDescriptor extends CallableDescriptor { boolean isVar(); @Nullable - CompileTimeConstant getCompileTimeInitializer(); + ConstantValue getCompileTimeInitializer(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationArgumentVisitor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationArgumentVisitor.java index 80e4162a899..b8038c25956 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationArgumentVisitor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationArgumentVisitor.java @@ -50,6 +50,4 @@ public interface AnnotationArgumentVisitor { R visitAnnotationValue(AnnotationValue value, D data); R visitKClassValue(KClassValue value, D data); - - R visitNumberTypeValue(IntegerValueTypeConstant value, D data); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java index 90332148026..f0a8e72179d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptor.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors.annotations; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.types.JetType; import java.util.Map; @@ -30,5 +30,5 @@ public interface AnnotationDescriptor { @NotNull @ReadOnly - Map> getAllValueArguments(); + Map> getAllValueArguments(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java index 44479d70dcd..aca2732e1d6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationDescriptorImpl.java @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.descriptors.annotations; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; import org.jetbrains.kotlin.renderer.DescriptorRenderer; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.types.JetType; import java.util.Collections; @@ -27,11 +27,11 @@ import java.util.Map; public class AnnotationDescriptorImpl implements AnnotationDescriptor { private final JetType annotationType; - private final Map> valueArguments; + private final Map> valueArguments; public AnnotationDescriptorImpl( @NotNull JetType annotationType, - @NotNull Map> valueArguments + @NotNull Map> valueArguments ) { this.annotationType = annotationType; this.valueArguments = Collections.unmodifiableMap(valueArguments); @@ -45,7 +45,7 @@ public class AnnotationDescriptorImpl implements AnnotationDescriptor { @Override @NotNull - public Map> getAllValueArguments() { + public Map> getAllValueArguments() { return valueArguments; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/DefaultAnnotationArgumentVisitor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/DefaultAnnotationArgumentVisitor.java index 96cbcb6da63..b9322932867 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/DefaultAnnotationArgumentVisitor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/DefaultAnnotationArgumentVisitor.java @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.resolve.constants.*; import org.jetbrains.kotlin.resolve.constants.StringValue; public abstract class DefaultAnnotationArgumentVisitor implements AnnotationArgumentVisitor { - public abstract R visitValue(@NotNull CompileTimeConstant value, D data); + public abstract R visitValue(@NotNull ConstantValue value, D data); @Override public R visitLongValue(@NotNull LongValue value, D data) { @@ -92,9 +92,4 @@ public abstract class DefaultAnnotationArgumentVisitor implements Annotati public R visitAnnotationValue(AnnotationValue value, D data) { return visitValue(value, data); } - - @Override - public R visitNumberTypeValue(IntegerValueTypeConstant value, D data) { - return visitValue(value, data); - } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java index b5ff6c55c58..45fc6153c27 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/VariableDescriptorImpl.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.storage.NullableLazyValue; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.LazyType; @@ -32,7 +32,7 @@ import java.util.Set; public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRootImpl implements VariableDescriptor { private JetType outType; - protected NullableLazyValue> compileTimeInitializer; + protected NullableLazyValue> compileTimeInitializer; public VariableDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @@ -59,7 +59,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo @Nullable @Override - public CompileTimeConstant getCompileTimeInitializer() { + public ConstantValue getCompileTimeInitializer() { // Force computation and setting of compileTimeInitializer, if needed if (compileTimeInitializer == null && outType instanceof LazyType) { outType.getConstructor(); @@ -71,7 +71,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo return null; } - public void setCompileTimeInitializer(@NotNull NullableLazyValue> compileTimeInitializer) { + public void setCompileTimeInitializer(@NotNull NullableLazyValue> compileTimeInitializer) { assert !isVar() : "Compile-time value for property initializer should be recorded only for final variables " + getName(); this.compileTimeInitializer = compileTimeInitializer; } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 24970e499a8..9179d91944b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -20,23 +20,20 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.descriptors.annotations.DefaultAnnotationArgumentVisitor -import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameBase -import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject +import org.jetbrains.kotlin.resolve.constants.AnnotationValue +import org.jetbrains.kotlin.resolve.constants.ArrayValue +import org.jetbrains.kotlin.resolve.constants.ConstantValue +import org.jetbrains.kotlin.resolve.constants.KClassValue import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.ErrorUtils.UninferredParameterTypeConstructor -import org.jetbrains.kotlin.types.error.MissingDependencyErrorClass -import org.jetbrains.kotlin.utils.* - -import java.util.* - -import org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject import org.jetbrains.kotlin.types.TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE +import org.jetbrains.kotlin.types.error.MissingDependencyErrorClass +import java.util.ArrayList internal class DescriptorRendererImpl( val options: DescriptorRendererOptionsImpl @@ -384,7 +381,7 @@ internal class DescriptorRendererImpl( return (defaultList + argumentList).sort() } - private fun renderConstant(value: CompileTimeConstant<*>): String { + private fun renderConstant(value: ConstantValue<*>): String { return when (value) { is ArrayValue -> value.value.map { renderConstant(it) }.joinToString(", ", "{", "}") is AnnotationValue -> renderAnnotation(value.value) @@ -709,9 +706,8 @@ internal class DescriptorRendererImpl( private fun renderInitializer(variable: VariableDescriptor, builder: StringBuilder) { if (includePropertyConstant) { - val initializer = variable.getCompileTimeInitializer() - if (initializer != null) { - builder.append(" = ").append(escape(renderConstant(initializer))) + variable.getCompileTimeInitializer()?.let { constant -> + builder.append(" = ").append(escape(renderConstant(constant))) } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt index 8ea1dc4dc19..793ae285248 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/AnnotationValue.kt @@ -16,13 +16,11 @@ package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.types.JetType -public class AnnotationValue(value: AnnotationDescriptor) : - CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { +public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue(value) { override val type: JetType get() = value.getType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt index 8c95657718b..6a69ae3e742 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ArrayValue.kt @@ -19,23 +19,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType -import java.util.* public class ArrayValue( - value: List>, - override val type: JetType, - parameters: CompileTimeConstant.Parameters -) : CompileTimeConstant>>(value, parameters) { - - public constructor( - value: List>, - type: JetType, - usesVariableAsConstant: Boolean - ) : this(value, type, CompileTimeConstant.Parameters.Impl(true, false, usesVariableAsConstant)) - - override fun canBeUsedInAnnotations() = true - override fun isPure() = false - + value: List>, + override val type: JetType +) : ConstantValue>>(value) { init { assert(KotlinBuiltIns.isArray(type) || KotlinBuiltIns.isPrimitiveArray(type)) { "Type should be an array, but was " + type + ": " + value } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt index 44dd0386c75..1b97566bb30 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/BooleanValue.kt @@ -18,15 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class BooleanValue( value: Boolean, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : CompileTimeConstant(value, parameters) { - override fun isPure(): Boolean = false - +) : ConstantValue(value) { override val type = builtIns.getBooleanType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitBooleanValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt index 2b230fbc5fa..45017963172 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ByteValue.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class ByteValue( value: Byte, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : IntegerValueConstant(value, parameters) { +) : IntegerValueConstant(value) { override val type = builtIns.getByteType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt index a14dd4ac4ab..58f52a4ebe8 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CharValue.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class CharValue( value: Char, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : IntegerValueConstant(value, parameters) { +) : IntegerValueConstant(value) { override val type = builtIns.getCharType() @@ -37,7 +35,7 @@ public class CharValue( '\b' -> return "\\b" '\t' -> return "\\t" '\n' -> return "\\n" - //TODO_R: can't escape form feed in Kotlin + //TODO: KT-8507 12.toChar() -> return "\\f" '\r' -> return "\\r" else -> return if (isPrintableUnicode(c)) Character.toString(c) else "?" diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index cb76122cdfd..7769ae1ab53 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -17,43 +17,84 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.types.* -public abstract class CompileTimeConstant protected constructor( - public open val value: T, - public val parameters: CompileTimeConstant.Parameters -) { - public open fun canBeUsedInAnnotations(): Boolean = parameters.canBeUsedInAnnotation +public interface CompileTimeConstant { + public val isError: Boolean + get() = false - public open fun isPure(): Boolean = parameters.isPure + public val parameters: CompileTimeConstant.Parameters - public open fun usesVariableAsConstant(): Boolean = parameters.usesVariableAsConstant + public fun toConstantValue(expectedType: JetType): ConstantValue - public abstract val type: JetType + public fun getValue(expectedType: JetType): T = toConstantValue(expectedType).value - public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R + public val canBeUsedInAnnotations: Boolean get() = parameters.canBeUsedInAnnotation - override fun toString() = value.toString() + public val usesVariableAsConstant: Boolean get() = parameters.usesVariableAsConstant - public interface Parameters { - public open val canBeUsedInAnnotation: Boolean - public open val isPure: Boolean - public open val usesVariableAsConstant: Boolean + public val isPure: Boolean get() = parameters.isPure - public class Impl( - override val canBeUsedInAnnotation: Boolean, - override val isPure: Boolean, - override val usesVariableAsConstant: Boolean - ) : Parameters + public class Parameters( + public val canBeUsedInAnnotation: Boolean, + public val isPure: Boolean, + public val usesVariableAsConstant: Boolean + ) +} - public object ThrowException : Parameters { - override val canBeUsedInAnnotation: Boolean - get() = error("Should not be called") - override val isPure: Boolean - get() = error("Should not be called") - override val usesVariableAsConstant: Boolean - get() = error("Should not be called") +public class TypedCompileTimeConstant( + public val constantValue: ConstantValue, + override val parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant { + override val isError: Boolean + get() = constantValue is ErrorValue + + public val type: JetType = constantValue.type + + override fun toConstantValue(expectedType: JetType): ConstantValue = constantValue +} + +public fun ConstantValue.wrap(parameters: CompileTimeConstant.Parameters): TypedCompileTimeConstant + = TypedCompileTimeConstant(this, parameters) + +public fun ConstantValue.wrap( + canBeUsedInAnnotation: Boolean = this !is NullValue, + isPure: Boolean = false, + usesVariableAsConstant: Boolean = false +): TypedCompileTimeConstant + = wrap(CompileTimeConstant.Parameters(canBeUsedInAnnotation, isPure, usesVariableAsConstant)) + +public class IntegerValueTypeConstant( + private val value: Number, + override val parameters: CompileTimeConstant.Parameters +) : CompileTimeConstant { + private val typeConstructor = IntegerValueTypeConstructor(value.toLong()) + + override fun toConstantValue(expectedType: JetType): ConstantValue { + val factory = ConstantValueFactory(KotlinBuiltIns.getInstance()) + return when (getType(expectedType)) { + KotlinBuiltIns.getInstance().getIntType() -> { + factory.createIntValue(value.toInt()) + } + KotlinBuiltIns.getInstance().getByteType() -> { + factory.createByteValue(value.toByte()) + } + KotlinBuiltIns.getInstance().getShortType() -> { + factory.createShortValue(value.toShort()) + } + else -> { + factory.createLongValue(value.toLong()) + } } } -} \ No newline at end of file + + val unknownIntegerType = JetTypeImpl( + Annotations.EMPTY, typeConstructor, false, emptyList(), + ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) + ) + + public fun getType(expectedType: JetType): JetType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) + + override fun toString() = typeConstructor.toString() +} diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt deleted file mode 100644 index 2283ad75233..00000000000 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstantFactory.kt +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.constants - -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeUtils - -public class CompileTimeConstantFactory( - private val parameters: CompileTimeConstant.Parameters, - private val builtins: KotlinBuiltIns -) { - fun createLongValue(value: Long) = LongValue(value, parameters, builtins) - - fun createIntValue(value: Int) = IntValue(value, parameters, builtins) - - fun createErrorValue(message: String) = ErrorValue.create(message) - - fun createShortValue(value: Short) = ShortValue(value, parameters, builtins) - - fun createByteValue(value: Byte) = ByteValue(value, parameters, builtins) - - fun createDoubleValue(value: Double) = DoubleValue(value, parameters, builtins) - - fun createFloatValue(value: Float) = FloatValue(value, parameters, builtins) - - fun createBooleanValue(value: Boolean) = BooleanValue(value, parameters, builtins) - - fun createCharValue(value: Char) = CharValue(value, parameters, builtins) - - fun createStringValue(value: String) = StringValue(value, parameters, builtins) - - fun createNullValue() = NullValue(builtins) - - fun createEnumValue(enumEntryClass: ClassDescriptor): EnumValue = EnumValue(enumEntryClass) - - fun createArrayValue( - value: List>, - type: JetType - ) = ArrayValue(value, type, parameters) - - fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value) - - fun createKClassValue(type: JetType) = KClassValue(type) - - fun createNumberTypeValue(value: Number) = IntegerValueTypeConstant(value, parameters) - - - fun createCompileTimeConstant( - value: Any?, - expectedType: JetType? = null - ): CompileTimeConstant<*>? { - // TODO: primitive arrays - if (expectedType == null) { - when (value) { - is Byte -> return createByteValue(value) - is Short -> return createShortValue(value) - is Int -> return createIntValue(value) - is Long -> return createLongValue(value) - } - } - return when (value) { - is Byte, is Short, is Int, is Long -> getIntegerValue((value as Number).toLong(), expectedType) - is Char -> createCharValue(value) - is Float -> createFloatValue(value) - is Double -> createDoubleValue(value) - is Boolean -> createBooleanValue(value) - is String -> createStringValue(value) - null -> createNullValue() - else -> null - } - } - - private fun getIntegerValue( - value: Long, - expectedType: JetType - ): CompileTimeConstant<*>? { - fun defaultIntegerValue(value: Long) = when (value) { - value.toInt().toLong() -> createIntValue(value.toInt()) - else -> createLongValue(value) - } - - if (TypeUtils.noExpectedType(expectedType) || expectedType.isError()) { - return createNumberTypeValue(value) - } - - val notNullExpected = TypeUtils.makeNotNullable(expectedType) - return when { - KotlinBuiltIns.isLong(notNullExpected) -> createLongValue(value) - - KotlinBuiltIns.isShort(notNullExpected) -> - if (value == value.toShort().toLong()) - createShortValue(value.toShort()) - else - defaultIntegerValue(value) - - KotlinBuiltIns.isByte(notNullExpected) -> - if (value == value.toByte().toLong()) - createByteValue(value.toByte()) - else - defaultIntegerValue(value) - - KotlinBuiltIns.isChar(notNullExpected) -> - createIntValue(value.toInt()) - - else -> defaultIntegerValue(value) - } - } -} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValue.kt new file mode 100644 index 00000000000..fe9a61cfc6b --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValue.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.constants + +import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor +import org.jetbrains.kotlin.types.JetType + +public abstract class ConstantValue(public open val value: T) { + public abstract val type: JetType + + public abstract fun accept(visitor: AnnotationArgumentVisitor, data: D): R + + override fun toString() = value.toString() + +} \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt new file mode 100644 index 00000000000..fddef729080 --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt @@ -0,0 +1,95 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.constants + +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeUtils + +public class ConstantValueFactory( + private val builtins: KotlinBuiltIns +) { + fun createLongValue(value: Long) = LongValue(value, builtins) + + fun createIntValue(value: Int) = IntValue(value, builtins) + + fun createErrorValue(message: String) = ErrorValue.create(message) + + fun createShortValue(value: Short) = ShortValue(value, builtins) + + fun createByteValue(value: Byte) = ByteValue(value, builtins) + + fun createDoubleValue(value: Double) = DoubleValue(value, builtins) + + fun createFloatValue(value: Float) = FloatValue(value, builtins) + + fun createBooleanValue(value: Boolean) = BooleanValue(value, builtins) + + fun createCharValue(value: Char) = CharValue(value, builtins) + + fun createStringValue(value: String) = StringValue(value, builtins) + + fun createNullValue() = NullValue(builtins) + + fun createEnumValue(enumEntryClass: ClassDescriptor): EnumValue = EnumValue(enumEntryClass) + + fun createArrayValue( + value: List>, + type: JetType + ) = ArrayValue(value, type) + + fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value) + + fun createKClassValue(type: JetType) = KClassValue(type) + + fun createConstantValue( + value: Any? + ): ConstantValue<*>? { + // TODO: primitive arrays + return when (value) { + is Byte -> createByteValue(value) + is Short -> createShortValue(value) + is Int -> createIntValue(value) + is Long -> createLongValue(value) + is Char -> createCharValue(value) + is Float -> createFloatValue(value) + is Double -> createDoubleValue(value) + is Boolean -> createBooleanValue(value) + is String -> createStringValue(value) + null -> createNullValue() + else -> null + } + } + + public fun createIntegerConstantValue( + value: Long, + expectedType: JetType + ): ConstantValue<*>? { + val notNullExpected = TypeUtils.makeNotNullable(expectedType) + return when { + KotlinBuiltIns.isLong(notNullExpected) -> createLongValue(value) + KotlinBuiltIns.isInt(notNullExpected) && value == value.toInt().toLong() -> createIntValue(value.toInt()) + KotlinBuiltIns.isShort(notNullExpected) && value == value.toShort().toLong() -> createShortValue(value.toShort()) + KotlinBuiltIns.isByte(notNullExpected) && value == value.toByte().toLong() -> createByteValue(value.toByte()) + KotlinBuiltIns.isChar(notNullExpected) -> createIntValue(value.toInt()) + else -> null + } + } +} + diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt index 1dcb99816bc..60483c806e6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/DoubleValue.kt @@ -18,16 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class DoubleValue( value: Double, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : CompileTimeConstant(value, parameters) { - - override fun isPure() = false - +) : ConstantValue(value) { override val type = builtIns.getDoubleType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitDoubleValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt index 7c7b6197178..c943df89c3e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/EnumValue.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.resolve.descriptorUtil.classObjectType @@ -25,7 +24,7 @@ import org.jetbrains.kotlin.utils.sure public class EnumValue( value: ClassDescriptor -) : CompileTimeConstant(value, CompileTimeConstant.Parameters.Impl(true, false, false)) { +) : ConstantValue(value) { override val type: JetType get() = value.classObjectType.sure { "Enum entry must have a class object type: " + value } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt index 4a0564c6a42..22ec21ffdc5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ErrorValue.kt @@ -16,12 +16,10 @@ package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.types.JetType -public abstract class ErrorValue : CompileTimeConstant(Unit, CompileTimeConstant.Parameters.Impl(true, false, false)) { +public abstract class ErrorValue : ConstantValue(Unit) { deprecated("Should not be called, for this is not a real value, but a indication of an error") override val value: Unit diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt index bb1e069e44c..a8b5e702e73 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/FloatValue.kt @@ -18,15 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class FloatValue( value: Float, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : CompileTimeConstant(value, parameters) { - override fun isPure() = false - +) : ConstantValue(value) { override val type = builtIns.getFloatType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitFloatValue(this, data) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt index 0649089b15d..aea685df995 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntValue.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class IntValue( value: Int, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : IntegerValueConstant(value, parameters) { +) : IntegerValueConstant(value) { override val type = builtIns.getIntType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt index e6501aee9e2..b23941722db 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueConstant.kt @@ -16,7 +16,4 @@ package org.jetbrains.kotlin.resolve.constants -public abstract class IntegerValueConstant protected constructor( - value: T, - parameters: CompileTimeConstant.Parameters -) : CompileTimeConstant(value, parameters) +public abstract class IntegerValueConstant protected constructor(value: T) : ConstantValue(value) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt deleted file mode 100644 index 054b47dc49e..00000000000 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/IntegerValueTypeConstant.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.resolve.constants - -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.types.* - -import java.util.Collections - -public class IntegerValueTypeConstant( - value: Number, - parameters: CompileTimeConstant.Parameters -) : IntegerValueConstant(value, parameters) { - - override fun isPure() = true - - private val typeConstructor = IntegerValueTypeConstructor(value.toLong()) - - override val type = JetTypeImpl( - Annotations.EMPTY, typeConstructor, false, emptyList() - , ErrorUtils.createErrorScope("Scope for number value type (" + typeConstructor.toString() + ")", true) - ) - - deprecated("") - override val value: Number - get() = throw UnsupportedOperationException("Use IntegerValueTypeConstant.getValue(expectedType) instead") - - public fun getType(expectedType: JetType): JetType = TypeUtils.getPrimitiveNumberType(typeConstructor, expectedType) - - public fun getValue(expectedType: JetType): Number { - val numberValue = typeConstructor.getValue() - val builtIns = KotlinBuiltIns.getInstance() - - val valueType = getType(expectedType) - if (valueType == builtIns.getIntType()) { - return numberValue.toInt() - } - else if (valueType == builtIns.getByteType()) { - return numberValue.toByte() - } - else if (valueType == builtIns.getShortType()) { - return numberValue.toShort() - } - else { - return numberValue.toLong() - } - } - - override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitNumberTypeValue(this, data) - - override fun toString() = typeConstructor.toString() -} diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt index a3eedd4e0b8..b31f7491743 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/KClassValue.kt @@ -16,12 +16,11 @@ package org.jetbrains.kotlin.resolve.constants -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.types.JetType public class KClassValue(override val type: JetType) : - CompileTimeConstant(type, CompileTimeConstant.Parameters.Impl(true, false, false)) { + ConstantValue(type) { override val value: JetType get() = type.getArguments().single().getType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt index 24811e33a6e..74eb173a3ce 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/LongValue.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class LongValue( value: Long, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : IntegerValueConstant(value, parameters) { +) : IntegerValueConstant(value) { override val type = builtIns.getLongType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt index 7676cdcdca7..b8f25749dc5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/NullValue.kt @@ -18,11 +18,10 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class NullValue( builtIns: KotlinBuiltIns -) : CompileTimeConstant(null, CompileTimeConstant.Parameters.Impl(false, false, false)) { +) : ConstantValue(null) { override val type = builtIns.getNullableNothingType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt index 45b6c88a745..04f0236d4c3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ShortValue.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class ShortValue( value: Short, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : IntegerValueConstant(value, parameters) { +) : IntegerValueConstant(value) { override val type = builtIns.getShortType() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt index 530e310f9d1..ccda72185ce 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/StringValue.kt @@ -18,15 +18,11 @@ package org.jetbrains.kotlin.resolve.constants import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor -import org.jetbrains.kotlin.types.JetType public class StringValue( value: String, - parameters: CompileTimeConstant.Parameters, builtIns: KotlinBuiltIns -) : CompileTimeConstant(value, parameters) { - override fun isPure() = false - +) : ConstantValue(value) { override val type = builtIns.getStringType() override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitStringValue(this, data) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 3773495ecc1..475a9e34f8b 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -16,22 +16,24 @@ package org.jetbrains.kotlin.serialization.deserialization -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.constants.AnnotationValue +import org.jetbrains.kotlin.resolve.constants.ConstantValue +import org.jetbrains.kotlin.resolve.constants.ConstantValueFactory import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.Type -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.constants.* -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.types.ErrorUtils -import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf @@ -39,7 +41,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { private val builtIns: KotlinBuiltIns get() = module.builtIns - private val factory = CompileTimeConstantFactory(CompileTimeConstant.Parameters.ThrowException, builtIns) + private val factory = ConstantValueFactory(builtIns) public fun deserializeAnnotation(proto: Annotation, nameResolver: NameResolver): AnnotationDescriptor { val annotationClass = resolveClass(nameResolver.getClassId(proto.getId())) @@ -60,7 +62,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { proto: Argument, parameterByName: Map, nameResolver: NameResolver - ): Pair>? { + ): Pair>? { val parameter = parameterByName[nameResolver.getName(proto.getNameId())] ?: return null return Pair(parameter, resolveValue(parameter.getType(), proto.getValue(), nameResolver)) } @@ -69,8 +71,8 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { expectedType: JetType, value: Value, nameResolver: NameResolver - ): CompileTimeConstant<*> { - val result = when (value.getType()) { + ): ConstantValue<*> { + val result: ConstantValue<*> = when (value.getType()) { Type.BYTE -> factory.createByteValue(value.getIntValue().toByte()) Type.CHAR -> factory.createCharValue(value.getIntValue().toChar()) Type.SHORT -> factory.createShortValue(value.getIntValue().toShort()) @@ -131,7 +133,7 @@ public class AnnotationDeserializer(private val module: ModuleDescriptor) { } // NOTE: see analogous code in BinaryClassAnnotationAndConstantLoaderImpl - private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): CompileTimeConstant<*> { + private fun resolveEnumValue(enumClassId: ClassId, enumEntryName: Name): ConstantValue<*> { val enumClass = resolveClass(enumClassId) if (enumClass.getKind() == ClassKind.ENUM_CLASS) { val enumEntry = enumClass.getUnsubstitutedInnerClassesScope().getClassifier(enumEntryName) diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 532075e94b4..694f079c0b2 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -16,14 +16,22 @@ package org.jetbrains.kotlin.serialization.deserialization -import org.jetbrains.kotlin.serialization.* -import org.jetbrains.kotlin.serialization.deserialization.descriptors.* import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.descriptors.impl.* +import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl import org.jetbrains.kotlin.resolve.DescriptorFactory +import org.jetbrains.kotlin.serialization.Flags import org.jetbrains.kotlin.serialization.ProtoBuf.Callable -import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.* +import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.FUN +import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.VAL +import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.VAR +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotations +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor +import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor public class MemberDeserializer(private val c: DeserializationContext) { public fun loadCallable(proto: Callable): CallableMemberDescriptor { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/context.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/context.kt index 002cf06197e..bdd5fdf394d 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/context.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/context.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.serialization.deserialization import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.storage.StorageManager @@ -27,7 +27,7 @@ public class DeserializationComponents( public val storageManager: StorageManager, public val moduleDescriptor: ModuleDescriptor, public val classDataFinder: ClassDataFinder, - public val annotationAndConstantLoader: AnnotationAndConstantLoader>, + public val annotationAndConstantLoader: AnnotationAndConstantLoader>, public val packageFragmentProvider: PackageFragmentProvider, public val localClassResolver: LocalClassResolver, public val flexibleTypeCapabilitiesDeserializer: FlexibleTypeCapabilitiesDeserializer, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt index e5165daf03b..badad22cf71 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/textBuilder/DeserializerForDecompilerBase.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.impl.MutablePackageFragmentDescriptor import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.deserialization.AnnotationAndConstantLoader import org.jetbrains.kotlin.serialization.deserialization.ClassDataFinder import org.jetbrains.kotlin.serialization.deserialization.DeserializationComponents @@ -43,7 +43,7 @@ public abstract class DeserializerForDecompilerBase( protected abstract val classDataFinder: ClassDataFinder - protected abstract val annotationAndConstantLoader: AnnotationAndConstantLoader> + protected abstract val annotationAndConstantLoader: AnnotationAndConstantLoader> protected val storageManager: StorageManager = LockBasedStorageManager.NO_LOCKS diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt index 01afc5eb16e..ca5a53a417a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToStringTemplateIntention.kt @@ -25,7 +25,6 @@ import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator public class ConvertToStringTemplateInspection : IntentionBasedInspection( @@ -90,13 +89,7 @@ public class ConvertToStringTemplateIntention : JetSelfTargetingOffsetIndependen is JetConstantExpression -> { val bindingContext = expression.analyze() val constant = ConstantExpressionEvaluator.getConstant(expression, bindingContext) - if (constant is IntegerValueTypeConstant) { - val type = bindingContext.getType(expression)!! - constant.getValue(type).toString() - } - else { - constant?.value.toString() - } + constant?.getValue(bindingContext.getType(expression)!!).toString() } is JetStringTemplateExpression -> { diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt index de5fabeb1e3..9cb24cfde40 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/JsCallChecker.kt @@ -20,37 +20,28 @@ import com.google.dart.compiler.backend.js.ast.JsFunctionScope import com.google.dart.compiler.backend.js.ast.JsProgram import com.google.dart.compiler.backend.js.ast.JsRootScope import com.google.gwt.dev.js.parserExceptions.AbortParsingException -import com.google.gwt.dev.js.rhino.* -import com.google.gwt.dev.js.rhino.Utils.* -import org.jetbrains.annotations.TestOnly +import com.google.gwt.dev.js.rhino.CodePosition +import com.google.gwt.dev.js.rhino.ErrorReporter +import com.google.gwt.dev.js.rhino.Utils.isEndOfLine +import com.intellij.openapi.util.TextRange import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 -import org.jetbrains.kotlin.diagnostics.DiagnosticSink -import org.jetbrains.kotlin.diagnostics.ParametrizedDiagnostic +import org.jetbrains.kotlin.js.parser.parse import org.jetbrains.kotlin.js.patterns.DescriptorPredicate import org.jetbrains.kotlin.js.patterns.PatternBuilder -import org.jetbrains.kotlin.js.resolve.diagnostics.ErrorsJs import org.jetbrains.kotlin.psi.JetCallExpression import org.jetbrains.kotlin.psi.JetExpression import org.jetbrains.kotlin.psi.JetLiteralStringTemplateEntry import org.jetbrains.kotlin.psi.JetStringTemplateExpression -import org.jetbrains.kotlin.renderer.Renderer -import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.TemporaryBindingTrace import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator -import org.jetbrains.kotlin.types.JetType - -import com.intellij.openapi.util.TextRange -import org.jetbrains.kotlin.js.parser.parse -import java.io.StringReader - import kotlin.platform.platformStatic -import org.jetbrains.kotlin.resolve.TemporaryBindingTrace public class JsCallChecker : CallChecker { @@ -84,7 +75,7 @@ public class JsCallChecker : CallChecker { return } - val code = evaluationResult.value as String + val code = evaluationResult.getValue(stringType) as String val errorReporter = JsCodeErrorReporter(argument, code, context.trace) try { diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java index ac87a14892d..88217baddd6 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.js.PredefinedAnnotation; import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import java.util.List; import java.util.Set; @@ -53,7 +53,7 @@ public final class AnnotationsUtils { if (annotationDescriptor.getAllValueArguments().isEmpty()) { return null; } - CompileTimeConstant constant = annotationDescriptor.getAllValueArguments().values().iterator().next(); + ConstantValue constant = annotationDescriptor.getAllValueArguments().values().iterator().next(); //TODO: this is a quick fix for unsupported default args problem if (constant == null) { return null; diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt index 33e9db38c2f..880df62257e 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptAnnotationAndConstantLoader.kt @@ -18,14 +18,14 @@ package org.jetbrains.kotlin.serialization.js import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.* import org.jetbrains.kotlin.types.JetType class KotlinJavascriptAnnotationAndConstantLoader( module: ModuleDescriptor -) : AnnotationAndConstantLoader> { +) : AnnotationAndConstantLoader> { private val deserializer = AnnotationDeserializer(module) override fun loadClassAnnotations( @@ -67,7 +67,7 @@ class KotlinJavascriptAnnotationAndConstantLoader( proto: ProtoBuf.Callable, nameResolver: NameResolver, expectedType: JetType - ): CompileTimeConstant<*>? { + ): ConstantValue<*>? { val value = proto.getExtension(JsProtoBuf.compileTimeValue) return deserializer.resolveValue(expectedType, value, nameResolver) } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index e680b560895..2f7271c7281 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.resolve.constants.NullValue -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.serialization.AnnotationSerializer import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.SerializerExtension @@ -48,10 +47,10 @@ public object KotlinJavascriptSerializerExtension : SerializerExtension() { proto.addExtension(JsProtoBuf.callableAnnotation, annotationSerializer.serializeAnnotation(annotation, stringTable)) } val propertyDescriptor = callable as? PropertyDescriptor ?: return - val compileTimeConstant = propertyDescriptor.getCompileTimeInitializer() - if (compileTimeConstant != null && compileTimeConstant !is NullValue) { - val type = compileTimeConstant.type - proto.setExtension(JsProtoBuf.compileTimeValue, annotationSerializer.valueProto(compileTimeConstant, type, stringTable).build()) + val constantInitializer = propertyDescriptor.getCompileTimeInitializer() + if (constantInitializer != null && constantInitializer !is NullValue) { + val type = constantInitializer.type + proto.setExtension(JsProtoBuf.compileTimeValue, annotationSerializer.valueProto(constantInitializer, type, stringTable).build()) } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java index 951c2deb0d0..e1aae4567b7 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/ExpressionVisitor.java @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilPackage; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; +import org.jetbrains.kotlin.resolve.constants.ConstantValue; import org.jetbrains.kotlin.resolve.constants.NullValue; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.inline.InlineUtil; @@ -75,14 +76,13 @@ public final class ExpressionVisitor extends TranslatorVisitor { @NotNull private static JsNode translateConstantExpression(@NotNull JetConstantExpression expression, @NotNull TranslationContext context) { CompileTimeConstant compileTimeValue = ConstantExpressionEvaluator.getConstant(expression, context.bindingContext()); - assert compileTimeValue != null : message(expression, "Expression is not compile time value: " + expression.getText() + " "); - - if (compileTimeValue instanceof NullValue) { + JetType expectedType = context.bindingContext().getType(expression); + ConstantValue constant = compileTimeValue.toConstantValue(expectedType != null ? expectedType : TypeUtils.NO_EXPECTED_TYPE); + if (constant instanceof NullValue) { return JsLiteral.NULL; } - - Object value = getCompileTimeValue(context.bindingContext(), expression, compileTimeValue); + Object value = constant.getValue(); if (value instanceof Integer || value instanceof Short || value instanceof Byte) { return context.program().getNumberLiteral(((Number) value).intValue()); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java index 951a1344628..ac8f2397703 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.psi.JetConstantExpression; import org.jetbrains.kotlin.psi.JetExpression; import org.jetbrains.kotlin.psi.JetUnaryExpression; -import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingContextUtils; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java index 5d6fc2fa0ef..950d877fed8 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java @@ -130,7 +130,7 @@ public final class CallExpressionTranslator extends AbstractCallExpressionTransl CompileTimeConstant constant = ConstantExpressionEvaluator.evaluate(jsCodeExpression, bindingTrace, stringType); assert constant != null: "jsCode must be compile time string " + jsCodeExpression; - String jsCode = (String) constant.getValue(); + String jsCode = (String) constant.getValue(stringType); assert jsCode != null: jsCodeExpression.toString(); // Parser can change local or global scope. diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java index e54e943e65a..68bf898c4f2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/BindingUtils.java @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeUtils; @@ -159,14 +158,8 @@ public final class BindingUtils { @Nullable public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull JetExpression expression, @NotNull CompileTimeConstant constant) { - if (constant != null) { - if (constant instanceof IntegerValueTypeConstant) { - JetType expectedType = context.getType(expression); - return ((IntegerValueTypeConstant) constant).getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType); - } - return constant.getValue(); - } - return null; + JetType expectedType = context.getType(expression); + return constant.getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType); } @NotNull From fdfabebcce0574ce7db9c6181c69640edbb71d38 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Thu, 25 Jun 2015 15:16:41 +0300 Subject: [PATCH 286/450] Fix debugger test on Java7 --- .../debugger/tinyApp/outs/frameSimple.out | 15 +++++---------- .../singleBreakpoint/frame/frameSimple.kt | 6 ++++-- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/idea/testData/debugger/tinyApp/outs/frameSimple.out b/idea/testData/debugger/tinyApp/outs/frameSimple.out index d0667b4581e..49ba752f490 100644 --- a/idea/testData/debugger/tinyApp/outs/frameSimple.out +++ b/idea/testData/debugger/tinyApp/outs/frameSimple.out @@ -12,18 +12,20 @@ val topVal1 = 1 fun main(args: Array) { val val1 = 1 - val val2 = "str" + val val2 = MyClass() //Breakpoint! val1 + topVal1 } +class MyClass + // PRINT_FRAME // EXPRESSION: val1 // RESULT: 1: I // EXPRESSION: val2 -// RESULT: "str": Ljava/lang/String; +// RESULT: instance of frameSimple.MyClass(id=ID): LframeSimple/MyClass; // EXPRESSION: topVal1 // RESULT: 1: I @@ -35,14 +37,7 @@ fun main(args: Array) { field = topVal1: int = 1 (sp = null) local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = frameSimple.kt, 5) local = val1: int = 1 (sp = frameSimple.kt, 6) - local = val2: java.lang.String = str (sp = frameSimple.kt, 7) - field = value: char[] = {char[3]@uniqueID} (sp = String.!EXT!) - unknown = [0] = 's' 115 - unknown = [1] = 't' 116 - unknown = [2] = 'r' 114 - field = offset: int = 0 (sp = String.!EXT!) - field = count: int = 3 (sp = String.!EXT!) - field = hash: int = 0 (sp = String.!EXT!) + local = val2: frameSimple.MyClass = {frameSimple.MyClass@uniqueID} (sp = frameSimple.kt, 7) Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' Process finished with exit code 0 diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/frameSimple.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/frameSimple.kt index 3607971a065..03f25463853 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/frameSimple.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/frameSimple.kt @@ -4,18 +4,20 @@ val topVal1 = 1 fun main(args: Array) { val val1 = 1 - val val2 = "str" + val val2 = MyClass() //Breakpoint! val1 + topVal1 } +class MyClass + // PRINT_FRAME // EXPRESSION: val1 // RESULT: 1: I // EXPRESSION: val2 -// RESULT: "str": Ljava/lang/String; +// RESULT: instance of frameSimple.MyClass(id=ID): LframeSimple/MyClass; // EXPRESSION: topVal1 // RESULT: 1: I From 9a53142b26a945633f3bbf24137b2364ba8f6700 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 23 Jun 2015 15:04:31 +0300 Subject: [PATCH 287/450] Refactoring: move similar part for obtaining scope for codeFragment to JetCodeFragment --- .../kotlin/resolve/lazy/ElementResolver.kt | 50 +++---------- .../resolve/util/codeFragmentResolveUtils.kt | 72 +++++++++++++++++++ .../idea/caches/resolve/KotlinResolveCache.kt | 40 ++--------- 3 files changed, 87 insertions(+), 75 deletions(-) create mode 100644 idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index ad87d432aef..0610a5ec0c3 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.context.withProject import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.frontend.di.createContainerForBodyResolve +import org.jetbrains.kotlin.resolve.util.getScopeAndDataFlowForAnalyzeFragment import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -206,53 +207,22 @@ public abstract class ElementResolver protected constructor( val trace = createDelegatingTrace(codeFragment) val codeFragmentExpression = codeFragment.getContentElement() as? JetExpression ?: return trace - val contextElement = codeFragment.correctedContext - val scopeForContextElement: JetScope? - val dataFlowInfoForContextElement: DataFlowInfo - when (contextElement) { - is JetClassOrObject -> { - val descriptor = resolveSession.resolveToDescriptor(contextElement) as LazyClassDescriptor - scopeForContextElement = descriptor.getScopeForMemberDeclarationResolution() - dataFlowInfoForContextElement = DataFlowInfo.EMPTY - } + val (scopeForContextElement, dataFlowInfoForContextElement) = codeFragment.getScopeAndDataFlowForAnalyzeFragment(resolveSession) { + val contextResolveMode = if (bodyResolveMode == BodyResolveMode.PARTIAL) + BodyResolveMode.PARTIAL_FOR_COMPLETION + else + bodyResolveMode - is JetExpression -> { - // do not use PARTIAL body resolve mode because because it does not know about names used in our fragment - val contextResolveMode = if (bodyResolveMode == BodyResolveMode.PARTIAL) - BodyResolveMode.PARTIAL_FOR_COMPLETION - else - bodyResolveMode - val contextForElement = resolveToElement(contextElement, contextResolveMode) - scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, contextElement] - dataFlowInfoForContextElement = contextForElement.getDataFlowInfo(contextElement) - } + resolveToElement(it, contextResolveMode) + } ?: return trace - else -> return trace - } - - if (scopeForContextElement == null) return trace - - val codeFragmentScope = resolveSession.getFileScopeProvider().getFileScope(codeFragment) - val chainedScope = ChainedScope(scopeForContextElement.getContainingDeclaration(), - "Scope for resolve code fragment", scopeForContextElement, codeFragmentScope) - - codeFragmentExpression.computeTypeInContext(chainedScope, trace, dataFlowInfoForContextElement, + codeFragmentExpression.computeTypeInContext(scopeForContextElement, trace, dataFlowInfoForContextElement, TypeUtils.NO_EXPECTED_TYPE, resolveSession.getModuleDescriptor()) return trace } - //TODO: this code should be moved into debugger which should set correct context for its code fragment - private val JetCodeFragment.correctedContext: PsiElement? - get() { - val context = getContext() - if (context is JetBlockExpression) { - return context.getStatements().lastOrNull() ?: context - } - return context - } - private fun annotationAdditionalResolve(resolveSession: ResolveSession, jetAnnotationEntry: JetAnnotationEntry): BindingTrace { val modifierList = jetAnnotationEntry.getParentOfType(true) val declaration = modifierList?.getParentOfType(true) @@ -397,7 +367,7 @@ public abstract class ElementResolver protected constructor( val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter) bodyResolver.resolveAnonymousInitializer(DataFlowInfo.EMPTY, classInitializer, classOrObjectDescriptor) - + return trace } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt new file mode 100644 index 00000000000..77afac95010 --- /dev/null +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt @@ -0,0 +1,72 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.util + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.descriptors.ClassDescriptorWithResolutionScopes +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo +import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer +import org.jetbrains.kotlin.resolve.scopes.ChainedScope +import org.jetbrains.kotlin.resolve.scopes.JetScope + +//TODO: this code should be moved into debugger which should set correct context for its code fragment +private fun correctContext(oldContext: PsiElement?): PsiElement? { + if (oldContext is JetBlockExpression) { + return oldContext.getStatements().lastOrNull() ?: oldContext + } + return oldContext +} + +public fun JetCodeFragment.getScopeAndDataFlowForAnalyzeFragment( + resolveSession: KotlinCodeAnalyzer, + resolveToElement: (JetElement) -> BindingContext +): Pair? { + val context = correctContext(getContext()) + if (context !is JetExpression) return null + + val scopeForContextElement: JetScope? + val dataFlowInfo: DataFlowInfo + + when (context) { + is JetClassOrObject -> { + val descriptor = resolveSession.getClassDescriptor(context) as ClassDescriptorWithResolutionScopes + + scopeForContextElement = descriptor.getScopeForMemberDeclarationResolution() + dataFlowInfo = DataFlowInfo.EMPTY + } + is JetExpression -> { + val contextForElement = resolveToElement(context) + + scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, context] + dataFlowInfo = contextForElement.getDataFlowInfo(context) + } + else -> return null + } + + if (scopeForContextElement == null) return null + + val codeFragmentScope = resolveSession.getFileScopeProvider().getFileScope(this) + val chainedScope = ChainedScope( + scopeForContextElement.getContainingDeclaration(), + "Scope for resolve code fragment", + scopeForContextElement, codeFragmentScope) + + return chainedScope to dataFlowInfo +} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt index 5e5d613a099..bea4defa543 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinResolveCache.kt @@ -48,6 +48,7 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor import org.jetbrains.kotlin.resolve.scopes.ChainedScope import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.util.getScopeAndDataFlowForAnalyzeFragment import org.jetbrains.kotlin.types.TypeUtils import java.util.HashMap @@ -270,44 +271,13 @@ private object KotlinResolveDataProvider { val codeFragmentExpression = codeFragment.getContentElement() if (codeFragmentExpression !is JetExpression) return BindingContext.EMPTY - val contextElement = codeFragment.getContext() + val (scopeForContextElement, dataFlowInfo) = codeFragment.getScopeAndDataFlowForAnalyzeFragment(resolveSession) { + resolveSession.resolveToElement(it, BodyResolveMode.PARTIAL_FOR_COMPLETION) //TODO: discuss it + } ?: return BindingContext.EMPTY - val scopeForContextElement: JetScope? - val dataFlowInfo: DataFlowInfo - if (contextElement is JetClassOrObject) { - val descriptor = resolveSession.resolveToDescriptor(contextElement) as LazyClassDescriptor - - scopeForContextElement = descriptor.getScopeForMemberDeclarationResolution() - dataFlowInfo = DataFlowInfo.EMPTY - } - else if (contextElement is JetBlockExpression) { - val newContextElement = contextElement.getStatements().lastOrNull() - if (newContextElement !is JetExpression) return BindingContext.EMPTY - - val contextForElement = newContextElement.getResolutionFacade().analyze(newContextElement, BodyResolveMode.FULL) - - scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, newContextElement] - dataFlowInfo = contextForElement.getDataFlowInfo(newContextElement) - } - else { - if (contextElement !is JetExpression) return BindingContext.EMPTY - - val contextForElement = contextElement.getResolutionFacade().analyze(contextElement, BodyResolveMode.PARTIAL_FOR_COMPLETION) //TODO: discuss it - - scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, contextElement] - dataFlowInfo = contextForElement.getDataFlowInfo(contextElement) - } - - if (scopeForContextElement == null) return BindingContext.EMPTY - - val codeFragmentScope = resolveSession.getFileScopeProvider().getFileScope(codeFragment) - val chainedScope = ChainedScope( - scopeForContextElement.getContainingDeclaration(), - "Scope for resolve code fragment", - scopeForContextElement, codeFragmentScope) return codeFragmentExpression.analyzeInContext( - chainedScope, + scopeForContextElement, BindingTraceContext(), dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, From 75edfa652793e47b0ff6128be332ea1e8a0736c3 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Thu, 16 Jul 2015 13:08:31 +0300 Subject: [PATCH 288/450] Debugger: do not resolve symbols on breakpoint line in Evaluate Expression --- .../resolve/util/codeFragmentResolveUtils.kt | 39 ++++++++++++++----- .../testData/basic/codeFragments/elementAt.kt | 9 +++++ .../basic/codeFragments/elementAt.kt.fragment | 1 + .../codeFragments/elementAtFirstInBlock.kt | 6 +++ .../elementAtFirstInBlock.kt.fragment | 1 + .../codeFragments/elementAtIfWithoutBraces.kt | 10 +++++ .../elementAtIfWithoutBraces.kt.fragment | 1 + .../codeFragments/elementAtWhenBranch.kt | 10 +++++ .../elementAtWhenBranch.kt.fragment | 1 + .../CodeFragmentCompletionTestGenerated.java | 12 ++++++ ...CodeFragmentHighlightingTestGenerated.java | 12 ++++++ 11 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 idea/idea-completion/testData/basic/codeFragments/elementAt.kt create mode 100644 idea/idea-completion/testData/basic/codeFragments/elementAt.kt.fragment create mode 100644 idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt create mode 100644 idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt.fragment create mode 100644 idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt create mode 100644 idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt.fragment create mode 100644 idea/testData/checker/codeFragments/elementAtWhenBranch.kt create mode 100644 idea/testData/checker/codeFragments/elementAtWhenBranch.kt.fragment diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt index 77afac95010..11b88ec2736 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt @@ -16,29 +16,48 @@ package org.jetbrains.kotlin.resolve.util -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.ClassDescriptorWithResolutionScopes import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.parents +import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer import org.jetbrains.kotlin.resolve.scopes.ChainedScope import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull //TODO: this code should be moved into debugger which should set correct context for its code fragment -private fun correctContext(oldContext: PsiElement?): PsiElement? { - if (oldContext is JetBlockExpression) { - return oldContext.getStatements().lastOrNull() ?: oldContext +private fun JetExpression.correctContextForExpression(): JetExpression { + when (this) { + is JetBlockExpression -> { + return this.getStatements().lastOrNull() ?: this + } + is JetFunctionLiteral -> { + return this.getBodyExpression()?.getStatements()?.lastOrNull() ?: this + } + else -> { + val previousExpression = this.siblings(forward = false, withItself = false).firstIsInstanceOrNull() + if (previousExpression is JetExpression) { + return previousExpression + } + else { + val parentExpression = this.parents.firstIsInstanceOrNull() + if (parentExpression is JetExpression) { + return parentExpression + } + } + } } - return oldContext + return this } public fun JetCodeFragment.getScopeAndDataFlowForAnalyzeFragment( resolveSession: KotlinCodeAnalyzer, resolveToElement: (JetElement) -> BindingContext ): Pair? { - val context = correctContext(getContext()) + val context = getContext() if (context !is JetExpression) return null val scopeForContextElement: JetScope? @@ -52,10 +71,12 @@ public fun JetCodeFragment.getScopeAndDataFlowForAnalyzeFragment( dataFlowInfo = DataFlowInfo.EMPTY } is JetExpression -> { - val contextForElement = resolveToElement(context) + val correctedContext = context.correctContextForExpression() - scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, context] - dataFlowInfo = contextForElement.getDataFlowInfo(context) + val contextForElement = resolveToElement(correctedContext) + + scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, correctedContext] + dataFlowInfo = contextForElement.getDataFlowInfo(correctedContext) } else -> return null } diff --git a/idea/idea-completion/testData/basic/codeFragments/elementAt.kt b/idea/idea-completion/testData/basic/codeFragments/elementAt.kt new file mode 100644 index 00000000000..45cae3892e1 --- /dev/null +++ b/idea/idea-completion/testData/basic/codeFragments/elementAt.kt @@ -0,0 +1,9 @@ +fun foo() { + val aaaB = 1 + val aaaC = 1 + val aaaD = 1 +} + +// INVOCATION_COUNT: 1 +// EXIST: aaaB +// ABSENT: aaaC, aaaD \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/codeFragments/elementAt.kt.fragment b/idea/idea-completion/testData/basic/codeFragments/elementAt.kt.fragment new file mode 100644 index 00000000000..1a83755fab1 --- /dev/null +++ b/idea/idea-completion/testData/basic/codeFragments/elementAt.kt.fragment @@ -0,0 +1 @@ +aaa \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt b/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt new file mode 100644 index 00000000000..3083066d049 --- /dev/null +++ b/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt @@ -0,0 +1,6 @@ +fun foo() { + val aaaB = 1 +} + +// INVOCATION_COUNT: 1 +// ABSENT: aaaB \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt.fragment b/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt.fragment new file mode 100644 index 00000000000..1a83755fab1 --- /dev/null +++ b/idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt.fragment @@ -0,0 +1 @@ +aaa \ No newline at end of file diff --git a/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt b/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt new file mode 100644 index 00000000000..d178d6df57e --- /dev/null +++ b/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt @@ -0,0 +1,10 @@ +fun main(args: Array) { + val str: String? = "" + + if (str != null) + test(str) + else + test("") +} + +fun test(s: String) = 1 \ No newline at end of file diff --git a/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt.fragment b/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt.fragment new file mode 100644 index 00000000000..fc12a393b72 --- /dev/null +++ b/idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt.fragment @@ -0,0 +1 @@ +test(str) \ No newline at end of file diff --git a/idea/testData/checker/codeFragments/elementAtWhenBranch.kt b/idea/testData/checker/codeFragments/elementAtWhenBranch.kt new file mode 100644 index 00000000000..47389c6aac1 --- /dev/null +++ b/idea/testData/checker/codeFragments/elementAtWhenBranch.kt @@ -0,0 +1,10 @@ +fun main(args: Array) { + val str: String? = "" + + when(str) { + null -> test("") + else -> test(str) + } +} + +fun test(s: String) = 1 \ No newline at end of file diff --git a/idea/testData/checker/codeFragments/elementAtWhenBranch.kt.fragment b/idea/testData/checker/codeFragments/elementAtWhenBranch.kt.fragment new file mode 100644 index 00000000000..fc12a393b72 --- /dev/null +++ b/idea/testData/checker/codeFragments/elementAtWhenBranch.kt.fragment @@ -0,0 +1 @@ +test(str) \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionTestGenerated.java index 5541f7c1e54..116c022dc08 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentCompletionTestGenerated.java @@ -47,6 +47,18 @@ public class CodeFragmentCompletionTestGenerated extends AbstractCodeFragmentCom doTest(fileName); } + @TestMetadata("elementAt.kt") + public void testElementAt() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/codeFragments/elementAt.kt"); + doTest(fileName); + } + + @TestMetadata("elementAtFirstInBlock.kt") + public void testElementAtFirstInBlock() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/codeFragments/elementAtFirstInBlock.kt"); + doTest(fileName); + } + @TestMetadata("localVal.kt") public void testLocalVal() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/codeFragments/localVal.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentHighlightingTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentHighlightingTestGenerated.java index 234d00c3012..346da628466 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentHighlightingTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/CodeFragmentHighlightingTestGenerated.java @@ -73,6 +73,18 @@ public class CodeFragmentHighlightingTestGenerated extends AbstractCodeFragmentH doTest(fileName); } + @TestMetadata("elementAtIfWithoutBraces.kt") + public void testElementAtIfWithoutBraces() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/codeFragments/elementAtIfWithoutBraces.kt"); + doTest(fileName); + } + + @TestMetadata("elementAtWhenBranch.kt") + public void testElementAtWhenBranch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/codeFragments/elementAtWhenBranch.kt"); + doTest(fileName); + } + @TestMetadata("localVariables.kt") public void testLocalVariables() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/checker/codeFragments/localVariables.kt"); From ec3c667f38fcb4e3edd04596b00a369ab27d491a Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Thu, 16 Jul 2015 13:09:26 +0300 Subject: [PATCH 289/450] Debugger: allow Evaluate Expression in context of File (for some synthetic methods or when file was changed during debug and breakpoint line no longer match the actual line) --- .../kotlin/resolve/util/codeFragmentResolveUtils.kt | 4 ++++ .../idea/debugger/KotlinEditorTextProvider.kt | 12 +++++++++--- .../debugger/evaluate/KotlinCodeFragmentFactory.kt | 5 +++-- .../evaluate/extractFunctionForDebuggerUtil.kt | 13 +++++++------ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt index 11b88ec2736..b9d79298474 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/util/codeFragmentResolveUtils.kt @@ -78,6 +78,10 @@ public fun JetCodeFragment.getScopeAndDataFlowForAnalyzeFragment( scopeForContextElement = contextForElement[BindingContext.RESOLUTION_SCOPE, correctedContext] dataFlowInfo = contextForElement.getDataFlowInfo(correctedContext) } + is JetFile -> { + scopeForContextElement = resolveSession.getFileScopeProvider().getFileScope(context) + dataFlowInfo = DataFlowInfo.EMPTY + } else -> return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt index 39ed62caaab..15d8e16a975 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinEditorTextProvider.kt @@ -56,9 +56,7 @@ class KotlinEditorTextProvider : EditorTextProvider { } fun findExpressionInner(element: PsiElement, allowMethodCalls: Boolean): JetExpression? { - if (PsiTreeUtil.getParentOfType(element, javaClass(), javaClass(), javaClass()) != null) { - return null - } + if (!isAcceptedAsCodeFragmentContext(element)) return null val jetElement = PsiTreeUtil.getParentOfType(element, javaClass()) if (jetElement == null) return null @@ -116,6 +114,14 @@ class KotlinEditorTextProvider : EditorTextProvider { } } + + private val NOT_ACCEPTED_AS_CONTEXT_TYPES = + arrayOf(javaClass(), javaClass(), javaClass()) + + fun isAcceptedAsCodeFragmentContext(element: PsiElement): Boolean { + return element.javaClass !in NOT_ACCEPTED_AS_CONTEXT_TYPES && + PsiTreeUtil.getParentOfType(element, *NOT_ACCEPTED_AS_CONTEXT_TYPES) == null + } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt index 0a824a0ac91..02a7f9ba129 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinCodeFragmentFactory.kt @@ -131,10 +131,11 @@ class KotlinCodeFragmentFactory: CodeFragmentFactory() { } val expressionAtOffset = PsiTreeUtil.findElementOfClassAtOffset(elementAt.getContainingFile()!!, elementAt.getTextOffset(), javaClass(), false) - if (expressionAtOffset != null) { + if (expressionAtOffset != null && KotlinEditorTextProvider.isAcceptedAsCodeFragmentContext(elementAt)) { return expressionAtOffset } - return KotlinEditorTextProvider.findExpressionInner(elementAt, true) + + return KotlinEditorTextProvider.findExpressionInner(elementAt, true) ?: elementAt.getContainingFile() } //internal for tests diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt index 39be2c91a05..3a2a85a80aa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/extractFunctionForDebuggerUtil.kt @@ -77,11 +77,6 @@ fun getFunctionForExtractedFragment( val contextElement = getExpressionToAddDebugExpressionBefore(tmpFile, codeFragment.getContext(), breakpointLine) if (contextElement == null) return null - // Don't evaluate smth when breakpoint is on package directive (ex. for package classes) - if (contextElement is JetFile) { - throw EvaluateExceptionUtil.createEvaluateException("Cannot perform an action at this breakpoint ${breakpointFile.getName()}:${breakpointLine}") - } - addImportsToFile(codeFragment.importsAsImportList(), tmpFile) val newDebugExpressions = addDebugExpressionBeforeContextElement(codeFragment, contextElement) @@ -158,7 +153,7 @@ private fun getExpressionToAddDebugExpressionBefore(tmpFile: JetFile, contextEle return getExpressionToAddDebugExpressionBefore(tmpFile, containingFile.getContext(), line) } - fun shouldStop(el: PsiElement?, p: PsiElement?) = p is JetBlockExpression || el is JetDeclaration + fun shouldStop(el: PsiElement?, p: PsiElement?) = p is JetBlockExpression || el is JetDeclaration || el is JetFile var elementAt = tmpFile.getElementInCopy(contextElement) @@ -192,6 +187,12 @@ private fun addDebugExpressionBeforeContextElement(codeFragment: JetCodeFragment } val elementBefore = when { + contextElement is JetFile -> { + val fakeFunction = psiFactory.createFunction("fun _debug_fun_() {}") + contextElement.add(psiFactory.createNewLine()) + val newFakeFun = contextElement.add(fakeFunction) as JetNamedFunction + newFakeFun.getBodyExpression()!!.getLastChild() + } contextElement is JetProperty && !contextElement.isLocal() -> { val delegateExpressionOrInitializer = contextElement.getDelegateExpressionOrInitializer() if (delegateExpressionOrInitializer != null) { From 03de31f1b6df7ab3a5e5523aee9e3135536b18fc Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 14 Jul 2015 12:46:30 +0300 Subject: [PATCH 290/450] Debugger: do not throw assert when context for codeFragment is null (ex. when file was changed and psi isn't valid any more) --- .../kotlin/idea/caches/resolve/KotlinCacheService.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt index b22b6120619..9d2a61818ba 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/KotlinCacheService.kt @@ -199,12 +199,12 @@ public class KotlinCacheService(val project: Project) { private fun findSyntheticFiles(files: Collection) = files.map { if (it is JetCodeFragment) it.getContextFile() else it - }.filter { + }.filterNotNull().filter { !ProjectRootsUtil.isInProjectSource(it) }.toSet() - private fun JetCodeFragment.getContextFile(): JetFile { - val contextElement = getContext() ?: throw AssertionError("Analyzing code fragment of type $javaClass with no context") + private fun JetCodeFragment.getContextFile(): JetFile? { + val contextElement = getContext() ?: return null val contextFile = (contextElement as? JetElement)?.getContainingJetFile() ?: throw AssertionError("Analyzing kotlin code fragment of type $javaClass with java context of type ${contextElement.javaClass}") return if (contextFile is JetCodeFragment) contextFile.getContextFile() else contextFile From 98da75c768aa6a38e07ff687b7464f43f8c583b7 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Tue, 14 Jul 2015 12:48:39 +0300 Subject: [PATCH 291/450] Debugger: check that file isn't shorter than breakpoint line (ex. after deleting some lines in file during debug) --- .../idea/debugger/evaluate/KotlinEvaluationBuilder.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt index 2e6c1e4e08e..8c023a01e53 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -30,6 +30,7 @@ import com.intellij.openapi.progress.ProcessCanceledException import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.CharsetToolkit import com.intellij.psi.JavaPsiFacade +import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiElement import com.intellij.psi.PsiFileFactory import com.intellij.psi.impl.PsiFileFactoryImpl @@ -101,6 +102,13 @@ object KotlinEvaluationBuilder: EvaluatorBuilder { throw EvaluateExceptionUtil.createEvaluateException("Couldn't evaluate kotlin expression at $position") } + val document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file) + if (document == null || document.getLineCount() < position.getLine()) { + throw EvaluateExceptionUtil.createEvaluateException( + "Couldn't evaluate kotlin expression: breakpoint is placed outside the file. " + + "It may happen when you've changed source file after starting a debug process.") + } + if (codeFragment.getContext() !is JetElement) { val attachments = arrayOf(attachmentByPsiFile(position.getFile()), attachmentByPsiFile(codeFragment), From e2fa9397c8e56fc45d3502386832a0535f79fd28 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Wed, 15 Jul 2015 15:08:13 +0300 Subject: [PATCH 292/450] Debugger: fix context element in SourcePositionProvider --- .../kotlin/idea/debugger/KotlinSourcePositionProvider.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt index adcfe5e9681..50274a38518 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/KotlinSourcePositionProvider.kt @@ -34,6 +34,7 @@ import com.sun.jdi.ClassNotPreparedException import com.sun.jdi.ReferenceType import org.jetbrains.kotlin.codegen.AsmUtil import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinCodeFragmentFactory import org.jetbrains.kotlin.psi.JetClassOrObject import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.psi.JetPsiFactory @@ -62,7 +63,7 @@ public class KotlinSourcePositionProvider: SourcePositionProvider() { private fun computeSourcePosition(descriptor: LocalVariableDescriptor, project: Project, context: DebuggerContextImpl, nearest: Boolean): SourcePosition? { val place = PositionUtil.getContextElement(context) ?: return null - val contextElement = PsiTreeUtil.getParentOfType(place, javaClass()) ?: return null + val contextElement = KotlinCodeFragmentFactory.getContextElement(place) ?: return null val codeFragment = JetPsiFactory(project).createExpressionCodeFragment(descriptor.getName(), contextElement) val expression = codeFragment.getContentElement() From c92b43c94bd9940c3725fdd1840fa5eaade820f5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 6 Jul 2015 19:38:25 +0300 Subject: [PATCH 293/450] Added JetScope.getSyntheticExtensionProperties() --- .../kotlin/resolve/AllUnderImportsScope.kt | 12 +++++++----- .../kotlin/resolve/SingleImportScope.kt | 3 +++ .../kotlin/resolve/lazy/LazyImportScope.kt | 6 ++++++ .../lazy/descriptors/AbstractLazyMemberScope.kt | 3 +++ .../lazy/descriptors/LazyJavaMemberScope.kt | 2 ++ .../resolve/scopes/AbstractScopeAdapter.kt | 5 +++++ .../kotlin/resolve/scopes/ChainedScope.kt | 9 +++++++-- .../resolve/scopes/ExplicitImportsScope.kt | 3 +++ .../kotlin/resolve/scopes/FilteringScope.kt | 5 ++++- .../jetbrains/kotlin/resolve/scopes/JetScope.kt | 3 +++ .../kotlin/resolve/scopes/JetScopeImpl.kt | 3 +++ .../resolve/scopes/StaticScopeForKotlinClass.kt | 7 +++++-- .../kotlin/resolve/scopes/SubstitutingScope.kt | 11 ++++++++--- .../org/jetbrains/kotlin/types/ErrorUtils.java | 16 ++++++++++++++++ .../descriptors/DeserializedMemberScope.kt | 17 +++++++++++------ 15 files changed, 86 insertions(+), 19 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index 3b09874fa63..3e653a4432a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -18,13 +18,11 @@ package org.jetbrains.kotlin.resolve import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap -import org.jetbrains.kotlin.resolve.scopes.FilteringScope -import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.resolve.scopes.WritableScope -import java.util.ArrayList import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer +import java.util.ArrayList class AllUnderImportsScope : JetScope { private val scopes = ArrayList() @@ -55,6 +53,10 @@ class AllUnderImportsScope : JetScope { return scopes.flatMap { it.getFunctions(name) } } + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType, name) } + } + override fun getPackage(name: Name): PackageViewDescriptor? = null // packages are not imported by all under imports override fun getLocalVariable(name: Name): VariableDescriptor? = null diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt index 9f918a70b6e..0dded31f58a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer class SingleImportScope(private val aliasName: Name, private val descriptors: Collection) : JetScope { @@ -35,6 +36,8 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co override fun getFunctions(name: Name) = if (name == aliasName) descriptors.filterIsInstance() else emptyList() + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = emptyList() + override fun getLocalVariable(name: Name): VariableDescriptor? = null override fun getContainingDeclaration(): DeclarationDescriptor = throw UnsupportedOperationException() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index e63d88e8f73..d3a9b7fdfa3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.LookupMode import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer import java.util.LinkedHashSet @@ -254,6 +255,11 @@ class LazyImportScope( return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) } } + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() + return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverType, name) } + } + override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt index 0346754dba1..fd3e126ac8a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull import org.jetbrains.kotlin.storage.StorageManager +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.LinkedHashSet @@ -110,6 +111,8 @@ protected constructor( protected abstract fun getNonDeclaredProperties(name: Name, result: MutableSet) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() + override fun getLocalVariable(name: Name): VariableDescriptor? = null override fun getDeclarationsByLabel(labelName: Name) = setOf() diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index 93e435d526c..e82897671a4 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -297,6 +297,8 @@ public abstract class LazyJavaMemberScope( override fun getProperties(name: Name): Collection = properties(name) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() + override fun getLocalVariable(name: Name): VariableDescriptor? = null override fun getDeclarationsByLabel(labelName: Name) = listOf() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index 549bb12dfe3..98f4032841d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer /** @@ -46,6 +47,10 @@ public abstract class AbstractScopeAdapter : JetScope { return workerScope.getProperties(name) } + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + return workerScope.getSyntheticExtensionProperties(receiverType, name) + } + override fun getLocalVariable(name: Name): VariableDescriptor? { return workerScope.getLocalVariable(name) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index 62b9938c8ca..0a270366fdb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -18,9 +18,11 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.util.collectionUtils.concat -import java.util.* +import org.jetbrains.kotlin.utils.Printer +import java.util.ArrayList +import java.util.LinkedHashSet public open class ChainedScope( private val containingDeclaration: DeclarationDescriptor?/* it's nullable as a hack for TypeUtils.intersect() */, @@ -63,6 +65,9 @@ public open class ChainedScope( override fun getFunctions(name: Name): Collection = getFromAllScopes { it.getFunctions(name) } + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType, name) } + override fun getImplicitReceiversHierarchy(): List { if (implicitReceiverHierarchy == null) { val result = ArrayList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt index a4338a758ca..b2e6067b031 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull @@ -32,6 +33,8 @@ public class ExplicitImportsScope(private val descriptors: Collection() + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() + override fun getContainingDeclaration() = throw UnsupportedOperationException() override fun getDeclarationsByLabel(labelName: Name) = emptyList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index bb245930cec..313181b5638 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -16,8 +16,9 @@ package org.jetbrains.kotlin.resolve.scopes -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope { @@ -35,6 +36,8 @@ public class FilteringScope(private val workerScope: JetScope, private val predi override fun getProperties(name: Name) = workerScope.getProperties(name).filter(predicate) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = workerScope.getSyntheticExtensionProperties(receiverType, name).filter(predicate) + override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name)) override fun getDescriptors(kindFilter: DescriptorKindFilter, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index 9fa86e94f1a..a6ba0850059 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.toReadOnlyList import java.lang.reflect.Modifier @@ -34,6 +35,8 @@ public trait JetScope { public fun getFunctions(name: Name): Collection + public fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + public fun getContainingDeclaration(): DeclarationDescriptor public fun getDeclarationsByLabel(labelName: Name): Collection diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt index 7a16104950e..3761435f6f0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer public abstract class JetScopeImpl : JetScope { @@ -31,6 +32,8 @@ public abstract class JetScopeImpl : JetScope { override fun getFunctions(name: Name): Collection = setOf() + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() + override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() override fun getDescriptors(kindFilter: DescriptorKindFilter, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt index e088eed4f45..d53d46cf158 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt @@ -16,12 +16,14 @@ package org.jetbrains.kotlin.resolve.scopes -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValueOfMethod +import org.jetbrains.kotlin.resolve.DescriptorFactory.createEnumValuesMethod +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer import java.util.ArrayList import kotlin.properties.Delegates -import org.jetbrains.kotlin.resolve.DescriptorFactory.* public class StaticScopeForKotlinClass( private val containingClass: ClassDescriptor @@ -46,6 +48,7 @@ public class StaticScopeForKotlinClass( override fun getPackage(name: Name) = null override fun getProperties(name: Name) = listOf() + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() override fun getLocalVariable(name: Name) = null override fun getContainingDeclaration() = containingClass override fun getDeclarationsByLabel(labelName: Name) = listOf() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index f72257b8ae8..19bc67d6cb6 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -16,11 +16,14 @@ package org.jetbrains.kotlin.resolve.scopes -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.utils.* -import java.util.* +import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.utils.newHashSetWithExpectedSize +import java.util.HashMap import kotlin.properties.Delegates public class SubstitutingScope(private val workerScope: JetScope, private val substitutor: TypeSubstitutor) : JetScope { @@ -66,6 +69,8 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su override fun getFunctions(name: Name) = substitute(workerScope.getFunctions(name)) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = substitute(workerScope.getSyntheticExtensionProperties(receiverType, name)) + override fun getPackage(name: Name) = workerScope.getPackage(name) override fun getImplicitReceiversHierarchy(): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index b579ac9e289..320058f54b3 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -91,6 +91,14 @@ public class ErrorUtils { return ERROR_PROPERTY_GROUP; } + @NotNull + @Override + public Collection getSyntheticExtensionProperties( + @NotNull JetType receiverType, @NotNull Name name + ) { + return ERROR_PROPERTY_GROUP; + } + @Override public VariableDescriptor getLocalVariable(@NotNull Name name) { return ERROR_PROPERTY; @@ -193,6 +201,14 @@ public class ErrorUtils { throw new IllegalStateException(); } + @NotNull + @Override + public Collection getSyntheticExtensionProperties( + @NotNull JetType receiverType, @NotNull Name name + ) { + throw new IllegalStateException(); + } + @NotNull @Override public DeclarationDescriptor getContainingDeclaration() { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index 688aee37174..7ead7345cf7 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -16,17 +16,20 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors -import org.jetbrains.kotlin.serialization.Flags -import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.utils.Printer -import org.jetbrains.kotlin.utils.toReadOnlyList import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.serialization.Flags +import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext -import java.util.* +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.utils.Printer +import org.jetbrains.kotlin.utils.toReadOnlyList +import java.util.ArrayList +import java.util.LinkedHashMap +import java.util.LinkedHashSet public abstract class DeserializedMemberScope protected constructor( protected val c: DeserializationContext, @@ -109,6 +112,8 @@ public abstract class DeserializedMemberScope protected constructor( protected abstract fun addClassDescriptors(result: MutableCollection, nameFilter: (Name) -> Boolean) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() + override fun getPackage(name: Name): PackageViewDescriptor? = null override fun getLocalVariable(name: Name): VariableDescriptor? = null From 2e351f3e4df4b273f632681d63295089e9dbb59d Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 7 Jul 2015 18:23:56 +0300 Subject: [PATCH 294/450] Initial implementation of synthetic extensions resolve --- .../kotlin/frontend/java/di/injection.kt | 2 + .../synthetic/SyntheticExtensionsScope.kt | 156 ++++++++++++++++++ .../tasks/CallableDescriptorCollectors.kt | 16 +- .../resolve/calls/tasks/TaskPrioritizer.kt | 4 +- .../resolve/calls/tasks/dynamicCalls.kt | 4 +- .../tests/syntheticExtensions/Bases.kt | 31 ++++ .../tests/syntheticExtensions/Bases.txt | 42 +++++ .../syntheticExtensions/CompiledClass.kt | 6 + .../syntheticExtensions/CompiledClass.txt | 3 + .../tests/syntheticExtensions/FalseGetters.kt | 14 ++ .../syntheticExtensions/FalseGetters.txt | 15 ++ .../tests/syntheticExtensions/FalseSetters.kt | 26 +++ .../syntheticExtensions/FalseSetters.txt | 22 +++ .../tests/syntheticExtensions/GenericClass.kt | 10 ++ .../syntheticExtensions/GenericClass.txt | 12 ++ .../tests/syntheticExtensions/Getter.kt | 20 +++ .../tests/syntheticExtensions/Getter.txt | 20 +++ .../syntheticExtensions/GetterAndSetter.kt | 10 ++ .../syntheticExtensions/GetterAndSetter.txt | 12 ++ .../syntheticExtensions/ImplicitReceiver.kt | 12 ++ .../syntheticExtensions/ImplicitReceiver.txt | 12 ++ .../tests/syntheticExtensions/OnlyPublic.kt | 18 ++ .../tests/syntheticExtensions/OnlyPublic.txt | 15 ++ .../tests/syntheticExtensions/SetterOnly.kt | 9 + .../tests/syntheticExtensions/SetterOnly.txt | 11 ++ .../checkers/JetDiagnosticsTestGenerated.java | 69 ++++++++ 26 files changed, 559 insertions(+), 12 deletions(-) create mode 100644 compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.txt 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 09f771e130c..5b3b7612f87 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 @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaLazyAnalyzerPostConstruct import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory +import org.jetbrains.kotlin.synthetic.AdditionalScopesWithSyntheticExtensions public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentScope: GlobalSearchScope, project: Project) { useInstance(moduleContentScope) @@ -65,6 +66,7 @@ public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentS useImpl() useImpl() useImpl() + useImpl() } public fun createContainerForLazyResolveWithJava( diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt new file mode 100644 index 00000000000..a0a8791600b --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -0,0 +1,156 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.synthetic + +import com.intellij.util.SmartList +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.annotations.Annotations +import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl +import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl +import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.storage.StorageManager +import org.jetbrains.kotlin.types.JetType + +interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { + val getMethod: FunctionDescriptor + val setMethod: FunctionDescriptor? +} + +class AdditionalScopesWithSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { + private val scope = SyntheticExtensionsScope(storageManager) + + override fun scopes(file: JetFile) = listOf(scope) +} + +class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { + private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { triple -> + syntheticPropertyInClass(triple.first, triple.second, triple.third) + } + + private fun syntheticPropertyInClass(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { + val memberScope = javaClass.getMemberScope(type.getArguments()) + val getMethod = memberScope.getFunctions(name.toGetMethodName()).singleOrNull { + it.getValueParameters().isEmpty() && it.getTypeParameters().isEmpty() && it.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? + } ?: return null + + val propertyType = getMethod.getReturnType() ?: return null + val setMethod = memberScope.getFunctions(name.toSetMethodName()).singleOrNull { + it.getValueParameters().singleOrNull()?.getType() == propertyType + && it.getTypeParameters().isEmpty() + && it.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false + && it.getVisibility() == Visibilities.PUBLIC + } + + return MyPropertyDescriptor(javaClass, getMethod, setMethod, name, propertyType, type) + } + + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + if (name.isSpecial()) return emptyList() + if (name.getIdentifier()[0].isUpperCase()) return emptyList() + return collectSyntheticProperties(null, receiverType, name) ?: emptyList() + } + + private fun collectSyntheticProperties(result: SmartList?, type: JetType, name: Name): SmartList? { + @suppress("NAME_SHADOWING") + var result = result + + val typeConstructor = type.getConstructor() + val classifier = typeConstructor.getDeclarationDescriptor() + if (classifier is JavaClassDescriptor) { + result = result.add(syntheticPropertyInClass(Triple(classifier, type, name))) + } + + typeConstructor.getSupertypes().forEach { result = collectSyntheticProperties(result, it, name) } + + return result + } + + private fun SmartList?.add(property: PropertyDescriptor?): SmartList? { + if (property == null) return this + val list = if (this != null) this else SmartList() + list.add(property) + return list + } + + //TODO: "is"? + //TODO: methods like "getURL"? + //TODO: reuse code with generation? + private fun Name.toGetMethodName(): Name { + return Name.identifier("get" + getIdentifier().capitalize()) + } + + private fun Name.toSetMethodName(): Name { + return Name.identifier("set" + getIdentifier().capitalize()) + } + + private class MyPropertyDescriptor( + javaClass: JavaClassDescriptor, + override val getMethod: FunctionDescriptor, + override val setMethod: FunctionDescriptor?, + name: Name, + type: JetType, + receiverType: JetType + ) : SyntheticExtensionPropertyDescriptor, PropertyDescriptorImpl( + DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, + null, + Annotations.EMPTY, + Modality.FINAL, + Visibilities.PUBLIC, + setMethod != null, + name, + CallableMemberDescriptor.Kind.SYNTHESIZED, + SourceElement.NO_SOURCE/*TODO?*/ + ) { + init { + setType(type, emptyList(), null, receiverType) + + val getter = PropertyGetterDescriptorImpl(this, + Annotations.EMPTY, + Modality.FINAL, + Visibilities.PUBLIC, + false, + false, + CallableMemberDescriptor.Kind.SYNTHESIZED, + null, + SourceElement.NO_SOURCE/*TODO*/) + getter.initialize(null) + + val setter = if (setMethod != null) + PropertySetterDescriptorImpl(this, + Annotations.EMPTY, + Modality.FINAL, + Visibilities.PUBLIC, + false, + false, + CallableMemberDescriptor.Kind.SYNTHESIZED, + null, + SourceElement.NO_SOURCE/*TODO*/) + else + null + setter?.initializeDefault() + + initialize(getter, setter) + } + } +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index ce0d4a0f67a..32555451aa8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -39,7 +39,7 @@ public trait CallableDescriptorCollector { public fun getStaticMembersByName(receiver: JetType, name: Name, bindingTrace: BindingTrace): Collection - public fun getExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection + public fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection } private fun CallableDescriptorCollector.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) } @@ -97,7 +97,7 @@ private object FunctionCollector : CallableDescriptorCollector { + override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { val functions = scope.getFunctions(name) val (extensions, nonExtensions) = functions.partition { it.getExtensionReceiverParameter() != null } @@ -151,9 +151,9 @@ private object VariableCollector : CallableDescriptorCollector { + override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { // property may have an extension function type, we check the applicability later to avoid an early computing of deferred types - return (listOf(scope.getLocalVariable(name)) + scope.getProperties(name)).filterNotNull() + return (listOf(scope.getLocalVariable(name)) + scope.getProperties(name) + scope.getSyntheticExtensionProperties(receiver, name)).filterNotNull() } override fun toString() = "VARIABLES" @@ -175,8 +175,8 @@ private object PropertyCollector : CallableDescriptorCollector { - return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, bindingTrace)) + override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { + return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, receiver, bindingTrace)) } override fun toString() = "PROPERTIES" @@ -197,8 +197,8 @@ private fun CallableDescriptorCollector.filtered(fil return delegate.getStaticMembersByName(receiver, name, bindingTrace).filter(filter) } - override fun getExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection { - return delegate.getExtensionsByName(scope, name, bindingTrace).filter(filter) + override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { + return delegate.getExtensionsByName(scope, name, receiver, bindingTrace).filter(filter) } override fun toString(): String { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index 1c7ae65a94e..e6b8ead5a3c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -164,7 +164,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { convertWithImpliedThis( c.scope, explicitReceiver, - callableDescriptorCollector.getExtensionsByName(c.scope, c.name, c.context.trace), + callableDescriptorCollector.getExtensionsByName(c.scope, c.name, explicitReceiver.getType(), c.context.trace), createKind(EXTENSION_RECEIVER, isExplicit), c.context.call ) @@ -237,7 +237,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { ) { c.result.addCandidates { val memberExtensions = - callableDescriptorCollector.getExtensionsByName(dispatchReceiver.getType().getMemberScope(), c.name, c.context.trace) + callableDescriptorCollector.getExtensionsByName(dispatchReceiver.getType().getMemberScope(), c.name, receiverParameter.getType(), c.context.trace) convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter, receiverKind, c.context.call) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index 0142950ccc8..eb376226710 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -223,8 +223,8 @@ public fun DeclarationDescriptor.isDynamic(): Boolean { } class CollectorForDynamicReceivers(val delegate: CallableDescriptorCollector) : CallableDescriptorCollector by delegate { - override fun getExtensionsByName(scope: JetScope, name: Name, bindingTrace: BindingTrace): Collection { - return delegate.getExtensionsByName(scope, name, bindingTrace).filter { + override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { + return delegate.getExtensionsByName(scope, name, receiver, bindingTrace).filter { it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false } } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt new file mode 100644 index 00000000000..1b924922c87 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt @@ -0,0 +1,31 @@ +// FILE: KotlinFile.kt +open class KotlinClass1 : JavaClass1() { + fun getSomethingKotlin1(): Int = 1 +} + +class KotlinClass2 : JavaClass2() { + fun getSomethingKotlin2(): Int = 1 +} + +fun foo(k: KotlinClass2) { + useInt(k.getSomething1()) + useInt(k.something1) + useInt(k.getSomething2()) + useInt(k.something2) + useInt(k.getSomethingKotlin1()) + useInt(k.getSomethingKotlin2()) + k.somethingKotlin1 + k.somethingKotlin2 +} + +fun useInt(i: Int) {} + +// FILE: JavaClass1.java +public class JavaClass1 { + public int getSomething1() { return 1; } +} + +// FILE: JavaClass2.java +public class JavaClass2 extends KotlinClass1 { + public int getSomething2() { return 1; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt new file mode 100644 index 00000000000..51a80c0f2d6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt @@ -0,0 +1,42 @@ +package + +internal fun foo(/*0*/ k: KotlinClass2): kotlin.Unit +internal fun useInt(/*0*/ i: kotlin.Int): kotlin.Unit + +public open class JavaClass1 { + public constructor JavaClass1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class JavaClass2 : KotlinClass1 { + public constructor JavaClass2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int + public open fun getSomething2(): kotlin.Int + internal final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal open class KotlinClass1 : JavaClass1 { + public constructor KotlinClass1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int + internal final fun getSomethingKotlin1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class KotlinClass2 : JavaClass2 { + public constructor KotlinClass2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun getSomething2(): kotlin.Int + internal final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int + internal final fun getSomethingKotlin2(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.kt new file mode 100644 index 00000000000..07e822a3ee7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.kt @@ -0,0 +1,6 @@ +// FILE: KotlinFile.kt +import java.io.File + +fun foo(file: File) { + file.absolutePath.length() +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.txt new file mode 100644 index 00000000000..736b22b85f4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.txt @@ -0,0 +1,3 @@ +package + +internal fun foo(/*0*/ file: java.io.File): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt new file mode 100644 index 00000000000..c822e42778b --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt @@ -0,0 +1,14 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something1 + javaClass.something2 + javaClass.somethingStatic +} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething1(int p) { return p; } + public T getSomething2() { return null; } + + public static int getSomethingStatic() { return 1; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt new file mode 100644 index 00000000000..e4ef1a33e60 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt @@ -0,0 +1,15 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething1(/*0*/ p: kotlin.Int): kotlin.Int + public open fun getSomething2(): T! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun getSomethingStatic(): kotlin.Int +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt new file mode 100644 index 00000000000..d82f34ef121 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt @@ -0,0 +1,26 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something1++ + javaClass.something2++ + javaClass.something3++ + javaClass.something4++ + javaClass.something5++ +} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething1() { return 1; } + public void setSomething1(int value, char c) { } + + public int getSomething2() { return 1; } + public void setSomething2(String value) { } + + public int getSomething3() { return 1; } + public int setSomething3(int value) { return value; } + + public int getSomething4() { return 1; } + public void setSomething4(int value) { return value; } + + public int getSomething5() { return 1; } + public static void setSomething5(int value) { } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt new file mode 100644 index 00000000000..8b6a8a97784 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt @@ -0,0 +1,22 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething1(): kotlin.Int + public open fun getSomething2(): kotlin.Int + public open fun getSomething3(): kotlin.Int + public open fun getSomething4(): kotlin.Int + public open fun getSomething5(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething1(/*0*/ value: kotlin.Int, /*1*/ c: kotlin.Char): kotlin.Unit + public open fun setSomething2(/*0*/ value: kotlin.String!): kotlin.Unit + public open fun setSomething3(/*0*/ value: kotlin.Int): kotlin.Int + public open fun setSomething4(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun setSomething5(/*0*/ value: kotlin.Int): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt new file mode 100644 index 00000000000..71a600c59a2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt @@ -0,0 +1,10 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something += "x" +} + +// FILE: JavaClass.java +public class JavaClass { + public T getSomething() { return null; } + public void setSomething(T value) { } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.txt new file mode 100644 index 00000000000..7f43ca97e8a --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.txt @@ -0,0 +1,12 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): T! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: T!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt new file mode 100644 index 00000000000..27eb7ad4cb2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt @@ -0,0 +1,20 @@ +// FILE: KotlinFile.kt +class KotlinClass { + fun getSomething(): Int = 1 +} + +fun foo(javaClass: JavaClass, kotlinClass: KotlinClass) { + useInt(javaClass.getSomething()) + useInt(javaClass.something) + javaClass.something = 1 + javaClass.Something + useInt(kotlinClass.getSomething()) + kotlinClass.something +} + +fun useInt(i: Int) {} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething() { return 1; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt new file mode 100644 index 00000000000..73feaeb7466 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt @@ -0,0 +1,20 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass, /*1*/ kotlinClass: KotlinClass): kotlin.Unit +internal fun useInt(/*0*/ i: kotlin.Int): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal final class KotlinClass { + public constructor KotlinClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.kt new file mode 100644 index 00000000000..c26c6947cd1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.kt @@ -0,0 +1,10 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something++ +} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething() { return 1; } + public void setSomething(int value) { } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.txt new file mode 100644 index 00000000000..b45913cb221 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.txt @@ -0,0 +1,12 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.kt new file mode 100644 index 00000000000..f8aa9d9af1c --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.kt @@ -0,0 +1,12 @@ +// FILE: KotlinFile.kt +fun JavaClass.foo() { + useInt(getSomething()) + useInt(something) +} + +fun useInt(i: Int) {} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething() { return 1; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.txt new file mode 100644 index 00000000000..31708c4748a --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.txt @@ -0,0 +1,12 @@ +package + +internal fun useInt(/*0*/ i: kotlin.Int): kotlin.Unit +internal fun JavaClass.foo(): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt new file mode 100644 index 00000000000..9bcc925eb27 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt @@ -0,0 +1,18 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.somethingPublic + javaClass.somethingProtected + javaClass.somethingPrivate + javaClass.somethingPackage + javaClass.somethingPublic = 1 +} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomethingPublic() { return 1; } + protected int getSomethingProtected() { return 1; } + private int getSomethingPrivate() { return 1; } + int getSomethingPackage() { return 1; } + + protected void setSomethingPublic(int value) {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.txt new file mode 100644 index 00000000000..cbb81bad348 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.txt @@ -0,0 +1,15 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun getSomethingPackage(): kotlin.Int + private open fun getSomethingPrivate(): kotlin.Int + protected/*protected and package*/ open fun getSomethingProtected(): kotlin.Int + public open fun getSomethingPublic(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + protected/*protected and package*/ open fun setSomethingPublic(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt new file mode 100644 index 00000000000..9d3bef5eabe --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt @@ -0,0 +1,9 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something = 1 +} + +// FILE: JavaClass.java +public class JavaClass { + public void setSomething(int value) { } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.txt new file mode 100644 index 00000000000..f22704ef214 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.txt @@ -0,0 +1,11 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 1fc9afd337e..7b4f1987491 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14002,6 +14002,75 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { } } + @TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SyntheticExtensions extends AbstractJetDiagnosticsTest { + public void testAllFilesPresentInSyntheticExtensions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("Bases.kt") + public void testBases() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt"); + doTest(fileName); + } + + @TestMetadata("CompiledClass.kt") + public void testCompiledClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/CompiledClass.kt"); + doTest(fileName); + } + + @TestMetadata("FalseGetters.kt") + public void testFalseGetters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt"); + doTest(fileName); + } + + @TestMetadata("FalseSetters.kt") + public void testFalseSetters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt"); + doTest(fileName); + } + + @TestMetadata("GenericClass.kt") + public void testGenericClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt"); + doTest(fileName); + } + + @TestMetadata("Getter.kt") + public void testGetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt"); + doTest(fileName); + } + + @TestMetadata("GetterAndSetter.kt") + public void testGetterAndSetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/GetterAndSetter.kt"); + doTest(fileName); + } + + @TestMetadata("ImplicitReceiver.kt") + public void testImplicitReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/ImplicitReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("OnlyPublic.kt") + public void testOnlyPublic() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt"); + doTest(fileName); + } + + @TestMetadata("SetterOnly.kt") + public void testSetterOnly() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 08754b9fc0a468747c25d8a7f525faee0a955b93 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 15:07:16 +0300 Subject: [PATCH 295/450] Support for synthetic extensions in codegen --- .../kotlin/codegen/ExpressionCodegen.java | 33 +++++++++++++++---- .../jetbrains/kotlin/codegen/StackValue.java | 6 ++-- .../syntheticExtensions/getter.java | 3 ++ .../syntheticExtensions/getter.kt | 3 ++ .../syntheticExtensions/implicitReceiver.java | 11 +++++++ .../syntheticExtensions/implicitReceiver.kt | 8 +++++ .../syntheticExtensions/plusPlus.java | 11 +++++++ .../syntheticExtensions/plusPlus.kt | 5 +++ .../syntheticExtensions/setter.java | 11 +++++++ .../syntheticExtensions/setter.kt | 5 +++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 33 +++++++++++++++++++ 11 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.kt create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 0596f41ee19..4a8052ef1e8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -76,6 +76,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.scopes.receivers.*; +import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; @@ -2144,6 +2145,10 @@ public class ExpressionCodegen extends JetVisitor implem @NotNull MethodKind methodKind, StackValue receiver ) { + if (propertyDescriptor instanceof SyntheticExtensionPropertyDescriptor) { + return intermediateValueForSyntheticExtensionProperty((SyntheticExtensionPropertyDescriptor) propertyDescriptor, receiver); + } + DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration(); boolean isBackingFieldInAnotherClass = AsmUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor); @@ -2166,10 +2171,12 @@ public class ExpressionCodegen extends JetVisitor implem if (isBackingFieldInAnotherClass && forceField) { backingFieldContext = context.findParentContextWithDescriptor(containingDeclaration.getContainingDeclaration()); int flags = AsmUtil.getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegatedProperty); - skipPropertyAccessors = (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER; + skipPropertyAccessors = + (flags & ACC_PRIVATE) == 0 || methodKind == MethodKind.SYNTHETIC_ACCESSOR || methodKind == MethodKind.INITIALIZER; if (!skipPropertyAccessors) { propertyDescriptor = (PropertyDescriptor) backingFieldContext.getAccessor(propertyDescriptor, true, delegateType); - changeOwnerOnTypeMapping = changeOwnerOnTypeMapping && !(propertyDescriptor instanceof AccessorForPropertyBackingFieldInOuterClass); + changeOwnerOnTypeMapping = + changeOwnerOnTypeMapping && !(propertyDescriptor instanceof AccessorForPropertyBackingFieldInOuterClass); } } @@ -2191,7 +2198,8 @@ public class ExpressionCodegen extends JetVisitor implem PropertyGetterDescriptor getter = propertyDescriptor.getGetter(); if (getter != null) { - callableGetter = typeMapper.mapToCallableMethod(getter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context); + callableGetter = + typeMapper.mapToCallableMethod(getter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context); } } @@ -2202,14 +2210,16 @@ public class ExpressionCodegen extends JetVisitor implem callableSetter = null; } else { - callableSetter = typeMapper.mapToCallableMethod(setter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context); + callableSetter = + typeMapper.mapToCallableMethod(setter, isSuper || MethodKind.SYNTHETIC_ACCESSOR == methodKind, context); } } } } propertyDescriptor = DescriptorUtils.unwrapFakeOverride(propertyDescriptor); - Type backingFieldOwner = typeMapper.mapOwner(changeOwnerOnTypeMapping ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor, + Type backingFieldOwner = + typeMapper.mapOwner(changeOwnerOnTypeMapping ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor, isCallInsideSameModuleAsDeclared(propertyDescriptor, context, state.getOutDirectory())); String fieldName; @@ -2226,9 +2236,18 @@ public class ExpressionCodegen extends JetVisitor implem } return StackValue.property(propertyDescriptor, backingFieldOwner, - typeMapper.mapType(isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()), - isStaticBackingField, fieldName, callableGetter, callableSetter, state, receiver); + typeMapper.mapType( + isDelegatedProperty && forceField ? delegateType : propertyDescriptor.getOriginal().getType()), + isStaticBackingField, fieldName, callableGetter, callableSetter, state, receiver); + } + @NotNull + private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticExtensionPropertyDescriptor propertyDescriptor, StackValue receiver) { + Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType()); + CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context); + FunctionDescriptor setMethod = propertyDescriptor.getSetMethod(); + CallableMethod callableSetter = setMethod != null ? typeMapper.mapToCallableMethod(setMethod, false, context) : null; + return StackValue.property(propertyDescriptor, null, type, false, null, callableGetter, callableSetter, state, receiver); } @Override diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index 025dc639989..517fde5f1ba 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -248,7 +248,7 @@ public abstract class StackValue { @NotNull public static Property property( @NotNull PropertyDescriptor descriptor, - @NotNull Type backingFieldOwner, + @Nullable Type backingFieldOwner, @NotNull Type type, boolean isStaticBackingField, @Nullable String fieldName, @@ -989,7 +989,7 @@ public abstract class StackValue { private final String fieldName; public Property( - @NotNull PropertyDescriptor descriptor, @NotNull Type backingFieldOwner, + @NotNull PropertyDescriptor descriptor, @Nullable Type backingFieldOwner, @Nullable CallableMethod getter, @Nullable CallableMethod setter, boolean isStaticBackingField, @Nullable String fieldName, @NotNull Type type, @NotNull GenerationState state, @NotNull StackValue receiver @@ -1007,6 +1007,7 @@ public abstract class StackValue { public void putSelector(@NotNull Type type, @NotNull InstructionAdapter v) { if (getter == null) { assert fieldName != null : "Property should have either a getter or a field name: " + descriptor; + assert backingFieldOwner != null : "Property should have either a getter or a backingFieldOwner: " + descriptor; v.visitFieldInsn(isStaticPut ? GETSTATIC : GETFIELD, backingFieldOwner.getInternalName(), fieldName, this.type.getDescriptor()); genNotNullAssertionForField(v, state, descriptor); coerceTo(type, v); @@ -1022,6 +1023,7 @@ public abstract class StackValue { coerceFrom(topOfStackType, v); if (setter == null) { assert fieldName != null : "Property should have either a setter or a field name: " + descriptor; + assert backingFieldOwner != null : "Property should have either a setter or a backingFieldOwner: " + descriptor; v.visitFieldInsn(isStaticStore ? PUTSTATIC : PUTFIELD, backingFieldOwner.getInternalName(), fieldName, this.type.getDescriptor()); } else { diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.java new file mode 100644 index 00000000000..a28f5ff490d --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.java @@ -0,0 +1,3 @@ +class JavaClass { + public String getOk() { return "OK"; } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt new file mode 100644 index 00000000000..de99f3e9890 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt @@ -0,0 +1,3 @@ +fun box(): String { + return JavaClass().ok +} diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.java new file mode 100644 index 00000000000..48b5ecade7b --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.java @@ -0,0 +1,11 @@ +class JavaClass { + private String myX; + + public String getX() { + return myX; + } + + public void setX(String x) { + myX = x; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.kt new file mode 100644 index 00000000000..b815079a31d --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.kt @@ -0,0 +1,8 @@ +fun box(): String { + return JavaClass().doIt() +} + +fun JavaClass.doIt(): String { + x = "OK" + return x +} diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.java new file mode 100644 index 00000000000..0b0e9b587ca --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.java @@ -0,0 +1,11 @@ +class JavaClass { + private int myX = 0; + + public int getX() { + return myX; + } + + public void setX(int x) { + myX = x; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt new file mode 100644 index 00000000000..4f9f39e43d2 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt @@ -0,0 +1,5 @@ +fun box(): String { + val javaClass = JavaClass() + javaClass.x++ + return if (javaClass.x == 1) "OK" else "ERROR" +} diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.java new file mode 100644 index 00000000000..48b5ecade7b --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.java @@ -0,0 +1,11 @@ +class JavaClass { + private String myX; + + public String getX() { + return myX; + } + + public void setX(String x) { + myX = x; + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt new file mode 100644 index 00000000000..1be9b657a1b --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt @@ -0,0 +1,5 @@ +fun box(): String { + val javaClass = JavaClass() + javaClass.x = "OK" + return javaClass.x +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java index 91cad226b8d..040a22f3ef9 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -827,6 +827,39 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod } } + @TestMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class SyntheticExtensions extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInSyntheticExtensions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("getter.kt") + public void testGetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt"); + doTestAgainstJava(fileName); + } + + @TestMetadata("implicitReceiver.kt") + public void testImplicitReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/implicitReceiver.kt"); + doTestAgainstJava(fileName); + } + + @TestMetadata("plusPlus.kt") + public void testPlusPlus() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt"); + doTestAgainstJava(fileName); + } + + @TestMetadata("setter.kt") + public void testSetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/setter.kt"); + doTestAgainstJava(fileName); + } + } + @TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 17442617bb045c60ec4ad230be8ba215b9d8560a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 18:49:52 +0300 Subject: [PATCH 296/450] Synthetic extensions suggested in completion --- compiler/frontend.java/frontend.java.iml | 1 + .../synthetic/SyntheticExtensionsScope.kt | 48 ++++++++++++++---- .../kotlin/resolve/AllUnderImportsScope.kt | 4 ++ .../kotlin/resolve/SingleImportScope.kt | 14 +----- .../kotlin/resolve/lazy/LazyImportScope.kt | 11 ++++ .../descriptors/AbstractLazyMemberScope.kt | 11 +--- .../lazy/descriptors/LazyJavaMemberScope.kt | 8 +-- .../resolve/scopes/AbstractScopeAdapter.kt | 4 ++ .../kotlin/resolve/scopes/ChainedScope.kt | 11 ++-- .../resolve/scopes/ExplicitImportsScope.kt | 12 +---- .../kotlin/resolve/scopes/FilteringScope.kt | 2 + .../kotlin/resolve/scopes/JetScope.kt | 2 + .../kotlin/resolve/scopes/JetScopeImpl.kt | 2 + .../scopes/StaticScopeForKotlinClass.kt | 8 +-- .../resolve/scopes/SubstitutingScope.kt | 2 + .../jetbrains/kotlin/types/ErrorUtils.java | 12 +++++ .../descriptors/DeserializedMemberScope.kt | 12 +---- .../codeInsight/ReferenceVariantsHelper.kt | 50 +++++++++++-------- .../idea/completion/LookupElementFactory.kt | 20 +++++--- .../basic/common/extensions/Extensions.kt | 3 ++ .../common/extensions/SyntheticExtensions1.kt | 7 +++ .../common/extensions/SyntheticExtensions2.kt | 7 +++ .../handlers/basic/SyntheticExtension.kt | 7 +++ .../basic/SyntheticExtension.kt.after | 7 +++ .../test/JSBasicCompletionTestGenerated.java | 12 +++++ .../test/JvmBasicCompletionTestGenerated.java | 12 +++++ .../BasicCompletionHandlerTestGenerated.java | 6 +++ 27 files changed, 196 insertions(+), 99 deletions(-) create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt create mode 100644 idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt create mode 100644 idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt.after diff --git a/compiler/frontend.java/frontend.java.iml b/compiler/frontend.java/frontend.java.iml index 6f37b7eda52..57f41bf2a78 100644 --- a/compiler/frontend.java/frontend.java.iml +++ b/compiler/frontend.java/frontend.java.iml @@ -13,5 +13,6 @@ + \ No newline at end of file diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index a0a8791600b..2a630a13a48 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -31,6 +31,8 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.utils.addIfNotNull +import java.util.* interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor @@ -50,12 +52,12 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet private fun syntheticPropertyInClass(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { val memberScope = javaClass.getMemberScope(type.getArguments()) - val getMethod = memberScope.getFunctions(name.toGetMethodName()).singleOrNull { + val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { it.getValueParameters().isEmpty() && it.getTypeParameters().isEmpty() && it.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? } ?: return null val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(name.toSetMethodName()).singleOrNull { + val setMethod = memberScope.getFunctions(toSetMethodName(name)).singleOrNull { it.getValueParameters().singleOrNull()?.getType() == propertyType && it.getTypeParameters().isEmpty() && it.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false @@ -68,10 +70,10 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { if (name.isSpecial()) return emptyList() if (name.getIdentifier()[0].isUpperCase()) return emptyList() - return collectSyntheticProperties(null, receiverType, name) ?: emptyList() + return collectSyntheticPropertiesByName(null, receiverType, name) ?: emptyList() } - private fun collectSyntheticProperties(result: SmartList?, type: JetType, name: Name): SmartList? { + private fun collectSyntheticPropertiesByName(result: SmartList?, type: JetType, name: Name): SmartList? { @suppress("NAME_SHADOWING") var result = result @@ -81,11 +83,32 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet result = result.add(syntheticPropertyInClass(Triple(classifier, type, name))) } - typeConstructor.getSupertypes().forEach { result = collectSyntheticProperties(result, it, name) } + typeConstructor.getSupertypes().forEach { result = collectSyntheticPropertiesByName(result, it, name) } return result } + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + val result = ArrayList() + result.collectSyntheticProperties(receiverType) + return result + } + + private fun MutableList.collectSyntheticProperties(type: JetType) { + val typeConstructor = type.getConstructor() + val classifier = typeConstructor.getDeclarationDescriptor() + if (classifier is JavaClassDescriptor) { + for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { + if (descriptor is FunctionDescriptor) { + val propertyName = fromGetMethodName(descriptor.getName()) ?: continue + addIfNotNull(syntheticPropertyInClass(classifier, type, propertyName)) + } + } + } + + typeConstructor.getSupertypes().forEach { collectSyntheticProperties(it) } + } + private fun SmartList?.add(property: PropertyDescriptor?): SmartList? { if (property == null) return this val list = if (this != null) this else SmartList() @@ -96,12 +119,19 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet //TODO: "is"? //TODO: methods like "getURL"? //TODO: reuse code with generation? - private fun Name.toGetMethodName(): Name { - return Name.identifier("get" + getIdentifier().capitalize()) + private fun toGetMethodName(propertyName: Name): Name { + return Name.identifier("get" + propertyName.getIdentifier().capitalize()) } - private fun Name.toSetMethodName(): Name { - return Name.identifier("set" + getIdentifier().capitalize()) + private fun toSetMethodName(propertyName: Name): Name { + return Name.identifier("set" + propertyName.getIdentifier().capitalize()) + } + + private fun fromGetMethodName(methodName: Name): Name? { + if (methodName.isSpecial()) return null + val identifier = methodName.getIdentifier() + if (!identifier.startsWith("get")) return null + return Name.identifier(identifier.removePrefix("get").decapitalize()) } private class MyPropertyDescriptor( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index 3e653a4432a..94a9868fae2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -57,6 +57,10 @@ class AllUnderImportsScope : JetScope { return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType, name) } } + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType) } + } + override fun getPackage(name: Name): PackageViewDescriptor? = null // packages are not imported by all under imports override fun getLocalVariable(name: Name): VariableDescriptor? = null diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt index 0dded31f58a..6b84617d723 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/SingleImportScope.kt @@ -19,11 +19,11 @@ package org.jetbrains.kotlin.resolve import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer -class SingleImportScope(private val aliasName: Name, private val descriptors: Collection) : JetScope { +class SingleImportScope(private val aliasName: Name, private val descriptors: Collection) : JetScopeImpl() { override fun getClassifier(name: Name) = if (name == aliasName) descriptors.filterIsInstance().singleOrNull() else null @@ -36,20 +36,10 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co override fun getFunctions(name: Name) = if (name == aliasName) descriptors.filterIsInstance() else emptyList() - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = emptyList() - - override fun getLocalVariable(name: Name): VariableDescriptor? = null - override fun getContainingDeclaration(): DeclarationDescriptor = throw UnsupportedOperationException() - override fun getDeclarationsByLabel(labelName: Name): Collection = emptyList() - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = descriptors - override fun getImplicitReceiversHierarchy(): List = emptyList() - - override fun getOwnDeclaredDescriptors(): Collection = emptyList() - override fun printScopeStructure(p: Printer) { p.println(javaClass.getSimpleName(), ": ", aliasName) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index d3a9b7fdfa3..903d61c4e9e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -260,6 +260,17 @@ class LazyImportScope( return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverType, name) } } + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway + if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() + + return importResolver.resolveSession.getStorageManager().compute { + importResolver.indexedImports.imports.flatMapTo(LinkedHashSet()) { import -> + importResolver.getImportScope(import, LookupMode.EVERYTHING).getSyntheticExtensionProperties(receiverType) + } + } + } + override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt index fd3e126ac8a..d6fe4b51cbf 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/AbstractLazyMemberScope.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.lazy.data.JetScriptInfo import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProvider import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType @@ -41,7 +42,7 @@ protected constructor( protected val declarationProvider: DP, protected val thisDescriptor: D, protected val trace: BindingTrace -) : JetScope { +) : JetScopeImpl() { protected val storageManager: StorageManager = c.storageManager private val classDescriptors: MemoizedFunctionToNotNull> = storageManager.createMemoizedFunction { resolveClassDescriptor(it) } @@ -111,12 +112,6 @@ protected constructor( protected abstract fun getNonDeclaredProperties(name: Name, result: MutableSet) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() - - override fun getLocalVariable(name: Name): VariableDescriptor? = null - - override fun getDeclarationsByLabel(labelName: Name) = setOf() - protected fun computeDescriptorsFromDeclaredElements(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): List { val declarations = declarationProvider.getDeclarations(kindFilter, nameFilter) @@ -163,8 +158,6 @@ protected constructor( return result.toReadOnlyList() } - override fun getImplicitReceiversHierarchy() = listOf() - // Do not change this, override in concrete subclasses: // it is very easy to compromise laziness of this class, and fail all the debugging // a generic implementation can't do this properly diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt index e82897671a4..0628b88ac3f 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaMemberScope.kt @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES import org.jetbrains.kotlin.resolve.scopes.DescriptorKindExclude.NonExtensions import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.storage.NotNullLazyValue import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils @@ -51,7 +52,7 @@ import java.util.LinkedHashSet public abstract class LazyJavaMemberScope( protected val c: LazyJavaResolverContext, private val containingDeclaration: DeclarationDescriptor -) : JetScope { +) : JetScopeImpl() { // this lazy value is not used at all in LazyPackageFragmentScopeForJavaPackage because we do not use caching there // but is placed in the base class to not duplicate code private val allDescriptors = c.storageManager.createRecursionTolerantLazyValue>( @@ -297,11 +298,6 @@ public abstract class LazyJavaMemberScope( override fun getProperties(name: Name): Collection = properties(name) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() - - override fun getLocalVariable(name: Name): VariableDescriptor? = null - override fun getDeclarationsByLabel(labelName: Name) = listOf() - override fun getOwnDeclaredDescriptors() = getDescriptors() override fun getDescriptors(kindFilter: DescriptorKindFilter, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index 98f4032841d..aee4d5f6423 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -51,6 +51,10 @@ public abstract class AbstractScopeAdapter : JetScope { return workerScope.getSyntheticExtensionProperties(receiverType, name) } + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + return workerScope.getSyntheticExtensionProperties(receiverType) + } + override fun getLocalVariable(name: Name): VariableDescriptor? { return workerScope.getLocalVariable(name) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index 0a270366fdb..7d1319fbeb4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -68,6 +68,9 @@ public open class ChainedScope( override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType, name) } + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection + = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType) } + override fun getImplicitReceiversHierarchy(): List { if (implicitReceiverHierarchy == null) { val result = ArrayList() @@ -82,12 +85,8 @@ public open class ChainedScope( override fun getDeclarationsByLabel(labelName: Name) = scopeChain.flatMap { it.getDeclarationsByLabel(labelName) } - override fun getDescriptors(kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean): Collection { - val result = LinkedHashSet() - scopeChain.flatMapTo(result) { it.getDescriptors(kindFilter, nameFilter) } - return result - } + override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) + = getFromAllScopes { it.getDescriptors(kindFilter, nameFilter) } override fun getOwnDeclaredDescriptors(): Collection { throw UnsupportedOperationException() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt index b2e6067b031..55dadbd0179 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ExplicitImportsScope.kt @@ -22,29 +22,19 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -public class ExplicitImportsScope(private val descriptors: Collection) : JetScope { +public class ExplicitImportsScope(private val descriptors: Collection) : JetScopeImpl() { override fun getClassifier(name: Name) = descriptors.filter { it.getName() == name }.firstIsInstanceOrNull() override fun getPackage(name: Name)= descriptors.filter { it.getName() == name }.firstIsInstanceOrNull() override fun getProperties(name: Name) = descriptors.filter { it.getName() == name }.filterIsInstance() - override fun getLocalVariable(name: Name): VariableDescriptor? = null - override fun getFunctions(name: Name) = descriptors.filter { it.getName() == name }.filterIsInstance() - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() - override fun getContainingDeclaration() = throw UnsupportedOperationException() - override fun getDeclarationsByLabel(labelName: Name) = emptyList() - override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean) = descriptors - override fun getImplicitReceiversHierarchy() = emptyList() - - override fun getOwnDeclaredDescriptors() = emptyList() - override fun printScopeStructure(p: Printer) { p.println(javaClass.getName()) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index 313181b5638..650c8ff0f8c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -38,6 +38,8 @@ public class FilteringScope(private val workerScope: JetScope, private val predi override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = workerScope.getSyntheticExtensionProperties(receiverType, name).filter(predicate) + override fun getSyntheticExtensionProperties(receiverType: JetType) = workerScope.getSyntheticExtensionProperties(receiverType).filter(predicate) + override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name)) override fun getDescriptors(kindFilter: DescriptorKindFilter, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index a6ba0850059..d2ddc74eca1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -37,6 +37,8 @@ public trait JetScope { public fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + public fun getSyntheticExtensionProperties(receiverType: JetType): Collection + public fun getContainingDeclaration(): DeclarationDescriptor public fun getDeclarationsByLabel(labelName: Name): Collection diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt index 3761435f6f0..011ed035050 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt @@ -34,6 +34,8 @@ public abstract class JetScopeImpl : JetScope { override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = listOf() + override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() override fun getDescriptors(kindFilter: DescriptorKindFilter, diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt index d53d46cf158..cfe0ea28415 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/StaticScopeForKotlinClass.kt @@ -27,7 +27,7 @@ import kotlin.properties.Delegates public class StaticScopeForKotlinClass( private val containingClass: ClassDescriptor -) : JetScope { +) : JetScopeImpl() { override fun getClassifier(name: Name) = null // TODO private val functions: List by Delegates.lazy { @@ -46,13 +46,7 @@ public class StaticScopeForKotlinClass( override fun getFunctions(name: Name) = functions.filterTo(ArrayList(2)) { it.getName() == name } - override fun getPackage(name: Name) = null - override fun getProperties(name: Name) = listOf() - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() - override fun getLocalVariable(name: Name) = null override fun getContainingDeclaration() = containingClass - override fun getDeclarationsByLabel(labelName: Name) = listOf() - override fun getImplicitReceiversHierarchy() = listOf() override fun printScopeStructure(p: Printer) { p.println("Static scope for $containingClass") diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 19bc67d6cb6..2d53c9f2ad9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -71,6 +71,8 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = substitute(workerScope.getSyntheticExtensionProperties(receiverType, name)) + override fun getSyntheticExtensionProperties(receiverType: JetType) = substitute(workerScope.getSyntheticExtensionProperties(receiverType)) + override fun getPackage(name: Name) = workerScope.getPackage(name) override fun getImplicitReceiversHierarchy(): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 320058f54b3..6c0716e61dc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -99,6 +99,12 @@ public class ErrorUtils { return ERROR_PROPERTY_GROUP; } + @NotNull + @Override + public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + return ERROR_PROPERTY_GROUP; + } + @Override public VariableDescriptor getLocalVariable(@NotNull Name name) { return ERROR_PROPERTY; @@ -209,6 +215,12 @@ public class ErrorUtils { throw new IllegalStateException(); } + @NotNull + @Override + public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + throw new IllegalStateException(); + } + @NotNull @Override public DeclarationDescriptor getContainingDeclaration() { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt index 7ead7345cf7..f2cc98fdb0c 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberScope.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.serialization.deserialization.descriptors import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl import org.jetbrains.kotlin.serialization.Flags import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind @@ -34,7 +34,7 @@ import java.util.LinkedHashSet public abstract class DeserializedMemberScope protected constructor( protected val c: DeserializationContext, membersList: Collection -) : JetScope { +) : JetScopeImpl() { private data class ProtoKey(val name: Name, val kind: Kind, val isExtension: Boolean) private enum class Kind { FUNCTION, PROPERTY } @@ -112,16 +112,8 @@ public abstract class DeserializedMemberScope protected constructor( protected abstract fun addClassDescriptors(result: MutableCollection, nameFilter: (Name) -> Boolean) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = listOf() - - override fun getPackage(name: Name): PackageViewDescriptor? = null - - override fun getLocalVariable(name: Name): VariableDescriptor? = null - override fun getContainingDeclaration() = c.containingDeclaration - override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() - protected fun computeDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection { //NOTE: descriptors should be in the same order they were serialized in diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 83fbe3443b2..96032f7e66f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -88,6 +88,8 @@ public class ReferenceVariantsHelper( val descriptors = LinkedHashSet() + val dataFlowInfo = context.getDataFlowInfo(expression) + val pair = getExplicitReceiverData(expression) if (pair != null) { val (receiverExpression, callType) = pair @@ -104,25 +106,17 @@ public class ReferenceVariantsHelper( context.getType(receiverExpression) if (expressionType != null && !expressionType.isError()) { val receiverValue = ExpressionReceiver(receiverExpression, expressionType) - val dataFlowInfo = context.getDataFlowInfo(expression) - - for (variant in SmartCastUtils.getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo)) { - descriptors.addMembersFromReceiver(variant, callType, kindFilter, nameFilter) - } + descriptors.addMembersFromReceiverAndSyntheticExtensions(receiverValue, callType, kindFilter, nameFilter, resolutionScope, dataFlowInfo) descriptors.addCallableExtensions(resolutionScope, receiverValue, dataFlowInfo, callType, kindFilter, nameFilter) } } else { - val dataFlowInfo = context.getDataFlowInfo(expression) - // process instance members that can be called via implicit receiver's instances val receivers = resolutionScope.getImplicitReceiversWithInstance() val receiverValues = receivers.map { it.getValue() } for (receiverValue in receiverValues) { - for (variant in SmartCastUtils.getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo)) { - descriptors.addMembersFromReceiver(variant, CallType.NORMAL, kindFilter, nameFilter) - } + descriptors.addMembersFromReceiverAndSyntheticExtensions(receiverValue, CallType.NORMAL, kindFilter, nameFilter, resolutionScope, dataFlowInfo) } // process extensions and non-instance members @@ -143,22 +137,36 @@ public class ReferenceVariantsHelper( return descriptors } - private fun MutableCollection.addMembersFromReceiver( - receiverType: JetType, + private fun MutableSet.addMembersFromReceiverAndSyntheticExtensions( + receiverValue: ReceiverValue, callType: CallType, kindFilter: DescriptorKindFilter, - nameFilter: (Name) -> Boolean + nameFilter: (Name) -> Boolean, + resolutionScope: JetScope, + dataFlowInfo: DataFlowInfo ) { - var memberFilter = kindFilter exclude DescriptorKindExclude.Extensions - val members = receiverType.getMemberScope().getDescriptorsFiltered(DescriptorKindFilter.ALL, nameFilter) // filter by kind later because of constructors - for (member in members) { - if (member is ClassDescriptor) { - if (member.isInner()) { - member.getConstructors().filterTo(this) { callType.canCall(it) && memberFilter.accepts(it) } + val memberFilter = kindFilter exclude DescriptorKindExclude.Extensions + val containingDeclaration = resolutionScope.getContainingDeclaration() + + for (receiverType in SmartCastUtils.getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo)) { + val members = receiverType.getMemberScope().getDescriptorsFiltered(DescriptorKindFilter.ALL, nameFilter) // filter by kind later because of constructors + for (member in members) { + if (member is ClassDescriptor) { + if (member.isInner()) { + member.getConstructors().filterTo(this) { callType.canCall(it) && memberFilter.accepts(it) } + } + } + else if (callType.canCall(member) && memberFilter.accepts(member)) { + this.add(member) } } - else if (callType.canCall(member) && memberFilter.accepts(member)) { - this.add(member) + + if (!kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) { + for (extension in resolutionScope.getSyntheticExtensionProperties(receiverType)) { + if (nameFilter(extension.getName()) && kindFilter.accepts(extension)) { + addAll(extension.substituteExtensionIfCallable(receiverValue, callType, context, dataFlowInfo, containingDeclaration)) + } + } } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 62e7260e9dd..7f2178a7dbb 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -217,16 +217,20 @@ public class LookupElementFactory( if (descriptor is CallableDescriptor) { if (descriptor.getExtensionReceiverParameter() != null) { - val container = descriptor.getContainingDeclaration() - val containerPresentation = if (container is ClassDescriptor) { - DescriptorUtils.getFqNameFromTopLevelClass(container).toString() - } - else { - DescriptorUtils.getFqName(container).toString() - } val originalReceiver = descriptor.getOriginal().getExtensionReceiverParameter()!! val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(originalReceiver.getType()) - element = element.appendTailText(" for $receiverPresentation in $containerPresentation", true) + element = element.appendTailText(" for $receiverPresentation", true) + + val container = descriptor.getContainingDeclaration() + val containerPresentation = if (container is ClassDescriptor) + DescriptorUtils.getFqNameFromTopLevelClass(container).toString() + else if (container is PackageFragmentDescriptor) + container.fqName.toString() + else + null + if (containerPresentation != null) { + element = element.appendTailText(" in $containerPresentation", true) + } } else { val container = descriptor.getContainingDeclaration() diff --git a/idea/idea-completion/testData/basic/common/extensions/Extensions.kt b/idea/idea-completion/testData/basic/common/extensions/Extensions.kt index 2da87f2994a..bc09d2cd9b9 100644 --- a/idea/idea-completion/testData/basic/common/extensions/Extensions.kt +++ b/idea/idea-completion/testData/basic/common/extensions/Extensions.kt @@ -3,6 +3,8 @@ package a.b class Some { inner class Inner { fun foo() { + fun String.localExtension() = 1 + "". } @@ -19,3 +21,4 @@ val String.extProp: Int get() = 1 // EXIST: { lookupString: "extProp", itemText: "extProp", tailText: " for String in a.b", typeText: "Int" } // EXIST: { lookupString: "memberExtFun", itemText: "memberExtFun", tailText: "() for String in Some.Inner", typeText: "Unit" } // EXIST: { lookupString: "memberExtProp", itemText: "memberExtProp", tailText: " for String in Some", typeText: "Int" } +// EXIST: { lookupString: "localExtension", itemText: "localExtension", tailText: "() for String", typeText: "Int" } diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt new file mode 100644 index 00000000000..568ab2a2869 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt @@ -0,0 +1,7 @@ +import java.io.File + +fun foo(file: File) { + file. +} + +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt new file mode 100644 index 00000000000..511ecc4b5bd --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -0,0 +1,7 @@ +import java.io.File + +fun File.foo() { + +} + +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } diff --git a/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt b/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt new file mode 100644 index 00000000000..a4f68a36f93 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt @@ -0,0 +1,7 @@ +import java.io.File + +fun foo(file: File) { + file.abs +} + +// ELEMENT: absolutePath diff --git a/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt.after b/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt.after new file mode 100644 index 00000000000..69f9eb2d9b1 --- /dev/null +++ b/idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt.after @@ -0,0 +1,7 @@ +import java.io.File + +fun foo(file: File) { + file.absolutePath +} + +// ELEMENT: absolutePath diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index f4c5eb64996..0b5a1a64a44 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1209,6 +1209,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("SyntheticExtensions1.kt") + public void testSyntheticExtensions1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); + doTest(fileName); + } + + @TestMetadata("SyntheticExtensions2.kt") + public void testSyntheticExtensions2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 3f3935b0f2b..c0771c4c166 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1209,6 +1209,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("SyntheticExtensions1.kt") + public void testSyntheticExtensions1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); + doTest(fileName); + } + + @TestMetadata("SyntheticExtensions2.kt") + public void testSyntheticExtensions2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java index e29bb1ea289..7f62698685d 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/handlers/BasicCompletionHandlerTestGenerated.java @@ -119,6 +119,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion doTest(fileName); } + @TestMetadata("SyntheticExtension.kt") + public void testSyntheticExtension() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/handlers/basic/SyntheticExtension.kt"); + doTest(fileName); + } + @TestMetadata("idea/idea-completion/testData/handlers/basic/exclChar") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 8bde9b098a81fab3d28911aab803bf1336777578 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 18:59:44 +0300 Subject: [PATCH 297/450] Code refactoring --- .../synthetic/SyntheticExtensionsScope.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 2a630a13a48..8e341708ee5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -52,21 +52,27 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet private fun syntheticPropertyInClass(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { val memberScope = javaClass.getMemberScope(type.getArguments()) - val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { - it.getValueParameters().isEmpty() && it.getTypeParameters().isEmpty() && it.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? - } ?: return null + val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(toSetMethodName(name)).singleOrNull { - it.getValueParameters().singleOrNull()?.getType() == propertyType - && it.getTypeParameters().isEmpty() - && it.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false - && it.getVisibility() == Visibilities.PUBLIC - } + val setMethod = memberScope.getFunctions(toSetMethodName(name)).singleOrNull { isGoodSetMethod(it, propertyType) } return MyPropertyDescriptor(javaClass, getMethod, setMethod, name, propertyType, type) } + private fun isGoodGetMethod(descriptor: FunctionDescriptor): Boolean { + return descriptor.getValueParameters().isEmpty() + && descriptor.getTypeParameters().isEmpty() + && descriptor.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? + } + + private fun isGoodSetMethod(descriptor: FunctionDescriptor, propertyType: JetType): Boolean { + return descriptor.getValueParameters().singleOrNull()?.getType() == propertyType + && descriptor.getTypeParameters().isEmpty() + && descriptor.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false + && descriptor.getVisibility() == Visibilities.PUBLIC + } + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { if (name.isSpecial()) return emptyList() if (name.getIdentifier()[0].isUpperCase()) return emptyList() From 16c4f5beddb921b132b2a51549c0c7226cf9252a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 19:37:46 +0300 Subject: [PATCH 298/450] Renamed a class --- .../org/jetbrains/kotlin/idea/completion/CompletionSorting.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt index 442c27c115b..6371f9ae533 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt @@ -51,7 +51,7 @@ public fun CompletionResultSet.addKotlinSorting(parameters: CompletionParameters sorter = sorter.weighBefore("kotlin.kind", NameSimilarityWeigher, SmartCompletionPriorityWeigher) } - sorter = sorter.weighAfter("stats", JetDeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile)) + sorter = sorter.weighAfter("stats", DeclarationRemotenessWeigher(parameters.getOriginalFile() as JetFile)) sorter = sorter.weighBefore("middleMatching", PreferMatchingItemWeigher) @@ -121,7 +121,7 @@ private object PreferMatchingItemWeigher : LookupElementWeigher("kotlin.preferMa } } -private class JetDeclarationRemotenessWeigher(private val file: JetFile) : LookupElementWeigher("kotlin.declarationRemoteness") { +private class DeclarationRemotenessWeigher(private val file: JetFile) : LookupElementWeigher("kotlin.declarationRemoteness") { private val importCache = ImportCache() private enum class Weight { From 434e3ab38b8236854a9f53c0b2130429c5569200 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:25:52 +0300 Subject: [PATCH 299/450] Moved utility functions for JetType from IDE to core --- .../org/jetbrains/kotlin/types/TypeUtils.kt | 23 +++++++++++++++++ .../jetbrains/kotlin/idea/util/FuzzyType.kt | 4 +++ .../jetbrains/kotlin/idea/util/TypeUtils.kt | 25 ++----------------- .../kotlin/idea/util/extensionsUtils.kt | 3 +++ .../idea/completion/CompletionSession.kt | 2 +- .../kotlin/idea/completion/CompletionUtils.kt | 7 +++--- .../kotlin/idea/completion/ExpectedInfos.kt | 2 +- .../idea/completion/LookupElementFactory.kt | 4 +-- .../idea/completion/smart/SmartCompletion.kt | 9 +++++-- .../smart/TypeInstantiationItems.kt | 2 +- .../smart/TypesWithContainsDetector.kt | 5 ++-- .../kotlin/idea/completion/smart/Utils.kt | 7 +++--- .../kotlin/idea/core/SmartCastCalculator.kt | 2 +- .../ConvertFunctionToPropertyIntention.kt | 2 +- ...precatedCallableAddReplaceWithIntention.kt | 2 +- .../idea/intentions/IfNullToElvisIntention.kt | 2 +- .../intentions/InvertIfConditionIntention.kt | 2 +- .../QuickFixFactoryForTypeMismatchError.java | 3 ++- .../callableBuilder/CallableBuilder.kt | 2 ++ .../callableBuilder/CallableInfo.kt | 4 +-- .../callableBuilder/typeUtils.kt | 2 +- .../ExtractableCodeDescriptor.kt | 2 +- .../extractableAnalysisUtil.kt | 2 +- .../KotlinInplaceParameterIntroducer.kt | 2 +- .../KotlinIntroduceParameterHandler.kt | 3 +++ 25 files changed, 72 insertions(+), 51 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index e521af97830..86c5aba7662 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -28,6 +28,29 @@ import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.utils.toReadOnlyList import java.util.* +public enum class TypeNullability { + NOT_NULL, + NULLABLE, + FLEXIBLE +} + +public fun JetType.nullability(): TypeNullability { + return when { + isNullabilityFlexible() -> TypeNullability.FLEXIBLE + TypeUtils.isNullableType(this) -> TypeNullability.NULLABLE + else -> TypeNullability.NOT_NULL + } +} + +fun JetType.makeNullable() = TypeUtils.makeNullable(this) +fun JetType.makeNotNullable() = TypeUtils.makeNotNullable(this) + +fun JetType.supertypes(): Set = TypeUtils.getAllSupertypes(this) + +fun JetType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this) +fun JetType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this) +fun JetType.isAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) + private fun JetType.getContainedTypeParameters(): Collection { val declarationDescriptor = getConstructor().getDeclarationDescriptor() if (declarationDescriptor is TypeParameterDescriptor) return listOf(declarationDescriptor) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index c62bf2b3c20..ff568c938f1 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -25,6 +25,10 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf +import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNullable +import org.jetbrains.kotlin.types.typeUtil.nullability import java.util.HashSet fun CallableDescriptor.fuzzyReturnType(): FuzzyType? { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt index 2b9061816df..9864f331b0c 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/TypeUtils.kt @@ -27,16 +27,9 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.substitute - -fun JetType.makeNullable() = TypeUtils.makeNullable(this) -fun JetType.makeNotNullable() = TypeUtils.makeNotNullable(this) - -fun JetType.supertypes(): Set = TypeUtils.getAllSupertypes(this) - -fun JetType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this) -fun JetType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this) -fun JetType.isAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) +import org.jetbrains.kotlin.types.typeUtil.supertypes public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true): JetType { if (jetType.isDynamic()) return jetType @@ -81,20 +74,6 @@ private fun JetType.hasAnnotationMaybeExternal(fqName: FqName) = with (getAnnota findAnnotation(fqName) ?: findExternalAnnotation(fqName) } != null -public enum class TypeNullability { - NOT_NULL, - NULLABLE, - FLEXIBLE -} - -public fun JetType.nullability(): TypeNullability { - return when { - isNullabilityFlexible() -> TypeNullability.FLEXIBLE - TypeUtils.isNullableType(this) -> TypeNullability.NULLABLE - else -> TypeNullability.NOT_NULL - } -} - fun JetType.isResolvableInScope(scope: JetScope?, checkTypeParameters: Boolean): Boolean { if (canBeReferencedViaImport()) return true diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt index 40680d232cd..bdabaa0ee08 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/extensionsUtils.kt @@ -28,6 +28,9 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver +import org.jetbrains.kotlin.types.typeUtil.TypeNullability +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.nullability public enum class CallType { NORMAL, diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index a4051bab04b..3883a756983 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -41,7 +41,7 @@ import org.jetbrains.kotlin.idea.core.* import org.jetbrains.kotlin.idea.references.JetSimpleNameReference import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter -import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptorKindExclude import org.jetbrains.kotlin.psi.* diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index 2b0cec2a384..21178f1bb34 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -31,7 +31,6 @@ import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.completion.handlers.CastReceiverInsertHandler import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler import org.jetbrains.kotlin.idea.util.* -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf @@ -42,9 +41,9 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeConstructor -import org.jetbrains.kotlin.types.checker.JetTypeChecker -import org.jetbrains.kotlin.types.typeUtil.equalTypesOrNulls +import org.jetbrains.kotlin.types.typeUtil.TypeNullability +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.nullability import java.util.ArrayList enum class ItemPriority { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt index 1f486d452d7..67a10814495 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ExpectedInfos.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.frontend.di.createContainerForMacros import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.completion.smart.toList import org.jetbrains.kotlin.idea.core.mapArgumentsToParameters -import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 7f2178a7dbb..89c414b38d0 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -27,8 +27,8 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.JetDescriptorIconProvider import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.completion.handlers.* -import org.jetbrains.kotlin.idea.util.TypeNullability -import org.jetbrains.kotlin.idea.util.nullability +import org.jetbrains.kotlin.types.typeUtil.TypeNullability +import org.jetbrains.kotlin.types.typeUtil.nullability import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.renderer.DescriptorRenderer diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index d923fb28642..0b7de60ffcd 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.idea.completion.smart -import com.intellij.codeInsight.completion.InsertHandler import com.intellij.codeInsight.completion.InsertionContext import com.intellij.codeInsight.completion.OffsetKey import com.intellij.codeInsight.completion.PrefixMatcher @@ -32,7 +31,10 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.completion.* import org.jetbrains.kotlin.idea.core.IterableTypesDetector import org.jetbrains.kotlin.idea.core.SmartCastCalculator -import org.jetbrains.kotlin.idea.util.* +import org.jetbrains.kotlin.idea.util.FuzzyType +import org.jetbrains.kotlin.idea.util.fuzzyReturnType +import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.idea.util.nullability import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression @@ -40,7 +42,10 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNullable import java.util.ArrayList import java.util.HashSet diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt index 23d3e9f76c0..3e5fe197101 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.idea.completion.handlers.KotlinFunctionInsertHandler import org.jetbrains.kotlin.idea.core.codeInsight.ImplementMethodsHandler import org.jetbrains.kotlin.idea.core.psiClassToDescriptor import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers -import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.load.java.descriptors.SamConstructorDescriptor import org.jetbrains.kotlin.platform.JavaToKotlinClassMap import org.jetbrains.kotlin.psi.JetClassOrObject diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt index 671f6a9386c..a08366ff98b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypesWithContainsDetector.kt @@ -23,13 +23,14 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.types.TypeUtils -import org.jetbrains.kotlin.idea.util.nullability -import org.jetbrains.kotlin.idea.util.TypeNullability +import org.jetbrains.kotlin.types.typeUtil.nullability +import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.idea.util.FuzzyType import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import com.intellij.openapi.project.Project import org.jetbrains.kotlin.idea.completion.HeuristicSignatures +import org.jetbrains.kotlin.idea.util.nullability class TypesWithContainsDetector( private val scope: JetScope, diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index 8fad66a4bd5..9bc71fb5727 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -22,17 +22,18 @@ import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementDecorator import com.intellij.codeInsight.lookup.LookupElementPresentation import com.intellij.openapi.util.Key -import com.intellij.psi.PsiDocumentManager import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.completion.* import org.jetbrains.kotlin.idea.completion.handlers.WithExpressionPrefixInsertHandler import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler -import org.jetbrains.kotlin.idea.util.* -import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.idea.util.FuzzyType +import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.idea.util.nullability import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import java.util.ArrayList import java.util.HashMap diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/SmartCastCalculator.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/SmartCastCalculator.kt index 4f0ffc01eed..057f44d30db 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/SmartCastCalculator.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/SmartCastCalculator.kt @@ -32,7 +32,7 @@ import java.util.HashMap import java.util.HashSet import com.intellij.openapi.util.Pair import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.utils.singletonOrEmptyList diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt index 71ab68953cc..19f3bb5481c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertFunctionToPropertyIntention.kt @@ -42,8 +42,8 @@ import org.jetbrains.kotlin.idea.search.usagesSearch.search import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.idea.util.application.executeWriteCommand -import org.jetbrains.kotlin.idea.util.supertypes import org.jetbrains.kotlin.load.java.JvmAbi +import org.jetbrains.kotlin.types.typeUtil.supertypes import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt index 3f3b11d2e3c..d1e79de71d7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/DeprecatedCallableAddReplaceWithIntention.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.quickfix.moveCaret import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.idea.util.ShortenReferences -import org.jetbrains.kotlin.idea.util.isUnit +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression import org.jetbrains.kotlin.resolve.BindingContext diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt index a1a1b9a55da..9ad9f06d699 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/IfNullToElvisIntention.kt @@ -24,7 +24,7 @@ import com.intellij.psi.PsiRecursiveElementVisitor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.intentions.branchedTransformations.expressionComparedToNull -import org.jetbrains.kotlin.idea.util.isNothing +import org.jetbrains.kotlin.types.typeUtil.isNothing import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt index 1e8742deb9b..d9e67831790 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/InvertIfConditionIntention.kt @@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.quickfix.moveCaret -import org.jetbrains.kotlin.idea.util.isUnit +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.idea.util.psi.patternMatching.matches import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java index edf939215f5..aaead43b052 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.java @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.types.JetType; +import org.jetbrains.kotlin.types.typeUtil.TypeUtilPackage; import java.util.Collections; import java.util.LinkedList; @@ -74,7 +75,7 @@ public class QuickFixFactoryForTypeMismatchError extends JetIntentionActionsFact DiagnosticWithParameters1 diagnosticWithParameters = Errors.NULL_FOR_NONNULL_TYPE.cast(diagnostic); expectedType = diagnosticWithParameters.getA(); - expressionType = UtilPackage.makeNullable(expectedType); + expressionType = TypeUtilPackage.makeNullable(expectedType); } else if (diagnostic.getFactory() == Errors.CONSTANT_EXPECTED_TYPE_MISMATCH) { DiagnosticWithParameters2 diagnosticWithParameters = diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 0fbd58f9dbf..3c4d5081922 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -66,6 +66,8 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.types.typeUtil.isAny +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* import kotlin.properties.Delegates diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt index 5b5bedb809e..ed54d5df39d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableInfo.kt @@ -21,8 +21,8 @@ import com.intellij.util.ArrayUtil import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.idea.core.KotlinNameSuggester import org.jetbrains.kotlin.idea.quickfix.createFromUsage.createClass.ClassInfo -import org.jetbrains.kotlin.idea.util.makeNotNullable -import org.jetbrains.kotlin.idea.util.supertypes +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.supertypes import org.jetbrains.kotlin.psi.JetElement import org.jetbrains.kotlin.psi.JetExpression import org.jetbrains.kotlin.psi.JetTypeReference diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt index 8e5f1485d09..c5481944753 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/typeUtils.kt @@ -24,7 +24,7 @@ import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.idea.references.JetSimpleNameReference -import org.jetbrains.kotlin.idea.util.makeNotNullable +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt index ae9185b1ce1..84e68557525 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.idea.references.JetSimpleNameReference.ShorteningMod import org.jetbrains.kotlin.idea.util.approximateFlexibleTypes import org.jetbrains.kotlin.idea.util.isAnnotatedNotNull import org.jetbrains.kotlin.idea.util.isAnnotatedNullable -import org.jetbrains.kotlin.idea.util.isUnit +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.idea.util.psi.patternMatching.JetPsiRange import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt index 49106b2830d..8f3e51a4dec 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractableAnalysisUtil.kt @@ -62,7 +62,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.OutputVa import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.approximateWithResolvableType import org.jetbrains.kotlin.idea.util.isResolvableInScope -import org.jetbrains.kotlin.idea.util.makeNullable +import org.jetbrains.kotlin.types.typeUtil.makeNullable import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt index 001c0b030bc..c773e3840e5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinInplaceParameterIntroducer.kt @@ -34,7 +34,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.AbstractKotlinInplaceIntr import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinInplaceVariableIntroducer import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange -import org.jetbrains.kotlin.idea.util.supertypes +import org.jetbrains.kotlin.types.typeUtil.supertypes import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getElementTextWithContext import org.jetbrains.kotlin.psi.psiUtil.getValueParameterList diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 718ae8afbf4..17fa5b7fd20 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -65,6 +65,9 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver +import org.jetbrains.kotlin.types.typeUtil.isNothing +import org.jetbrains.kotlin.types.typeUtil.isUnit +import org.jetbrains.kotlin.types.typeUtil.supertypes import java.util.* import kotlin.test.fail From 46a512215e7e36a65bf7852800a83564f417cc77 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:26:21 +0300 Subject: [PATCH 300/450] Used utility --- .../kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index 1be97fe23b2..c919b836110 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -132,8 +132,7 @@ public abstract class DeprecatedSymbolUsageFixBase( val descriptor = resolvedCall.getResultingDescriptor() val callExpression = resolvedCall.getCall().getCallElement() as JetExpression - val parent = callExpression.getParent() - val qualifiedExpression = if (parent is JetQualifiedExpression && callExpression == parent.getSelectorExpression()) parent else null + val qualifiedExpression = callExpression.getQualifiedExpressionForSelector() val expressionToBeReplaced = qualifiedExpression ?: callExpression val commentSaver = CommentSaver(expressionToBeReplaced, saveLineBreaks = true) From 48b163758f4dab20c4a894a7d229b74a22a6c249 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:13:19 +0300 Subject: [PATCH 301/450] Fixed caching --- .../jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 8e341708ee5..0c976a5bfb9 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -47,10 +47,10 @@ class AdditionalScopesWithSyntheticExtensions(storageManager: StorageManager) : class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { triple -> - syntheticPropertyInClass(triple.first, triple.second, triple.third) + syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third) } - private fun syntheticPropertyInClass(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { + private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { val memberScope = javaClass.getMemberScope(type.getArguments()) val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null @@ -107,7 +107,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { if (descriptor is FunctionDescriptor) { val propertyName = fromGetMethodName(descriptor.getName()) ?: continue - addIfNotNull(syntheticPropertyInClass(classifier, type, propertyName)) + addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) } } } From 9b3cbc6f25df888818ea45a2ebe1c3fe14be6b60 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:34:41 +0300 Subject: [PATCH 302/450] Fixed completion for safe call --- .../jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt | 5 +++-- .../basic/common/extensions/SyntheticExtensionsSafeCall.kt | 7 +++++++ .../completion/test/JSBasicCompletionTestGenerated.java | 6 ++++++ .../completion/test/JvmBasicCompletionTestGenerated.java | 6 ++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 0c976a5bfb9..40689ed3d92 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* @@ -76,7 +77,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { if (name.isSpecial()) return emptyList() if (name.getIdentifier()[0].isUpperCase()) return emptyList() - return collectSyntheticPropertiesByName(null, receiverType, name) ?: emptyList() + return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList() } private fun collectSyntheticPropertiesByName(result: SmartList?, type: JetType, name: Name): SmartList? { @@ -96,7 +97,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { val result = ArrayList() - result.collectSyntheticProperties(receiverType) + result.collectSyntheticProperties(receiverType.makeNotNullable()) return result } diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt new file mode 100644 index 00000000000..8865bcb0403 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt @@ -0,0 +1,7 @@ +import java.io.File + +fun foo(file: File?) { + file?. +} + +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 0b5a1a64a44..96778ee88b5 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1221,6 +1221,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("SyntheticExtensionsSafeCall.kt") + public void testSyntheticExtensionsSafeCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index c0771c4c166..ae651dd71f6 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1221,6 +1221,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("SyntheticExtensionsSafeCall.kt") + public void testSyntheticExtensionsSafeCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); From fa02a1521204aaa7f36529097e47acac54f29479 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:35:01 +0300 Subject: [PATCH 303/450] One more test for completion --- .../SyntheticExtensionForGenericClass.dependency.java | 8 ++++++++ .../SyntheticExtensionForGenericClass.kt | 5 +++++ .../test/MultiFileJvmBasicCompletionTestGenerated.java | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.dependency.java create mode 100644 idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt diff --git a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.dependency.java b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.dependency.java new file mode 100644 index 00000000000..6d641e919ce --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.dependency.java @@ -0,0 +1,8 @@ +class JavaClass { + public T getSomething() { + return null; + } + + public void setSomething(T t) { + } +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt new file mode 100644 index 00000000000..3472811499d --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt @@ -0,0 +1,5 @@ +fun foo(javaClass: JavaClass) { + javaClass. +} + +// EXIST: { lookupString: "something", itemText: "something", tailText: " for JavaClass", typeText: "String!" } diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index a8116ef2271..381132ceeab 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -281,6 +281,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("SyntheticExtensionForGenericClass") + public void testSyntheticExtensionForGenericClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/"); + doTest(fileName); + } + @TestMetadata("TopLevelFunction") public void testTopLevelFunction() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/TopLevelFunction/"); From a014f5c8db9d5ff1d68e8916471b8c510f2beae5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 22:56:43 +0300 Subject: [PATCH 304/450] No synthetic properties with incorrect names --- .../kotlin/synthetic/SyntheticExtensionsScope.kt | 10 +++++++--- .../IncorrectGetters/IncorrectGetters.dependency.java | 4 ++++ .../multifile/IncorrectGetters/IncorrectGetters.kt | 6 ++++++ .../test/MultiFileJvmBasicCompletionTestGenerated.java | 6 ++++++ 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java create mode 100644 idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 40689ed3d92..2ae729be32d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -52,6 +52,10 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { + if (name.isSpecial()) return null + val firstChar = name.getIdentifier()[0] + if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null + val memberScope = javaClass.getMemberScope(type.getArguments()) val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null @@ -75,8 +79,6 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { - if (name.isSpecial()) return emptyList() - if (name.getIdentifier()[0].isUpperCase()) return emptyList() return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList() } @@ -138,7 +140,9 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith("get")) return null - return Name.identifier(identifier.removePrefix("get").decapitalize()) + val name = identifier.removePrefix("get").decapitalize() + if (!Name.isValidIdentifier(name)) return null + return Name.identifier(name) } private class MyPropertyDescriptor( diff --git a/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java new file mode 100644 index 00000000000..366ce6faf45 --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.dependency.java @@ -0,0 +1,4 @@ +class JavaClass { + public int get() { return 1; } + public int get1() { return 1; } +} \ No newline at end of file diff --git a/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt new file mode 100644 index 00000000000..1618af5451f --- /dev/null +++ b/idea/idea-completion/testData/basic/multifile/IncorrectGetters/IncorrectGetters.kt @@ -0,0 +1,6 @@ +fun foo(javaClass: JavaClass) { + javaClass. +} + +// ABSENT: "" +// ABSENT: "1" diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java index 381132ceeab..dc47865b47f 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/MultiFileJvmBasicCompletionTestGenerated.java @@ -131,6 +131,12 @@ public class MultiFileJvmBasicCompletionTestGenerated extends AbstractMultiFileJ doTest(fileName); } + @TestMetadata("IncorrectGetters") + public void testIncorrectGetters() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/IncorrectGetters/"); + doTest(fileName); + } + @TestMetadata("JavaInnerClasses") public void testJavaInnerClasses() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/multifile/JavaInnerClasses/"); From bfdc74ce74afdfc1e3c55f53da62efe3644b889e Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 8 Jul 2015 23:12:44 +0300 Subject: [PATCH 305/450] Intention&inspection to use synthetic property instead of get/set method call --- .../UsePropertyAccessSyntax.html | 5 + .../after.kt.template | 3 + .../before.kt.template | 3 + .../description.html | 5 + idea/src/META-INF/plugin.xml | 12 ++ .../UsePropertyAccessSyntaxIntention.kt | 136 ++++++++++++++++++ .../usePropertyAccessSyntax/.intention | 1 + .../accessThroughKotlinClassInstance.kt | 8 ++ .../accessThroughKotlinClassInstance.kt.after | 8 ++ ...sThroughKotlinClassInstanceWithOverride.kt | 12 ++ ...ghKotlinClassInstanceWithOverride.kt.after | 12 ++ .../usePropertyAccessSyntax/conflict1.kt | 7 + .../usePropertyAccessSyntax/conflict2.kt | 9 ++ .../intentions/usePropertyAccessSyntax/get.kt | 6 + .../usePropertyAccessSyntax/get.kt.after | 6 + .../getImplicitReceiver.kt | 6 + .../getImplicitReceiver.kt.after | 6 + .../usePropertyAccessSyntax/getSafeCall.kt | 6 + .../getSafeCall.kt.after | 6 + .../intentions/usePropertyAccessSyntax/set.kt | 4 + .../usePropertyAccessSyntax/set.kt.after | 4 + .../setImplicitReceiver.kt | 4 + .../setImplicitReceiver.kt.after | 4 + .../usePropertyAccessSyntax/setSafeCall.kt | 4 + .../setSafeCall.kt.after | 4 + .../usePropertyAccessSyntax/superCall.kt | 9 ++ .../intentions/IntentionTestGenerated.java | 75 ++++++++++ 27 files changed, 365 insertions(+) create mode 100644 idea/resources/inspectionDescriptions/UsePropertyAccessSyntax.html create mode 100644 idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/after.kt.template create mode 100644 idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/before.kt.template create mode 100644 idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/description.html create mode 100644 idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/.intention create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/conflict1.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/conflict2.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/get.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/get.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/set.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/set.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/superCall.kt diff --git a/idea/resources/inspectionDescriptions/UsePropertyAccessSyntax.html b/idea/resources/inspectionDescriptions/UsePropertyAccessSyntax.html new file mode 100644 index 00000000000..718fb306473 --- /dev/null +++ b/idea/resources/inspectionDescriptions/UsePropertyAccessSyntax.html @@ -0,0 +1,5 @@ + + +This inspection reports calls to java get and set methods that can be replaced with use of Kotlin synthetic properties. + + diff --git a/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/after.kt.template b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/after.kt.template new file mode 100644 index 00000000000..3351cf05bec --- /dev/null +++ b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/after.kt.template @@ -0,0 +1,3 @@ +fun foo(thread: Thread) { + thread.daemon = true +} diff --git a/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/before.kt.template b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/before.kt.template new file mode 100644 index 00000000000..17249916001 --- /dev/null +++ b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/before.kt.template @@ -0,0 +1,3 @@ +fun foo(thread: Thread) { + thread.setDaemon(true) +} diff --git a/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/description.html b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/description.html new file mode 100644 index 00000000000..cca81724012 --- /dev/null +++ b/idea/resources/intentionDescriptions/UsePropertyAccessSyntaxIntention/description.html @@ -0,0 +1,5 @@ + + +This inspection replaces calls to java get and set methods with use of Kotlin synthetic properties. + + \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index cc30188b4b7..8894006e50b 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -942,6 +942,11 @@ Kotlin + + org.jetbrains.kotlin.idea.intentions.UsePropertyAccessSyntaxIntention + Kotlin + + + + (UsePropertyAccessSyntaxIntention()) + +class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Use property access syntax") { + override fun isApplicableTo(element: JetCallExpression): Boolean { + if (element.getQualifiedExpressionForSelector()?.getReceiverExpression() is JetSuperExpression) return false // cannot call extensions on "super" + + return findExtensionPropertyToUse(element) != null + } + + override fun applyTo(element: JetCallExpression, editor: Editor) { + val propertyName = findExtensionPropertyToUse(element)!!.getName() + val arguments = element.getValueArguments() + when (arguments.size()) { + 0 -> replaceWithPropertyGet(element, propertyName) + 1 -> replaceWithPropertySet(element, propertyName, arguments.single()) + else -> error("More than one argument in call to accessor") + } + } + + private fun findExtensionPropertyToUse(callExpression: JetCallExpression): PropertyDescriptor? { + val callee = callExpression.getCalleeExpression() as? JetSimpleNameExpression ?: return null + + val bindingContext = callExpression.analyze(BodyResolveMode.PARTIAL) + val resolvedCall = callExpression.getResolvedCall(bindingContext) ?: return null + if (!resolvedCall.getStatus().isSuccess()) return null + + val function = resolvedCall.getResultingDescriptor() as? FunctionDescriptor ?: return null + val resolutionScope = callExpression.getResolutionScope(bindingContext, callExpression.getResolutionFacade()) + val property = findSyntheticProperty(function, resolutionScope) ?: return null + + val moduleDescriptor = callExpression.getResolutionFacade().findModuleDescriptor(callExpression) + val inDescriptor = resolutionScope.getContainingDeclaration() + + fun isVisible(descriptor: DeclarationDescriptor): Boolean { + return if (descriptor is DeclarationDescriptorWithVisibility) + descriptor.isVisible(inDescriptor, bindingContext, callee) + else + true + } + + val referenceVariantsHelper = ReferenceVariantsHelper(bindingContext, moduleDescriptor, callExpression.getProject(), ::isVisible) + val propertyName = property.getName() + val accessibleVariables = referenceVariantsHelper.getReferenceVariants(callee, DescriptorKindFilter.VARIABLES, false, { it == propertyName }) + if (property !in accessibleVariables) return null // shadowed by something else + + return property + } + + private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { + findSyntheticPropertyNoOverriddenCheck(function, resolutionScope)?.let { return it } + + for (overridden in function.getOverriddenDescriptors()) { + findSyntheticProperty(overridden, resolutionScope)?.let { return it } + } + + return null + } + + private fun findSyntheticPropertyNoOverriddenCheck(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { + val owner = function.getContainingDeclaration() + if (owner !is JavaClassDescriptor) return null + + return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) + .filterIsInstance() + .firstOrNull { function == it.getMethod || function == it.setMethod } + } + + private fun replaceWithPropertyGet(callExpression: JetCallExpression, propertyName: Name) { + val newExpression = JetPsiFactory(callExpression).createExpression(propertyName.render()) + callExpression.replace(newExpression) + } + + //TODO: what if it was used as expression (of type Unit)? + private fun replaceWithPropertySet(callExpression: JetCallExpression, propertyName: Name, argument: JetValueArgument) { + val qualifiedExpression = callExpression.getQualifiedExpressionForSelector() + if (qualifiedExpression != null) { + val pattern = when (qualifiedExpression) { + is JetDotQualifiedExpression -> "$0.$1=$2" + is JetSafeQualifiedExpression -> "$0?.$1=$2" + else -> error(qualifiedExpression) //TODO: make it sealed? + } + val newExpression = JetPsiFactory(callExpression).createExpressionByPattern( + pattern, + qualifiedExpression.getReceiverExpression(), + propertyName, + argument.getArgumentExpression()!! + ) + qualifiedExpression.replace(newExpression) + } + else { + val newExpression = JetPsiFactory(callExpression).createExpressionByPattern("$0=$1", propertyName, argument.getArgumentExpression()!!) + callExpression.replace(newExpression) + } + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/.intention b/idea/testData/intentions/usePropertyAccessSyntax/.intention new file mode 100644 index 00000000000..07c59e83a91 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/.intention @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.intentions.UsePropertyAccessSyntaxIntention diff --git a/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt new file mode 100644 index 00000000000..18d4bff3b10 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +import java.io.File + +class MyFile : File("file") + +fun foo(file: MyFile) { + file.getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt.after new file mode 100644 index 00000000000..1581334f1b5 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +import java.io.File + +class MyFile : File("file") + +fun foo(file: MyFile) { + file.absolutePath +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt new file mode 100644 index 00000000000..dcec7f3b695 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME +import java.io.File + +class MyFile : File("file") { + override fun getCanonicalFile(): File { + return super.getCanonicalFile() + } +} + +fun foo(file: MyFile) { + file.getCanonicalFile() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt.after new file mode 100644 index 00000000000..89f43a93045 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt.after @@ -0,0 +1,12 @@ +// WITH_RUNTIME +import java.io.File + +class MyFile : File("file") { + override fun getCanonicalFile(): File { + return super.getCanonicalFile() + } +} + +fun foo(file: MyFile) { + file.canonicalFile +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/conflict1.kt b/idea/testData/intentions/usePropertyAccessSyntax/conflict1.kt new file mode 100644 index 00000000000..24a31ad2bf1 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/conflict1.kt @@ -0,0 +1,7 @@ +// WITH_RUNTIME +// IS_APPLICABLE: false +import java.io.File + +fun File.foo(absolutePath: String) { + getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/conflict2.kt b/idea/testData/intentions/usePropertyAccessSyntax/conflict2.kt new file mode 100644 index 00000000000..872ab35fa8f --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/conflict2.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// IS_APPLICABLE: false +import java.io.File + +val File.absolutePath: String get() = "" + +fun foo(file: File) { + file.getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/get.kt b/idea/testData/intentions/usePropertyAccessSyntax/get.kt new file mode 100644 index 00000000000..c675ee0285e --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/get.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(file: File) { + file.getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/get.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/get.kt.after new file mode 100644 index 00000000000..f0bfca56602 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/get.kt.after @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(file: File) { + file.absolutePath +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt b/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt new file mode 100644 index 00000000000..cccad1ce70e --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun File.foo() { + getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt.after new file mode 100644 index 00000000000..1dba46cb7c2 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt.after @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun File.foo() { + absolutePath +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt b/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt new file mode 100644 index 00000000000..43cb61ce3f3 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(file: File?) { + file?.getAbsolutePath() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt.after new file mode 100644 index 00000000000..214787cebcb --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt.after @@ -0,0 +1,6 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(file: File?) { + file?.absolutePath +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/set.kt b/idea/testData/intentions/usePropertyAccessSyntax/set.kt new file mode 100644 index 00000000000..1a5be1d26aa --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/set.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.setName("name") +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/set.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/set.kt.after new file mode 100644 index 00000000000..3a7238cc003 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/set.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.name = "name" +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt b/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt new file mode 100644 index 00000000000..c35a7e6f944 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun Thread.foo() { + setName("name") +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt.after new file mode 100644 index 00000000000..a639d2fcc57 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun Thread.foo() { + name = "name" +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt b/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt new file mode 100644 index 00000000000..2c44ee53f9b --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread?) { + thread?.setName("name") +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt.after new file mode 100644 index 00000000000..15254f25621 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread?) { + thread?.name = "name" +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/superCall.kt b/idea/testData/intentions/usePropertyAccessSyntax/superCall.kt new file mode 100644 index 00000000000..a28fb98d88a --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/superCall.kt @@ -0,0 +1,9 @@ +// WITH_RUNTIME +// IS_APPLICABLE: false +import java.io.File + +class MyFile : File("file") { + override fun getCanonicalFile(): File { + return super.getCanonicalFile() + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index f068e1782f7..67130b4b574 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -7382,4 +7382,79 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } } + + @TestMetadata("idea/testData/intentions/usePropertyAccessSyntax") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class UsePropertyAccessSyntax extends AbstractIntentionTest { + @TestMetadata("accessThroughKotlinClassInstance.kt") + public void testAccessThroughKotlinClassInstance() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstance.kt"); + doTest(fileName); + } + + @TestMetadata("accessThroughKotlinClassInstanceWithOverride.kt") + public void testAccessThroughKotlinClassInstanceWithOverride() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/accessThroughKotlinClassInstanceWithOverride.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInUsePropertyAccessSyntax() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/usePropertyAccessSyntax"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true); + } + + @TestMetadata("conflict1.kt") + public void testConflict1() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/conflict1.kt"); + doTest(fileName); + } + + @TestMetadata("conflict2.kt") + public void testConflict2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/conflict2.kt"); + doTest(fileName); + } + + @TestMetadata("get.kt") + public void testGet() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/get.kt"); + doTest(fileName); + } + + @TestMetadata("getImplicitReceiver.kt") + public void testGetImplicitReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/getImplicitReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("getSafeCall.kt") + public void testGetSafeCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/getSafeCall.kt"); + doTest(fileName); + } + + @TestMetadata("set.kt") + public void testSet() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/set.kt"); + doTest(fileName); + } + + @TestMetadata("setImplicitReceiver.kt") + public void testSetImplicitReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/setImplicitReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("setSafeCall.kt") + public void testSetSafeCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/setSafeCall.kt"); + doTest(fileName); + } + + @TestMetadata("superCall.kt") + public void testSuperCall() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/superCall.kt"); + doTest(fileName); + } + } } From 82f1eafa0bb5fb2551e32277c3a4f0fcbe54b8d2 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 12:43:32 +0300 Subject: [PATCH 306/450] No synthetic properties of type Unit --- .../jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt | 2 ++ .../diagnostics/tests/syntheticExtensions/FalseGetters.kt | 6 +++++- .../diagnostics/tests/syntheticExtensions/FalseGetters.txt | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 2ae729be32d..c3a1f4e0d34 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* @@ -69,6 +70,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return descriptor.getValueParameters().isEmpty() && descriptor.getTypeParameters().isEmpty() && descriptor.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? + && !(descriptor.getReturnType()?.isUnit() ?: true) } private fun isGoodSetMethod(descriptor: FunctionDescriptor, propertyType: JetType): Boolean { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt index c822e42778b..f0733cc1564 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt @@ -3,12 +3,16 @@ fun foo(javaClass: JavaClass) { javaClass.something1 javaClass.something2 javaClass.somethingStatic + javaClass.somethingVoid } // FILE: JavaClass.java public class JavaClass { public int getSomething1(int p) { return p; } + public T getSomething2() { return null; } public static int getSomethingStatic() { return 1; } -} \ No newline at end of file + + public void getSomethingVoid() { } +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt index e4ef1a33e60..0b48f1f6f53 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt @@ -7,6 +7,7 @@ public open class JavaClass { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open fun getSomething1(/*0*/ p: kotlin.Int): kotlin.Int public open fun getSomething2(): T! + public open fun getSomethingVoid(): kotlin.Unit public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String From 2ec6f504029c0fb0a35eb2a1adc6565a23c6ed0b Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 12:53:11 +0300 Subject: [PATCH 307/450] Set method should not accept vararg --- .../jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt | 4 +++- .../diagnostics/tests/syntheticExtensions/FalseSetters.kt | 4 ++++ .../diagnostics/tests/syntheticExtensions/FalseSetters.txt | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index c3a1f4e0d34..ab7b91d3933 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -74,7 +74,9 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } private fun isGoodSetMethod(descriptor: FunctionDescriptor, propertyType: JetType): Boolean { - return descriptor.getValueParameters().singleOrNull()?.getType() == propertyType + val parameter = descriptor.getValueParameters().singleOrNull() ?: return false + return parameter.getType() == propertyType + && parameter.getVarargElementType() == null && descriptor.getTypeParameters().isEmpty() && descriptor.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false && descriptor.getVisibility() == Visibilities.PUBLIC diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt index d82f34ef121..1c46a2c1073 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.kt @@ -5,6 +5,7 @@ fun foo(javaClass: JavaClass) { javaClass.something3++ javaClass.something4++ javaClass.something5++ + javaClass.something6 = null } // FILE: JavaClass.java @@ -23,4 +24,7 @@ public class JavaClass { public int getSomething5() { return 1; } public static void setSomething5(int value) { } + + public int[] getSomething6() { return null; } + public void setSomething6(int... value) { } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt index 8b6a8a97784..9493dc52099 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseSetters.txt @@ -10,11 +10,13 @@ public open class JavaClass { public open fun getSomething3(): kotlin.Int public open fun getSomething4(): kotlin.Int public open fun getSomething5(): kotlin.Int + public open fun getSomething6(): kotlin.IntArray! public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open fun setSomething1(/*0*/ value: kotlin.Int, /*1*/ c: kotlin.Char): kotlin.Unit public open fun setSomething2(/*0*/ value: kotlin.String!): kotlin.Unit public open fun setSomething3(/*0*/ value: kotlin.Int): kotlin.Int public open fun setSomething4(/*0*/ value: kotlin.Int): kotlin.Unit + public open fun setSomething6(/*0*/ vararg value: kotlin.Int /*kotlin.IntArray!*/): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String // Static members From 73dd4a214e3737aa1c7f1e7676c99c380f78f2c8 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 17:26:46 +0300 Subject: [PATCH 308/450] Reference resolve from synthetic extension usages to get/set-methods --- .../kotlin/psi/psiUtil/jetPsiUtil.kt | 2 +- .../idea/references/JetSimpleNameReference.kt | 81 +++++++-- .../ExtractableCodeDescriptor.kt | 3 +- .../references/SyntheticProperty.Data.java | 4 + .../resolve/references/SyntheticProperty.kt | 28 +++ ...actReferenceResolveInLibrarySourcesTest.kt | 2 +- .../resolve/AbstractReferenceResolveTest.java | 164 ------------------ .../resolve/AbstractReferenceResolveTest.kt | 151 ++++++++++++++++ .../ReferenceResolveTestGenerated.java | 6 + .../jetbrains/kotlin/test/ReferenceUtils.java | 20 --- 10 files changed, 257 insertions(+), 204 deletions(-) create mode 100644 idea/testData/resolve/references/SyntheticProperty.Data.java create mode 100644 idea/testData/resolve/references/SyntheticProperty.kt delete mode 100644 idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.java create mode 100644 idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt index 8dd690897fb..8d3c0dbc594 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/jetPsiUtil.kt @@ -130,7 +130,7 @@ public fun JetElement.getQualifiedExpressionForSelector(): JetQualifiedExpressio return if (parent is JetQualifiedExpression && parent.getSelectorExpression() == this) parent else null } -public fun JetElement.getQualifiedExpressionForSelectorOrThis(): JetElement { +public fun JetExpression.getQualifiedExpressionForSelectorOrThis(): JetExpression { return getQualifiedExpressionForSelector() ?: this } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index fa01d90bd26..7d7c3913480 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -16,34 +16,81 @@ package org.jetbrains.kotlin.idea.references +import com.intellij.openapi.extensions.Extensions import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.idea.util.ShortenReferences -import org.jetbrains.kotlin.idea.refactoring.fqName.changeQualifiedName -import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet -import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName -import org.jetbrains.kotlin.types.expressions.OperatorConventions -import org.jetbrains.kotlin.lexer.JetToken -import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention -import org.jetbrains.kotlin.resolve.BindingContext import com.intellij.util.IncorrectOperationException -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike +import com.intellij.util.SmartList +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze -import org.jetbrains.kotlin.psi.psiUtil.* -import com.intellij.psi.impl.light.LightElement -import com.intellij.openapi.extensions.Extensions -import org.jetbrains.kotlin.idea.util.ProjectRootsUtil +import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet +import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention +import org.jetbrains.kotlin.idea.refactoring.fqName.changeQualifiedName +import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName +import org.jetbrains.kotlin.idea.util.ShortenReferences +import org.jetbrains.kotlin.lexer.JetToken +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.plugin.references.SimpleNameReferenceExtension +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike +import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.types.expressions.OperatorConventions +import org.jetbrains.kotlin.utils.addIfNotNull +import org.jetbrains.kotlin.utils.addToStdlib.constant public class JetSimpleNameReference( jetSimpleNameExpression: JetSimpleNameExpression ) : JetSimpleReference(jetSimpleNameExpression) { + override fun getTargetDescriptors(context: BindingContext): Collection { + val targets = super.getTargetDescriptors(context) + if (targets.none { it is SyntheticExtensionPropertyDescriptor }) return targets + + val newTargets = SmartList() + for (target in targets) { + if (!(target !is SyntheticExtensionPropertyDescriptor)) { + val access = access() + if (access == Access.READ || access == Access.READ_WRITE) { + newTargets.add(target.getMethod) + } + if (access == Access.WRITE || access == Access.READ_WRITE) { + newTargets.addIfNotNull(target.setMethod) + } + } + else { + newTargets.add(target) + } + } + return newTargets + } + + //TODO: there should be some common util for that + private enum class Access { + READ, WRITE, READ_WRITE + } + + private fun access(): Access { + var expression = myElement.getQualifiedExpressionForSelectorOrThis() + while (expression.getParent() is JetParenthesizedExpression) { + expression = expression.getParent() as JetParenthesizedExpression + } + + val assignment = expression.getAssignmentByLHS() + if (assignment != null) { + return if (assignment.getOperationToken() == JetTokens.EQ) Access.WRITE else Access.READ_WRITE + } + + return if ((expression.getParent() as? JetUnaryExpression)?.getOperationToken() in constant { setOf(JetTokens.PLUSPLUS, JetTokens.MINUSMINUS) }) + Access.READ_WRITE + else + Access.READ + } + override fun isReferenceTo(element: PsiElement?): Boolean { if (element != null) { if (!canBeReferenceTo(element)) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt index 84e68557525..a7abfdc6f6b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/ExtractableCodeDescriptor.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.util.psi.patternMatching.JetPsiRange import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.BindingContext @@ -82,7 +83,7 @@ class RenameReplacement(override val parameter: Parameter): ParameterReplacement override fun copy(parameter: Parameter) = RenameReplacement(parameter) override fun invoke(e: JetElement): JetElement { - var expressionToReplace = (e.getParent() as? JetThisExpression ?: e).getQualifiedExpressionForSelectorOrThis() + var expressionToReplace = (e.getParent() as? JetThisExpression ?: e).let { it.getQualifiedExpressionForSelector() ?: it } val parameterName = JetPsiUtil.unquoteIdentifier(parameter.nameForRef) val replacingName = if (e.getText().startsWith('`') || !KotlinNameSuggester.isIdentifier(parameterName)) "`$parameterName`" else parameterName diff --git a/idea/testData/resolve/references/SyntheticProperty.Data.java b/idea/testData/resolve/references/SyntheticProperty.Data.java new file mode 100644 index 00000000000..a55591d9ff4 --- /dev/null +++ b/idea/testData/resolve/references/SyntheticProperty.Data.java @@ -0,0 +1,4 @@ +class JavaClass { + public int getSomething() { return 1; } + public void setSomething(int value) {} +} \ No newline at end of file diff --git a/idea/testData/resolve/references/SyntheticProperty.kt b/idea/testData/resolve/references/SyntheticProperty.kt new file mode 100644 index 00000000000..1a1cfa017d3 --- /dev/null +++ b/idea/testData/resolve/references/SyntheticProperty.kt @@ -0,0 +1,28 @@ +fun JavaClass.foo(javaClass: JavaClass) { + print(javaClass.something) + javaClass.something = 1 + javaClass.something += 1 + javaClass.something++ + --javaClass.something + + something++ + (something)++ + (something) = 1 + (javaClass.something) = 1 +} + +// MULTIRESOLVE +// REF1: (in JavaClass).getSomething() +// REF2: (in JavaClass).setSomething(int) +// REF3: (in JavaClass).getSomething() +// REF3: (in JavaClass).setSomething(int) +// REF4: (in JavaClass).getSomething() +// REF4: (in JavaClass).setSomething(int) +// REF5: (in JavaClass).getSomething() +// REF5: (in JavaClass).setSomething(int) +// REF6: (in JavaClass).getSomething() +// REF6: (in JavaClass).setSomething(int) +// REF7: (in JavaClass).getSomething() +// REF7: (in JavaClass).setSomething(int) +// REF8: (in JavaClass).setSomething(int) +// REF9: (in JavaClass).setSomething(int) diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt index a9becbfd00f..a4d38ec7450 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveInLibrarySourcesTest.kt @@ -34,7 +34,7 @@ public abstract class AbstractReferenceResolveInLibrarySourcesTest : JetLightCod fixture.configureByFile(path) - val expectedResolveData = AbstractReferenceResolveTest.readResolveData(fixture.getFile()!!.getText()) + val expectedResolveData = AbstractReferenceResolveTest.readResolveData(fixture.getFile()!!.getText(), 0) val gotoData = NavigationTestUtils.invokeGotoImplementations(fixture.getEditor(), fixture.getFile())!! Assert.assertEquals("Single target expected for origianl file", 1, gotoData.targets.size()) diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.java deleted file mode 100644 index 811a2fd490a..00000000000 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.resolve; - -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiPolyVariantReference; -import com.intellij.psi.PsiReference; -import com.intellij.psi.ResolveResult; -import com.intellij.testFramework.LightProjectDescriptor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor; -import org.jetbrains.kotlin.idea.test.KotlinLightPlatformCodeInsightFixtureTestCase; -import org.jetbrains.kotlin.test.InTextDirectivesUtils; -import org.jetbrains.kotlin.test.ReferenceUtils; -import org.jetbrains.kotlin.test.util.UtilPackage; -import org.junit.Assert; - -import java.util.List; - -public abstract class AbstractReferenceResolveTest extends KotlinLightPlatformCodeInsightFixtureTestCase { - public static class ExpectedResolveData { - private final Boolean shouldBeUnresolved; - private final String referenceToString; - - public ExpectedResolveData(Boolean shouldBeUnresolved, String referenceToString) { - this.shouldBeUnresolved = shouldBeUnresolved; - this.referenceToString = referenceToString; - } - - public boolean shouldBeUnresolved() { - return shouldBeUnresolved; - } - - public String getReferenceString() { - return referenceToString; - } - } - - public static final String MULTIRESOLVE = "MULTIRESOLVE"; - public static final String REF_EMPTY = "REF_EMPTY"; - - protected void doTest(@NotNull String path) { - assert path.endsWith(".kt") : path; - UtilPackage.configureWithExtraFile(myFixture, path, ".Data"); - performChecks(); - } - - protected void performChecks() { - if (InTextDirectivesUtils.isDirectiveDefined(myFixture.getFile().getText(), MULTIRESOLVE)) { - doMultiResolveTest(); - } - else { - doSingleResolveTest(); - } - } - - protected void doSingleResolveTest() { - ExpectedResolveData expectedResolveData = readResolveData(myFixture.getFile().getText()); - - int offset = myFixture.getEditor().getCaretModel().getOffset(); - PsiReference psiReference = myFixture.getFile().findReferenceAt(offset); - - checkReferenceResolve(expectedResolveData, offset, psiReference); - } - - protected void doMultiResolveTest() { - List expectedReferences = ReferenceUtils.getExpectedReferences(myFixture.getFile().getText()); - - PsiReference psiReference = myFixture.getFile().findReferenceAt(myFixture.getEditor().getCaretModel().getOffset()); - - assertTrue(psiReference instanceof PsiPolyVariantReference); - - PsiPolyVariantReference variantReference = (PsiPolyVariantReference) psiReference; - - ResolveResult[] results = variantReference.multiResolve(true); - - List actualResolvedTo = Lists.newArrayList(); - for (ResolveResult result : results) { - PsiElement resolvedToElement = result.getElement(); - assertNotNull(resolvedToElement); - - actualResolvedTo.add(ReferenceUtils.renderAsGotoImplementation(resolvedToElement)); - } - - assertOrderedEquals(Ordering.natural().sortedCopy(actualResolvedTo), Ordering.natural().sortedCopy(expectedReferences)); - } - - @NotNull - public static ExpectedResolveData readResolveData(String fileText) { - boolean shouldBeUnresolved = InTextDirectivesUtils.isDirectiveDefined(fileText, REF_EMPTY); - List refs = ReferenceUtils.getExpectedReferences(fileText); - - String referenceToString; - if (shouldBeUnresolved) { - Assert.assertTrue("REF: directives will be ignored for " + REF_EMPTY + " test: " + refs, refs.isEmpty()); - referenceToString = ""; - } - else { - assertTrue("Must be a single ref: " + refs + ".\n" + - "Use " + MULTIRESOLVE + " if you need multiple refs\n" + - "Use "+ REF_EMPTY + " for an unresolved reference", - refs.size() == 1); - referenceToString = refs.get(0); - Assert.assertNotNull("Test data wasn't found, use \"// REF: \" directive", referenceToString); - } - - return new ExpectedResolveData(shouldBeUnresolved, referenceToString); - } - - public static void checkReferenceResolve(ExpectedResolveData expectedResolveData, int offset, PsiReference psiReference) { - if (psiReference != null) { - PsiElement resolvedTo = psiReference.resolve(); - if (resolvedTo != null) { - String resolvedToElementStr = ReferenceUtils.renderAsGotoImplementation(resolvedTo); - String notEqualMessage = String.format("Found reference to '%s', but '%s' was expected", - resolvedToElementStr, expectedResolveData.getReferenceString()); - assertEquals(notEqualMessage, expectedResolveData.getReferenceString(), resolvedToElementStr); - } - else { - if (!expectedResolveData.shouldBeUnresolved()) { - Assert.assertNull( - String.format("Element %s wasn't resolved to anything, but %s was expected", - psiReference, expectedResolveData.getReferenceString()), - expectedResolveData.getReferenceString()); - } - } - } - else { - Assert.assertNull( - String.format("No reference found at offset: %s, but one resolved to %s was expected", - offset, expectedResolveData.getReferenceString()), - expectedResolveData.getReferenceString()); - } - } - - @Nullable - @Override - protected LightProjectDescriptor getProjectDescriptor() { - return JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE; - } - - @NotNull - @Override - protected String getTestDataPath() { - return "./"; - } -} diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt new file mode 100644 index 00000000000..6211bc78dcc --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/AbstractReferenceResolveTest.kt @@ -0,0 +1,151 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.resolve + +import com.google.common.collect.Lists +import com.google.common.collect.Ordering +import com.intellij.psi.PsiPolyVariantReference +import com.intellij.psi.PsiReference +import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.testFramework.UsefulTestCase +import com.intellij.util.PathUtil +import org.jetbrains.kotlin.idea.test.JetWithJdkAndRuntimeLightProjectDescriptor +import org.jetbrains.kotlin.idea.test.KotlinLightPlatformCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.PluginTestCaseBase +import org.jetbrains.kotlin.test.InTextDirectivesUtils +import org.jetbrains.kotlin.test.ReferenceUtils +import org.jetbrains.kotlin.test.util.configureWithExtraFile +import org.junit.Assert +import kotlin.test.assertEquals +import kotlin.test.assertNotNull +import kotlin.test.assertNull +import kotlin.test.assertTrue + +public abstract class AbstractReferenceResolveTest : KotlinLightPlatformCodeInsightFixtureTestCase() { + public class ExpectedResolveData(private val shouldBeUnresolved: Boolean?, public val referenceString: String) { + + public fun shouldBeUnresolved(): Boolean { + return shouldBeUnresolved!! + } + } + + protected open fun doTest(path: String) { + assert(path.endsWith(".kt")) { path } + myFixture.configureWithExtraFile(path, ".Data") + performChecks() + } + + protected fun performChecks() { + if (InTextDirectivesUtils.isDirectiveDefined(myFixture.getFile().getText(), MULTIRESOLVE)) { + doMultiResolveTest() + } + else { + doSingleResolveTest() + } + } + + protected fun doSingleResolveTest() { + forEachCaret { index, offset -> + val expectedResolveData = readResolveData(myFixture.getFile().getText(), index) + val psiReference = myFixture.getFile().findReferenceAt(offset) + checkReferenceResolve(expectedResolveData, offset, psiReference) + } + } + + protected fun doMultiResolveTest() { + forEachCaret { index, offset -> + val expectedReferences = getExpectedReferences(myFixture.getFile().getText(), index) + + val psiReference = myFixture.getFile().findReferenceAt(offset) + assertTrue(psiReference is PsiPolyVariantReference) + psiReference as PsiPolyVariantReference + + val results = psiReference.multiResolve(true) + + val actualResolvedTo = Lists.newArrayList() + for (result in results) { + actualResolvedTo.add(ReferenceUtils.renderAsGotoImplementation(result.getElement()!!)) + } + + UsefulTestCase.assertOrderedEquals("Not matching for reference #$index", actualResolvedTo.sort(), expectedReferences.sort()) + } + } + + private fun forEachCaret(action: (index: Int, offset: Int) -> Unit) { + val offsets = myFixture.getEditor().getCaretModel().getAllCarets().map { it.getOffset() } + val singleCaret = offsets.size() == 1 + for ((index, offset) in offsets.withIndex()) { + action(if (singleCaret) -1 else index + 1, offset) + } + } + + override fun getProjectDescriptor(): LightProjectDescriptor? = JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE + + override fun getTestDataPath() = "./" + + companion object { + public val MULTIRESOLVE: String = "MULTIRESOLVE" + public val REF_EMPTY: String = "REF_EMPTY" + + public fun readResolveData(fileText: String, index: Int): ExpectedResolveData { + val shouldBeUnresolved = InTextDirectivesUtils.isDirectiveDefined(fileText, REF_EMPTY) + val refs = getExpectedReferences(fileText, index) + + val referenceToString: String + if (shouldBeUnresolved) { + Assert.assertTrue("REF: directives will be ignored for $REF_EMPTY test: $refs", refs.isEmpty()) + referenceToString = "" + } + else { + assertTrue(refs.size() == 1, "Must be a single ref: $refs.\nUse $MULTIRESOLVE if you need multiple refs\nUse $REF_EMPTY for an unresolved reference") + referenceToString = refs.get(0) + Assert.assertNotNull("Test data wasn't found, use \"// REF: \" directive", referenceToString) + } + + return ExpectedResolveData(shouldBeUnresolved, referenceToString) + } + + // purpose of this helper is to deal with the case when navigation element is a file + // see ReferenceResolveInJavaTestGenerated.testPackageFacade() + private fun getExpectedReferences(text: String, index: Int): List { + val prefix = if (index > 0) "// REF$index:" else "// REF:" + val prefixes = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, prefix) + return prefixes.map { + val replaced = it.replace("", PluginTestCaseBase.getTestDataPathBase()) + PathUtil.toSystemDependentName(replaced).replace("//", "/") //happens on Unix + } + } + + public fun checkReferenceResolve(expectedResolveData: ExpectedResolveData, offset: Int, psiReference: PsiReference?) { + if (psiReference != null) { + val resolvedTo = psiReference.resolve() + if (resolvedTo != null) { + val resolvedToElementStr = ReferenceUtils.renderAsGotoImplementation(resolvedTo) + assertEquals(expectedResolveData.referenceString, resolvedToElementStr, "Found reference to '$resolvedToElementStr', but '${expectedResolveData.referenceString}' was expected") + } + else { + if (!expectedResolveData.shouldBeUnresolved()) { + assertNull(expectedResolveData.referenceString, "Element $psiReference wasn't resolved to anything, but ${expectedResolveData.referenceString} was expected") + } + } + } + else { + assertNull(expectedResolveData.referenceString, "No reference found at offset: $offset, but one resolved to ${expectedResolveData.referenceString} was expected") + } + } + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java index 5c38f574575..afaea8b1dc3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/ReferenceResolveTestGenerated.java @@ -347,6 +347,12 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest doTest(fileName); } + @TestMetadata("SyntheticProperty.kt") + public void testSyntheticProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/SyntheticProperty.kt"); + doTest(fileName); + } + @TestMetadata("TypeParameterInAnonymousObject.kt") public void testTypeParameterInAnonymousObject() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/TypeParameterInAnonymousObject.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/test/ReferenceUtils.java b/idea/tests/org/jetbrains/kotlin/test/ReferenceUtils.java index 25070b8c380..647ebfdd9b4 100644 --- a/idea/tests/org/jetbrains/kotlin/test/ReferenceUtils.java +++ b/idea/tests/org/jetbrains/kotlin/test/ReferenceUtils.java @@ -21,17 +21,11 @@ import com.intellij.navigation.NavigationItem; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiPackage; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.PathUtil; -import kotlin.KotlinPackage; -import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase; import org.jetbrains.kotlin.psi.JetClass; import org.jetbrains.kotlin.psi.JetObjectDeclaration; import org.junit.Assert; -import java.util.List; - public final class ReferenceUtils { private ReferenceUtils() { } @@ -60,18 +54,4 @@ public final class ReferenceUtils { ? presentableText : locationString + "." + presentableText; } - - // purpose of this helper is to deal with the case when navigation element is a file - // see ReferenceResolveInJavaTestGenerated.testPackageFacade() - @NotNull - public static List getExpectedReferences(@NotNull String text) { - List prefixes = InTextDirectivesUtils.findLinesWithPrefixesRemoved(text, "// REF:"); - return KotlinPackage.map(prefixes, new Function1() { - @Override - public String invoke(String s) { - String replaced = s.replace("", PluginTestCaseBase.getTestDataPathBase()); - return PathUtil.toSystemDependentName(replaced).replace("//", "/"); //happens on Unix - } - }); - } } From 13f0d3ca23c6852c185f7e1288a131dabae440d1 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 18:22:22 +0300 Subject: [PATCH 309/450] Initial implementation of usage search for get/set methods in form of synthetic extension --- .../synthetic/SyntheticExtensionsScope.kt | 11 ++++++ .../caches/resolve/JavaResolveExtension.kt | 23 +++-------- idea/src/META-INF/plugin.xml | 2 +- .../UsePropertyAccessSyntaxIntention.kt | 11 +----- .../changeSignature/JetChangeInfo.kt | 2 +- .../JetChangeSignatureUsageProcessor.java | 2 + .../changeSignature/ui/KotlinCallerChooser.kt | 2 +- ...nIntroduceParameterMethodUsageProcessor.kt | 2 +- ...tlinPropertyAccessorsReferenceSearcher.kt} | 38 ++++++++++++------- .../SyntheticProperties.0.java | 6 +++ .../SyntheticProperties.1.kt | 5 +++ .../SyntheticProperties.results.txt | 2 + .../JetFindUsagesTestGenerated.java | 6 +++ 13 files changed, 68 insertions(+), 44 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/{KotlinLightPropertyAccessorsReferenceSearcher.kt => KotlinPropertyAccessorsReferenceSearcher.kt} (58%) create mode 100644 idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java create mode 100644 idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.1.kt create mode 100644 idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.results.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index ab7b91d3933..ec392b71faf 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -39,6 +39,17 @@ import java.util.* interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor val setMethod: FunctionDescriptor? + + companion object { + fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { + val owner = getterOrSetter.getContainingDeclaration() + if (owner !is JavaClassDescriptor) return null + + return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) + .filterIsInstance() + .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } + } + } } class AdditionalScopesWithSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt index ba0e9518b98..1baf2103b85 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt @@ -45,32 +45,21 @@ public object JavaResolveExtension : CacheExtension<(PsiElement) -> Pair resolver.resolveConstructor(JavaConstructorImpl(method)) else -> resolver.resolveMethod(JavaMethodImpl(method)) } - assert(methodDescriptor != null) { "No descriptor found for " + method.getText() } - - return methodDescriptor!! } -fun PsiClass.getJavaClassDescriptor(): ClassDescriptor { - val resolver = JavaResolveExtension.getResolver(getProject(), this) - val classDescriptor = resolver.resolveClass(JavaClassImpl(this)) - assert(classDescriptor != null) { "No descriptor found for " + getText() } - - return classDescriptor!! +fun PsiClass.getJavaClassDescriptor(): ClassDescriptor? { + return JavaResolveExtension.getResolver(getProject(), this).resolveClass(JavaClassImpl(this)) } -fun PsiField.getJavaFieldDescriptor(): PropertyDescriptor { - val resolver = JavaResolveExtension.getResolver(getProject(), this) - val fieldDescriptor = resolver.resolveField(JavaFieldImpl(this)) - assert(fieldDescriptor != null) { "No descriptor found for " + getText() } - - return fieldDescriptor!! +fun PsiField.getJavaFieldDescriptor(): PropertyDescriptor? { + return JavaResolveExtension.getResolver(getProject(), this).resolveField(JavaFieldImpl(this)) } fun PsiMember.getJavaMemberDescriptor(): DeclarationDescriptor? { diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 8894006e50b..d3edb629a19 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -502,7 +502,7 @@ - + diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 964c9d2412a..6a035528e54 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -88,7 +88,7 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent } private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { - findSyntheticPropertyNoOverriddenCheck(function, resolutionScope)?.let { return it } + SyntheticExtensionPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } for (overridden in function.getOverriddenDescriptors()) { findSyntheticProperty(overridden, resolutionScope)?.let { return it } @@ -97,15 +97,6 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent return null } - private fun findSyntheticPropertyNoOverriddenCheck(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { - val owner = function.getContainingDeclaration() - if (owner !is JavaClassDescriptor) return null - - return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) - .filterIsInstance() - .firstOrNull { function == it.getMethod || function == it.setMethod } - } - private fun replaceWithPropertyGet(callExpression: JetCallExpression, propertyName: Name) { val newExpression = JetPsiFactory(callExpression).createExpression(propertyName.render()) callExpression.replace(newExpression) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt index 0f049551a01..9a15bb58bd2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeInfo.kt @@ -388,7 +388,7 @@ public fun JetChangeInfo.getAffectedCallables(): Collection = methodD public fun ChangeInfo.toJetChangeInfo(originalChangeSignatureDescriptor: JetMethodDescriptor): JetChangeInfo { val method = getMethod() as PsiMethod - val functionDescriptor = method.getJavaMethodDescriptor() + val functionDescriptor = method.getJavaMethodDescriptor()!! val parameterDescriptors = functionDescriptor.getValueParameters() //noinspection ConstantConditions diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java index fd3bd9db57b..2b5c86bc055 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/JetChangeSignatureUsageProcessor.java @@ -394,6 +394,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro if (!RefactoringPackage.isTrueJavaMethod(method)) return; FunctionDescriptor methodDescriptor = ResolvePackage.getJavaMethodDescriptor((PsiMethod) method); + assert methodDescriptor != null; DeclarationDescriptor containingDescriptor = methodDescriptor.getContainingDeclaration(); if (!(containingDescriptor instanceof JavaClassDescriptor)) return; @@ -958,6 +959,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro boolean startedFromJava = method instanceof PsiMethod; if (startedFromJava && originalJavaMethodDescriptor == null) { FunctionDescriptor methodDescriptor = ResolvePackage.getJavaMethodDescriptor((PsiMethod) method); + assert methodDescriptor != null; originalJavaMethodDescriptor = new JetChangeSignatureData(methodDescriptor, method, Collections.singletonList(methodDescriptor));; diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt index 7c71b4f010a..9ee84b4ed31 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt @@ -83,7 +83,7 @@ public class KotlinMethodNode( val descriptor = when (myMethod) { is JetFunction -> myMethod.resolveToDescriptor() as FunctionDescriptor is JetClass -> (myMethod.resolveToDescriptor() as ClassDescriptor).getUnsubstitutedPrimaryConstructor() ?: return - is PsiMethod -> myMethod.getJavaMethodDescriptor() + is PsiMethod -> myMethod.getJavaMethodDescriptor() ?: return else -> throw AssertionError("Invalid declaration: ${myMethod.getElementTextWithContext()}") } val containerName = sequence(descriptor) { it.getContainingDeclaration() } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt index ae465fde734..206873cb47f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterMethodUsageProcessor.kt @@ -89,7 +89,7 @@ public class KotlinIntroduceParameterMethodUsageProcessor : IntroduceParameterMe val changeInfo = createChangeInfo(data, element) ?: return true // Java method is already updated at this point - val addedParameterType = data.getMethodToReplaceIn().getJavaMethodDescriptor().getValueParameters().last().getType() + val addedParameterType = data.getMethodToReplaceIn().getJavaMethodDescriptor()!!.getValueParameters().last().getType() changeInfo.getNewParameters().last().currentTypeText = IdeDescriptorRenderers.SOURCE_CODE.renderType(addedParameterType) val scope = element.getUseScope().let { diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinLightPropertyAccessorsReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt similarity index 58% rename from idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinLightPropertyAccessorsReferenceSearcher.kt rename to idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt index 91bc4c5a187..c65191aa4b9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinLightPropertyAccessorsReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt @@ -17,27 +17,27 @@ package org.jetbrains.kotlin.idea.search.ideaExtensions import com.intellij.openapi.application.QueryExecutorBase +import com.intellij.psi.PsiMethod import com.intellij.psi.PsiReference import com.intellij.psi.search.GlobalSearchScope import com.intellij.psi.search.SearchScope import com.intellij.psi.search.UsageSearchContext import com.intellij.psi.search.searches.MethodReferencesSearch import com.intellij.util.Processor -import org.jetbrains.kotlin.idea.JetFileType import org.jetbrains.kotlin.asJava.namedUnwrappedElement +import org.jetbrains.kotlin.idea.JetFileType +import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor import org.jetbrains.kotlin.psi.JetProperty +import org.jetbrains.kotlin.storage.LockBasedStorageManager +import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticExtensionsScope -public class KotlinLightPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { +public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor) { val method = queryParameters.getMethod() - val unwrapped = method.namedUnwrappedElement + val propertyName = propertyName(method) ?: return - if (unwrapped !is JetProperty) return - - val propertyName = unwrapped.getName() - if (propertyName == null) return - - val onlyKotlinFiles = restrictToKotlinSources(queryParameters.getScope()) + val onlyKotlinFiles = restrictToKotlinSources(queryParameters.getEffectiveSearchScope()) queryParameters.getOptimizer()!!.searchWord( propertyName, @@ -47,10 +47,22 @@ public class KotlinLightPropertyAccessorsReferenceSearcher() : QueryExecutorBase method) } - private fun restrictToKotlinSources(originalScope: SearchScope): SearchScope { - if (originalScope is GlobalSearchScope) { - return GlobalSearchScope.getScopeRestrictedByFileTypes(originalScope as GlobalSearchScope, JetFileType.INSTANCE) + private fun propertyName(method: PsiMethod): String? { + val unwrapped = method.namedUnwrappedElement + if (unwrapped is JetProperty) { + return unwrapped.getName() + } + + val functionDescriptor = method.getJavaMethodDescriptor() ?: return null + val syntheticExtensionsScope = SyntheticExtensionsScope(LockBasedStorageManager()) + val property = SyntheticExtensionPropertyDescriptor.findByGetterOrSetter(functionDescriptor, syntheticExtensionsScope) ?: return null + return property.getName().asString() + } + + private fun restrictToKotlinSources(originalScope: SearchScope): SearchScope { + return when (originalScope) { + is GlobalSearchScope -> GlobalSearchScope.getScopeRestrictedByFileTypes(originalScope, JetFileType.INSTANCE) + else -> originalScope } - return originalScope } } diff --git a/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java new file mode 100644 index 00000000000..763832cbb04 --- /dev/null +++ b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java @@ -0,0 +1,6 @@ +// PSI_ELEMENT: com.intellij.psi.PsiMethod +// OPTIONS: usages +class JavaClass { + public int getSomething() { return 1; } + public void setSomething(int value) {} +} \ No newline at end of file diff --git a/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.1.kt b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.1.kt new file mode 100644 index 00000000000..f305e8e07e3 --- /dev/null +++ b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.1.kt @@ -0,0 +1,5 @@ +fun foo(javaClass: JavaClass) { + print(javaClass.something) + javaClass.something = 1 + javaClass.something++ +} diff --git a/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.results.txt b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.results.txt new file mode 100644 index 00000000000..2be354cdc95 --- /dev/null +++ b/idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.results.txt @@ -0,0 +1,2 @@ +Value read (2: 21) print(javaClass.something) +Value read (4: 15) javaClass.something++ diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/JetFindUsagesTestGenerated.java b/idea/tests/org/jetbrains/kotlin/findUsages/JetFindUsagesTestGenerated.java index cdf5da168d4..dcbe2cdde33 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/JetFindUsagesTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/findUsages/JetFindUsagesTestGenerated.java @@ -1250,6 +1250,12 @@ public class JetFindUsagesTestGenerated extends AbstractJetFindUsagesTest { String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/java/findJavaMethodUsages/JKMethodUsages.0.java"); doTest(fileName); } + + @TestMetadata("SyntheticProperties.0.java") + public void testSyntheticProperties() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/findUsages/java/findJavaMethodUsages/SyntheticProperties.0.java"); + doTest(fileName); + } } } } From 63614c5892c0162556eaaf97354416163c981bb1 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 19:44:54 +0300 Subject: [PATCH 310/450] Initial implementation of renaming extension property usages on getter or setter rename --- .../synthetic/SyntheticExtensionsScope.kt | 20 ++++++--- .../idea/references/JetSimpleNameReference.kt | 44 +++++++++++++------ .../syntheticPropertyUsages1/after/Usages.kt | 6 +++ .../after/testing/JavaClass.java | 6 +++ .../syntheticPropertyUsages1/before/Usages.kt | 6 +++ .../before/testing/JavaClass.java | 6 +++ .../renameGetMethod.test | 6 +++ .../syntheticPropertyUsages2/after/Usages.kt | 6 +++ .../after/testing/JavaClass.java | 6 +++ .../syntheticPropertyUsages2/before/Usages.kt | 6 +++ .../before/testing/JavaClass.java | 6 +++ .../renameSetMethod.test | 6 +++ .../refactoring/rename/AbstractRenameTest.kt | 8 +--- .../rename/RenameTestGenerated.java | 12 +++++ 14 files changed, 117 insertions(+), 27 deletions(-) create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages1/after/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages1/after/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages1/before/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages1/before/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages1/renameGetMethod.test create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages2/after/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages2/after/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages2/before/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index ec392b71faf..0442717dae0 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -151,13 +151,19 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return Name.identifier("set" + propertyName.getIdentifier().capitalize()) } - private fun fromGetMethodName(methodName: Name): Name? { - if (methodName.isSpecial()) return null - val identifier = methodName.getIdentifier() - if (!identifier.startsWith("get")) return null - val name = identifier.removePrefix("get").decapitalize() - if (!Name.isValidIdentifier(name)) return null - return Name.identifier(name) + companion object { + public fun fromGetMethodName(methodName: Name): Name? = fromAccessorMethodName(methodName, "get") + + public fun fromSetMethodName(methodName: Name): Name? = fromAccessorMethodName(methodName, "set") + + private fun fromAccessorMethodName(methodName: Name, prefix: String): Name? { + if (methodName.isSpecial()) return null + val identifier = methodName.getIdentifier() + if (!identifier.startsWith(prefix)) return null + val name = identifier.removePrefix(prefix).decapitalize() + if (!Name.isValidIdentifier(name)) return null + return Name.identifier(name) + } } private class MyPropertyDescriptor( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index 7d7c3913480..16e3b194e05 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -38,7 +38,9 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticExtensionsScope import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.constant @@ -135,6 +137,22 @@ public class JetSimpleNameReference( } } + @suppress("NAME_SHADOWING") + var newElementName = newElementName!! + + val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) + if (bindingContext[BindingContext.REFERENCE_TARGET, expression] is SyntheticExtensionPropertyDescriptor) { + if (Name.isValidIdentifier(newElementName)) { + val newNameAsName = Name.identifier(newElementName) + val newName = when (access()) { + Access.READ -> SyntheticExtensionsScope.fromGetMethodName(newNameAsName) + Access.WRITE -> SyntheticExtensionsScope.fromSetMethodName(newNameAsName) + Access.READ_WRITE -> SyntheticExtensionsScope.fromGetMethodName(newNameAsName) ?: SyntheticExtensionsScope.fromSetMethodName(newNameAsName) + } ?: return expression //TODO: handle the case when get/set becomes ordinary method + newElementName = newName.getIdentifier() + } + } + val psiFactory = JetPsiFactory(expression) val element = when (expression.getReferencedNameElementType()) { JetTokens.FIELD_IDENTIFIER -> psiFactory.createFieldIdentifier(newElementName) @@ -156,23 +174,21 @@ public class JetSimpleNameReference( var nameElement = expression.getReferencedNameElement() val elementType = nameElement.getNode()?.getElementType() - val opExpression = - PsiTreeUtil.getParentOfType(expression, javaClass(), javaClass()) + val opExpression = PsiTreeUtil.getParentOfType(expression, javaClass(), javaClass()) if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null && opExpression != null) { - val oldDescriptor = expression.analyze()[BindingContext.REFERENCE_TARGET, expression] + val oldDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, expression] val newExpression = OperatorToFunctionIntention.convert(opExpression) - newExpression.accept( - object: JetTreeVisitorVoid() { - override fun visitCallExpression(expression: JetCallExpression) { - val callee = expression.getCalleeExpression() as? JetSimpleNameExpression - if (callee != null && callee.analyze()[BindingContext.REFERENCE_TARGET, callee] == oldDescriptor) { - nameElement = callee.getReferencedNameElement() - } - else { - super.visitCallExpression(expression) - } - } + newExpression.accept(object : JetTreeVisitorVoid() { + override fun visitCallExpression(expression: JetCallExpression) { + val callee = expression.getCalleeExpression() as? JetSimpleNameExpression + if (callee != null && bindingContext[BindingContext.REFERENCE_TARGET, callee] == oldDescriptor) { + nameElement = callee.getReferencedNameElement() } + else { + super.visitCallExpression(expression) + } + } + } ) } diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/Usages.kt new file mode 100644 index 00000000000..c9635f4e917 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/Usages.kt @@ -0,0 +1,6 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.something = javaClass.somethingNew + 1 + javaClass.somethingNew++ +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/testing/JavaClass.java new file mode 100644 index 00000000000..daec9622c18 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages1/after/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public int getSomethingNew() { return 1; } + public void setSomething(int value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/Usages.kt new file mode 100644 index 00000000000..97a3bb2eda3 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/Usages.kt @@ -0,0 +1,6 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.something = javaClass.something + 1 + javaClass.something++ +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/testing/JavaClass.java new file mode 100644 index 00000000000..87b737c9ce3 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages1/before/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public int getSomething() { return 1; } + public void setSomething(int value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages1/renameGetMethod.test b/idea/testData/refactoring/rename/syntheticPropertyUsages1/renameGetMethod.test new file mode 100644 index 00000000000..bdf2e845685 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages1/renameGetMethod.test @@ -0,0 +1,6 @@ +{ + "type": "JAVA_METHOD", + "classId": "testing/JavaClass", + "methodSignature": "int getSomething()", + "newName": "getSomethingNew" +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/Usages.kt new file mode 100644 index 00000000000..d850719ed2e --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/Usages.kt @@ -0,0 +1,6 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.somethingNew = javaClass.something + 1 + javaClass.somethingNew++ +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/testing/JavaClass.java new file mode 100644 index 00000000000..a592c8fe126 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/after/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public int getSomething() { return 1; } + public void setSomethingNew(int value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt new file mode 100644 index 00000000000..d850719ed2e --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt @@ -0,0 +1,6 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.somethingNew = javaClass.something + 1 + javaClass.somethingNew++ +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/testing/JavaClass.java new file mode 100644 index 00000000000..87b737c9ce3 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public int getSomething() { return 1; } + public void setSomething(int value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test b/idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test new file mode 100644 index 00000000000..41fee1bdcf5 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test @@ -0,0 +1,6 @@ +{ + "type": "JAVA_METHOD", + "classId": "testing/JavaClass", + "methodSignature": "void setSomething(int value)", + "newName": "setSomethingNew" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt index 0622cd4efc3..1add86f238a 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt @@ -299,11 +299,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { private fun String.toClassId(): ClassId { - val lastSlash = lastIndexOf("/") - if (lastSlash == -1) { - throw IllegalArgumentException("Class id should contain slash: $this") - } - val relativeClassName = FqName(substring(lastSlash + 1)) - val packageFqName = FqName(substring(0, lastSlash).replace('/', '.')) + val relativeClassName = FqName(substringAfterLast('/')) + val packageFqName = FqName(substringBeforeLast('/', "").replace('/', '.')) return ClassId(packageFqName, relativeClassName, false) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java index 536fce18bfd..22b18c54325 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java @@ -370,4 +370,16 @@ public class RenameTestGenerated extends AbstractRenameTest { String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/renameUnaryMinus/unaryMinus.test"); doTest(fileName); } + + @TestMetadata("syntheticPropertyUsages1/renameGetMethod.test") + public void testSyntheticPropertyUsages1_RenameGetMethod() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/syntheticPropertyUsages1/renameGetMethod.test"); + doTest(fileName); + } + + @TestMetadata("syntheticPropertyUsages2/renameSetMethod.test") + public void testSyntheticPropertyUsages2_RenameSetMethod() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test"); + doTest(fileName); + } } From 92349e41ec184c6412f5b712092f4247a87352b7 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:00:17 +0300 Subject: [PATCH 311/450] Reordered parameters --- .../kotlin/idea/codeInsight/ReferenceVariantsHelper.kt | 4 ++-- .../org/jetbrains/kotlin/idea/completion/CompletionSession.kt | 4 ++-- .../idea/intentions/UsePropertyAccessSyntaxIntention.kt | 2 +- .../idea/parameterInfo/JetFunctionParameterInfoHandler.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 96032f7e66f..16a0f36ab0e 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -60,8 +60,8 @@ public class ReferenceVariantsHelper( public fun getReferenceVariants( expression: JetSimpleNameExpression, kindFilter: DescriptorKindFilter, - useRuntimeReceiverType: Boolean, - nameFilter: (Name) -> Boolean + nameFilter: (Name) -> Boolean, + useRuntimeReceiverType: Boolean = false ): Collection { val variants = getReferenceVariantsNoVisibilityFilter(expression, kindFilter, useRuntimeReceiverType, nameFilter) .filter(visibilityFilter) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 3883a756983..094b146acf7 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -209,7 +209,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val referenceVariants: Collection by Delegates.lazy { if (descriptorKindFilter != null) { val expression = reference!!.expression - referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, false, prefixMatcher.asNameFilter()) + referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter()) .excludeNonInitializedVariable(expression) } else { @@ -231,7 +231,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } protected fun getRuntimeReceiverTypeReferenceVariants(): Collection { - val descriptors = referenceVariantsHelper.getReferenceVariants(reference!!.expression, descriptorKindFilter!!, true, prefixMatcher.asNameFilter()) + val descriptors = referenceVariantsHelper.getReferenceVariants(reference!!.expression, descriptorKindFilter!!, prefixMatcher.asNameFilter(), useRuntimeReceiverType = true) return descriptors.filter { descriptor -> referenceVariants.none { comparePossiblyOverridingDescriptors(project, it, descriptor) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 6a035528e54..760ec6279a9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -81,7 +81,7 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent val referenceVariantsHelper = ReferenceVariantsHelper(bindingContext, moduleDescriptor, callExpression.getProject(), ::isVisible) val propertyName = property.getName() - val accessibleVariables = referenceVariantsHelper.getReferenceVariants(callee, DescriptorKindFilter.VARIABLES, false, { it == propertyName }) + val accessibleVariables = referenceVariantsHelper.getReferenceVariants(callee, DescriptorKindFilter.VARIABLES, { it == propertyName }) if (property !in accessibleVariables) return null // shadowed by something else return property diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java index c0ce8301b09..bb395ba8842 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java @@ -414,7 +414,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith }; Collection variants = new ReferenceVariantsHelper(bindingContext, moduleDescriptor, file.getProject(), visibilityFilter).getReferenceVariants( callNameExpression, new DescriptorKindFilter(DescriptorKindFilter.FUNCTIONS_MASK | DescriptorKindFilter.CLASSIFIERS_MASK, - Collections.emptyList()), false, nameFilter); + Collections.emptyList()), nameFilter, false); Collection> itemsToShow = new ArrayList>(); for (DeclarationDescriptor variant : variants) { From 3faa0a193df02963ed3bb0714914c6a83cb33f20 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:01:32 +0300 Subject: [PATCH 312/450] Removed obsolete comment --- .../org/jetbrains/kotlin/idea/completion/CompletionSession.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 094b146acf7..1e7377c0bc6 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -205,7 +205,6 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected abstract val descriptorKindFilter: DescriptorKindFilter? - // set is used only for completion in code fragments protected val referenceVariants: Collection by Delegates.lazy { if (descriptorKindFilter != null) { val expression = reference!!.expression From b33202d32df8a750cf5a2debccb4090afaae9f2d Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:32:30 +0300 Subject: [PATCH 313/450] Hiding getters and setters from completion --- .../codeInsight/ReferenceVariantsHelper.kt | 33 +++++++++++++++---- .../idea/completion/CompletionSession.kt | 10 ++++-- .../completion/KotlinCompletionContributor.kt | 3 +- ...oNotHideGetterWhenExtensionCannotBeUsed.kt | 8 +++++ .../ShowGetMethodWhenNothingElseMatch.kt | 5 +++ .../ShowGetSetOnSecondCompletion.kt | 8 +++++ .../common/extensions/SyntheticExtensions1.kt | 1 + .../common/extensions/SyntheticExtensions2.kt | 8 ++--- .../extensions/SyntheticExtensionsSafeCall.kt | 1 + .../test/JSBasicCompletionTestGenerated.java | 18 ++++++++++ .../test/JvmBasicCompletionTestGenerated.java | 18 ++++++++++ .../JetFunctionParameterInfoHandler.java | 2 +- 12 files changed, 99 insertions(+), 16 deletions(-) create mode 100644 idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt create mode 100644 idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt create mode 100644 idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 16a0f36ab0e..1f135a237dd 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -18,11 +18,11 @@ package org.jetbrains.kotlin.idea.codeInsight import com.intellij.openapi.project.Project -import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.idea.util.* +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.idea.util.CallType +import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter +import org.jetbrains.kotlin.idea.util.getImplicitReceiversWithInstance +import org.jetbrains.kotlin.idea.util.substituteExtensionIfCallable import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* @@ -37,9 +37,11 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.utils.addIfNotNull import java.util.* public class ReferenceVariantsHelper( @@ -61,11 +63,28 @@ public class ReferenceVariantsHelper( expression: JetSimpleNameExpression, kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean, + filterOutJavaGettersAndSetters: Boolean = false, useRuntimeReceiverType: Boolean = false ): Collection { - val variants = getReferenceVariantsNoVisibilityFilter(expression, kindFilter, useRuntimeReceiverType, nameFilter) + var variants: Collection + = getReferenceVariantsNoVisibilityFilter(expression, kindFilter, useRuntimeReceiverType, nameFilter) .filter(visibilityFilter) - return ShadowedDeclarationsFilter(context, moduleDescriptor, project).filter(variants, expression) + + variants = ShadowedDeclarationsFilter(context, moduleDescriptor, project).filter(variants, expression) + + if (filterOutJavaGettersAndSetters) { + val accessorMethodsToRemove = HashSet() + for (variant in variants) { + if (variant is SyntheticExtensionPropertyDescriptor) { + accessorMethodsToRemove.add(variant.getMethod) + accessorMethodsToRemove.addIfNotNull(variant.setMethod) + } + } + + variants = variants.filter { it !in accessorMethodsToRemove } + } + + return variants } private fun getReferenceVariantsNoVisibilityFilter( diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 1e7377c0bc6..c4b6fe976a6 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -61,11 +61,15 @@ import kotlin.properties.Delegates class CompletionSessionConfiguration( val completeNonImportedDeclarations: Boolean, - val completeNonAccessibleDeclarations: Boolean) + val completeNonAccessibleDeclarations: Boolean, + val filterOutJavaGettersAndSetters: Boolean +) fun CompletionSessionConfiguration(parameters: CompletionParameters) = CompletionSessionConfiguration( completeNonImportedDeclarations = parameters.getInvocationCount() >= 2, - completeNonAccessibleDeclarations = parameters.getInvocationCount() >= 2) + completeNonAccessibleDeclarations = parameters.getInvocationCount() >= 2, + filterOutJavaGettersAndSetters = parameters.getInvocationCount() < 2 +) abstract class CompletionSession(protected val configuration: CompletionSessionConfiguration, protected val parameters: CompletionParameters, @@ -208,7 +212,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val referenceVariants: Collection by Delegates.lazy { if (descriptorKindFilter != null) { val expression = reference!!.expression - referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter()) + referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter(), filterOutJavaGettersAndSetters = configuration.filterOutJavaGettersAndSetters) .excludeNonInitializedVariable(expression) } else { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt index 443661a2189..6bbb421b308 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt @@ -249,7 +249,8 @@ public class KotlinCompletionContributor : CompletionContributor() { if (!somethingAdded && parameters.getInvocationCount() < 2) { // Rerun completion if nothing was found val newConfiguration = CompletionSessionConfiguration(completeNonImportedDeclarations = true, - completeNonAccessibleDeclarations = false) + completeNonAccessibleDeclarations = false, + filterOutJavaGettersAndSetters = false) BasicCompletionSession(newConfiguration, parameters, result).complete() } } diff --git a/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt b/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt new file mode 100644 index 00000000000..bfad110447f --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt @@ -0,0 +1,8 @@ +import java.io.File + +fun File.foo(absolutePath: String) { + +} + +// EXIST_JAVA_ONLY: getAbsolutePath +// ABSENT: { itemText: "absolutePath", tailText: " for File" } diff --git a/idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt b/idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt new file mode 100644 index 00000000000..bc619e05fd9 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt @@ -0,0 +1,5 @@ +fun foo(thread: Thread) { + thread.get +} + +// EXIST_JAVA_ONLY: getPriority diff --git a/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt b/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt new file mode 100644 index 00000000000..fef508589b2 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt @@ -0,0 +1,8 @@ +fun foo(thread: Thread) { + thread. +} + +// INVOCATION_COUNT: 2 +// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } +// EXIST_JAVA_ONLY: getPriority +// EXIST_JAVA_ONLY: setPriority diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt index 568ab2a2869..b8625274b72 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt @@ -5,3 +5,4 @@ fun foo(file: File) { } // EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } +// ABSENT: getAbsolutePath diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index 511ecc4b5bd..6fdc9c39ef0 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -1,7 +1,7 @@ -import java.io.File - -fun File.foo() { +fun Thread.foo() { } -// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } +// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } +// ABSENT: getPriority +// ABSENT: setPriority diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt index 8865bcb0403..e145299c03d 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt @@ -5,3 +5,4 @@ fun foo(file: File?) { } // EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } +// ABSENT: getAbsolutePath diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 96778ee88b5..210106ae8d0 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1107,6 +1107,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("DoNotHideGetterWhenExtensionCannotBeUsed.kt") + public void testDoNotHideGetterWhenExtensionCannotBeUsed() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt"); + doTest(fileName); + } + @TestMetadata("ExtensionInExtendedClass.kt") public void testExtensionInExtendedClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ExtensionInExtendedClass.kt"); @@ -1209,6 +1215,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("ShowGetMethodWhenNothingElseMatch.kt") + public void testShowGetMethodWhenNothingElseMatch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt"); + doTest(fileName); + } + + @TestMetadata("ShowGetSetOnSecondCompletion.kt") + public void testShowGetSetOnSecondCompletion() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensions1.kt") public void testSyntheticExtensions1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index ae651dd71f6..d149189acfa 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1107,6 +1107,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("DoNotHideGetterWhenExtensionCannotBeUsed.kt") + public void testDoNotHideGetterWhenExtensionCannotBeUsed() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt"); + doTest(fileName); + } + @TestMetadata("ExtensionInExtendedClass.kt") public void testExtensionInExtendedClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ExtensionInExtendedClass.kt"); @@ -1209,6 +1215,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("ShowGetMethodWhenNothingElseMatch.kt") + public void testShowGetMethodWhenNothingElseMatch() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetMethodWhenNothingElseMatch.kt"); + doTest(fileName); + } + + @TestMetadata("ShowGetSetOnSecondCompletion.kt") + public void testShowGetSetOnSecondCompletion() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensions1.kt") public void testSyntheticExtensions1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java index bb395ba8842..61df88e3725 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/JetFunctionParameterInfoHandler.java @@ -414,7 +414,7 @@ public class JetFunctionParameterInfoHandler implements ParameterInfoHandlerWith }; Collection variants = new ReferenceVariantsHelper(bindingContext, moduleDescriptor, file.getProject(), visibilityFilter).getReferenceVariants( callNameExpression, new DescriptorKindFilter(DescriptorKindFilter.FUNCTIONS_MASK | DescriptorKindFilter.CLASSIFIERS_MASK, - Collections.emptyList()), nameFilter, false); + Collections.emptyList()), nameFilter, false, false); Collection> itemsToShow = new ArrayList>(); for (DeclarationDescriptor variant : variants) { From a08fe96a8bb29dee2396106942293c6f7229c2b4 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:49:17 +0300 Subject: [PATCH 314/450] Renamed methods --- .../kotlin/synthetic/SyntheticExtensionsScope.kt | 8 ++++---- .../kotlin/idea/references/JetSimpleNameReference.kt | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 0442717dae0..7a4300cd35e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -124,7 +124,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (classifier is JavaClassDescriptor) { for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { if (descriptor is FunctionDescriptor) { - val propertyName = fromGetMethodName(descriptor.getName()) ?: continue + val propertyName = propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) } } @@ -152,11 +152,11 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet } companion object { - public fun fromGetMethodName(methodName: Name): Name? = fromAccessorMethodName(methodName, "get") + public fun propertyNameByGetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "get") - public fun fromSetMethodName(methodName: Name): Name? = fromAccessorMethodName(methodName, "set") + public fun propertyNameBySetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "set") - private fun fromAccessorMethodName(methodName: Name, prefix: String): Name? { + private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String): Name? { if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith(prefix)) return null diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index 16e3b194e05..8da8fced153 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -145,9 +145,9 @@ public class JetSimpleNameReference( if (Name.isValidIdentifier(newElementName)) { val newNameAsName = Name.identifier(newElementName) val newName = when (access()) { - Access.READ -> SyntheticExtensionsScope.fromGetMethodName(newNameAsName) - Access.WRITE -> SyntheticExtensionsScope.fromSetMethodName(newNameAsName) - Access.READ_WRITE -> SyntheticExtensionsScope.fromGetMethodName(newNameAsName) ?: SyntheticExtensionsScope.fromSetMethodName(newNameAsName) + Access.READ -> SyntheticExtensionsScope.propertyNameByGetMethodName(newNameAsName) + Access.WRITE -> SyntheticExtensionsScope.propertyNameBySetMethodName(newNameAsName) + Access.READ_WRITE -> SyntheticExtensionsScope.propertyNameByGetMethodName(newNameAsName) ?: SyntheticExtensionsScope.propertyNameBySetMethodName(newNameAsName) } ?: return expression //TODO: handle the case when get/set becomes ordinary method newElementName = newName.getIdentifier() } From 962bef6584d37623c9dd19055769f3cc7ba7d0c5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:50:44 +0300 Subject: [PATCH 315/450] Moved methods --- .../synthetic/SyntheticExtensionsScope.kt | 30 +++++++++---------- .../idea/references/JetSimpleNameReference.kt | 8 ++--- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 7a4300cd35e..59608ba56f9 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -49,6 +49,19 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { .filterIsInstance() .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } } + + fun propertyNameByGetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "get") + + fun propertyNameBySetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "set") + + private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String): Name? { + if (methodName.isSpecial()) return null + val identifier = methodName.getIdentifier() + if (!identifier.startsWith(prefix)) return null + val name = identifier.removePrefix(prefix).decapitalize() + if (!Name.isValidIdentifier(name)) return null + return Name.identifier(name) + } } } @@ -124,7 +137,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (classifier is JavaClassDescriptor) { for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { if (descriptor is FunctionDescriptor) { - val propertyName = propertyNameByGetMethodName(descriptor.getName()) ?: continue + val propertyName = SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) } } @@ -151,21 +164,6 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return Name.identifier("set" + propertyName.getIdentifier().capitalize()) } - companion object { - public fun propertyNameByGetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "get") - - public fun propertyNameBySetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "set") - - private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String): Name? { - if (methodName.isSpecial()) return null - val identifier = methodName.getIdentifier() - if (!identifier.startsWith(prefix)) return null - val name = identifier.removePrefix(prefix).decapitalize() - if (!Name.isValidIdentifier(name)) return null - return Name.identifier(name) - } - } - private class MyPropertyDescriptor( javaClass: JavaClassDescriptor, override val getMethod: FunctionDescriptor, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index 8da8fced153..8daa638292c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -40,7 +40,6 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor -import org.jetbrains.kotlin.synthetic.SyntheticExtensionsScope import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.addToStdlib.constant @@ -145,9 +144,10 @@ public class JetSimpleNameReference( if (Name.isValidIdentifier(newElementName)) { val newNameAsName = Name.identifier(newElementName) val newName = when (access()) { - Access.READ -> SyntheticExtensionsScope.propertyNameByGetMethodName(newNameAsName) - Access.WRITE -> SyntheticExtensionsScope.propertyNameBySetMethodName(newNameAsName) - Access.READ_WRITE -> SyntheticExtensionsScope.propertyNameByGetMethodName(newNameAsName) ?: SyntheticExtensionsScope.propertyNameBySetMethodName(newNameAsName) + Access.READ -> SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) + Access.WRITE -> SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) + Access.READ_WRITE -> SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) + ?: SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) } ?: return expression //TODO: handle the case when get/set becomes ordinary method newElementName = newName.getIdentifier() } From 42678bc79af067df284c1bd02e0dbe2aa5e7e8c7 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 9 Jul 2015 20:52:16 +0300 Subject: [PATCH 316/450] Minor optimization --- .../org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 59608ba56f9..88c4f6aaba7 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -42,6 +42,9 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { companion object { fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { + val name = getterOrSetter.getName() + if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization + val owner = getterOrSetter.getContainingDeclaration() if (owner !is JavaClassDescriptor) return null From fac15d29339c5835337576b4f52406bb84a87154 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 10:32:32 +0300 Subject: [PATCH 317/450] Minor simplification in CompletionSession --- .../idea/completion/BasicCompletionSession.kt | 4 +- .../idea/completion/CompletionSession.kt | 37 ++++++++++--------- .../idea/completion/SmartCompletionSession.kt | 6 +-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index ce541503e30..7193af5162b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -82,7 +82,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, return CompletionKind.NAMED_ARGUMENTS_ONLY } - if (reference == null) { + if (nameExpression == null) { val parameter = position.getParent() as? JetParameter return if (parameter != null && position == parameter.getNameIdentifier()) CompletionKind.PARAMETER_NAME @@ -107,7 +107,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, val typeReference = position.getStrictParentOfType() if (typeReference != null) { val firstPartReference = PsiTreeUtil.findChildOfType(typeReference, javaClass()) - if (firstPartReference == reference.expression) { + if (firstPartReference == nameExpression) { return CompletionKind.TYPES } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index c4b6fe976a6..4fdddaf071b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -80,23 +80,23 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val moduleDescriptor: ModuleDescriptor = resolutionFacade.findModuleDescriptor(file) protected val project: Project = position.getProject() - protected val reference: JetSimpleNameReference? + protected val nameExpression: JetSimpleNameExpression? protected val expression: JetExpression? init { val reference = position.getParent()?.getReferences()?.firstIsInstanceOrNull() if (reference != null) { if (reference.expression is JetLabelReferenceExpression) { + this.nameExpression = null this.expression = reference.expression.getParent().getParent() as? JetExpressionWithLabel - this.reference = null } else { - this.expression = reference.expression - this.reference = reference + this.nameExpression = reference.expression + this.expression = nameExpression } } else { - this.reference = null + this.nameExpression = null this.expression = null } } @@ -131,7 +131,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val referenceVariantsHelper: ReferenceVariantsHelper = ReferenceVariantsHelper(bindingContext, moduleDescriptor, project, isVisibleFilter) - protected val receiversData: ReferenceVariantsHelper.ReceiversData? = reference?.let { referenceVariantsHelper.getReferenceVariantsReceivers(it.expression) } + protected val receiversData: ReferenceVariantsHelper.ReceiversData? = nameExpression?.let { referenceVariantsHelper.getReferenceVariantsReceivers(it) } protected val lookupElementFactory: LookupElementFactory = run { if (receiversData != null) { @@ -175,7 +175,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC if (descriptor is TypeParameterDescriptor && !isTypeParameterVisible(descriptor)) return false if (descriptor is DeclarationDescriptorWithVisibility) { - val visible = descriptor.isVisible(inDescriptor, bindingContext, reference?.expression) + val visible = descriptor.isVisible(inDescriptor, bindingContext, nameExpression) if (visible) return true if (!configuration.completeNonAccessibleDeclarations) return false return DescriptorToSourceUtilsIde.getAnyDeclaration(project, descriptor) !is PsiCompiledElement @@ -211,9 +211,12 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val referenceVariants: Collection by Delegates.lazy { if (descriptorKindFilter != null) { - val expression = reference!!.expression - referenceVariantsHelper.getReferenceVariants(expression, descriptorKindFilter!!, prefixMatcher.asNameFilter(), filterOutJavaGettersAndSetters = configuration.filterOutJavaGettersAndSetters) - .excludeNonInitializedVariable(expression) + referenceVariantsHelper.getReferenceVariants( + nameExpression!!, + descriptorKindFilter!!, + prefixMatcher.asNameFilter(), + filterOutJavaGettersAndSetters = configuration.filterOutJavaGettersAndSetters + ).excludeNonInitializedVariable(nameExpression) } else { emptyList() @@ -234,7 +237,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } protected fun getRuntimeReceiverTypeReferenceVariants(): Collection { - val descriptors = referenceVariantsHelper.getReferenceVariants(reference!!.expression, descriptorKindFilter!!, prefixMatcher.asNameFilter(), useRuntimeReceiverType = true) + val descriptors = referenceVariantsHelper.getReferenceVariants(nameExpression!!, descriptorKindFilter!!, prefixMatcher.asNameFilter(), useRuntimeReceiverType = true) return descriptors.filter { descriptor -> referenceVariants.none { comparePossiblyOverridingDescriptors(project, it, descriptor) } } @@ -249,17 +252,17 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } protected fun getTopLevelCallables(): Collection { - val descriptors = indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) }) - return filterShadowedNonImported(descriptors, reference!!) + return indicesHelper.getTopLevelCallables({ prefixMatcher.prefixMatches(it) }) + .filterShadowedNonImported() } protected fun getTopLevelExtensions(): Collection { - val descriptors = indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, reference!!.expression, bindingContext) - return filterShadowedNonImported(descriptors, reference) + return indicesHelper.getCallableTopLevelExtensions({ prefixMatcher.prefixMatches(it) }, nameExpression!!, bindingContext) + .filterShadowedNonImported() } - private fun filterShadowedNonImported(descriptors: Collection, reference: JetSimpleNameReference): Collection { - return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(descriptors, referenceVariants, reference.expression) + private fun Collection.filterShadowedNonImported(): Collection { + return ShadowedDeclarationsFilter(bindingContext, moduleDescriptor, project).filterNonImported(this, referenceVariants, nameExpression!!) } protected fun addAllClasses(kindFilter: (ClassKind) -> Boolean) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt index fd370e8ee82..38f42d0e95e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt @@ -57,7 +57,7 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para if (result != null) { collector.addElements(result.additionalItems) - if (reference != null) { + if (nameExpression != null) { val filter = result.declarationFilter if (filter != null) { referenceVariants.forEach { collector.addElements(filter(it)) } @@ -86,8 +86,8 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para // special completion for outside parenthesis lambda argument private fun addFunctionLiteralArgumentCompletions() { - if (reference != null) { - val receiverData = ReferenceVariantsHelper.getExplicitReceiverData(reference.expression) + if (nameExpression != null) { + val receiverData = ReferenceVariantsHelper.getExplicitReceiverData(nameExpression) if (receiverData != null && receiverData.second == CallType.INFIX) { val call = receiverData.first.getCall(bindingContext) if (call != null && call.getFunctionLiteralArguments().isEmpty()) { From f53a0b0536555c6cb90caa6dc245970a56d4d1b9 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 14:48:40 +0300 Subject: [PATCH 318/450] Converted JetNameReferenceExpression to Kotlin --- .../psi/JetNameReferenceExpression.java | 86 ------------------- .../kotlin/psi/JetNameReferenceExpression.kt | 69 +++++++++++++++ .../kotlin/psi/JetSimpleNameExpression.kt | 27 +++--- 3 files changed, 82 insertions(+), 100 deletions(-) delete mode 100644 compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.java create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.kt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.java deleted file mode 100644 index 9f7cdf5ac33..00000000000 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.psi; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.psi.stubs.KotlinNameReferenceExpressionStub; -import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; -import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.lexer.JetTokens; - -import static org.jetbrains.kotlin.lexer.JetTokens.*; - -public class JetNameReferenceExpression extends JetExpressionImplStub implements JetSimpleNameExpression { - - private static final TokenSet NAME_REFERENCE_EXPRESSIONS = TokenSet.create(IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD); - - public JetNameReferenceExpression(@NotNull ASTNode node) { - super(node); - } - - public JetNameReferenceExpression(@NotNull KotlinNameReferenceExpressionStub stub) { - super(stub, JetStubElementTypes.REFERENCE_EXPRESSION); - } - - @Override - @NotNull - public String getReferencedName() { - KotlinNameReferenceExpressionStub stub = getStub(); - if (stub != null) { - return stub.getReferencedName(); - } - return JetSimpleNameExpressionImpl.Helper.getReferencedNameImpl(this); - } - - @Override - @NotNull - public Name getReferencedNameAsName() { - return JetSimpleNameExpressionImpl.Helper.getReferencedNameAsNameImpl(this); - } - - @Override - @NotNull - public PsiElement getReferencedNameElement() { - PsiElement element = findChildByType(NAME_REFERENCE_EXPRESSIONS); - if (element == null) { - return this; - } - return element; - } - - @Override - @Nullable - public PsiElement getIdentifier() { - return findChildByType(JetTokens.IDENTIFIER); - } - - @NotNull - @Override - public IElementType getReferencedNameElementType() { - return JetSimpleNameExpressionImpl.Helper.getReferencedNameElementTypeImpl(this); - } - - @Override - public R accept(@NotNull JetVisitor visitor, D data) { - return visitor.visitSimpleNameExpression(this, data); - } -} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.kt new file mode 100644 index 00000000000..e2132dc5732 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetNameReferenceExpression.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.psi + +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.tree.IElementType +import com.intellij.psi.tree.TokenSet +import org.jetbrains.kotlin.psi.stubs.KotlinNameReferenceExpressionStub +import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.lexer.JetTokens + +import org.jetbrains.kotlin.lexer.JetTokens.* + +public class JetNameReferenceExpression : JetExpressionImplStub, JetSimpleNameExpression { + public constructor(node: ASTNode) : super(node) { + } + + public constructor(stub: KotlinNameReferenceExpressionStub) : super(stub, JetStubElementTypes.REFERENCE_EXPRESSION) { + } + + override fun getReferencedName(): String { + val stub = getStub() + if (stub != null) { + return stub.getReferencedName() + } + return JetSimpleNameExpressionImpl.getReferencedNameImpl(this) + } + + override fun getReferencedNameAsName(): Name { + return JetSimpleNameExpressionImpl.getReferencedNameAsNameImpl(this) + } + + override fun getReferencedNameElement(): PsiElement { + val element = findChildByType(NAME_REFERENCE_EXPRESSIONS) ?: return this + return element + } + + override fun getIdentifier(): PsiElement? { + return findChildByType(JetTokens.IDENTIFIER) + } + + override fun getReferencedNameElementType(): IElementType { + return JetSimpleNameExpressionImpl.getReferencedNameElementTypeImpl(this) + } + + override fun accept(visitor: JetVisitor, data: D): R { + return visitor.visitSimpleNameExpression(this, data) + } + + companion object { + private val NAME_REFERENCE_EXPRESSIONS = TokenSet.create(IDENTIFIER, FIELD_IDENTIFIER, THIS_KEYWORD, SUPER_KEYWORD) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetSimpleNameExpression.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetSimpleNameExpression.kt index ea8976929c3..3223f76655e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetSimpleNameExpression.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetSimpleNameExpression.kt @@ -18,11 +18,12 @@ package org.jetbrains.kotlin.psi import com.intellij.lang.ASTNode import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference import com.intellij.psi.tree.IElementType -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.name.Name -public trait JetSimpleNameExpression : JetReferenceExpression { +public interface JetSimpleNameExpression : JetReferenceExpression { public fun getReferencedName(): String @@ -36,33 +37,31 @@ public trait JetSimpleNameExpression : JetReferenceExpression { } abstract class JetSimpleNameExpressionImpl(node: ASTNode) : JetExpressionImpl(node), JetSimpleNameExpression { - override fun getIdentifier(): PsiElement? = findChildByType(JetTokens.IDENTIFIER) - override fun getReferencedNameElementType() = getReferencedNameElementTypeImpl() + override fun getReferencedNameElementType() = getReferencedNameElementTypeImpl(this) override fun accept(visitor: JetVisitor, data: D): R { return visitor.visitSimpleNameExpression(this, data) } - override fun getReferencedNameAsName() = getReferencedNameAsNameImpl() + override fun getReferencedNameAsName() = getReferencedNameAsNameImpl(this) - override fun getReferencedName() = getReferencedNameImpl() + override fun getReferencedName() = getReferencedNameImpl(this) //NOTE: an unfortunate way to share an implementation between stubbed and not stubbed tree - companion object Helper { - - fun JetSimpleNameExpression.getReferencedNameElementTypeImpl(): IElementType { - return this.getReferencedNameElement().getNode()!!.getElementType()!! + companion object { + fun getReferencedNameElementTypeImpl(expression: JetSimpleNameExpression): IElementType { + return expression.getReferencedNameElement().getNode()!!.getElementType() } - fun JetSimpleNameExpression.getReferencedNameAsNameImpl(): Name { - val name = this.getReferencedName() + fun getReferencedNameAsNameImpl(expresssion: JetSimpleNameExpression): Name { + val name = expresssion.getReferencedName() return Name.identifierNoValidate(name) } - fun JetSimpleNameExpression.getReferencedNameImpl(): String { - val text = this.getReferencedNameElement().getNode()!!.getText() + fun getReferencedNameImpl(expression: JetSimpleNameExpression): String { + val text = expression.getReferencedNameElement().getNode()!!.getText() return JetPsiUtil.unquoteIdentifierOrFieldReference(text) } } From d8d00a83bbce5899252bec1a1338b262ef78f357 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 16:50:03 +0300 Subject: [PATCH 319/450] Separated references to get/set methods on synthetic extension usage into separate PsiReference's to avoid putting usages like "x++" into "Dynamic usages" group --- .../kotlin/idea/references/JetReference.kt | 2 + .../references/JetReferenceContributor.kt | 60 ++++++++-- .../idea/references/JetSimpleNameReference.kt | 104 +++--------------- .../SyntheticPropertyAccessorReference.kt | 69 ++++++++++++ 4 files changed, 137 insertions(+), 98 deletions(-) create mode 100644 idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt index f56408f4947..ce1a9eb59b5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt @@ -114,6 +114,8 @@ public abstract class AbstractJetReference(element: T) } return context[BindingContext.AMBIGUOUS_LABEL_TARGET, reference] } + + override fun toString() = javaClass.getSimpleName() + ": " + expression.getText() } public abstract class JetSimpleReference(expression: T) : AbstractJetReference(expression) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt index ba9e1b958c8..e123f54f596 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt @@ -16,12 +16,16 @@ package org.jetbrains.kotlin.idea.references -import com.intellij.psi.* -import org.jetbrains.kotlin.psi.* -import com.intellij.util.ProcessingContext import com.intellij.patterns.PlatformPatterns +import com.intellij.psi.* +import com.intellij.util.ProcessingContext import org.jetbrains.kotlin.idea.kdoc.KDocReference import org.jetbrains.kotlin.kdoc.psi.impl.KDocName +import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.getAssignmentByLHS +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis +import org.jetbrains.kotlin.utils.addToStdlib.constant public class JetReferenceContributor() : PsiReferenceContributor() { public override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { @@ -29,38 +33,78 @@ public class JetReferenceContributor() : PsiReferenceContributor() { registerProvider(javaClass()) { JetSimpleNameReference(it) } + + registerMultiProvider(javaClass()) { + if (it.getReferencedNameElementType() != JetTokens.IDENTIFIER) return@registerMultiProvider emptyArray() + + when (it.access()) { + Access.READ -> arrayOf(SyntheticPropertyAccessorReference(it, true)) + Access.WRITE -> arrayOf(SyntheticPropertyAccessorReference(it, false)) + Access.READ_WRITE -> arrayOf(SyntheticPropertyAccessorReference(it, true), SyntheticPropertyAccessorReference(it, false)) + } + } + registerProvider(javaClass()) { JetConstructorDelegationReference(it) } + registerProvider(javaClass()) { JetInvokeFunctionReference(it) } + registerProvider(javaClass()) { JetArrayAccessReference(it) } + registerProvider(javaClass()) { JetForLoopInReference(it) } + registerProvider(javaClass()) { JetPropertyDelegationMethodsReference(it) } + registerProvider(javaClass()) { JetMultiDeclarationReference(it) } + registerProvider(javaClass()) { KDocReference(it) } } } - private fun > PsiReferenceRegistrar.registerProvider( - elementClass: Class, - factory: (E) -> R - ) { + //TODO: there should be some common util for that + private enum class Access { + READ, WRITE, READ_WRITE + } + + private fun JetSimpleNameExpression.access(): Access { + var expression = getQualifiedExpressionForSelectorOrThis() + while (expression.getParent() is JetParenthesizedExpression) { + expression = expression.getParent() as JetParenthesizedExpression + } + + val assignment = expression.getAssignmentByLHS() + if (assignment != null) { + return if (assignment.getOperationToken() == JetTokens.EQ) Access.WRITE else Access.READ_WRITE + } + + return if ((expression.getParent() as? JetUnaryExpression)?.getOperationToken() in constant { setOf(JetTokens.PLUSPLUS, JetTokens.MINUSMINUS) }) + Access.READ_WRITE + else + Access.READ + } + + private fun PsiReferenceRegistrar.registerProvider(elementClass: Class, factory: (E) -> JetReference) { + registerMultiProvider(elementClass, { arrayOf(factory(it)) }) + } + + private fun PsiReferenceRegistrar.registerMultiProvider(elementClass: Class, factory: (E) -> Array) { registerReferenceProvider(PlatformPatterns.psiElement(elementClass), object: PsiReferenceProvider() { override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array { @suppress("UNCHECKED_CAST") - return arrayOf(factory(element as E)) + return factory(element as E) } }) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index 8daa638292c..b4453c21d1f 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -21,8 +21,6 @@ import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil import com.intellij.util.IncorrectOperationException -import com.intellij.util.SmartList -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.codeInsight.shorten.addToShorteningWaitSet import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention @@ -35,69 +33,21 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.plugin.references.SimpleNameReferenceExtension import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElement +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector +import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor import org.jetbrains.kotlin.types.expressions.OperatorConventions -import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.constant - -public class JetSimpleNameReference( - jetSimpleNameExpression: JetSimpleNameExpression -) : JetSimpleReference(jetSimpleNameExpression) { - - override fun getTargetDescriptors(context: BindingContext): Collection { - val targets = super.getTargetDescriptors(context) - if (targets.none { it is SyntheticExtensionPropertyDescriptor }) return targets - - val newTargets = SmartList() - for (target in targets) { - if (!(target !is SyntheticExtensionPropertyDescriptor)) { - val access = access() - if (access == Access.READ || access == Access.READ_WRITE) { - newTargets.add(target.getMethod) - } - if (access == Access.WRITE || access == Access.READ_WRITE) { - newTargets.addIfNotNull(target.setMethod) - } - } - else { - newTargets.add(target) - } - } - return newTargets - } - - //TODO: there should be some common util for that - private enum class Access { - READ, WRITE, READ_WRITE - } - - private fun access(): Access { - var expression = myElement.getQualifiedExpressionForSelectorOrThis() - while (expression.getParent() is JetParenthesizedExpression) { - expression = expression.getParent() as JetParenthesizedExpression - } - - val assignment = expression.getAssignmentByLHS() - if (assignment != null) { - return if (assignment.getOperationToken() == JetTokens.EQ) Access.WRITE else Access.READ_WRITE - } - - return if ((expression.getParent() as? JetUnaryExpression)?.getOperationToken() in constant { setOf(JetTokens.PLUSPLUS, JetTokens.MINUSMINUS) }) - Access.READ_WRITE - else - Access.READ - } +class JetSimpleNameReference(expression: JetSimpleNameExpression) : JetSimpleReference(expression) { override fun isReferenceTo(element: PsiElement?): Boolean { if (element != null) { if (!canBeReferenceTo(element)) return false - val extensions = Extensions.getArea(element.getProject()).getExtensionPoint( - SimpleNameReferenceExtension.EP_NAME).getExtensions() + val extensions = Extensions.getArea(element.getProject()).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).getExtensions() for (extension in extensions) { val value = extension.isReferenceTo(this, element) if (value != null) { @@ -124,7 +74,7 @@ public class JetSimpleNameReference( return true } - public override fun handleElementRename(newElementName: String?): PsiElement? { + override fun handleElementRename(newElementName: String?): PsiElement { if (!canRename()) throw IncorrectOperationException() if (newElementName == null) return expression; @@ -136,38 +86,15 @@ public class JetSimpleNameReference( } } - @suppress("NAME_SHADOWING") - var newElementName = newElementName!! - - val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) - if (bindingContext[BindingContext.REFERENCE_TARGET, expression] is SyntheticExtensionPropertyDescriptor) { - if (Name.isValidIdentifier(newElementName)) { - val newNameAsName = Name.identifier(newElementName) - val newName = when (access()) { - Access.READ -> SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) - Access.WRITE -> SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) - Access.READ_WRITE -> SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) - ?: SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) - } ?: return expression //TODO: handle the case when get/set becomes ordinary method - newElementName = newName.getIdentifier() - } - } - val psiFactory = JetPsiFactory(expression) val element = when (expression.getReferencedNameElementType()) { JetTokens.FIELD_IDENTIFIER -> psiFactory.createFieldIdentifier(newElementName) - else -> { - val extensions = Extensions.getArea(expression.getProject()).getExtensionPoint( - SimpleNameReferenceExtension.EP_NAME).getExtensions() - var handled: PsiElement? = null - for (extension in extensions) { - handled = extension.handleElementRename(this, psiFactory, newElementName) - if (handled != null) { - break - } - } - handled ?: psiFactory.createNameIdentifier(newElementName) + else -> { + Extensions.getArea(expression.getProject()).getExtensionPoint(SimpleNameReferenceExtension.EP_NAME).getExtensions() + .asSequence() + .map { it.handleElementRename(this, psiFactory, newElementName) } + .firstOrNull { it != null } ?: psiFactory.createNameIdentifier(newElementName) } } @@ -176,6 +103,7 @@ public class JetSimpleNameReference( val elementType = nameElement.getNode()?.getElementType() val opExpression = PsiTreeUtil.getParentOfType(expression, javaClass(), javaClass()) if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null && opExpression != null) { + val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) val oldDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, expression] val newExpression = OperatorToFunctionIntention.convert(opExpression) newExpression.accept(object : JetTreeVisitorVoid() { @@ -209,7 +137,7 @@ public class JetSimpleNameReference( fun bindToElement(element: PsiElement, shorteningMode: ShorteningMode): PsiElement = element.getKotlinFqName()?.let { fqName -> bindToFqName(fqName, shorteningMode) } ?: expression - public fun bindToFqName(fqName: FqName, shorteningMode: ShorteningMode = ShorteningMode.DELAYED_SHORTENING): PsiElement { + fun bindToFqName(fqName: FqName, shorteningMode: ShorteningMode = ShorteningMode.DELAYED_SHORTENING): PsiElement { if (fqName.isRoot()) return expression val newExpression = expression.changeQualifiedName(fqName).getQualifiedElementSelector() as JetSimpleNameExpression @@ -231,9 +159,5 @@ public class JetSimpleNameReference( return newExpression } - override fun toString(): String { - return javaClass().getSimpleName() + ": " + expression.getText() - } - override fun getCanonicalText(): String = expression.getText() } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt new file mode 100644 index 00000000000..04194df0f62 --- /dev/null +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.references + +import com.intellij.openapi.util.TextRange +import com.intellij.psi.PsiElement +import com.intellij.util.SmartList +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.JetNameReferenceExpression +import org.jetbrains.kotlin.psi.JetPsiFactory +import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.utils.addIfNotNull + +class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, val getter: Boolean) : JetSimpleReference(expression) { + override fun getTargetDescriptors(context: BindingContext): Collection { + val descriptors = super.getTargetDescriptors(context) + if (descriptors.none { it is SyntheticExtensionPropertyDescriptor }) return emptyList() + + val result = SmartList() + for (descriptor in descriptors) { + if (descriptor is SyntheticExtensionPropertyDescriptor) { + if (getter) { + result.add(descriptor.getMethod) + } + else { + result.addIfNotNull(descriptor.setMethod) + } + } + } + return result + } + + override fun getRangeInElement() = TextRange(0, expression.getTextLength()) + + override fun canRename() = true + + override fun handleElementRename(newElementName: String?): PsiElement? { + if (!Name.isValidIdentifier(newElementName!!)) return expression + + val newNameAsName = Name.identifier(newElementName) + val newName = if (getter) + SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) + else + SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) + if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method + + val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) + expression.getReferencedNameElement().replace(nameIdentifier) + return expression + } +} \ No newline at end of file From 283c8668f5faf6b6e94f5c99b2270685fc8c0616 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 16:50:27 +0300 Subject: [PATCH 320/450] Don't use PsiElement.getReference() on JetElement --- .../psi/{JetElement.java => JetElement.kt} | 18 ++-- .../evaluate/ConstantExpressionEvaluator.kt | 2 +- .../kotlin/idea/findUsages/UsageTypeUtils.kt | 6 +- .../kotlin/idea/highlighter/JetPsiChecker.kt | 3 +- .../TypeKindHighlightingVisitor.java | 8 +- .../kdoc/KDocUnresolvedReferenceInspection.kt | 5 +- .../kotlin/idea/references/JetReference.kt | 6 +- .../kotlin/idea/references/referenceUtil.kt | 27 +++++- .../idea/search/usagesSearch/searchHelpers.kt | 2 +- .../idea/completion/CompletionSession.kt | 3 +- .../completion/NamedArgumentCompletion.kt | 6 +- .../kotlin-android-plugin.iml | 1 + .../android/navigation/gotoResourceHelper.kt | 5 +- .../kotlin/idea/actions/JetAddImportAction.kt | 7 +- .../KotlinCopyPasteReferenceProcessor.kt | 86 ++++++++----------- .../calls/CalleeReferenceVisitorBase.java | 2 +- .../KotlinCalleeMethodsTreeStructure.java | 5 +- .../KotlinCallerMethodsTreeStructure.java | 5 +- ...KotlinHighlightExitPointsHandlerFactory.kt | 3 +- .../idea/imports/KotlinImportOptimizer.kt | 43 +++++----- ...icitFunctionLiteralParamWithItIntention.kt | 5 +- ...thExplicitFunctionLiteralParamIntention.kt | 4 +- .../jetbrains/kotlin/idea/intentions/Utils.kt | 4 +- .../branchedTransformations/IfThenUtils.kt | 5 +- .../kotlin/idea/j2k/J2kPostProcessor.kt | 4 + .../AddOpenModifierToClassDeclarationFix.java | 19 ++-- .../DeprecatedSymbolUsageInWholeProjectFix.kt | 5 +- .../MakeClassAnAnnotationClassFix.java | 13 ++- .../JetChangeSignatureUsageProcessor.java | 3 +- .../changeSignature/JetParameterInfo.kt | 3 +- .../usages/JetPropertyCallUsage.kt | 3 +- .../ExtractableCodeDescriptor.kt | 3 +- .../extractableAnalysisUtil.kt | 7 +- .../KotlinIntroduceParameterHandler.kt | 3 +- .../KotlinInplaceVariableIntroducer.java | 3 +- .../MoveJavaInnerClassKotlinUsagesHandler.kt | 3 +- .../kotlin/idea/refactoring/move/moveUtils.kt | 3 +- .../refactoring/rename/AbstractRenameTest.kt | 3 +- .../kotlin/j2k/ConstructorConverter.kt | 2 +- .../kotlin/j2k/ExpressionConverter.kt | 2 +- .../kotlin/j2k/JavaToKotlinConverter.kt | 14 +-- .../AccessorToPropertyProcessing.kt | 9 +- .../ElementRenamedCodeProcessor.kt | 6 +- .../FieldToPropertyProcessing.kt | 10 +-- .../MethodIntoObjectProcessing.kt | 6 +- .../ToObjectWithOnlyMethodsProcessing.kt | 4 +- .../j2k/usageProcessing/UsageProcessing.kt | 2 +- 47 files changed, 214 insertions(+), 177 deletions(-) rename compiler/frontend/src/org/jetbrains/kotlin/psi/{JetElement.java => JetElement.kt} (55%) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.kt similarity index 55% rename from compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.java rename to compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.kt index 2f809423585..2a727701013 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetElement.kt @@ -14,16 +14,18 @@ * limitations under the License. */ -package org.jetbrains.kotlin.psi; +package org.jetbrains.kotlin.psi -import com.intellij.psi.NavigatablePsiElement; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.NavigatablePsiElement +import com.intellij.psi.PsiReference -public interface JetElement extends NavigatablePsiElement { - @NotNull - JetFile getContainingJetFile(); +public interface JetElement : NavigatablePsiElement { + public fun getContainingJetFile(): JetFile - void acceptChildren(@NotNull JetVisitor visitor, D data); + public fun acceptChildren(visitor: JetVisitor, data: D) - R accept(@NotNull JetVisitor visitor, D data); + public fun accept(visitor: JetVisitor, data: D): R + + @deprecated("Don't use getReference() on JetElement for the choice is unpredictable") + override fun getReference(): PsiReference? } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 0c51f3846b5..1f9a01c1061 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -82,7 +82,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return null } - private val stringExpressionEvaluator = object : JetVisitor, Nothing>() { + private val stringExpressionEvaluator = object : JetVisitor, Nothing?>() { private fun createStringConstant(compileTimeConstant: CompileTimeConstant<*>): TypedCompileTimeConstant? { val constantValue = compileTimeConstant.toConstantValue(TypeUtils.NO_EXPECTED_TYPE) return when (constantValue) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt index 2ea675ccd76..124068962d1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/findUsages/UsageTypeUtils.kt @@ -36,6 +36,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch import org.jetbrains.kotlin.idea.references.JetArrayAccessReference import org.jetbrains.kotlin.idea.references.JetInvokeFunctionReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.references.unwrappedTargets import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.DescriptorUtils @@ -161,8 +162,7 @@ public object UsageTypeUtils { } fun getFunctionUsageType(descriptor: FunctionDescriptor): UsageTypeEnum? { - val ref = refExpr.getReference() - when (ref) { + when (refExpr.mainReference) { is JetArrayAccessReference -> { return when { context[BindingContext.INDEXED_LVALUE_GET, refExpr] != null -> IMPLICIT_GET @@ -216,7 +216,7 @@ public object UsageTypeUtils { else -> getClassUsageType() } is PackageViewDescriptor -> { - if (refExpr.getReference()?.resolve() is PsiPackage) getPackageUsageType() else getClassUsageType() + if (refExpr.mainReference.resolve() is PsiPackage) getPackageUsageType() else getClassUsageType() } is VariableDescriptor -> getVariableUsageType() is FunctionDescriptor -> getFunctionUsageType(descriptor) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt index 7b43e047252..e6d441994be 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/JetPsiChecker.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult import org.jetbrains.kotlin.idea.kdoc.KDocHighlightingVisitor import org.jetbrains.kotlin.idea.quickfix.QuickFixes +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.ProjectRootsUtil import org.jetbrains.kotlin.psi.JetCodeFragment import org.jetbrains.kotlin.psi.JetFile @@ -104,7 +105,7 @@ public open class JetPsiChecker : Annotator, HighlightRangeExtension { when (factory) { in Errors.UNRESOLVED_REFERENCE_DIAGNOSTICS -> { val referenceExpression = diagnostic.getPsiElement() as JetReferenceExpression - val reference = referenceExpression.getReference() + val reference = referenceExpression.mainReference if (reference is MultiRangeReference) { for (range in reference.getRanges()) { val annotation = holder.createErrorAnnotation(range.shiftRight(referenceExpression.getTextOffset()), getDefaultMessage(diagnostic)) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/TypeKindHighlightingVisitor.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/TypeKindHighlightingVisitor.java index a4267bd75fa..31b8a1db3d4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/TypeKindHighlightingVisitor.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/TypeKindHighlightingVisitor.java @@ -20,10 +20,12 @@ import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.psi.*; +import org.jetbrains.kotlin.psi.JetClassOrObject; +import org.jetbrains.kotlin.psi.JetDynamicType; +import org.jetbrains.kotlin.psi.JetSimpleNameExpression; +import org.jetbrains.kotlin.psi.JetTypeParameter; import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage; import org.jetbrains.kotlin.resolve.BindingContext; @@ -34,8 +36,6 @@ class TypeKindHighlightingVisitor extends AfterAnalysisHighlightingVisitor { @Override public void visitSimpleNameExpression(@NotNull JetSimpleNameExpression expression) { - PsiReference ref = expression.getReference(); - if (ref == null) return; if (JetPsiChecker.Companion.getNamesHighlightingEnabled()) { DeclarationDescriptor referenceTarget = bindingContext.get(BindingContext.REFERENCE_TARGET, expression); if (referenceTarget instanceof ConstructorDescriptor) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt index cede495a1a0..a82f28d4bdf 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocUnresolvedReferenceInspection.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.idea.inspections.AbstractKotlinInspection import com.intellij.codeInspection.ProblemsHolder import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.kdoc.psi.impl.KDocName public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() { @@ -29,8 +30,8 @@ public class KDocUnresolvedReferenceInspection(): AbstractKotlinInspection() { private class KDocUnresolvedReferenceVisitor(private val holder: ProblemsHolder): PsiElementVisitor() { override fun visitElement(element: PsiElement) { if (element is KDocName) { - val ref = element.getReference() - if (ref != null && ref.resolve() == null) { + val ref = element.mainReference + if (ref.resolve() == null) { holder.registerProblem(ref) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt index ce1a9eb59b5..983f9885c27 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReference.kt @@ -30,8 +30,10 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.Collections -public trait JetReference : PsiPolyVariantReference { - public fun resolveToDescriptors(bindingContext: BindingContext): Collection +public interface JetReference : PsiPolyVariantReference { + fun resolveToDescriptors(bindingContext: BindingContext): Collection + + override fun getElement(): JetElement } public abstract class AbstractJetReference(element: T) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt index aab2fdae0d3..d10c7cb6c76 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt @@ -19,12 +19,14 @@ package org.jetbrains.kotlin.idea.references import com.intellij.psi.* import org.jetbrains.kotlin.asJava.unwrapped import org.jetbrains.kotlin.idea.intentions.OperatorToFunctionIntention -import org.jetbrains.kotlin.idea.search.usagesSearch.dataClassComponentFunctionName +import org.jetbrains.kotlin.idea.kdoc.KDocReference import org.jetbrains.kotlin.idea.util.ProjectRootsUtil +import org.jetbrains.kotlin.kdoc.psi.impl.KDocName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType -import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.jetbrains.kotlin.utils.emptyOrSingletonList import java.util.HashSet @@ -111,6 +113,25 @@ fun AbstractJetReference.renameImplicitConventionalCall(newNa if (newName == null) return expression val expr = OperatorToFunctionIntention.convert(expression) as JetQualifiedExpression - val newCallee = (expr.getSelectorExpression() as JetCallExpression).getCalleeExpression()!!.getReference()!!.handleElementRename(newName) + val callee = (expr.getSelectorExpression() as JetCallExpression).getCalleeExpression() as JetSimpleNameExpression + val newCallee = callee.mainReference.handleElementRename(newName) return newCallee.getStrictParentOfType() as JetExpression } + +val JetSimpleNameExpression.mainReference: JetSimpleNameReference + get() = getReferences().firstIsInstance() + +val JetReferenceExpression.mainReference: JetReference + get() = if (this is JetSimpleNameExpression) mainReference else getReferences().firstIsInstance() + +val KDocName.mainReference: KDocReference + get() = getReferences().firstIsInstance() + +val JetElement.mainReference: JetReference? + get() { + return when { + this is JetSimpleNameExpression -> mainReference + this is KDocName -> mainReference + else -> getReferences().firstIsInstanceOrNull() + } + } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt index 909c2a5ea63..dc4439c4ec4 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/searchHelpers.kt @@ -173,7 +173,7 @@ class ClassUsagesSearchHelper( val resolvedCall = bindingContext[BindingContext.RESOLVED_CALL, call] ?: return if ((resolvedCall.getDispatchReceiver() as? ClassReceiver)?.getDeclarationDescriptor() == companionObjectDescriptor || (resolvedCall.getExtensionReceiver() as? ClassReceiver)?.getDeclarationDescriptor() == companionObjectDescriptor) { - element.getReference()?.let { processor.process(it) } + element.getReferences().forEach { processor.process(it) } } } }) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 4fdddaf071b..019630f52db 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.idea.completion.smart.LambdaItems import org.jetbrains.kotlin.idea.completion.smart.SmartCompletion import org.jetbrains.kotlin.idea.core.* import org.jetbrains.kotlin.idea.references.JetSimpleNameReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.CallType import org.jetbrains.kotlin.idea.util.ShadowedDeclarationsFilter import org.jetbrains.kotlin.types.typeUtil.makeNotNullable @@ -84,7 +85,7 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC protected val expression: JetExpression? init { - val reference = position.getParent()?.getReferences()?.firstIsInstanceOrNull() + val reference = (position.getParent() as? JetSimpleNameExpression)?.mainReference if (reference != null) { if (reference.expression is JetLabelReferenceExpression) { this.nameExpression = null diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt index 1911f49d556..b292e979329 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.idea.JetIcons import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler import org.jetbrains.kotlin.idea.core.mapArgumentsToParameters import org.jetbrains.kotlin.idea.references.JetReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.name.Name @@ -80,9 +81,8 @@ object NamedArgumentCompletion { val callElement = valueArgument.getStrictParentOfType() ?: return val callSimpleName = callElement.getCallNameExpression() ?: return - val callReference = callSimpleName.getReference() as JetReference - - val functionDescriptors = callReference.resolveToDescriptors(bindingContext).map { it as? FunctionDescriptor }.filterNotNull() + val functionDescriptors = callSimpleName.mainReference.resolveToDescriptors(bindingContext) + .filterIsInstance() for (funDescriptor in functionDescriptors) { if (!funDescriptor.hasStableParameterNames()) continue diff --git a/idea/kotlin-android-plugin/kotlin-android-plugin.iml b/idea/kotlin-android-plugin/kotlin-android-plugin.iml index 00cb2b04cd1..894dae4c845 100644 --- a/idea/kotlin-android-plugin/kotlin-android-plugin.iml +++ b/idea/kotlin-android-plugin/kotlin-android-plugin.iml @@ -11,5 +11,6 @@ + \ No newline at end of file diff --git a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt index 02706282ea4..8ca8649ef67 100644 --- a/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt +++ b/idea/kotlin-android-plugin/src/org/jetbrains/kotlin/android/navigation/gotoResourceHelper.kt @@ -25,6 +25,7 @@ import com.intellij.psi.PsiClass import org.jetbrains.android.util.AndroidUtils import com.android.SdkConstants import org.jetbrains.android.augment.AndroidPsiElementFinder +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.JetDotQualifiedExpression import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression import org.jetbrains.kotlin.psi.JetExpression @@ -65,9 +66,7 @@ private fun getReferredInfo( val firstPart = getReceiverAsSimpleNameExpression(middlePart) ?: return null - val reference = firstPart.getReference() ?: return null - - val resolvedClass = reference.resolve() as? PsiClass ?: return null + val resolvedClass = firstPart.mainReference.resolve() as? PsiClass ?: return null //the following code is copied from // org.jetbrains.android.util.AndroidResourceUtil.getReferredResourceOrManifestField diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt index e99cbc5cf7e..e9225f8c1c6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt @@ -43,6 +43,7 @@ import org.jetbrains.kotlin.idea.imports.importableFqNameSafe import org.jetbrains.kotlin.idea.references.JetSimpleNameReference import org.jetbrains.kotlin.idea.JetDescriptorIconProvider import org.jetbrains.kotlin.idea.codeInsight.DescriptorToSourceUtilsIde +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.application.executeWriteCommand /** @@ -166,10 +167,8 @@ public class JetAddImportAction( val file = element.getContainingFile() as JetFile val descriptor = selectedVariant.descriptorToImport // for class or package we use ShortenReferences because we not necessary insert an import but may want to insert partly qualified name - if (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor) { - val fqName = descriptor.importableFqNameSafe - val reference = element.getReference() as JetSimpleNameReference - reference.bindToFqName(fqName, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING) + if (element is JetSimpleNameExpression && (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor)) { + element.mainReference.bindToFqName(descriptor.importableFqNameSafe, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING) } else { ImportInsertHelper.getInstance(project).importDescriptor(file, descriptor) diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index 8b6e6c37441..b07a053380a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -42,14 +42,13 @@ import org.jetbrains.kotlin.idea.conversion.copy.range import org.jetbrains.kotlin.idea.conversion.copy.start import org.jetbrains.kotlin.idea.imports.canBeReferencedViaImport import org.jetbrains.kotlin.idea.imports.importableFqName -import org.jetbrains.kotlin.idea.references.JetMultiReference -import org.jetbrains.kotlin.idea.references.JetReference -import org.jetbrains.kotlin.idea.references.JetSimpleNameReference +import org.jetbrains.kotlin.idea.references.* import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.idea.util.application.runWriteAction import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.elementsInRange +import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension @@ -138,37 +137,31 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor(canGoInside = { it.javaClass !in IGNORE_REFERENCES_INSIDE }) { element -> + val reference = element.mainReference ?: return@forEachDescendantOfType - element.acceptChildren(this) + val descriptors = reference.resolveToDescriptors(element.analyze()) //TODO: we could use partial body resolve for all references together + //check whether this reference is unambiguous + if (reference !is JetMultiReference<*> && descriptors.size() > 1) return@forEachDescendantOfType - val reference = element.getReference() as? JetReference ?: return + for (descriptor in descriptors) { + val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(file.getProject(), descriptor) + val declaration = declarations.singleOrNull() + if (declaration != null && declaration.isInCopiedArea(file, startOffsets, endOffsets)) continue - val descriptors = reference.resolveToDescriptors((element as JetElement).analyze()) //TODO: we could use partial body resolve for all references together - //check whether this reference is unambiguous - if (reference !is JetMultiReference<*> && descriptors.size() > 1) return - - for (descriptor in descriptors) { - val declarations = DescriptorToSourceUtilsIde.getAllDeclarations(file.getProject(), descriptor) - val declaration = declarations.singleOrNull() - if (declaration != null && declaration.isInCopiedArea(file, startOffsets, endOffsets)) continue - - if (!descriptor.isExtension) { - if (element !is JetNameReferenceExpression) continue - if (element.getIdentifier() == null) continue // skip 'this' etc - if (element.getReceiverExpression() != null) continue - } - - val fqName = descriptor.importableFqName ?: continue - if (!descriptor.canBeReferencedViaImport()) continue - - val kind = KotlinReferenceData.Kind.fromDescriptor(descriptor) ?: continue - add(KotlinReferenceData(element.range.start - startOffset, element.range.end - startOffset, fqName.asString(), kind)) + if (!descriptor.isExtension) { + if (element !is JetNameReferenceExpression) continue + if (element.getIdentifier() == null) continue // skip 'this' etc + if (element.getReceiverExpression() != null) continue } + + val fqName = descriptor.importableFqName ?: continue + if (!descriptor.canBeReferencedViaImport()) continue + + val kind = KotlinReferenceData.Kind.fromDescriptor(descriptor) ?: continue + add(KotlinReferenceData(element.range.start - startOffset, element.range.end - startOffset, fqName.asString(), kind)) } - }) + } } private data class ReferenceToRestoreData( @@ -213,36 +206,32 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor referencesToElements = new HashMap(); codeBlockForLocalDeclaration.accept(new CalleeReferenceVisitorBase(bindingContext, true) { @Override - protected void processDeclaration(JetReferenceExpression reference, PsiElement declaration) { + protected void processDeclaration(JetSimpleNameExpression reference, PsiElement declaration) { if (!declaration.equals(element)) return; //noinspection unchecked @@ -88,7 +89,7 @@ public class KotlinCallerMethodsTreeStructure extends KotlinCallTreeStructure { } if (container != null) { - referencesToElements.put(reference.getReference(), container); + referencesToElements.put(ReferencesPackage.getMainReference(reference), container); } } }); diff --git a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt index fe6bca02f7f..5602581d7d4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/highlighter/KotlinHighlightExitPointsHandlerFactory.kt @@ -26,6 +26,7 @@ import com.intellij.psi.tree.TokenSet import com.intellij.psi.util.PsiTreeUtil import com.intellij.util.Consumer import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType @@ -86,7 +87,7 @@ public class KotlinHighlightExitPointsHandlerFactory: HighlightUsagesHandlerFact private fun JetExpression.getRelevantFunction(): JetFunction? { if (this is JetReturnExpression) { - (this.getTargetLabel()?.getReference()?.resolve() as? JetFunction)?.let { return it } + (this.getTargetLabel()?.mainReference?.resolve() as? JetFunction)?.let { return it } } for (parent in parents) { if (InlineUtil.canBeInlineArgument(parent) && !InlineUtil.isInlinedArgument(parent as JetFunction, parent.analyze(), false)) { diff --git a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt index 4a1a1994516..7fff9242ba2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt @@ -187,30 +187,31 @@ public class KotlinImportOptimizer() : ImportOptimizer { } override fun visitJetElement(element: JetElement) { - val reference = element.getReference() - if (reference is JetReference) { - val referencedName = (element as? JetNameReferenceExpression)?.getReferencedNameAsName() //TODO: other types of references + for (reference in element.getReferences()) { + if (reference is JetReference) { + val referencedName = (element as? JetNameReferenceExpression)?.getReferencedNameAsName() //TODO: other types of references - val bindingContext = element.analyze() - //class qualifiers that refer to companion objects should be considered (containing) class references - val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, element as? JetReferenceExpression]?.let { listOf(it) } - ?: reference.resolveToDescriptors(bindingContext) - for (target in targets) { - if (!target.canBeReferencedViaImport()) continue - if (target is PackageViewDescriptor && target.fqName.parent() == FqName.ROOT) continue // no need to import top-level packages + val bindingContext = element.analyze() + //class qualifiers that refer to companion objects should be considered (containing) class references + val targets = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, element as? JetReferenceExpression]?.let { listOf(it) } + ?: reference.resolveToDescriptors(bindingContext) + for (target in targets) { + if (!target.canBeReferencedViaImport()) continue + if (target is PackageViewDescriptor && target.fqName.parent() == FqName.ROOT) continue // no need to import top-level packages - if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages - if (element !is JetNameReferenceExpression) continue - if (element.getIdentifier() == null) continue // skip 'this' etc - if (element.getReceiverExpression() != null) continue + if (!target.isExtension) { // for non-extension targets, count only non-qualified simple name usages + if (element !is JetNameReferenceExpression) continue + if (element.getIdentifier() == null) continue // skip 'this' etc + if (element.getReceiverExpression() != null) continue + } + + val importableDescriptor = target.getImportableDescriptor() + if (referencedName != null && importableDescriptor.getName() != referencedName) continue // resolved via alias + + if (isAccessibleAsMember(importableDescriptor, element)) continue + + usedDescriptors.add(importableDescriptor) } - - val importableDescriptor = target.getImportableDescriptor() - if (referencedName != null && importableDescriptor.getName() != referencedName) continue // resolved via alias - - if (isAccessibleAsMember(importableDescriptor, element)) continue - - usedDescriptors.add(importableDescriptor) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt index ae2fa4b3bf1..5fff4887cbc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceExplicitFunctionLiteralParamWithItIntention.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.references.JetReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.JetFunctionLiteral import org.jetbrains.kotlin.psi.JetSimpleNameExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -57,8 +58,8 @@ public class ReplaceExplicitFunctionLiteralParamWithItIntention() : PsiElementBa private fun targetFunctionLiteral(element: PsiElement, caretOffset: Int): JetFunctionLiteral? { val expression = element.getParentOfType(true) if (expression != null) { - val reference = expression.getReference() as JetReference? - val target = reference?.resolveToDescriptors(expression.analyze())?.firstOrNull() as? ParameterDescriptor ?: return null + val target = expression.mainReference.resolveToDescriptors(expression.analyze()) + .singleOrNull() as? ParameterDescriptor ?: return null val functionDescriptor = target.getContainingDeclaration() as? AnonymousFunctionDescriptor ?: return null return DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor) as? JetFunctionLiteral } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt index 3c93a461dfb..6f1384660c0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceItWithExplicitFunctionLiteralParamIntention.kt @@ -22,6 +22,7 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.refactoring.rename.inplace.VariableInplaceRenameHandler import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.references.JetReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.JetFunctionLiteral import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression import org.jetbrains.kotlin.psi.JetPsiFactory @@ -35,8 +36,7 @@ public class ReplaceItWithExplicitFunctionLiteralParamIntention() : JetSelfTarge = isAutoCreatedItUsage(element) override fun applyTo(element: JetSimpleNameExpression, editor: Editor) { - val reference = element.getReference() as JetReference - val target = reference.resolveToDescriptors(element.analyze()).single() + val target = element.mainReference.resolveToDescriptors(element.analyze()).single() val functionLiteral = DescriptorToSourceUtils.descriptorToDeclaration(target.getContainingDeclaration()!!) as JetFunctionLiteral diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt index 090393e84c3..c45c637b2e6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/Utils.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithVisibility import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.references.JetReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers import org.jetbrains.kotlin.idea.util.ShortenReferences import org.jetbrains.kotlin.lexer.JetTokens @@ -66,8 +67,7 @@ fun JetContainerNode.description(): String? { fun isAutoCreatedItUsage(expression: JetSimpleNameExpression): Boolean { if (expression.getReferencedName() != "it") return false val context = expression.analyze() - val reference = expression.getReference() as JetReference? - val target = reference?.resolveToDescriptors(context)?.singleOrNull() as? ValueParameterDescriptor? ?: return false + val target = expression.mainReference.resolveToDescriptors(context).singleOrNull() as? ValueParameterDescriptor? ?: return false return context[BindingContext.AUTO_CREATED_IT, target]!! } diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt index 093a04bff2c..0a2b8ba4917 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/IfThenUtils.kt @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinI import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.idea.core.replaced +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContextUtils import org.jetbrains.kotlin.resolve.DescriptorUtils @@ -104,9 +105,7 @@ fun JetIfExpression.introduceValueForCondition(occurrenceInThenClause: JetExpres } fun JetSimpleNameExpression.inlineIfDeclaredLocallyAndOnlyUsedOnceWithPrompt(editor: Editor) { - val declaration = this.getReference()?.resolve() as JetDeclaration - - if (declaration !is JetProperty) return + val declaration = this.mainReference.resolve() as? JetProperty ?: return val enclosingElement = JetPsiUtil.getEnclosingElementForLocalDeclaration(declaration) val isLocal = enclosingElement != null diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt index e3b8588db32..62f4bdd45a0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.j2k import com.intellij.openapi.editor.RangeMarker import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.search.LocalSearchScope import com.intellij.psi.search.searches.ReferencesSearch @@ -34,6 +35,7 @@ import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.I import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix import org.jetbrains.kotlin.idea.quickfix.RemoveRightPartOfBinaryExpressionFix +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.j2k.PostProcessor import org.jetbrains.kotlin.name.FqName @@ -188,4 +190,6 @@ public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor { } } } + + override fun simpleNameReference(nameExpression: JetSimpleNameExpression) = nameExpression.mainReference } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOpenModifierToClassDeclarationFix.java b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOpenModifierToClassDeclarationFix.java index 93a405f1cf3..788895af679 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOpenModifierToClassDeclarationFix.java +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddOpenModifierToClassDeclarationFix.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.idea.JetBundle; import org.jetbrains.kotlin.idea.core.quickfix.QuickFixUtil; +import org.jetbrains.kotlin.idea.references.ReferencesPackage; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.psi.*; @@ -50,16 +51,14 @@ public class AddOpenModifierToClassDeclarationFix extends JetIntentionAction { @@ -57,13 +58,11 @@ public class MakeClassAnAnnotationClassFix extends JetIntentionAction { val typeConstraints = getNonStrictParentOfType()?.getTypeConstraints() if (typeConstraints == null) return Collections.emptyList() - return typeConstraints.filter { it.getSubjectTypeParameterName()?.getReference()?.resolve() == this} + return typeConstraints.filter { it.getSubjectTypeParameterName()?.mainReference?.resolve() == this} } fun TypeParameter.collectReferencedTypes(bindingContext: BindingContext): List { @@ -780,7 +781,7 @@ private fun ExtractionData.checkDeclarationsMovingOutOfScope( controlFlow.jumpOutputValue?.elementToInsertAfterCall?.accept( object : JetTreeVisitorVoid() { override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) { - val target = expression.getReference()?.resolve() + val target = expression.mainReference.resolve() if (target is JetNamedDeclaration && target.isInsideOf(originalElements) && target.getStrictParentOfType() == enclosingDeclaration) { @@ -1006,7 +1007,7 @@ fun ExtractableCodeDescriptor.validate(): ExtractableCodeDescriptorWithConflicts object : JetTreeVisitorVoid() { override fun visitUserType(userType: JetUserType) { val refExpr = userType.getReferenceExpression() ?: return - val declaration = refExpr.getReference()?.resolve() as? PsiNamedElement ?: return + val declaration = refExpr.mainReference.resolve() as? PsiNamedElement ?: return val diagnostics = bindingContext.getDiagnostics().forElement(refExpr) diagnostics.firstOrNull { it.getFactory() == Errors.INVISIBLE_REFERENCE }?.let { conflicts.putValue(declaration, getDeclarationMessage(declaration, "0.will.become.invisible.after.extraction")) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt index 17fa5b7fd20..d8deb8e1b8c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterHandler.kt @@ -50,6 +50,7 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.introduceVariable.KotlinI import org.jetbrains.kotlin.idea.refactoring.introduce.selectElementsWithTargetParent import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHint import org.jetbrains.kotlin.idea.refactoring.introduce.showErrorHintByKey +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.usagesSearch.DefaultSearchHelper import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchTarget import org.jetbrains.kotlin.idea.search.usagesSearch.search @@ -367,7 +368,7 @@ private fun findInternalUsagesOfParametersAndReceiver( override fun visitThisExpression(expression: JetThisExpression) { super.visitThisExpression(expression) - if (expression.getInstanceReference().getReference()?.resolve() == targetDescriptor) { + if (expression.getInstanceReference().mainReference.resolve() == targetDescriptor) { usages.putValue(receiverTypeRef, expression) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java index c1e142904d2..ea611e0d6ea 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinInplaceVariableIntroducer.java @@ -41,6 +41,7 @@ import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.idea.intentions.SpecifyTypeExplicitlyIntention; +import org.jetbrains.kotlin.idea.references.ReferencesPackage; import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.psi.*; @@ -394,7 +395,7 @@ public class KotlinInplaceVariableIntroducer e new Function1() { @Override public PsiReference invoke(JetSimpleNameExpression expression) { - return expression.getReference(); + return ReferencesPackage.getMainReference(expression); } } ); diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt index 12989985765..4ab4c538c94 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/MoveJavaInnerClassKotlinUsagesHandler.kt @@ -27,6 +27,7 @@ import java.util.ArrayList import org.jetbrains.kotlin.psi.JetSimpleNameExpression import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.PsiWhiteSpace +import org.jetbrains.kotlin.idea.references.mainReference public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler { override fun correctInnerClassUsage(usage: UsageInfo, outerClass: PsiClass) { @@ -38,7 +39,7 @@ public class MoveJavaInnerClassKotlinUsagesHandler: MoveInnerClassUsagesHandler is JetQualifiedExpression -> receiver.getQualifiedElementSelector() else -> null } as? JetSimpleNameExpression - if (outerClassRef?.getReference()?.resolve() != outerClass) return + if (outerClassRef?.mainReference?.resolve() != outerClass) return val outerCall = outerClassRef!!.getParent() as? JetCallExpression ?: return diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt index 029ac09a417..bcc5ac28dbb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveUtils.kt @@ -56,6 +56,7 @@ import org.jetbrains.kotlin.idea.refactoring.move.moveTopLevelDeclarations.ui.Mo import org.jetbrains.kotlin.idea.references.JetReference import org.jetbrains.kotlin.idea.references.JetSimpleNameReference import org.jetbrains.kotlin.idea.references.JetSimpleNameReference.ShorteningMode +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.util.ImportInsertHelper import org.jetbrains.kotlin.idea.util.application.executeCommand import org.jetbrains.kotlin.idea.util.application.runWriteAction @@ -119,7 +120,7 @@ public fun JetElement.getInternalReferencesToUpdateOnPackageNameChange(packageNa packageName == packageNameInfo.oldPackageName, packageName == packageNameInfo.newPackageName, isImported(descriptor) -> { - (refExpr.getReference() as? JetSimpleNameReference)?.let { createMoveUsageInfoIfPossible(it, declaration, false) } + refExpr.mainReference?.let { createMoveUsageInfoIfPossible(it, declaration, false) } } else -> null diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt index 1add86f238a..0dd94677975 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/AbstractRenameTest.kt @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult import org.jetbrains.kotlin.idea.jsonUtils.getNullableString import org.jetbrains.kotlin.idea.jsonUtils.getString +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.allScope import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils import org.jetbrains.kotlin.idea.test.KotlinMultiFileTestCase @@ -215,7 +216,7 @@ public abstract class AbstractRenameTest : KotlinMultiFileTestCase() { Assert.assertTrue("File '${mainFilePath}' should have package containing ${fqn}", fileFqn.isSubpackageOf(fqn)) val packageSegment = jetFile.getPackageDirective()!!.getPackageNames()[fqn.pathSegments().size() - 1] - val segmentReference = packageSegment.getReference()!! + val segmentReference = packageSegment.mainReference val psiElement = segmentReference.resolve()!! diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt index 8f562fa3213..13ada6f895f 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ConstructorConverter.kt @@ -265,7 +265,7 @@ class ConstructorConverter( if (expression is PsiReferenceExpression && expression.getQualifier() == null) { val replacement = parameterUsageReplacementMap[expression.getReferenceName()] if (replacement != null) { - val target = expression.getReference()?.resolve() + val target = expression.resolve() if (target is PsiParameter) { val scope = target.getDeclarationScope() // we do not check for exactly this constructor because default values reference parameters in other constructors diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt index 3f647481442..81c8a949c61 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ExpressionConverter.kt @@ -397,7 +397,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter { } val referenceName = expression.getReferenceName()!! - val target = expression.getReference()?.resolve() + val target = expression.resolve() val isNullable = target is PsiVariable && typeConverter.variableNullability(target).isNullable(codeConverter.settings) val qualifier = expression.getQualifierExpression() diff --git a/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt index 534584ffe3f..5ea64db9afa 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt @@ -59,10 +59,12 @@ public interface PostProcessor { } Errors.VAL_REASSIGNMENT -> { -> - val property = (psiElement as? JetSimpleNameExpression)?.getReference()?.resolve() as? JetProperty - if (property != null && !property.isVar()) { - val factory = JetPsiFactory(psiElement.getProject()) - property.getValOrVarKeyword().replace(factory.createVarKeyword()) + if (psiElement is JetSimpleNameExpression) { + val property = simpleNameReference(psiElement).resolve() as? JetProperty + if (property != null && !property.isVar()) { + val factory = JetPsiFactory(psiElement.getProject()) + property.getValOrVarKeyword().replace(factory.createVarKeyword()) + } } } @@ -71,6 +73,8 @@ public interface PostProcessor { } public fun doAdditionalProcessing(file: JetFile, rangeMarker: RangeMarker?) + + public fun simpleNameReference(nameExpression: JetSimpleNameExpression): PsiReference } public enum class ParseContext { @@ -233,7 +237,7 @@ public class JavaToKotlinConverter( var references = listOf(reference) for (processor in processors) { - references = references.flatMap { processor.processUsage(it) ?: listOf(it) } + references = references.flatMap { processor.processUsage(it)?.toList() ?: listOf(it) } references.forEach { checkReferenceValid(it) } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt index 334151d7356..ec00ac68016 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/AccessorToPropertyProcessing.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.j2k.usageProcessing import com.intellij.psi.* import org.jetbrains.kotlin.j2k.AccessorKind import org.jetbrains.kotlin.j2k.CodeConverter +import org.jetbrains.kotlin.j2k.ResolverForConverter import org.jetbrains.kotlin.j2k.ast.* import org.jetbrains.kotlin.psi.* @@ -53,7 +54,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi null else object : ExternalCodeProcessor { - override fun processUsage(reference: PsiReference): Collection? { + override fun processUsage(reference: PsiReference): Array? { val nameExpr = reference.getElement() as? JetSimpleNameExpression ?: return null val callExpr = nameExpr.getParent() as? JetCallExpression ?: return null @@ -64,7 +65,7 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi if (accessorKind == AccessorKind.GETTER) { if (arguments.size() != 0) return null // incorrect call propertyNameExpr = callExpr.replace(propertyNameExpr) as JetSimpleNameExpression - return listOf(propertyNameExpr.getReference()!!) + return propertyNameExpr.getReferences() } else { val value = arguments.singleOrNull()?.getArgumentExpression() ?: return null @@ -76,12 +77,12 @@ class AccessorToPropertyProcessing(val accessorMethod: PsiMethod, val accessorKi callExpr.replace(propertyNameExpr) assignment.getLeft()!!.replace(qualifiedExpression) assignment = qualifiedExpression.replace(assignment) as JetBinaryExpression - return listOf((assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReference()!!) + return (assignment.getLeft() as JetQualifiedExpression).getSelectorExpression()!!.getReferences() } else { assignment.getLeft()!!.replace(propertyNameExpr) assignment = callExpr.replace(assignment) as JetBinaryExpression - return listOf(assignment.getLeft()!!.getReference()!!) + return assignment.getLeft()!!.getReferences() } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ElementRenamedCodeProcessor.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ElementRenamedCodeProcessor.kt index 1a3927fa929..ef0d4608480 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ElementRenamedCodeProcessor.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ElementRenamedCodeProcessor.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.j2k.usageProcessing import com.intellij.psi.PsiReference +import org.jetbrains.kotlin.j2k.ResolverForConverter class ElementRenamedCodeProcessor(private val newName: String) : ExternalCodeProcessor { - override fun processUsage(reference: PsiReference): Collection? { - val newReference = reference.handleElementRename(newName).getReference()!! - return listOf(newReference) + override fun processUsage(reference: PsiReference): Array? { + return reference.handleElementRename(newName).getReferences() } } \ No newline at end of file diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt index 58f916b192f..d9c55bca34f 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/FieldToPropertyProcessing.kt @@ -68,7 +68,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v private inner class UseAccessorsJavaCodeProcessor : ExternalCodeProcessor { private val factory = PsiElementFactory.SERVICE.getInstance(field.getProject()) - override fun processUsage(reference: PsiReference): Collection? { + override fun processUsage(reference: PsiReference): Array? { val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null val qualifier = refExpr.getQualifierExpression() @@ -78,7 +78,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v if (refExpr == parent.getLExpression()) { if (parent.getOperationTokenType() == JavaTokenType.EQ) { val callExpr = parent.replace(generateSetterCall(qualifier, parent.getRExpression() ?: return null)) as PsiMethodCallExpression - return listOf(callExpr.getMethodExpression()) + return arrayOf(callExpr.getMethodExpression()) } else { val assignmentOpText = parent.getOperationSign().getText() @@ -107,11 +107,11 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v } val callExpr = refExpr.replace(generateGetterCall(qualifier)) as PsiMethodCallExpression - return listOf(callExpr.getMethodExpression()) + return arrayOf(callExpr.getMethodExpression()) } //TODO: what if qualifier has side effects? - private fun PsiExpression.replaceWithModificationCalls(qualifier: PsiExpression?, op: String, value: PsiExpression): Collection { + private fun PsiExpression.replaceWithModificationCalls(qualifier: PsiExpression?, op: String, value: PsiExpression): Array { var getCall = generateGetterCall(qualifier) var binary = factory.createExpressionFromText("x $op y", null) as PsiBinaryExpression @@ -124,7 +124,7 @@ class FieldToPropertyProcessing(val field: PsiField, val propertyName: String, v binary = setCall.getArgumentList().getExpressions().single() as PsiBinaryExpression getCall = binary.getLOperand() as PsiMethodCallExpression - return listOf(getCall.getMethodExpression().getReference()!!, setCall.getMethodExpression().getReference()!!) + return arrayOf(getCall.getMethodExpression(), setCall.getMethodExpression()) } private fun generateGetterCall(qualifier: PsiExpression?): PsiMethodCallExpression { diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt index 21494e7a9bd..7efd376cdeb 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/MethodIntoObjectProcessing.kt @@ -24,19 +24,19 @@ public class MethodIntoObjectProcessing(private val method: PsiMethod, private v override val convertedCodeProcessor: ConvertedCodeProcessor? get() = null override val javaCodeProcessor = object: ExternalCodeProcessor { - override fun processUsage(reference: PsiReference): Collection? { + override fun processUsage(reference: PsiReference): Array? { val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null val qualifier = refExpr.getQualifierExpression() val factory = PsiElementFactory.SERVICE.getInstance(method.getProject()) if (qualifier != null) { val newQualifier = factory.createExpressionFromText(qualifier.getText() + "." + objectName, null) qualifier.replace(newQualifier) - return listOf(reference) + return arrayOf(reference) } else { var qualifiedExpr = factory.createExpressionFromText(objectName + "." + refExpr.getText(), null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()!!) + return arrayOf(qualifiedExpr) } } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt index 3b5c151e758..9b3df209128 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/ToObjectWithOnlyMethodsProcessing.kt @@ -25,12 +25,12 @@ class ToObjectWithOnlyMethodsProcessing(private val psiClass: PsiClass) : UsageP override val convertedCodeProcessor: ConvertedCodeProcessor? get() = null override val javaCodeProcessor = object: ExternalCodeProcessor { - override fun processUsage(reference: PsiReference): Collection? { + override fun processUsage(reference: PsiReference): Array? { val refExpr = reference.getElement() as? PsiReferenceExpression ?: return null val factory = PsiElementFactory.SERVICE.getInstance(psiClass.getProject()) var qualifiedExpr = factory.createExpressionFromText(refExpr.getText() + "." + JvmAbi.INSTANCE_FIELD, null) as PsiReferenceExpression qualifiedExpr = refExpr.replace(qualifiedExpr) as PsiReferenceExpression - return listOf(qualifiedExpr.getReference()!!) + return arrayOf(qualifiedExpr) } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/UsageProcessing.kt b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/UsageProcessing.kt index a08e907e41d..4137d04d942 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/UsageProcessing.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/usageProcessing/UsageProcessing.kt @@ -36,7 +36,7 @@ trait ConvertedCodeProcessor { } trait ExternalCodeProcessor { - fun processUsage(reference: PsiReference): Collection? + fun processUsage(reference: PsiReference): Array? } class UsageProcessingExpressionConverter(val processings: Map>) : SpecialExpressionConverter { From 27b496000160bf85435ba65d2c94b8b35df38764 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 17:09:35 +0300 Subject: [PATCH 321/450] Fixed crash on searching constructor usages --- .../kotlin/idea/caches/resolve/JavaResolveExtension.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt index 1baf2103b85..6bfc09d511e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/JavaResolveExtension.kt @@ -46,7 +46,7 @@ public object JavaResolveExtension : CacheExtension<(PsiElement) -> Pair resolver.resolveConstructor(JavaConstructorImpl(method)) From 22e631dda32ff17e1ba47eb0027e7dd9df050926 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 18:23:20 +0300 Subject: [PATCH 322/450] Naming with "is" supported for synthetic extensions --- .../synthetic/SyntheticExtensionsScope.kt | 30 ++++++++++++------- .../tests/syntheticExtensions/IsNaming.kt | 13 ++++++++ .../tests/syntheticExtensions/IsNaming.txt | 13 ++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++ .../org/jetbrains/kotlin/types/TypeUtils.kt | 3 +- .../common/extensions/SyntheticExtensions2.kt | 3 ++ .../callableBuilder/CallableBuilder.kt | 4 +-- 7 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 88c4f6aaba7..000a35d8337 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull @@ -53,9 +54,11 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } } - fun propertyNameByGetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "get") + fun propertyNameByGetMethodName(methodName: Name): Name? + = propertyNameFromAccessorMethodName(methodName, "get") ?: propertyNameFromAccessorMethodName(methodName, "is") - fun propertyNameBySetMethodName(methodName: Name): Name? = propertyNameFromAccessorMethodName(methodName, "set") + fun propertyNameBySetMethodName(methodName: Name): Name? + = propertyNameFromAccessorMethodName(methodName, "set") private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String): Name? { if (methodName.isSpecial()) return null @@ -85,19 +88,25 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null val memberScope = javaClass.getMemberScope(type.getArguments()) - val getMethod = memberScope.getFunctions(toGetMethodName(name)).singleOrNull { isGoodGetMethod(it) } ?: return null + val getMethod = possibleGetMethodNames(name) + .asSequence() + .flatMap { memberScope.getFunctions(it).asSequence() } + .singleOrNull { isGoodGetMethod(it) } ?: return null val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(toSetMethodName(name)).singleOrNull { isGoodSetMethod(it, propertyType) } + val setMethod = memberScope.getFunctions(possibleSetMethodName(name)).singleOrNull { isGoodSetMethod(it, propertyType) } return MyPropertyDescriptor(javaClass, getMethod, setMethod, name, propertyType, type) } private fun isGoodGetMethod(descriptor: FunctionDescriptor): Boolean { + val returnType = descriptor.getReturnType() ?: return false + if (returnType.isUnit()) return false + if (descriptor.getName().asString().startsWith("is") && !returnType.isBoolean()) return false + return descriptor.getValueParameters().isEmpty() && descriptor.getTypeParameters().isEmpty() && descriptor.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? - && !(descriptor.getReturnType()?.isUnit() ?: true) } private fun isGoodSetMethod(descriptor: FunctionDescriptor, propertyType: JetType): Boolean { @@ -105,7 +114,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return parameter.getType() == propertyType && parameter.getVarargElementType() == null && descriptor.getTypeParameters().isEmpty() - && descriptor.getReturnType()?.let { KotlinBuiltIns.isUnit(it) } ?: false + && descriptor.getReturnType()?.let { it.isUnit() } ?: false && descriptor.getVisibility() == Visibilities.PUBLIC } @@ -156,14 +165,15 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return list } - //TODO: "is"? //TODO: methods like "getURL"? //TODO: reuse code with generation? - private fun toGetMethodName(propertyName: Name): Name { - return Name.identifier("get" + propertyName.getIdentifier().capitalize()) + + private fun possibleGetMethodNames(propertyName: Name): Collection { + val capitalized = propertyName.getIdentifier().capitalize() + return listOf(Name.identifier("get" + capitalized), Name.identifier("is" + capitalized)) } - private fun toSetMethodName(propertyName: Name): Name { + private fun possibleSetMethodName(propertyName: Name): Name { return Name.identifier("set" + propertyName.getIdentifier().capitalize()) } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt new file mode 100644 index 00000000000..c4883eddbf2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt @@ -0,0 +1,13 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.something = !javaClass.something + + javaClass.somethingWrong +} + +// FILE: JavaClass.java +public class JavaClass { + public boolean isSomething() { return true; } + public void setSomething(boolean value) { } + public int isSomethingWrong() { return 1; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt new file mode 100644 index 00000000000..f80114acd07 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt @@ -0,0 +1,13 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun isSomething(): kotlin.Boolean + public open fun isSomethingWrong(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Boolean): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 7b4f1987491..36c115ecd15 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14058,6 +14058,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("IsNaming.kt") + public void testIsNaming() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt"); + doTest(fileName); + } + @TestMetadata("OnlyPublic.kt") public void testOnlyPublic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt index 86c5aba7662..64f76e5d310 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.kt @@ -49,7 +49,8 @@ fun JetType.supertypes(): Set = TypeUtils.getAllSupertypes(this) fun JetType.isNothing(): Boolean = KotlinBuiltIns.isNothing(this) fun JetType.isUnit(): Boolean = KotlinBuiltIns.isUnit(this) -fun JetType.isAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) +fun JetType.isAnyOrNullableAny(): Boolean = KotlinBuiltIns.isAnyOrNullableAny(this) +fun JetType.isBoolean(): Boolean = KotlinBuiltIns.isBoolean(this) private fun JetType.getContainedTypeParameters(): Collection { val declarationDescriptor = getConstructor().getDeclarationDescriptor() diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index 6fdc9c39ef0..a85c4f8780b 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -3,5 +3,8 @@ fun Thread.foo() { } // EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } +// EXIST_JAVA_ONLY: { lookupString: "daemon", itemText: "daemon", tailText: " for Thread", typeText: "Boolean" } // ABSENT: getPriority // ABSENT: setPriority +// ABSENT: isDaemon +// ABSENT: setDaemon diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 3c4d5081922..413b270489d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -66,7 +66,7 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeProjectionImpl import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.checker.JetTypeChecker -import org.jetbrains.kotlin.types.typeUtil.isAny +import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList import java.util.* @@ -316,7 +316,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) { CallableKind.FUNCTION -> returnTypeCandidate?.theType?.isUnit() ?: false CallableKind.CLASS_WITH_PRIMARY_CONSTRUCTOR -> - callableInfo.returnTypeInfo == TypeInfo.Empty || returnTypeCandidate?.theType?.isAny() ?: false + callableInfo.returnTypeInfo == TypeInfo.Empty || returnTypeCandidate?.theType?.isAnyOrNullableAny() ?: false CallableKind.SECONDARY_CONSTRUCTOR -> true CallableKind.PROPERTY -> containingElement is JetBlockExpression } From 28e9fbf9b880cb82794f62497fadaa2a01bd6da8 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 10 Jul 2015 18:55:18 +0300 Subject: [PATCH 323/450] Correct synthetic extensions for methods like "getURL" --- .../synthetic/SyntheticExtensionsScope.kt | 19 +++++++++++++------ .../syntheticExtensions/AbbreviationName.kt | 13 +++++++++++++ .../syntheticExtensions/AbbreviationName.txt | 12 ++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ .../common/extensions/SyntheticExtensions2.kt | 8 ++++++-- 5 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt index 000a35d8337..c55ea8fa21e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.synthetic import com.intellij.util.SmartList -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl @@ -35,7 +34,8 @@ import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull -import java.util.* +import java.beans.Introspector +import java.util.ArrayList interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor @@ -64,7 +64,7 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith(prefix)) return null - val name = identifier.removePrefix(prefix).decapitalize() + val name = Introspector.decapitalize(identifier.removePrefix(prefix)) if (!Name.isValidIdentifier(name)) return null return Name.identifier(name) } @@ -84,8 +84,16 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { if (name.isSpecial()) return null - val firstChar = name.getIdentifier()[0] - if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null + val identifier = name.getIdentifier() + if (identifier.isEmpty()) return null + val firstChar = identifier[0] + if (!firstChar.isJavaIdentifierStart()) return null + if (identifier.length() > 1) { + if (firstChar.isUpperCase() != identifier[1].isUpperCase()) return null + } + else { + if (firstChar.isUpperCase()) return null + } val memberScope = javaClass.getMemberScope(type.getArguments()) val getMethod = possibleGetMethodNames(name) @@ -165,7 +173,6 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet return list } - //TODO: methods like "getURL"? //TODO: reuse code with generation? private fun possibleGetMethodNames(propertyName: Name): Collection { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt new file mode 100644 index 00000000000..b1b397fe5f9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt @@ -0,0 +1,13 @@ +// FILE: KotlinFile.kt +fun foo(javaClass: JavaClass) { + javaClass.URL = javaClass.URL + "/" + + javaClass.url + javaClass.uRL +} + +// FILE: JavaClass.java +public class JavaClass { + public String getURL() { return true; } + public void setURL(String value) { } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt new file mode 100644 index 00000000000..c2731564e6d --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt @@ -0,0 +1,12 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getURL(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setURL(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 36c115ecd15..c0dda0e8434 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14006,6 +14006,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class SyntheticExtensions extends AbstractJetDiagnosticsTest { + @TestMetadata("AbbreviationName.kt") + public void testAbbreviationName() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt"); + doTest(fileName); + } + public void testAllFilesPresentInSyntheticExtensions() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), true); } diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index a85c4f8780b..7a340e36334 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -1,10 +1,14 @@ -fun Thread.foo() { - +fun Thread.foo(urlConnection: java.net.URLConnection) { + with (urlConnection) { + + } } // EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } // EXIST_JAVA_ONLY: { lookupString: "daemon", itemText: "daemon", tailText: " for Thread", typeText: "Boolean" } +// EXIST_JAVA_ONLY: { lookupString: "URL", itemText: "URL", tailText: " for URLConnection", typeText: "URL!" } // ABSENT: getPriority // ABSENT: setPriority // ABSENT: isDaemon // ABSENT: setDaemon +// ABSENT: getURL From e52b524d9ab3ebef0c1372fd27eb1ab5f31b6fc6 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sat, 11 Jul 2015 14:28:41 +0300 Subject: [PATCH 324/450] Fixed rename of operator functions --- .../intentions/OperatorToFunctionIntention.kt | 28 ++++++++++++++--- .../idea/references/JetSimpleNameReference.kt | 31 ++++++------------- .../kotlin/idea/references/referenceUtil.kt | 8 ++--- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt index 5b9f0734b0e..7e932fa33af 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/OperatorToFunctionIntention.kt @@ -22,8 +22,9 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.expressions.OperatorConventions public class OperatorToFunctionIntention : JetSelfTargetingIntention(javaClass(), "Replace overloaded operator with function call") { @@ -126,7 +127,7 @@ public class OperatorToFunctionIntention : JetSelfTargetingIntention { + val result = when (element) { is JetPrefixExpression -> convertPrefix(element) is JetPostfixExpression -> convertPostFix(element) is JetBinaryExpression -> convertBinary(element) is JetArrayAccessExpression -> convertArrayAccess(element) is JetCallExpression -> convertCall(element) - else -> element + else -> throw IllegalArgumentException(element.toString()) + } + + return result to findCallName(result) + } + + private fun findCallName(result: JetExpression): JetSimpleNameExpression { + return when (result) { + is JetBinaryExpression -> { + if (JetPsiUtil.isAssignment(result)) + findCallName(result.getRight()!!) + else + findCallName(result.getLeft()!!) + } + + is JetUnaryExpression -> findCallName(result.getBaseExpression()!!) + + else -> result.getQualifiedElementSelector() as JetSimpleNameExpression } } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt index b4453c21d1f..eaaeb37fba7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetSimpleNameReference.kt @@ -33,10 +33,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.plugin.references.SimpleNameReferenceExtension import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.getParentOfTypeAndBranch -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElement -import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector -import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.dataClassUtils.isComponentLike import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode @@ -98,26 +95,16 @@ class JetSimpleNameReference(expression: JetSimpleNameExpression) : JetSimpleRef } } - var nameElement = expression.getReferencedNameElement() + val nameElement = expression.getReferencedNameElement() - val elementType = nameElement.getNode()?.getElementType() - val opExpression = PsiTreeUtil.getParentOfType(expression, javaClass(), javaClass()) - if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null && opExpression != null) { - val bindingContext = expression.analyze(BodyResolveMode.PARTIAL) - val oldDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, expression] - val newExpression = OperatorToFunctionIntention.convert(opExpression) - newExpression.accept(object : JetTreeVisitorVoid() { - override fun visitCallExpression(expression: JetCallExpression) { - val callee = expression.getCalleeExpression() as? JetSimpleNameExpression - if (callee != null && bindingContext[BindingContext.REFERENCE_TARGET, callee] == oldDescriptor) { - nameElement = callee.getReferencedNameElement() - } - else { - super.visitCallExpression(expression) - } - } + val elementType = nameElement.getNode().getElementType() + if (elementType is JetToken && OperatorConventions.getNameForOperationSymbol(elementType) != null) { + val opExpression = expression.getParent() as? JetOperationExpression + if (opExpression != null) { + val (newExpression, newNameElement) = OperatorToFunctionIntention.convert(opExpression) + newNameElement.replace(element) + return newExpression } - ) } nameElement.replace(element) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt index d10c7cb6c76..ce5caa01a32 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.idea.util.ProjectRootsUtil import org.jetbrains.kotlin.kdoc.psi.impl.KDocName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType +import org.jetbrains.kotlin.psi.psiUtil.getQualifiedElementSelector import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull @@ -112,10 +113,9 @@ private fun PsiElement.isConstructorOf(unwrappedCandidate: PsiElement) = fun AbstractJetReference.renameImplicitConventionalCall(newName: String?): JetExpression { if (newName == null) return expression - val expr = OperatorToFunctionIntention.convert(expression) as JetQualifiedExpression - val callee = (expr.getSelectorExpression() as JetCallExpression).getCalleeExpression() as JetSimpleNameExpression - val newCallee = callee.mainReference.handleElementRename(newName) - return newCallee.getStrictParentOfType() as JetExpression + val (newExpression, newNameElement) = OperatorToFunctionIntention.convert(expression) + newNameElement.mainReference.handleElementRename(newName) + return newExpression } val JetSimpleNameExpression.mainReference: JetSimpleNameReference From 27a23e8e07f7017f9a1fd739f467de849b562239 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sat, 11 Jul 2015 14:28:55 +0300 Subject: [PATCH 325/450] Fixed package directive completion --- .../completion/PackageDirectiveCompletion.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt index 57dc2d30122..907701e62d1 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/PackageDirectiveCompletion.kt @@ -24,8 +24,10 @@ import com.intellij.patterns.PlatformPatterns import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.codeInsight.ReferenceVariantsHelper import org.jetbrains.kotlin.idea.references.JetSimpleNameReference +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.psi.JetPackageDirective +import org.jetbrains.kotlin.psi.JetSimpleNameExpression /** * Performs completion in package directive. Should suggest only packages and avoid showing fake package produced by @@ -41,19 +43,19 @@ object PackageDirectiveCompletion { val file = position.getContainingFile() as JetFile - val ref = file.findReferenceAt(parameters.getOffset()) as? JetSimpleNameReference ?: return false - val name = ref.expression.getText()!! + val expression = file.findElementAt(parameters.getOffset())?.getParent() as? JetSimpleNameExpression ?: return false try { - val prefixLength = parameters.getOffset() - ref.expression.getTextOffset() - val prefixMatcher = PlainPrefixMatcher(name.substring(0, prefixLength)) + val prefixLength = parameters.getOffset() - expression.getTextOffset() + val prefix = expression.getText()!! + val prefixMatcher = PlainPrefixMatcher(prefix.substring(0, prefixLength)) val result = result.withPrefixMatcher(prefixMatcher) - val resolutionFacade = ref.expression.getResolutionFacade() - val bindingContext = resolutionFacade.analyze(ref.expression) + val resolutionFacade = expression.getResolutionFacade() + val bindingContext = resolutionFacade.analyze(expression) val moduleDescriptor = resolutionFacade.findModuleDescriptor(file) - val variants = ReferenceVariantsHelper(bindingContext, moduleDescriptor, file.getProject(), { true }).getPackageReferenceVariants(ref.expression, prefixMatcher.asNameFilter()) + val variants = ReferenceVariantsHelper(bindingContext, moduleDescriptor, file.getProject(), { true }).getPackageReferenceVariants(expression, prefixMatcher.asNameFilter()) for (variant in variants) { val lookupElement = LookupElementFactory(resolutionFacade, listOf()).createLookupElement(variant, false) if (!lookupElement.getLookupString().contains(DUMMY_IDENTIFIER)) { From d1db0ce30a6b336f22b315de223025295f760806 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sat, 11 Jul 2015 14:29:01 +0300 Subject: [PATCH 326/450] Fixed tests --- .../AbstractNavigateToLibrarySourceTest.kt | 39 ++++++++++--------- .../BuiltInsReferenceResolverTest.java | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt index 30d3fe1fc35..01969b22337 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/navigation/AbstractNavigateToLibrarySourceTest.kt @@ -18,16 +18,13 @@ package org.jetbrains.kotlin.idea.decompiler.navigation import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.psi.PsiElement +import com.intellij.psi.impl.source.resolve.reference.impl.PsiMultiReference import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.UsefulTestCase import junit.framework.TestCase -import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor -import org.jetbrains.kotlin.idea.test.KotlinCodeInsightTestCase -import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.navigation.NavigationTestUtils import org.jetbrains.kotlin.idea.references.JetReference -import org.jetbrains.kotlin.idea.test.ModuleKind -import org.jetbrains.kotlin.idea.test.configureAs +import org.jetbrains.kotlin.idea.test.* import org.jetbrains.kotlin.test.JetTestUtils import java.io.File import java.util.LinkedHashMap @@ -73,24 +70,30 @@ public abstract class AbstractNavigateToLibrarySourceTest : KotlinCodeInsightTes val referenceContainersToReferences = LinkedHashMap() for (offset in 0..psiFile.getTextLength() - 1) { val ref = psiFile.findReferenceAt(offset) - if (ref is JetReference && !referenceContainersToReferences.containsKey(ref.getElement())) { - val target = ref.resolve() - if (target == null) continue - - val targetNavPsiFile = target.getNavigationElement().getContainingFile() - if (targetNavPsiFile == null) continue - - val targetNavFile = targetNavPsiFile.getVirtualFile() - if (targetNavFile == null) continue - - if (ProjectFileIndex.SERVICE.getInstance(getProject()).isInLibrarySource(targetNavFile)) { - referenceContainersToReferences.put(ref.getElement(), ref) - } + val refs = when (ref) { + is JetReference -> listOf(ref) + is PsiMultiReference -> ref.getReferences().filterIsInstance() + else -> emptyList() } + + refs.forEach { referenceContainersToReferences.addReference(it) } } return referenceContainersToReferences.values() } + private fun MutableMap.addReference(ref: JetReference) { + if (containsKey(ref.getElement())) return + val target = ref.resolve() ?: return + + val targetNavPsiFile = target.getNavigationElement().getContainingFile() ?: return + + val targetNavFile = targetNavPsiFile.getVirtualFile() ?: return + + if (ProjectFileIndex.SERVICE.getInstance(getProject()).isInLibrarySource(targetNavFile)) { + put(ref.getElement(), ref) + } + } + private fun collectInterestingNavigationElements() = collectInterestingReferences().map { val target = it.resolve() diff --git a/idea/tests/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolverTest.java b/idea/tests/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolverTest.java index b660dc5e81f..7ad145cae5f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolverTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/references/BuiltInsReferenceResolverTest.java @@ -116,7 +116,7 @@ public class BuiltInsReferenceResolverTest extends ResolveTestCase { } private void doTest() throws Exception { - JetReference reference = (JetReference) configureByFile(getTestName(true) + ".kt"); + PsiPolyVariantReference reference = (PsiPolyVariantReference) configureByFile(getTestName(true) + ".kt"); PsiElement resolved = reference.resolve(); assertNotNull(resolved); assertEquals(1, reference.multiResolve(false).length); From 5735248be8f554a69eb6672f58201478df7fefbd Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 13:57:52 +0300 Subject: [PATCH 327/450] Fixed highlight usages --- .../references/JetReferenceContributor.kt | 6 ++-- .../SyntheticPropertyAccessorReference.kt | 7 +++-- .../findUsages/KotlinReferenceUsageInfo.kt | 30 +++++++++++++++++++ .../handlers/KotlinFindClassUsagesHandler.kt | 3 +- .../KotlinFindMemberUsagesHandler.java | 2 +- .../handlers/KotlinFindUsagesHandler.java | 8 ++--- 6 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt index e123f54f596..7dfa4ec0d87 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/JetReferenceContributor.kt @@ -38,9 +38,9 @@ public class JetReferenceContributor() : PsiReferenceContributor() { if (it.getReferencedNameElementType() != JetTokens.IDENTIFIER) return@registerMultiProvider emptyArray() when (it.access()) { - Access.READ -> arrayOf(SyntheticPropertyAccessorReference(it, true)) - Access.WRITE -> arrayOf(SyntheticPropertyAccessorReference(it, false)) - Access.READ_WRITE -> arrayOf(SyntheticPropertyAccessorReference(it, true), SyntheticPropertyAccessorReference(it, false)) + Access.READ -> arrayOf(SyntheticPropertyAccessorReference.Getter(it)) + Access.WRITE -> arrayOf(SyntheticPropertyAccessorReference.Setter(it)) + Access.READ_WRITE -> arrayOf(SyntheticPropertyAccessorReference.Getter(it), SyntheticPropertyAccessorReference.Setter(it)) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 04194df0f62..fa92062357e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor import org.jetbrains.kotlin.utils.addIfNotNull -class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, val getter: Boolean) : JetSimpleReference(expression) { +sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference(expression) { override fun getTargetDescriptors(context: BindingContext): Collection { val descriptors = super.getTargetDescriptors(context) if (descriptors.none { it is SyntheticExtensionPropertyDescriptor }) return emptyList() @@ -66,4 +66,7 @@ class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, expression.getReferencedNameElement().replace(nameIdentifier) return expression } -} \ No newline at end of file + + public class Getter(expression: JetNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, true) + public class Setter(expression: JetNameReferenceExpression) : SyntheticPropertyAccessorReference(expression, false) +} diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt new file mode 100644 index 00000000000..9a846f7e005 --- /dev/null +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinReferenceUsageInfo.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.findUsages + +import com.intellij.psi.PsiReference +import com.intellij.usageView.UsageInfo +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull + +public class KotlinReferenceUsageInfo(reference: PsiReference) : UsageInfo(reference) { + private val referenceType = reference.javaClass + + override fun getReference(): PsiReference? { + val element = getElement() ?: return null + return element.getReferences().singleOrNull { it.javaClass == referenceType } + } +} \ No newline at end of file diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt index 8905dd83ef4..fd838b0fad0 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt @@ -43,6 +43,7 @@ import com.intellij.psi.search.searches.MethodReferencesSearch import com.intellij.util.CommonProcessors import org.jetbrains.kotlin.asJava.KotlinLightMethod import org.jetbrains.kotlin.asJava.toLightClass +import org.jetbrains.kotlin.idea.references.mainReference import org.jetbrains.kotlin.idea.search.usagesSearch.processDelegationCallConstructorUsages import org.jetbrains.kotlin.psi.JetClass import org.jetbrains.kotlin.psi.psiUtil.isInheritable @@ -98,7 +99,7 @@ public class KotlinFindClassUsagesHandler( for (constructor in constructors) { if (constructor !is KotlinLightMethod) continue constructor.processDelegationCallConstructorUsages(constructor.getUseScope()) { - it.getCalleeExpression()?.getReference()?.let { KotlinFindUsagesHandler.processUsage(uniqueProcessor, it) } + it.getCalleeExpression()?.mainReference?.let { KotlinFindUsagesHandler.processUsage(uniqueProcessor, it) } } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java index 6467533fe7d..ba2e0e4f8cd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java @@ -168,7 +168,7 @@ public abstract class KotlinFindMemberUsagesHandler extends Find return factory; } - protected static boolean processUsage(Processor processor, PsiReference ref) { - if (ref == null) return true; - TextRange rangeInElement = ref.getRangeInElement(); - return processor.process(new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false)); + protected static boolean processUsage(@NotNull Processor processor, @NotNull PsiReference ref) { + return processor.process(new KotlinReferenceUsageInfo(ref)); } protected static boolean processUsage(@NotNull Processor processor, @NotNull PsiElement element) { From bf7afae8057a8c7424d2e1d0fc1a755cd039e086 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 14:37:42 +0300 Subject: [PATCH 328/450] Converted ResolveElementCache to Kotlin (step 1) --- .../idea/project/ResolveElementCache.java | 144 +++++++----------- 1 file changed, 58 insertions(+), 86 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java index 8475afbc693..368677522e8 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java @@ -14,113 +14,85 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.project; +package org.jetbrains.kotlin.idea.project -import com.intellij.openapi.project.Project; -import com.intellij.psi.util.CachedValue; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; -import com.intellij.psi.util.PsiModificationTracker; -import kotlin.jvm.functions.Function1; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.ModuleDescriptor; -import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex; -import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex; -import org.jetbrains.kotlin.psi.JetElement; -import org.jetbrains.kotlin.psi.JetFile; -import org.jetbrains.kotlin.psi.JetNamedFunction; -import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider; -import org.jetbrains.kotlin.resolve.BindingContext; -import org.jetbrains.kotlin.resolve.BodyResolveCache; -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; -import org.jetbrains.kotlin.resolve.lazy.ElementResolver; -import org.jetbrains.kotlin.resolve.lazy.ProbablyNothingCallableNames; -import org.jetbrains.kotlin.resolve.lazy.ResolveSession; -import org.jetbrains.kotlin.storage.LazyResolveStorageManager; -import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull; -import org.jetbrains.kotlin.types.DynamicTypesSettings; +import com.intellij.openapi.project.Project +import com.intellij.psi.util.CachedValue +import com.intellij.psi.util.CachedValueProvider +import com.intellij.psi.util.CachedValuesManager +import com.intellij.psi.util.PsiModificationTracker +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex +import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex +import org.jetbrains.kotlin.psi.JetElement +import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.psi.JetNamedFunction +import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.BodyResolveCache +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode +import org.jetbrains.kotlin.resolve.lazy.ElementResolver +import org.jetbrains.kotlin.resolve.lazy.ProbablyNothingCallableNames +import org.jetbrains.kotlin.resolve.lazy.ResolveSession +import org.jetbrains.kotlin.storage.LazyResolveStorageManager +import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull +import org.jetbrains.kotlin.types.DynamicTypesSettings -import java.util.Collection; +public class ResolveElementCache(resolveSession: ResolveSession, private val project: Project) : ElementResolver(resolveSession), BodyResolveCache { + private val additionalResolveCache: CachedValue> -public class ResolveElementCache extends ElementResolver implements BodyResolveCache { - private final Project project; - private final CachedValue> additionalResolveCache; - - public ResolveElementCache(ResolveSession resolveSession, Project project) { - super(resolveSession); - this.project = project; + init { // Recreate internal cache after change of modification count - this.additionalResolveCache = - CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider>() { - @Nullable - @Override - public Result> compute() { - ResolveSession resolveSession = ResolveElementCache.this.getResolveSession(); - LazyResolveStorageManager manager = resolveSession.getStorageManager(); - MemoizedFunctionToNotNull elementsCacheFunction = - manager.createSoftlyRetainedMemoizedFunction(new Function1() { - @Override - public BindingContext invoke(JetElement jetElement) { - return performElementAdditionalResolve(jetElement, jetElement, BodyResolveMode.FULL); - } - }); + this.additionalResolveCache = CachedValuesManager.getManager(project).createCachedValue(object : CachedValueProvider> { + override fun compute(): CachedValueProvider.Result>? { + val resolveSession = this@ResolveElementCache.resolveSession + val manager = resolveSession.getStorageManager() + val elementsCacheFunction = manager.createSoftlyRetainedMemoizedFunction(object : Function1 { + override fun invoke(jetElement: JetElement): BindingContext { + return performElementAdditionalResolve(jetElement, jetElement, BodyResolveMode.FULL) + } + }) - return Result.create(elementsCacheFunction, - PsiModificationTracker.MODIFICATION_COUNT, - resolveSession.getExceptionTracker()); - } - }, - false); + return CachedValueProvider.Result.create(elementsCacheFunction, + PsiModificationTracker.MODIFICATION_COUNT, + resolveSession.getExceptionTracker()) + } + }, + false) } - @NotNull - @Override - public BindingContext getElementAdditionalResolve(@NotNull JetElement jetElement) { - return additionalResolveCache.getValue().invoke(jetElement); + override fun getElementAdditionalResolve(jetElement: JetElement): BindingContext { + return additionalResolveCache.getValue().invoke(jetElement) } - @Override - public boolean hasElementAdditionalResolveCached(@NotNull JetElement jetElement) { - if (!additionalResolveCache.hasUpToDateValue()) return false; - return additionalResolveCache.getValue().isComputed(jetElement); + override fun hasElementAdditionalResolveCached(jetElement: JetElement): Boolean { + if (!additionalResolveCache.hasUpToDateValue()) return false + return additionalResolveCache.getValue().isComputed(jetElement) } - @NotNull - @Override - public AdditionalCheckerProvider createAdditionalCheckerProvider(@NotNull JetFile jetFile, @NotNull ModuleDescriptor module) { - return TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module); + override fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor): AdditionalCheckerProvider { + return TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module) } - @NotNull - @Override - public DynamicTypesSettings getDynamicTypesSettings(@NotNull JetFile jetFile) { - return TargetPlatformDetector.getPlatform(jetFile).getDynamicTypesSettings(); + override fun getDynamicTypesSettings(jetFile: JetFile): DynamicTypesSettings { + return TargetPlatformDetector.getPlatform(jetFile).getDynamicTypesSettings() } - @NotNull - @Override - protected ProbablyNothingCallableNames probablyNothingCallableNames() { - return new ProbablyNothingCallableNames() { - @NotNull - @Override - public Collection functionNames() { + override fun probablyNothingCallableNames(): ProbablyNothingCallableNames { + return object : ProbablyNothingCallableNames { + override fun functionNames(): Collection { // we have to add hardcoded-names until we have Kotlin compiled classes in caches - return JetProbablyNothingFunctionShortNameIndex.getInstance().getAllKeys(project); + return JetProbablyNothingFunctionShortNameIndex.getInstance().getAllKeys(project) } - @NotNull - @Override - public Collection propertyNames() { - return JetProbablyNothingPropertyShortNameIndex.getInstance().getAllKeys(project); + override fun propertyNames(): Collection { + return JetProbablyNothingPropertyShortNameIndex.getInstance().getAllKeys(project) } - }; + } } - @NotNull - @Override - public BindingContext resolveFunctionBody(@NotNull JetNamedFunction function) { - return getElementAdditionalResolve(function); + override fun resolveFunctionBody(function: JetNamedFunction): BindingContext { + return getElementAdditionalResolve(function) } } From 077c8a82c79fb4f7dce93c94623ed38a06748db1 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 14:47:23 +0300 Subject: [PATCH 329/450] Converted ResolveElementCache to Kotlin (step 2) --- .../idea/project/ResolveElementCache.java | 98 ------------------- .../idea/project/ResolveElementCache.kt | 75 ++++++++++++++ 2 files changed, 75 insertions(+), 98 deletions(-) delete mode 100644 idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java create mode 100644 idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java deleted file mode 100644 index 368677522e8..00000000000 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.project - -import com.intellij.openapi.project.Project -import com.intellij.psi.util.CachedValue -import com.intellij.psi.util.CachedValueProvider -import com.intellij.psi.util.CachedValuesManager -import com.intellij.psi.util.PsiModificationTracker -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex -import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex -import org.jetbrains.kotlin.psi.JetElement -import org.jetbrains.kotlin.psi.JetFile -import org.jetbrains.kotlin.psi.JetNamedFunction -import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.BodyResolveCache -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.resolve.lazy.ElementResolver -import org.jetbrains.kotlin.resolve.lazy.ProbablyNothingCallableNames -import org.jetbrains.kotlin.resolve.lazy.ResolveSession -import org.jetbrains.kotlin.storage.LazyResolveStorageManager -import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull -import org.jetbrains.kotlin.types.DynamicTypesSettings - -public class ResolveElementCache(resolveSession: ResolveSession, private val project: Project) : ElementResolver(resolveSession), BodyResolveCache { - private val additionalResolveCache: CachedValue> - - init { - - // Recreate internal cache after change of modification count - this.additionalResolveCache = CachedValuesManager.getManager(project).createCachedValue(object : CachedValueProvider> { - override fun compute(): CachedValueProvider.Result>? { - val resolveSession = this@ResolveElementCache.resolveSession - val manager = resolveSession.getStorageManager() - val elementsCacheFunction = manager.createSoftlyRetainedMemoizedFunction(object : Function1 { - override fun invoke(jetElement: JetElement): BindingContext { - return performElementAdditionalResolve(jetElement, jetElement, BodyResolveMode.FULL) - } - }) - - return CachedValueProvider.Result.create(elementsCacheFunction, - PsiModificationTracker.MODIFICATION_COUNT, - resolveSession.getExceptionTracker()) - } - }, - false) - } - - override fun getElementAdditionalResolve(jetElement: JetElement): BindingContext { - return additionalResolveCache.getValue().invoke(jetElement) - } - - override fun hasElementAdditionalResolveCached(jetElement: JetElement): Boolean { - if (!additionalResolveCache.hasUpToDateValue()) return false - return additionalResolveCache.getValue().isComputed(jetElement) - } - - override fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor): AdditionalCheckerProvider { - return TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module) - } - - override fun getDynamicTypesSettings(jetFile: JetFile): DynamicTypesSettings { - return TargetPlatformDetector.getPlatform(jetFile).getDynamicTypesSettings() - } - - override fun probablyNothingCallableNames(): ProbablyNothingCallableNames { - return object : ProbablyNothingCallableNames { - override fun functionNames(): Collection { - // we have to add hardcoded-names until we have Kotlin compiled classes in caches - return JetProbablyNothingFunctionShortNameIndex.getInstance().getAllKeys(project) - } - - override fun propertyNames(): Collection { - return JetProbablyNothingPropertyShortNameIndex.getInstance().getAllKeys(project) - } - } - } - - override fun resolveFunctionBody(function: JetNamedFunction): BindingContext { - return getElementAdditionalResolve(function) - } -} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt new file mode 100644 index 00000000000..b9134fc691d --- /dev/null +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -0,0 +1,75 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea.project + +import com.intellij.openapi.project.Project +import com.intellij.psi.util.CachedValue +import com.intellij.psi.util.CachedValueProvider +import com.intellij.psi.util.CachedValuesManager +import com.intellij.psi.util.PsiModificationTracker +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex +import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex +import org.jetbrains.kotlin.psi.JetElement +import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.psi.JetNamedFunction +import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.BodyResolveCache +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode +import org.jetbrains.kotlin.resolve.lazy.ElementResolver +import org.jetbrains.kotlin.resolve.lazy.ProbablyNothingCallableNames +import org.jetbrains.kotlin.resolve.lazy.ResolveSession +import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull + +public class ResolveElementCache(resolveSession: ResolveSession, private val project: Project) : ElementResolver(resolveSession), BodyResolveCache { + // Recreate internal cache after change of modification count + private val additionalResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( + object : CachedValueProvider> { + override fun compute(): CachedValueProvider.Result> { + val manager = resolveSession.getStorageManager() + val elementsCacheFunction = manager.createSoftlyRetainedMemoizedFunction { element -> + performElementAdditionalResolve(element, element, BodyResolveMode.FULL) + } + return CachedValueProvider.Result.create(elementsCacheFunction, + PsiModificationTracker.MODIFICATION_COUNT, + resolveSession.getExceptionTracker()) + } + }, + false) + + override fun getElementAdditionalResolve(jetElement: JetElement) + = additionalResolveCache.getValue().invoke(jetElement) + + override fun hasElementAdditionalResolveCached(jetElement: JetElement) + = additionalResolveCache.hasUpToDateValue() && additionalResolveCache.getValue().isComputed(jetElement) + + override fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor) + = TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module) + + override fun getDynamicTypesSettings(jetFile: JetFile) + = TargetPlatformDetector.getPlatform(jetFile).getDynamicTypesSettings() + + override fun probablyNothingCallableNames(): ProbablyNothingCallableNames { + return object : ProbablyNothingCallableNames { + override fun functionNames() = JetProbablyNothingFunctionShortNameIndex.getInstance().getAllKeys(project) + override fun propertyNames() = JetProbablyNothingPropertyShortNameIndex.getInstance().getAllKeys(project) + } + } + + override fun resolveFunctionBody(function: JetNamedFunction) + = getElementAdditionalResolve(function) +} From 53e751be1f93f5db0bf1ea6e04b179aecb2043a5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 16:21:37 +0300 Subject: [PATCH 330/450] Caching of partial body resolve --- .../kotlin/resolve/lazy/ElementResolver.kt | 60 ++++---- .../resolve/lazy/PartialBodyResolveFilter.kt | 5 + .../idea/project/ResolveElementCache.kt | 49 +++++-- .../kotlin/idea/ResolveElementCacheTest.kt | 135 ++++++++++++++++++ 4 files changed, 203 insertions(+), 46 deletions(-) create mode 100644 idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 0610a5ec0c3..999cdbd03f1 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -46,41 +46,26 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull public abstract class ElementResolver protected constructor( public val resolveSession: ResolveSession ) { - - public open fun getElementAdditionalResolve(jetElement: JetElement): BindingContext { - return performElementAdditionalResolve(jetElement, jetElement, BodyResolveMode.FULL) + public open fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { + return performElementAdditionalResolve(resolveElement, resolveElement, bodyResolveMode) } - public open fun hasElementAdditionalResolveCached(jetElement: JetElement): Boolean = false - protected open fun probablyNothingCallableNames(): ProbablyNothingCallableNames = throw UnsupportedOperationException("Cannot use partial body resolve with no Nothing-functions index"); - public fun resolveToElement(jetElement: JetElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext { - @suppress("NAME_SHADOWING") - var jetElement = jetElement + public fun resolveToElement(element: JetElement, bodyResolveMode: BodyResolveMode = BodyResolveMode.FULL): BindingContext { + var contextElement = element - val elementOfAdditionalResolve = findElementOfAdditionalResolve(jetElement) + val elementOfAdditionalResolve = findElementOfAdditionalResolve(contextElement) - if (elementOfAdditionalResolve != null) { - if (elementOfAdditionalResolve !is JetParameter) { - if (bodyResolveMode != BodyResolveMode.FULL && !hasElementAdditionalResolveCached(elementOfAdditionalResolve)) { - return performElementAdditionalResolve(elementOfAdditionalResolve, jetElement, bodyResolveMode) - } - - return getElementAdditionalResolve(elementOfAdditionalResolve) - } - - val klass = elementOfAdditionalResolve.getParentOfType(true) - if (klass != null && elementOfAdditionalResolve.getParent() == klass.getPrimaryConstructorParameterList()) { - return getElementAdditionalResolve(klass) - } - - // Parameters for function literal could be met inside other parameters. We can't make resolveToDescriptors for internal elements. - jetElement = elementOfAdditionalResolve + if (elementOfAdditionalResolve is JetParameter) { + contextElement = elementOfAdditionalResolve + } + else if (elementOfAdditionalResolve != null) { + return getElementAdditionalResolve(elementOfAdditionalResolve, contextElement, bodyResolveMode) } - val declaration = jetElement.getParentOfType(false) + val declaration = contextElement.getParentOfType(false) if (declaration != null && declaration !is JetClassInitializer) { // Activate descriptor resolution resolveSession.resolveToDescriptor(declaration) @@ -89,8 +74,8 @@ public abstract class ElementResolver protected constructor( return resolveSession.getBindingContext() } - private fun findElementOfAdditionalResolve(element: JetElement): JetElement? { - var elementOfAdditionalResolve = JetPsiUtil.getTopmostParentOfTypes( + protected fun findElementOfAdditionalResolve(element: JetElement): JetElement? { + val elementOfAdditionalResolve = JetPsiUtil.getTopmostParentOfTypes( element, javaClass(), javaClass(), @@ -104,13 +89,22 @@ public abstract class ElementResolver protected constructor( javaClass(), javaClass(), javaClass(), - javaClass()) as JetElement? + javaClass()) as JetElement? ?: return null - if (elementOfAdditionalResolve is JetPackageDirective) { - return element + when (elementOfAdditionalResolve) { + is JetPackageDirective -> return element + + is JetParameter -> { + val klass = elementOfAdditionalResolve.getParentOfType(strict = true) + if (klass != null && elementOfAdditionalResolve.getParent() == klass.getPrimaryConstructorParameterList()) { + return klass + } + + return elementOfAdditionalResolve + } + + else -> return elementOfAdditionalResolve } - - return elementOfAdditionalResolve } protected fun performElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index 5a1407fe076..1eb9319cb4a 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -27,6 +27,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.JetNodeTypes import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.jetbrains.kotlin.psi.psiUtil.isAncestor +import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.resolve.StatementFilter import org.jetbrains.kotlin.utils.addToStdlib.swap import org.jetbrains.kotlin.util.isProbablyNothing @@ -538,6 +539,10 @@ class PartialBodyResolveFilter( } companion object { + public fun findResolveElement(element: JetElement, declaration: JetDeclaration): JetExpression? { + return element.parentsWithSelf.takeWhile { it != declaration }.firstOrNull { it.isStatement() } as JetExpression? + } + private fun JetElement.blocks(): Collection { val result = ArrayList(1) this.accept(object : JetVisitorVoid() { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index b9134fc691d..4fcfea60318 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -24,15 +24,10 @@ import com.intellij.psi.util.PsiModificationTracker import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex -import org.jetbrains.kotlin.psi.JetElement -import org.jetbrains.kotlin.psi.JetFile -import org.jetbrains.kotlin.psi.JetNamedFunction +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BodyResolveCache -import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode -import org.jetbrains.kotlin.resolve.lazy.ElementResolver -import org.jetbrains.kotlin.resolve.lazy.ProbablyNothingCallableNames -import org.jetbrains.kotlin.resolve.lazy.ResolveSession +import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull public class ResolveElementCache(resolveSession: ResolveSession, private val project: Project) : ElementResolver(resolveSession), BodyResolveCache { @@ -41,20 +36,48 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro object : CachedValueProvider> { override fun compute(): CachedValueProvider.Result> { val manager = resolveSession.getStorageManager() - val elementsCacheFunction = manager.createSoftlyRetainedMemoizedFunction { element -> + val cacheFunction = manager.createSoftlyRetainedMemoizedFunction { element -> performElementAdditionalResolve(element, element, BodyResolveMode.FULL) } - return CachedValueProvider.Result.create(elementsCacheFunction, + return CachedValueProvider.Result.create(cacheFunction, PsiModificationTracker.MODIFICATION_COUNT, resolveSession.getExceptionTracker()) } }, false) - override fun getElementAdditionalResolve(jetElement: JetElement) - = additionalResolveCache.getValue().invoke(jetElement) + private val partialBodyResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( + object : CachedValueProvider> { + override fun compute(): CachedValueProvider.Result> { + val manager = resolveSession.getStorageManager() + val cacheFunction = manager.createSoftlyRetainedMemoizedFunction { expression -> + val resolveElement = findElementOfAdditionalResolve(expression)!! + performElementAdditionalResolve(resolveElement, expression, BodyResolveMode.PARTIAL) + } + return CachedValueProvider.Result.create(cacheFunction, + PsiModificationTracker.MODIFICATION_COUNT, + resolveSession.getExceptionTracker()) + } + }, + false) - override fun hasElementAdditionalResolveCached(jetElement: JetElement) + override fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { + if (bodyResolveMode != BodyResolveMode.FULL && !hasElementAdditionalResolveCached(resolveElement) && resolveElement is JetDeclaration) { + if (bodyResolveMode == BodyResolveMode.PARTIAL) { + val partialResolveElement = PartialBodyResolveFilter.findResolveElement(contextElement, resolveElement) + if (partialResolveElement != null) { + return partialBodyResolveCache.getValue().invoke(partialResolveElement) + } + } + else { + return performElementAdditionalResolve(resolveElement, contextElement, bodyResolveMode) + } + } + + return additionalResolveCache.getValue().invoke(resolveElement) + } + + private fun hasElementAdditionalResolveCached(jetElement: JetElement) = additionalResolveCache.hasUpToDateValue() && additionalResolveCache.getValue().isComputed(jetElement) override fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor) @@ -71,5 +94,5 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro } override fun resolveFunctionBody(function: JetNamedFunction) - = getElementAdditionalResolve(function) + = getElementAdditionalResolve(function, function, BodyResolveMode.FULL) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt new file mode 100644 index 00000000000..c2fd2c652bc --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -0,0 +1,135 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.idea + +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.test.JetLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.JetLightProjectDescriptor +import org.jetbrains.kotlin.idea.util.application.executeWriteCommand +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode + +public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() { + override fun getProjectDescriptor() = JetLightProjectDescriptor.INSTANCE + + private val FILE_TEXT = +""" +class C { + fun a() { + b(1, 2) + c() + } + + fun b() { + } + + fun c() { + } +} +""" + + private data class Data( + val file: JetFile, + val members: List, + val statements: List, + val factory: JetPsiFactory + ) + + private fun doTest(handler: Data.() -> Unit) { + val file = myFixture.configureByText("Test.kt", FILE_TEXT) as JetFile + val klass = file.getDeclarations().single() as JetClass + val members = klass.getDeclarations() + val function = members.first() as JetNamedFunction + val statements = (function.getBodyExpression() as JetBlockExpression).getStatements() + myFixture.getProject().executeWriteCommand("") { + Data(file, members, statements, JetPsiFactory(getProject())).handler() + } + } + + public fun testResolveCaching() { + doTest { + val statement1 = statements[0] + val statement2 = statements[1] + val bindingContext1 = statement1.analyze(BodyResolveMode.FULL) + val bindingContext2 = statement2.analyze(BodyResolveMode.FULL) + assert(bindingContext1 === bindingContext2) + + val bindingContext3 = statement1.analyze(BodyResolveMode.FULL) + assert(bindingContext3 === bindingContext1) + + file.add(factory.createFunction("fun foo(){}")) + + val bindingContext4 = statement1.analyze(BodyResolveMode.FULL) + assert(bindingContext4 !== bindingContext1) + + statement1.getParent().addAfter(factory.createExpression("x()"), statement1) + + val bindingContext5 = statement1.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext5 !== bindingContext4) + } + } + + public fun testPartialResolveUsesFullResolveCached() { + doTest { + val statement1 = statements[0] + val statement2 = statements[1] + val bindingContext1 = statement1.analyze(BodyResolveMode.FULL) + + val bindingContext2 = statement2.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext2 === bindingContext1) + + val bindingContext3 = statement2.analyze(BodyResolveMode.PARTIAL_FOR_COMPLETION) + assert(bindingContext3 === bindingContext1) + } + } + + public fun testPartialResolveCaching() { + doTest { + val statement1 = statements[0] + val statement2 = statements[1] + val bindingContext1 = statement1.analyze(BodyResolveMode.PARTIAL) + val bindingContext2 = statement2.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext1 !== bindingContext2) + + val bindingContext3 = statement1.analyze(BodyResolveMode.PARTIAL) + val bindingContext4 = statement2.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext3 === bindingContext1) + assert(bindingContext4 === bindingContext2) + + file.add(factory.createFunction("fun foo(){}")) + + val bindingContext5 = statement1.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext5 !== bindingContext1) + + statement1.getParent().addAfter(factory.createExpression("x()"), statement1) + + val bindingContext6 = statement1.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext6 !== bindingContext5) + } + } + + public fun testPartialResolveCachedForWholeStatement() { + doTest { + val statement = statements[0] as JetCallExpression + val argument1 = statement.getValueArguments()[0] + val argument2 = statement.getValueArguments()[1] + val bindingContext1 = argument1.analyze(BodyResolveMode.PARTIAL) + val bindingContext2 = argument2.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext1 === bindingContext2) + } + } +} From e612787833c81f78dfac8fe1941aba39c66685b9 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 16:50:48 +0300 Subject: [PATCH 331/450] More advanced partial body resolve caching --- .../kotlin/resolve/lazy/ElementResolver.kt | 13 ++--- .../resolve/lazy/PartialBodyResolveFilter.kt | 18 ++++--- .../idea/project/ResolveElementCache.kt | 47 +++++++++++-------- .../kotlin/idea/ResolveElementCacheTest.kt | 14 +++++- 4 files changed, 59 insertions(+), 33 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 999cdbd03f1..700ef298eb0 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -47,7 +47,7 @@ public abstract class ElementResolver protected constructor( public val resolveSession: ResolveSession ) { public open fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { - return performElementAdditionalResolve(resolveElement, resolveElement, bodyResolveMode) + return performElementAdditionalResolve(resolveElement, resolveElement, bodyResolveMode).first } protected open fun probablyNothingCallableNames(): ProbablyNothingCallableNames @@ -74,7 +74,7 @@ public abstract class ElementResolver protected constructor( return resolveSession.getBindingContext() } - protected fun findElementOfAdditionalResolve(element: JetElement): JetElement? { + private fun findElementOfAdditionalResolve(element: JetElement): JetElement? { val elementOfAdditionalResolve = JetPsiUtil.getTopmostParentOfTypes( element, javaClass(), @@ -107,7 +107,7 @@ public abstract class ElementResolver protected constructor( } } - protected fun performElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { + protected fun performElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): Pair { val file = resolveElement.getContainingJetFile() val statementFilter = if (bodyResolveMode != BodyResolveMode.FULL && resolveElement is JetDeclaration) @@ -158,7 +158,7 @@ public abstract class ElementResolver protected constructor( JetFlowInformationProvider(resolveElement, controlFlowTrace).checkDeclaration() controlFlowTrace.addOwnDataTo(trace, null, false) - return trace.getBindingContext() + return Pair(trace.getBindingContext(), statementFilter) } private fun packageRefAdditionalResolve(resolveSession: ResolveSession, jetElement: JetElement): BindingTrace { @@ -447,8 +447,9 @@ public abstract class ElementResolver protected constructor( return null } - protected abstract fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor): AdditionalCheckerProvider - protected abstract fun getDynamicTypesSettings(jetFile: JetFile): DynamicTypesSettings + protected abstract fun createAdditionalCheckerProvider(file: JetFile, module: ModuleDescriptor): AdditionalCheckerProvider + + protected abstract fun getDynamicTypesSettings(file: JetFile): DynamicTypesSettings private class BodyResolveContextForLazy( private val topDownAnalysisMode: TopDownAnalysisMode, diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index 1eb9319cb4a..614f0c655e3 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -46,7 +46,10 @@ class PartialBodyResolveFilter( private val nothingFunctionNames = HashSet(probablyNothingCallableNames.functionNames()) private val nothingVariableNames = HashSet(probablyNothingCallableNames.propertyNames()) - override val filter: ((JetExpression) -> Boolean)? = { statementMarks.statementMark(it) != MarkLevel.SKIP } + override val filter: ((JetExpression) -> Boolean)? = { statementMarks.statementMark(it) != MarkLevel.NONE } + + val allStatementsToResolve: Collection + get() = statementMarks.allMarkedStatements() init { assert(declaration.isAncestor(elementToResolve)) @@ -532,14 +535,14 @@ class PartialBodyResolveFilter( } private enum class MarkLevel { - SKIP, + NONE, TAKE, NEED_REFERENCE_RESOLVE, NEED_COMPLETION } companion object { - public fun findResolveElement(element: JetElement, declaration: JetDeclaration): JetExpression? { + public fun findStatementToResolve(element: JetElement, declaration: JetDeclaration): JetExpression? { return element.parentsWithSelf.takeWhile { it != declaration }.firstOrNull { it.isStatement() } as JetExpression? } @@ -628,7 +631,7 @@ class PartialBodyResolveFilter( statementMarks[statement] = level val block = statement.getParent() as JetBlockExpression - val currentBlockLevel = blockLevels[block] ?: MarkLevel.SKIP + val currentBlockLevel = blockLevels[block] ?: MarkLevel.NONE if (currentBlockLevel < level) { blockLevels[block] = level } @@ -636,10 +639,13 @@ class PartialBodyResolveFilter( } fun statementMark(statement: JetExpression): MarkLevel - = statementMarks[statement] ?: MarkLevel.SKIP + = statementMarks[statement] ?: MarkLevel.NONE + + fun allMarkedStatements(): Collection + = statementMarks.keySet() fun lastMarkedStatement(block: JetBlockExpression, minLevel: MarkLevel): JetExpression? { - val level = blockLevels[block] ?: MarkLevel.SKIP + val level = blockLevels[block] ?: MarkLevel.NONE if (level < minLevel) return null // optimization return block.getLastChild().siblings(forward = false) .filterIsInstance() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index 4fcfea60318..03aa716c118 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -21,6 +21,7 @@ import com.intellij.psi.util.CachedValue import com.intellij.psi.util.CachedValueProvider import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.PsiModificationTracker +import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingFunctionShortNameIndex import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIndex @@ -37,7 +38,7 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro override fun compute(): CachedValueProvider.Result> { val manager = resolveSession.getStorageManager() val cacheFunction = manager.createSoftlyRetainedMemoizedFunction { element -> - performElementAdditionalResolve(element, element, BodyResolveMode.FULL) + performElementAdditionalResolve(element, element, BodyResolveMode.FULL).first } return CachedValueProvider.Result.create(cacheFunction, PsiModificationTracker.MODIFICATION_COUNT, @@ -46,15 +47,10 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro }, false) - private val partialBodyResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( - object : CachedValueProvider> { - override fun compute(): CachedValueProvider.Result> { - val manager = resolveSession.getStorageManager() - val cacheFunction = manager.createSoftlyRetainedMemoizedFunction { expression -> - val resolveElement = findElementOfAdditionalResolve(expression)!! - performElementAdditionalResolve(resolveElement, expression, BodyResolveMode.PARTIAL) - } - return CachedValueProvider.Result.create(cacheFunction, + private val partialBodyResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( + object : CachedValueProvider> { + override fun compute(): CachedValueProvider.Result> { + return CachedValueProvider.Result.create(ContainerUtil.createConcurrentSoftValueMap(), PsiModificationTracker.MODIFICATION_COUNT, resolveSession.getExceptionTracker()) } @@ -64,27 +60,38 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro override fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { if (bodyResolveMode != BodyResolveMode.FULL && !hasElementAdditionalResolveCached(resolveElement) && resolveElement is JetDeclaration) { if (bodyResolveMode == BodyResolveMode.PARTIAL) { - val partialResolveElement = PartialBodyResolveFilter.findResolveElement(contextElement, resolveElement) - if (partialResolveElement != null) { - return partialBodyResolveCache.getValue().invoke(partialResolveElement) + val statementToResolve = PartialBodyResolveFilter.findStatementToResolve(contextElement, resolveElement) + if (statementToResolve != null) { + val map = partialBodyResolveCache.getValue() + map[statementToResolve]?.let { return it } + + val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, statementToResolve, BodyResolveMode.PARTIAL) + + for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) { + if (!map.containsKey(statement)) { + map[statement] = bindingContext + } + } + + return bindingContext } } else { - return performElementAdditionalResolve(resolveElement, contextElement, bodyResolveMode) + return performElementAdditionalResolve(resolveElement, contextElement, bodyResolveMode).first } } return additionalResolveCache.getValue().invoke(resolveElement) } - private fun hasElementAdditionalResolveCached(jetElement: JetElement) - = additionalResolveCache.hasUpToDateValue() && additionalResolveCache.getValue().isComputed(jetElement) + private fun hasElementAdditionalResolveCached(element: JetElement) + = additionalResolveCache.hasUpToDateValue() && additionalResolveCache.getValue().isComputed(element) - override fun createAdditionalCheckerProvider(jetFile: JetFile, module: ModuleDescriptor) - = TargetPlatformDetector.getPlatform(jetFile).createAdditionalCheckerProvider(module) + override fun createAdditionalCheckerProvider(file: JetFile, module: ModuleDescriptor) + = TargetPlatformDetector.getPlatform(file).createAdditionalCheckerProvider(module) - override fun getDynamicTypesSettings(jetFile: JetFile) - = TargetPlatformDetector.getPlatform(jetFile).getDynamicTypesSettings() + override fun getDynamicTypesSettings(file: JetFile) + = TargetPlatformDetector.getPlatform(file).getDynamicTypesSettings() override fun probablyNothingCallableNames(): ProbablyNothingCallableNames { return object : ProbablyNothingCallableNames { diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt index c2fd2c652bc..371180bc9e7 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -31,7 +31,8 @@ public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() { class C { fun a() { b(1, 2) - c() + val x = c() + d(x) } fun b() { @@ -132,4 +133,15 @@ class C { assert(bindingContext1 === bindingContext2) } } + + public fun testPartialResolveCachedForAllStatementsResolved() { + doTest { + val bindingContext1 = statements[2].analyze(BodyResolveMode.PARTIAL) // resolve 'd(x)' + val bindingContext2 = (statements[1] as JetVariableDeclaration).getInitializer()!!.analyze(BodyResolveMode.PARTIAL) // resolve initializer in 'val x = c()' - it required for resolved 'd(x)' and should be already resolved + assert(bindingContext1 === bindingContext2) + + val bindingContext3 = statements[0].analyze(BodyResolveMode.PARTIAL) + assert(bindingContext3 !== bindingContext1) + } + } } From 02de67417a0daae9ad093bb521604d83095d8fac Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 17:16:50 +0300 Subject: [PATCH 332/450] Minor code refactorings --- .../resolve/lazy/PartialBodyResolveFilter.kt | 104 +++++------------- 1 file changed, 29 insertions(+), 75 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index 614f0c655e3..37c122657b4 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -16,21 +16,19 @@ package org.jetbrains.kotlin.resolve.lazy -import java.util.HashSet -import org.jetbrains.kotlin.psi.* -import org.jetbrains.kotlin.psi.psiUtil.siblings +import com.intellij.psi.PsiElement +import com.intellij.util.SmartList +import org.jetbrains.kotlin.JetNodeTypes import org.jetbrains.kotlin.lexer.JetTokens -import org.jetbrains.kotlin.utils.addIfNotNull +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.psiUtil.* +import org.jetbrains.kotlin.resolve.StatementFilter +import org.jetbrains.kotlin.util.isProbablyNothing +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull +import org.jetbrains.kotlin.utils.addToStdlib.swap import java.util.ArrayList import java.util.HashMap -import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.JetNodeTypes -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -import org.jetbrains.kotlin.psi.psiUtil.isAncestor -import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf -import org.jetbrains.kotlin.resolve.StatementFilter -import org.jetbrains.kotlin.utils.addToStdlib.swap -import org.jetbrains.kotlin.util.isProbablyNothing +import java.util.HashSet //TODO: do resolve anonymous object's body @@ -56,32 +54,22 @@ class PartialBodyResolveFilter( assert(!JetPsiUtil.isLocal(declaration), "Should never be invoked on local declaration otherwise we may miss some local declarations with type Nothing") - declaration.accept(object : JetVisitorVoid() { - override fun visitDeclaration(declaration: JetDeclaration) { - super.visitDeclaration(declaration) - - if (declaration is JetCallableDeclaration) { - if (declaration.getTypeReference().containsProbablyNothing()) { - val name = declaration.getName() - if (name != null) { - if (declaration is JetNamedFunction) { - nothingFunctionNames.add(name) - } - else { - nothingVariableNames.add(name) - } - } + declaration.forEachDescendantOfType { declaration -> + if (declaration.getTypeReference().containsProbablyNothing()) { + val name = declaration.getName() + if (name != null) { + if (declaration is JetNamedFunction) { + nothingFunctionNames.add(name) + } + else { + nothingVariableNames.add(name) } } } - - override fun visitElement(element: PsiElement) { - element.acceptChildren(this) - } - }) + } statementMarks.mark(elementToResolve, if (forCompletion) MarkLevel.NEED_COMPLETION else MarkLevel.NEED_REFERENCE_RESOLVE) - declaration.blocks().forEach { processBlock(it) } + declaration.forEachBlock { processBlock(it) } } //TODO: do..while is special case @@ -135,7 +123,7 @@ class PartialBodyResolveFilter( val level = statementMarks.statementMark(statement) if (level > MarkLevel.TAKE) { // otherwise there are no statements inside that need processBlock which only works when reference resolve needed - for (nestedBlock in statement.blocks()) { + statement.forEachBlock { nestedBlock -> val childFilter = processBlock(nestedBlock) nameFilter.addNamesFromFilter(childFilter) } @@ -500,22 +488,11 @@ class PartialBodyResolveFilter( val isEmpty: Boolean get() = names?.isEmpty() ?: false - private val addUsedNamesVisitor = object : JetVisitorVoid(){ - override fun visitSimpleNameExpression(expression: JetSimpleNameExpression) { - names!!.add(expression.getReferencedName()) - } - - override fun visitJetElement(element: JetElement) { - element.acceptChildren(this) - } - - override fun visitBlockExpression(expression: JetBlockExpression) { - } - } - fun addUsedNames(statement: JetExpression) { if (names != null) { - statement.accept(addUsedNamesVisitor) + statement.forEachDescendantOfType(canGoInside = { it !is JetBlockExpression }) { + names!!.add(it.getReferencedName()) + } } } @@ -546,18 +523,8 @@ class PartialBodyResolveFilter( return element.parentsWithSelf.takeWhile { it != declaration }.firstOrNull { it.isStatement() } as JetExpression? } - private fun JetElement.blocks(): Collection { - val result = ArrayList(1) - this.accept(object : JetVisitorVoid() { - override fun visitBlockExpression(expression: JetBlockExpression) { - result.add(expression) - } - - override fun visitElement(element: PsiElement) { - element.acceptChildren(this) - } - }) - return result + private fun JetElement.forEachBlock(action: (JetBlockExpression) -> Unit) { + forEachDescendantOfType({ it !is JetBlockExpression }, action) } private fun JetExpression?.isNullLiteral() = this?.getNode()?.getElementType() == JetNodeTypes.NULL @@ -594,21 +561,8 @@ class PartialBodyResolveFilter( private fun PsiElement.isStatement() = this is JetExpression && getParent() is JetBlockExpression - private fun JetTypeReference?.containsProbablyNothing(): Boolean { - var result = false - this?.getTypeElement()?.accept(object : JetVisitorVoid() { - override fun visitJetElement(element: JetElement) { - element.acceptChildren(this) - } - - override fun visitUserType(type: JetUserType) { - if (type.isProbablyNothing()) { - result = true - } - } - }) - return result - } + private fun JetTypeReference?.containsProbablyNothing() + = this?.getTypeElement()?.anyDescendantOfType { it.isProbablyNothing() } ?: false } private inner class StatementMarks { From ea25e5d02a3569e7a3dc9e3d6712081e7e9fa6c9 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 17:46:29 +0300 Subject: [PATCH 333/450] Fixed partial resolve for default parameter values --- .../idea/project/ResolveElementCache.kt | 19 +++++++++---------- .../kotlin/idea/ResolveElementCacheTest.kt | 14 +++++++++++++- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index 03aa716c118..e8e0fb98c39 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -61,20 +61,19 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro if (bodyResolveMode != BodyResolveMode.FULL && !hasElementAdditionalResolveCached(resolveElement) && resolveElement is JetDeclaration) { if (bodyResolveMode == BodyResolveMode.PARTIAL) { val statementToResolve = PartialBodyResolveFilter.findStatementToResolve(contextElement, resolveElement) - if (statementToResolve != null) { - val map = partialBodyResolveCache.getValue() - map[statementToResolve]?.let { return it } + val map = partialBodyResolveCache.getValue() + map[statementToResolve ?: resolveElement]?.let { return it } - val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, statementToResolve, BodyResolveMode.PARTIAL) + val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, contextElement, BodyResolveMode.PARTIAL) - for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) { - if (!map.containsKey(statement)) { - map[statement] = bindingContext - } + for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) { + if (!map.containsKey(statement)) { + map[statement] = bindingContext } - - return bindingContext } + map[resolveElement] = bindingContext // we use the whole declaration key in the map to obtain resolve not inside any block (e.g. default parameter values) + + return bindingContext } else { return performElementAdditionalResolve(resolveElement, contextElement, bodyResolveMode).first diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt index 371180bc9e7..b221940bd9d 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -29,7 +29,7 @@ public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() { private val FILE_TEXT = """ class C { - fun a() { + fun a(p: Int = 0) { b(1, 2) val x = c() d(x) @@ -144,4 +144,16 @@ class C { assert(bindingContext3 !== bindingContext1) } } + + public fun testPartialResolveCachedForDefaultParameterValue() { + doTest { + val defaultValue = (members[0] as JetNamedFunction).getValueParameters()[0].getDefaultValue() + val bindingContext1 = defaultValue!!.analyze(BodyResolveMode.PARTIAL) + val bindingContext2 = defaultValue.analyze(BodyResolveMode.PARTIAL) + assert(bindingContext1 === bindingContext2) + + val bindingContext3 = statements[0].analyze(BodyResolveMode.PARTIAL) + assert(bindingContext3 !== bindingContext2) + } + } } From 58f2d37d953ec80f63c1754fb6b28201a3be985c Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 13 Jul 2015 22:45:51 +0300 Subject: [PATCH 334/450] Changed element of additional resolve from single import to whole import list (as we resolve all imports anyway) --- .../src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 700ef298eb0..da45fed7a95 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -84,7 +84,7 @@ public abstract class ElementResolver protected constructor( javaClass(), javaClass(), javaClass(), - javaClass(), + javaClass(), javaClass(), javaClass(), javaClass(), @@ -128,7 +128,7 @@ public abstract class ElementResolver protected constructor( is JetInitializerList -> delegationSpecifierAdditionalResolve(resolveSession, resolveElement, resolveElement.getParent() as JetEnumEntry, file) - is JetImportDirective -> { + is JetImportList -> { val scope = resolveSession.getFileScopeProvider().getFileScope(resolveElement.getContainingJetFile()) scope.forceResolveAllImports() resolveSession.getTrace() From 8d1499197e507d707931700c19f680fbc32d7424 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 12:44:27 +0300 Subject: [PATCH 335/450] Fixed partial resolve caching to cache only for statements that are guaranteed to be processed --- .../jetbrains/kotlin/idea/project/ResolveElementCache.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index e8e0fb98c39..34c7f007228 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -66,9 +66,11 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, contextElement, BodyResolveMode.PARTIAL) - for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) { - if (!map.containsKey(statement)) { - map[statement] = bindingContext + if (statementFilter is PartialBodyResolveFilter) { + for (statement in statementFilter.allStatementsToResolve) { + if (!map.containsKey(statement) && bindingContext[BindingContext.PROCESSED, statement] == true) { + map[statement] = bindingContext + } } } map[resolveElement] = bindingContext // we use the whole declaration key in the map to obtain resolve not inside any block (e.g. default parameter values) From 745bed74b251d723f6e3ce5be5ffca73e26f4e5a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 12:48:11 +0300 Subject: [PATCH 336/450] Minor fix in partial body resolve --- .../kotlin/resolve/lazy/PartialBodyResolveFilter.kt | 2 ++ .../ClassInitializerHasNoValue.dump | 11 +++++++++++ .../partialBodyResolve/ClassInitializerHasNoValue.kt | 9 +++++++++ .../idea/resolve/PartialBodyResolveTestGenerated.java | 6 ++++++ 4 files changed, 28 insertions(+) create mode 100644 idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.dump create mode 100644 idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.kt diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index 37c122657b4..d24c58ee33f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -552,6 +552,8 @@ class PartialBodyResolveFilter( true } + is JetClassInitializer -> false + else -> true } } diff --git a/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.dump b/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.dump new file mode 100644 index 00000000000..beeecf55bac --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.dump @@ -0,0 +1,11 @@ +Resolve target: fun foo(): kotlin.Int +---------------------------------------------- +class C { + init { + foo() + /* STATEMENT DELETED: bar() */ + } +} + +fun foo() = 1 +fun bar() = 2 diff --git a/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.kt b/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.kt new file mode 100644 index 00000000000..70322619994 --- /dev/null +++ b/idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.kt @@ -0,0 +1,9 @@ +class C { + init { + foo() + bar() + } +} + +fun foo() = 1 +fun bar() = 2 \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/resolve/PartialBodyResolveTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/resolve/PartialBodyResolveTestGenerated.java index cb3f15221fb..a0a08e82022 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/resolve/PartialBodyResolveTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/resolve/PartialBodyResolveTestGenerated.java @@ -65,6 +65,12 @@ public class PartialBodyResolveTestGenerated extends AbstractPartialBodyResolveT doTest(fileName); } + @TestMetadata("ClassInitializerHasNoValue.kt") + public void testClassInitializerHasNoValue() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/ClassInitializerHasNoValue.kt"); + doTest(fileName); + } + @TestMetadata("DeclarationsBefore.kt") public void testDeclarationsBefore() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/partialBodyResolve/DeclarationsBefore.kt"); From bae90e9c2bf0f6ed50070fd36ac1821e895c7a2f Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 13:21:03 +0300 Subject: [PATCH 337/450] Perform and cache full resolve when partial is not supported --- .../kotlin/resolve/lazy/ElementResolver.kt | 33 ++++++---- .../idea/project/ResolveElementCache.kt | 62 ++++++++++++------- .../kotlin/idea/ResolveElementCacheTest.kt | 15 ++++- 3 files changed, 72 insertions(+), 38 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index da45fed7a95..6fd783360c8 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -110,19 +110,28 @@ public abstract class ElementResolver protected constructor( protected fun performElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): Pair { val file = resolveElement.getContainingJetFile() - val statementFilter = if (bodyResolveMode != BodyResolveMode.FULL && resolveElement is JetDeclaration) - PartialBodyResolveFilter(contextElement, resolveElement, probablyNothingCallableNames(), bodyResolveMode == BodyResolveMode.PARTIAL_FOR_COMPLETION) - else - StatementFilter.NONE + var statementFilterUsed = StatementFilter.NONE + + fun createStatementFilter(): StatementFilter { + assert(resolveElement is JetDeclaration) + if (bodyResolveMode != BodyResolveMode.FULL) { + statementFilterUsed = PartialBodyResolveFilter( + contextElement, + resolveElement as JetDeclaration, + probablyNothingCallableNames(), + bodyResolveMode == BodyResolveMode.PARTIAL_FOR_COMPLETION) + } + return statementFilterUsed + } val trace : BindingTrace = when (resolveElement) { - is JetNamedFunction -> functionAdditionalResolve(resolveSession, resolveElement, file, statementFilter) + is JetNamedFunction -> functionAdditionalResolve(resolveSession, resolveElement, file, createStatementFilter()) - is JetClassInitializer -> initializerAdditionalResolve(resolveSession, resolveElement, file, statementFilter) + is JetClassInitializer -> initializerAdditionalResolve(resolveSession, resolveElement, file, createStatementFilter()) - is JetSecondaryConstructor -> secondaryConstructorAdditionalResolve(resolveSession, resolveElement, file, statementFilter) + is JetSecondaryConstructor -> secondaryConstructorAdditionalResolve(resolveSession, resolveElement, file, createStatementFilter()) - is JetProperty -> propertyAdditionalResolve(resolveSession, resolveElement, file, statementFilter) + is JetProperty -> propertyAdditionalResolve(resolveSession, resolveElement, file, createStatementFilter()) is JetDelegationSpecifierList -> delegationSpecifierAdditionalResolve(resolveSession, resolveElement, resolveElement.getParent() as JetClassOrObject, file) @@ -136,7 +145,7 @@ public abstract class ElementResolver protected constructor( is JetAnnotationEntry -> annotationAdditionalResolve(resolveSession, resolveElement) - is JetClass -> constructorAdditionalResolve(resolveSession, resolveElement, file, statementFilter) + is JetClass -> constructorAdditionalResolve(resolveSession, resolveElement, file) is JetTypeParameter -> typeParameterAdditionalResolve(resolveSession, resolveElement) @@ -158,7 +167,7 @@ public abstract class ElementResolver protected constructor( JetFlowInformationProvider(resolveElement, controlFlowTrace).checkDeclaration() controlFlowTrace.addOwnDataTo(trace, null, false) - return Pair(trace.getBindingContext(), statementFilter) + return Pair(trace.getBindingContext(), statementFilterUsed) } private fun packageRefAdditionalResolve(resolveSession: ResolveSession, jetElement: JetElement): BindingTrace { @@ -339,7 +348,7 @@ public abstract class ElementResolver protected constructor( return trace } - private fun constructorAdditionalResolve(resolveSession: ResolveSession, klass: JetClass, file: JetFile, statementFilter: StatementFilter): BindingTrace { + private fun constructorAdditionalResolve(resolveSession: ResolveSession, klass: JetClass, file: JetFile): BindingTrace { val trace = createDelegatingTrace(klass) val scope = resolveSession.getDeclarationScopeProvider().getResolutionScopeForDeclaration(klass) @@ -347,7 +356,7 @@ public abstract class ElementResolver protected constructor( val constructorDescriptor = classDescriptor.getUnsubstitutedPrimaryConstructor() ?: error("Can't get primary constructor for descriptor '$classDescriptor' in from class '${klass.getElementTextWithContext()}'") - val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter) + val bodyResolver = createBodyResolver(resolveSession, trace, file, StatementFilter.NONE) bodyResolver.resolveConstructorParameterDefaultValuesAndAnnotations(DataFlowInfo.EMPTY, trace, klass, constructorDescriptor, scope) return trace diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index 34c7f007228..b7ee86f7969 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -28,19 +28,16 @@ import org.jetbrains.kotlin.idea.stubindex.JetProbablyNothingPropertyShortNameIn import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BodyResolveCache +import org.jetbrains.kotlin.resolve.StatementFilter import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull public class ResolveElementCache(resolveSession: ResolveSession, private val project: Project) : ElementResolver(resolveSession), BodyResolveCache { // Recreate internal cache after change of modification count - private val additionalResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( - object : CachedValueProvider> { - override fun compute(): CachedValueProvider.Result> { - val manager = resolveSession.getStorageManager() - val cacheFunction = manager.createSoftlyRetainedMemoizedFunction { element -> - performElementAdditionalResolve(element, element, BodyResolveMode.FULL).first - } - return CachedValueProvider.Result.create(cacheFunction, + private val fullResolveCache: CachedValue> = CachedValuesManager.getManager(project).createCachedValue( + object : CachedValueProvider> { + override fun compute(): CachedValueProvider.Result> { + return CachedValueProvider.Result.create(ContainerUtil.createConcurrentSoftValueMap(), PsiModificationTracker.MODIFICATION_COUNT, resolveSession.getExceptionTracker()) } @@ -58,36 +55,53 @@ public class ResolveElementCache(resolveSession: ResolveSession, private val pro false) override fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { - if (bodyResolveMode != BodyResolveMode.FULL && !hasElementAdditionalResolveCached(resolveElement) && resolveElement is JetDeclaration) { - if (bodyResolveMode == BodyResolveMode.PARTIAL) { + val fullResolveMap = fullResolveCache.getValue() + fullResolveMap[resolveElement]?.let { return it } // check if full additional resolve already performed + + when (bodyResolveMode) { + BodyResolveMode.FULL -> { + val bindingContext = performElementAdditionalResolve(resolveElement, resolveElement, BodyResolveMode.FULL).first + fullResolveMap[resolveElement] = bindingContext + return bindingContext + } + + BodyResolveMode.PARTIAL -> { + if (resolveElement !is JetDeclaration) { + return getElementAdditionalResolve(resolveElement, contextElement, BodyResolveMode.FULL) + } + val statementToResolve = PartialBodyResolveFilter.findStatementToResolve(contextElement, resolveElement) - val map = partialBodyResolveCache.getValue() - map[statementToResolve ?: resolveElement]?.let { return it } + val partialResolveMap = partialBodyResolveCache.getValue() + partialResolveMap[statementToResolve ?: resolveElement]?.let { return it } // partial resolve is already cached for this statement val (bindingContext, statementFilter) = performElementAdditionalResolve(resolveElement, contextElement, BodyResolveMode.PARTIAL) - if (statementFilter is PartialBodyResolveFilter) { - for (statement in statementFilter.allStatementsToResolve) { - if (!map.containsKey(statement) && bindingContext[BindingContext.PROCESSED, statement] == true) { - map[statement] = bindingContext - } + if (statementFilter == StatementFilter.NONE) { // partial resolve is not supported for the given declaration - full resolve performed instead + fullResolveMap[resolveElement] = bindingContext + return bindingContext + } + + for (statement in (statementFilter as PartialBodyResolveFilter).allStatementsToResolve) { + if (!partialResolveMap.containsKey(statement) && bindingContext[BindingContext.PROCESSED, statement] == true) { + partialResolveMap[statement] = bindingContext } } - map[resolveElement] = bindingContext // we use the whole declaration key in the map to obtain resolve not inside any block (e.g. default parameter values) + partialResolveMap[resolveElement] = bindingContext // we use the whole declaration key in the map to obtain resolve not inside any block (e.g. default parameter values) return bindingContext } - else { + + BodyResolveMode.PARTIAL_FOR_COMPLETION -> { + if (resolveElement !is JetDeclaration) { + return getElementAdditionalResolve(resolveElement, contextElement, BodyResolveMode.FULL) + } + + // not cached return performElementAdditionalResolve(resolveElement, contextElement, bodyResolveMode).first } } - - return additionalResolveCache.getValue().invoke(resolveElement) } - private fun hasElementAdditionalResolveCached(element: JetElement) - = additionalResolveCache.hasUpToDateValue() && additionalResolveCache.getValue().isComputed(element) - override fun createAdditionalCheckerProvider(file: JetFile, module: ModuleDescriptor) = TargetPlatformDetector.getPlatform(file).createAdditionalCheckerProvider(module) diff --git a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt index b221940bd9d..7cd291f6d96 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/ResolveElementCacheTest.kt @@ -28,7 +28,7 @@ public class ResolveElementCacheTest : JetLightCodeInsightFixtureTestCase() { private val FILE_TEXT = """ -class C { +class C(param1: String = "", param2: Int = 0) { fun a(p: Int = 0) { b(1, 2) val x = c() @@ -45,6 +45,7 @@ class C { private data class Data( val file: JetFile, + val klass: JetClass, val members: List, val statements: List, val factory: JetPsiFactory @@ -57,7 +58,7 @@ class C { val function = members.first() as JetNamedFunction val statements = (function.getBodyExpression() as JetBlockExpression).getStatements() myFixture.getProject().executeWriteCommand("") { - Data(file, members, statements, JetPsiFactory(getProject())).handler() + Data(file, klass, members, statements, JetPsiFactory(getProject())).handler() } } @@ -156,4 +157,14 @@ class C { assert(bindingContext3 !== bindingContext2) } } + + public fun testFullResolvedCachedWhenPartialForConstructorInvoked() { + doTest { + val defaultValue1 = klass.getPrimaryConstructorParameters()[0].getDefaultValue()!! + val defaultValue2 = klass.getPrimaryConstructorParameters()[1].getDefaultValue()!! + val bindingContext1 = defaultValue1.analyze(BodyResolveMode.PARTIAL) + val bindingContext2 = defaultValue2.analyze(BodyResolveMode.FULL) + assert(bindingContext1 === bindingContext2) + } + } } From be5c0ea28bab813e2534811ad5814f45b23c72c1 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 13:24:18 +0300 Subject: [PATCH 338/450] Renamed function --- .../kotlin/resolve/lazy/PartialBodyResolveFilter.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index d24c58ee33f..bc63a7b9bcc 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -69,7 +69,7 @@ class PartialBodyResolveFilter( } statementMarks.mark(elementToResolve, if (forCompletion) MarkLevel.NEED_COMPLETION else MarkLevel.NEED_REFERENCE_RESOLVE) - declaration.forEachBlock { processBlock(it) } + declaration.forTopLevelBlocksInside { processBlock(it) } } //TODO: do..while is special case @@ -123,7 +123,7 @@ class PartialBodyResolveFilter( val level = statementMarks.statementMark(statement) if (level > MarkLevel.TAKE) { // otherwise there are no statements inside that need processBlock which only works when reference resolve needed - statement.forEachBlock { nestedBlock -> + statement.forTopLevelBlocksInside { nestedBlock -> val childFilter = processBlock(nestedBlock) nameFilter.addNamesFromFilter(childFilter) } @@ -523,7 +523,7 @@ class PartialBodyResolveFilter( return element.parentsWithSelf.takeWhile { it != declaration }.firstOrNull { it.isStatement() } as JetExpression? } - private fun JetElement.forEachBlock(action: (JetBlockExpression) -> Unit) { + private fun JetElement.forTopLevelBlocksInside(action: (JetBlockExpression) -> Unit) { forEachDescendantOfType({ it !is JetBlockExpression }, action) } From f5e7483d19ac9daeeba194871a440c40f92a952e Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 15:52:14 +0300 Subject: [PATCH 339/450] Renames --- .../kotlin/codegen/ExpressionCodegen.java | 8 ++++---- ...ensionsScope.kt => JavaBeansExtensionsScope.kt} | 14 +++++++------- .../idea/codeInsight/ReferenceVariantsHelper.kt | 4 ++-- .../SyntheticPropertyAccessorReference.kt | 10 +++++----- .../intentions/UsePropertyAccessSyntaxIntention.kt | 6 +++--- .../KotlinPropertyAccessorsReferenceSearcher.kt | 8 ++++---- 6 files changed, 25 insertions(+), 25 deletions(-) rename compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/{SyntheticExtensionsScope.kt => JavaBeansExtensionsScope.kt} (95%) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 4a8052ef1e8..d52b296ad68 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -76,7 +76,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.scopes.receivers.*; -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor; +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; @@ -2145,8 +2145,8 @@ public class ExpressionCodegen extends JetVisitor implem @NotNull MethodKind methodKind, StackValue receiver ) { - if (propertyDescriptor instanceof SyntheticExtensionPropertyDescriptor) { - return intermediateValueForSyntheticExtensionProperty((SyntheticExtensionPropertyDescriptor) propertyDescriptor, receiver); + if (propertyDescriptor instanceof SyntheticJavaBeansPropertyDescriptor) { + return intermediateValueForSyntheticExtensionProperty((SyntheticJavaBeansPropertyDescriptor) propertyDescriptor, receiver); } DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration(); @@ -2242,7 +2242,7 @@ public class ExpressionCodegen extends JetVisitor implem } @NotNull - private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticExtensionPropertyDescriptor propertyDescriptor, StackValue receiver) { + private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaBeansPropertyDescriptor propertyDescriptor, StackValue receiver) { Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType()); CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context); FunctionDescriptor setMethod = propertyDescriptor.getSetMethod(); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt similarity index 95% rename from compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt rename to compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt index c55ea8fa21e..eac09de0921 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt @@ -37,12 +37,12 @@ import org.jetbrains.kotlin.utils.addIfNotNull import java.beans.Introspector import java.util.ArrayList -interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { +interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor val setMethod: FunctionDescriptor? companion object { - fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { + fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { val name = getterOrSetter.getName() if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization @@ -50,7 +50,7 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { if (owner !is JavaClassDescriptor) return null return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) - .filterIsInstance() + .filterIsInstance() .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } } @@ -72,12 +72,12 @@ interface SyntheticExtensionPropertyDescriptor : PropertyDescriptor { } class AdditionalScopesWithSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { - private val scope = SyntheticExtensionsScope(storageManager) + private val scope = JavaBeansExtensionsScope(storageManager) override fun scopes(file: JetFile) = listOf(scope) } -class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { +class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { triple -> syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third) } @@ -157,7 +157,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (classifier is JavaClassDescriptor) { for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { if (descriptor is FunctionDescriptor) { - val propertyName = SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue + val propertyName = SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) } } @@ -191,7 +191,7 @@ class SyntheticExtensionsScope(storageManager: StorageManager) : JetScope by Jet name: Name, type: JetType, receiverType: JetType - ) : SyntheticExtensionPropertyDescriptor, PropertyDescriptorImpl( + ) : SyntheticJavaBeansPropertyDescriptor, PropertyDescriptorImpl( DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, null, Annotations.EMPTY, diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 1f135a237dd..b877da621df 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.JetTypeChecker @@ -75,7 +75,7 @@ public class ReferenceVariantsHelper( if (filterOutJavaGettersAndSetters) { val accessorMethodsToRemove = HashSet() for (variant in variants) { - if (variant is SyntheticExtensionPropertyDescriptor) { + if (variant is SyntheticJavaBeansPropertyDescriptor) { accessorMethodsToRemove.add(variant.getMethod) accessorMethodsToRemove.addIfNotNull(variant.setMethod) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index fa92062357e..703f46f7f51 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -26,17 +26,17 @@ import org.jetbrains.kotlin.psi.JetNameReferenceExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.utils.addIfNotNull sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference(expression) { override fun getTargetDescriptors(context: BindingContext): Collection { val descriptors = super.getTargetDescriptors(context) - if (descriptors.none { it is SyntheticExtensionPropertyDescriptor }) return emptyList() + if (descriptors.none { it is SyntheticJavaBeansPropertyDescriptor }) return emptyList() val result = SmartList() for (descriptor in descriptors) { - if (descriptor is SyntheticExtensionPropertyDescriptor) { + if (descriptor is SyntheticJavaBeansPropertyDescriptor) { if (getter) { result.add(descriptor.getMethod) } @@ -57,9 +57,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr val newNameAsName = Name.identifier(newElementName) val newName = if (getter) - SyntheticExtensionPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) + SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) else - SyntheticExtensionPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) + SyntheticJavaBeansPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 760ec6279a9..273c8a0ddc3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor class UsePropertyAccessSyntaxInspection : IntentionBasedInspection(UsePropertyAccessSyntaxIntention()) @@ -87,8 +87,8 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent return property } - private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticExtensionPropertyDescriptor? { - SyntheticExtensionPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } + private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { + SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } for (overridden in function.getOverriddenDescriptors()) { findSyntheticProperty(overridden, resolutionScope)?.let { return it } diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt index c65191aa4b9..3ea9e34c1cd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt @@ -29,8 +29,8 @@ import org.jetbrains.kotlin.idea.JetFileType import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor import org.jetbrains.kotlin.psi.JetProperty import org.jetbrains.kotlin.storage.LockBasedStorageManager -import org.jetbrains.kotlin.synthetic.SyntheticExtensionPropertyDescriptor -import org.jetbrains.kotlin.synthetic.SyntheticExtensionsScope +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor +import org.jetbrains.kotlin.synthetic.JavaBeansExtensionsScope public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor) { @@ -54,8 +54,8 @@ public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase Date: Tue, 14 Jul 2015 18:06:42 +0300 Subject: [PATCH 340/450] Minor --- .../org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt index eac09de0921..fe7941e5081 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider +import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType @@ -155,7 +156,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() if (classifier is JavaClassDescriptor) { - for (descriptor in classifier.getMemberScope(type.getArguments()).getAllDescriptors()) { + for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { val propertyName = SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) From d743924be9eb3e56f0baa992c178580336b47695 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 18:12:59 +0300 Subject: [PATCH 341/450] Changed signatures --- .../kotlin/synthetic/JavaBeansExtensionsScope.kt | 4 ++-- .../kotlin/resolve/AllUnderImportsScope.kt | 4 ++-- .../kotlin/resolve/lazy/LazyImportScope.kt | 6 +++--- .../kotlin/resolve/scopes/AbstractScopeAdapter.kt | 4 ++-- .../kotlin/resolve/scopes/ChainedScope.kt | 4 ++-- .../kotlin/resolve/scopes/FilteringScope.kt | 5 +++-- .../jetbrains/kotlin/resolve/scopes/JetScope.kt | 4 ++-- .../kotlin/resolve/scopes/JetScopeImpl.kt | 4 ++-- .../kotlin/resolve/scopes/SubstitutingScope.kt | 5 +++-- .../org/jetbrains/kotlin/types/ErrorUtils.java | 15 ++++++++------- 10 files changed, 29 insertions(+), 26 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt index fe7941e5081..5834b3c763e 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt @@ -127,7 +127,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet && descriptor.getVisibility() == Visibilities.PUBLIC } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList() } @@ -146,7 +146,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet return result } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { val result = ArrayList() result.collectSyntheticProperties(receiverType.makeNotNullable()) return result diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index 94a9868fae2..f4218d6fc5c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -53,11 +53,11 @@ class AllUnderImportsScope : JetScope { return scopes.flatMap { it.getFunctions(name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType, name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index 903d61c4e9e..e6a157b09c8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -255,17 +255,17 @@ class LazyImportScope( return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverType, name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() return importResolver.resolveSession.getStorageManager().compute { - importResolver.indexedImports.imports.flatMapTo(LinkedHashSet()) { import -> + importResolver.indexedImports.imports.flatMapTo(LinkedHashSet()) { import -> importResolver.getImportScope(import, LookupMode.EVERYTHING).getSyntheticExtensionProperties(receiverType) } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index aee4d5f6423..bd2484fe4fe 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -47,11 +47,11 @@ public abstract class AbstractScopeAdapter : JetScope { return workerScope.getProperties(name) } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { return workerScope.getSyntheticExtensionProperties(receiverType, name) } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { return workerScope.getSyntheticExtensionProperties(receiverType) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index 7d1319fbeb4..7ba44c9658b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -65,10 +65,10 @@ public open class ChainedScope( override fun getFunctions(name: Name): Collection = getFromAllScopes { it.getFunctions(name) } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType, name) } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType) } override fun getImplicitReceiversHierarchy(): List { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index 650c8ff0f8c..5dc3782cee5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.utils.Printer @@ -36,9 +37,9 @@ public class FilteringScope(private val workerScope: JetScope, private val predi override fun getProperties(name: Name) = workerScope.getProperties(name).filter(predicate) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = workerScope.getSyntheticExtensionProperties(receiverType, name).filter(predicate) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = workerScope.getSyntheticExtensionProperties(receiverType, name).filter(predicate) - override fun getSyntheticExtensionProperties(receiverType: JetType) = workerScope.getSyntheticExtensionProperties(receiverType).filter(predicate) + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = workerScope.getSyntheticExtensionProperties(receiverType).filter(predicate) override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index d2ddc74eca1..102d79a2f7a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -35,9 +35,9 @@ public trait JetScope { public fun getFunctions(name: Name): Collection - public fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + public fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection - public fun getSyntheticExtensionProperties(receiverType: JetType): Collection + public fun getSyntheticExtensionProperties(receiverType: JetType): Collection public fun getContainingDeclaration(): DeclarationDescriptor diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt index 011ed035050..e55a691dffc 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt @@ -32,9 +32,9 @@ public abstract class JetScopeImpl : JetScope { override fun getFunctions(name: Name): Collection = setOf() - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = listOf() + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = listOf() override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index 2d53c9f2ad9..d1533271a52 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.scopes import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.JetType @@ -69,9 +70,9 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su override fun getFunctions(name: Name) = substitute(workerScope.getFunctions(name)) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name) = substitute(workerScope.getSyntheticExtensionProperties(receiverType, name)) + override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverType, name)) - override fun getSyntheticExtensionProperties(receiverType: JetType) = substitute(workerScope.getSyntheticExtensionProperties(receiverType)) + override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverType)) override fun getPackage(name: Name) = workerScope.getPackage(name) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 6c0716e61dc..4c1299be7ec 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -88,12 +88,12 @@ public class ErrorUtils { @NotNull @Override public Set getProperties(@NotNull Name name) { - return ERROR_PROPERTY_GROUP; + return ERROR_VARIABLE_GROUP; } @NotNull @Override - public Collection getSyntheticExtensionProperties( + public Collection getSyntheticExtensionProperties( @NotNull JetType receiverType, @NotNull Name name ) { return ERROR_PROPERTY_GROUP; @@ -101,7 +101,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { return ERROR_PROPERTY_GROUP; } @@ -209,7 +209,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getSyntheticExtensionProperties( + public Collection getSyntheticExtensionProperties( @NotNull JetType receiverType, @NotNull Name name ) { throw new IllegalStateException(); @@ -217,7 +217,7 @@ public class ErrorUtils { @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { throw new IllegalStateException(); } @@ -333,9 +333,10 @@ public class ErrorUtils { } private static final JetType ERROR_PROPERTY_TYPE = createErrorType(""); - private static final VariableDescriptor ERROR_PROPERTY = createErrorProperty(); + private static final PropertyDescriptor ERROR_PROPERTY = createErrorProperty(); - private static final Set ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY); + private static final Set ERROR_VARIABLE_GROUP = Collections.singleton(ERROR_PROPERTY); + private static final Set ERROR_PROPERTY_GROUP = Collections.singleton(ERROR_PROPERTY); @NotNull private static PropertyDescriptorImpl createErrorProperty() { From 0cea5fc9b2e393b5f6d799940c09b9ce3f81b8ba Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 22:10:16 +0300 Subject: [PATCH 342/450] More informative presentation of synthetic properties in completion --- .../idea/completion/LookupElementFactory.kt | 50 +++++++++++-------- .../ShowGetSetOnSecondCompletion.kt | 2 +- .../common/extensions/SyntheticExtensions1.kt | 2 +- .../common/extensions/SyntheticExtensions2.kt | 6 +-- .../extensions/SyntheticExtensionsSafeCall.kt | 2 +- .../SyntheticExtensionForGenericClass.kt | 2 +- 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 89c414b38d0..2a5d7d25f20 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils @@ -216,27 +217,36 @@ public class LookupElementFactory( } if (descriptor is CallableDescriptor) { - if (descriptor.getExtensionReceiverParameter() != null) { - val originalReceiver = descriptor.getOriginal().getExtensionReceiverParameter()!! - val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(originalReceiver.getType()) - element = element.appendTailText(" for $receiverPresentation", true) - - val container = descriptor.getContainingDeclaration() - val containerPresentation = if (container is ClassDescriptor) - DescriptorUtils.getFqNameFromTopLevelClass(container).toString() - else if (container is PackageFragmentDescriptor) - container.fqName.toString() - else - null - if (containerPresentation != null) { - element = element.appendTailText(" in $containerPresentation", true) + when { + descriptor is SyntheticJavaBeansPropertyDescriptor -> { + var from = descriptor.getMethod.getName().asString() + "()" + descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" } + element = element.appendTailText(" (from $from)", true) } - } - else { - val container = descriptor.getContainingDeclaration() - if (container is PackageFragmentDescriptor) { // we show container only for global functions and properties - //TODO: it would be probably better to show it also for static declarations which are not from the current class (imported) - element = element.appendTailText(" (${container.fqName})", true) + + descriptor.getExtensionReceiverParameter() != null -> { + val originalReceiver = descriptor.getOriginal().getExtensionReceiverParameter()!! + val receiverPresentation = DescriptorRenderer.SHORT_NAMES_IN_TYPES.renderType(originalReceiver.getType()) + element = element.appendTailText(" for $receiverPresentation", true) + + val container = descriptor.getContainingDeclaration() + val containerPresentation = if (container is ClassDescriptor) + DescriptorUtils.getFqNameFromTopLevelClass(container).toString() + else if (container is PackageFragmentDescriptor) + container.fqName.toString() + else + null + if (containerPresentation != null) { + element = element.appendTailText(" in $containerPresentation", true) + } + } + + else -> { + val container = descriptor.getContainingDeclaration() + if (container is PackageFragmentDescriptor) { // we show container only for global functions and properties + //TODO: it would be probably better to show it also for static declarations which are not from the current class (imported) + element = element.appendTailText(" (${container.fqName})", true) + } } } } diff --git a/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt b/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt index fef508589b2..3c286d2bd9f 100644 --- a/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt +++ b/idea/idea-completion/testData/basic/common/extensions/ShowGetSetOnSecondCompletion.kt @@ -3,6 +3,6 @@ fun foo(thread: Thread) { } // INVOCATION_COUNT: 2 -// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } +// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " (from getPriority()/setPriority())", typeText: "Int" } // EXIST_JAVA_ONLY: getPriority // EXIST_JAVA_ONLY: setPriority diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt index b8625274b72..8eec756323e 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt @@ -4,5 +4,5 @@ fun foo(file: File) { file. } -// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " (from getAbsolutePath())", typeText: "String!" } // ABSENT: getAbsolutePath diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index 7a340e36334..cc74e6dfe9b 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -4,9 +4,9 @@ fun Thread.foo(urlConnection: java.net.URLConnection) { } } -// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " for Thread", typeText: "Int" } -// EXIST_JAVA_ONLY: { lookupString: "daemon", itemText: "daemon", tailText: " for Thread", typeText: "Boolean" } -// EXIST_JAVA_ONLY: { lookupString: "URL", itemText: "URL", tailText: " for URLConnection", typeText: "URL!" } +// EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " (from getPriority()/setPriority())", typeText: "Int" } +// EXIST_JAVA_ONLY: { lookupString: "daemon", itemText: "daemon", tailText: " (from isDaemon()/setDaemon())", typeText: "Boolean" } +// EXIST_JAVA_ONLY: { lookupString: "URL", itemText: "URL", tailText: " (from getURL())", typeText: "URL!" } // ABSENT: getPriority // ABSENT: setPriority // ABSENT: isDaemon diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt index e145299c03d..dd92a12b02a 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt @@ -4,5 +4,5 @@ fun foo(file: File?) { file?. } -// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " for File", typeText: "String!" } +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " (from getAbsolutePath())", typeText: "String!" } // ABSENT: getAbsolutePath diff --git a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt index 3472811499d..f4129d0185c 100644 --- a/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt +++ b/idea/idea-completion/testData/basic/multifile/SyntheticExtensionForGenericClass/SyntheticExtensionForGenericClass.kt @@ -2,4 +2,4 @@ fun foo(javaClass: JavaClass) { javaClass. } -// EXIST: { lookupString: "something", itemText: "something", tailText: " for JavaClass", typeText: "String!" } +// EXIST: { lookupString: "something", itemText: "something", tailText: " (from getSomething()/setSomething())", typeText: "String!" } From a740b60134b5585345e3215dac6dd86962704e21 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 14 Jul 2015 19:11:03 +0300 Subject: [PATCH 343/450] Temporary workaround until iterable injection is supported in di Synthetic accessors won't work in REPL until this is fixed --- .../src/org/jetbrains/kotlin/frontend/java/di/injection.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 5b3b7612f87..5f27659b0f5 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,7 +66,6 @@ public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentS useImpl() useImpl() useImpl() - useImpl() } public fun createContainerForLazyResolveWithJava( @@ -76,6 +75,7 @@ public fun createContainerForLazyResolveWithJava( configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) + useImpl() useInstance(moduleClassResolver) useInstance(declarationProviderFactory) @@ -96,6 +96,8 @@ public fun createContainerForTopDownAnalyzerForJvm( ): ContainerForTopDownAnalyzerForJvm = createContainer("TopDownAnalyzerForJvm") { configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) + + useImpl() useInstance(declarationProviderFactory) useInstance(BodyResolveCache.ThrowException) From 867b0b5075149ce57a333d2dba62d22bdffc514d Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 14 Jul 2015 22:26:22 +0300 Subject: [PATCH 344/450] Renamed class --- .../src/org/jetbrains/kotlin/frontend/java/di/injection.kt | 6 +++--- .../jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 5f27659b0f5..2f671afa407 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 @@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.jvm.JavaLazyAnalyzerPostConstruct import org.jetbrains.kotlin.resolve.lazy.FileScopeProviderImpl import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory -import org.jetbrains.kotlin.synthetic.AdditionalScopesWithSyntheticExtensions +import org.jetbrains.kotlin.synthetic.AdditionalScopesWithJavaSyntheticExtensions public fun StorageComponentContainer.configureJavaTopDownAnalysis(moduleContentScope: GlobalSearchScope, project: Project) { useInstance(moduleContentScope) @@ -75,7 +75,7 @@ public fun createContainerForLazyResolveWithJava( configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) - useImpl() + useImpl() useInstance(moduleClassResolver) useInstance(declarationProviderFactory) @@ -97,7 +97,7 @@ public fun createContainerForTopDownAnalyzerForJvm( configureModule(moduleContext, KotlinJvmCheckerProvider(moduleContext.module), bindingTrace) configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project) - useImpl() + useImpl() useInstance(declarationProviderFactory) useInstance(BodyResolveCache.ThrowException) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt index 5834b3c763e..3c019f06ba5 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt @@ -72,7 +72,7 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { } } -class AdditionalScopesWithSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { +class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { private val scope = JavaBeansExtensionsScope(storageManager) override fun scopes(file: JetFile) = listOf(scope) From 53810c67db138f38e626aeea0fd10a1255cdd6c8 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 15 Jul 2015 16:06:46 +0300 Subject: [PATCH 345/450] Changes on code review --- .../kotlin/resolve/lazy/ElementResolver.kt | 3 +- .../resolve/lazy/PartialBodyResolveFilter.kt | 2 +- .../kotlin/idea/references/referenceUtil.kt | 2 +- ...oNotHideGetterWhenExtensionCannotBeUsed.kt | 4 +-- .../kotlin/idea/actions/JetAddImportAction.kt | 31 +++++++++---------- .../KotlinCopyPasteReferenceProcessor.kt | 7 ++--- .../kotlin/idea/ResolveElementCacheTest.kt | 2 +- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt index 6fd783360c8..5e973a05733 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/ElementResolver.kt @@ -46,7 +46,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull public abstract class ElementResolver protected constructor( public val resolveSession: ResolveSession ) { - public open fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { + protected open fun getElementAdditionalResolve(resolveElement: JetElement, contextElement: JetElement, bodyResolveMode: BodyResolveMode): BindingContext { return performElementAdditionalResolve(resolveElement, resolveElement, bodyResolveMode).first } @@ -59,6 +59,7 @@ public abstract class ElementResolver protected constructor( val elementOfAdditionalResolve = findElementOfAdditionalResolve(contextElement) if (elementOfAdditionalResolve is JetParameter) { + // Parameters for function literal could be met inside other parameters. We can't make resolveToDescriptors for internal elements. contextElement = elementOfAdditionalResolve } else if (elementOfAdditionalResolve != null) { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt index bc63a7b9bcc..c6bce01f18f 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/resolve/lazy/PartialBodyResolveFilter.kt @@ -524,7 +524,7 @@ class PartialBodyResolveFilter( } private fun JetElement.forTopLevelBlocksInside(action: (JetBlockExpression) -> Unit) { - forEachDescendantOfType({ it !is JetBlockExpression }, action) + forEachDescendantOfType(canGoInside = { it !is JetBlockExpression }, action = action) } private fun JetExpression?.isNullLiteral() = this?.getNode()?.getElementType() == JetNodeTypes.NULL diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt index ce5caa01a32..6b076a2a7c1 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/referenceUtil.kt @@ -130,7 +130,7 @@ val KDocName.mainReference: KDocReference val JetElement.mainReference: JetReference? get() { return when { - this is JetSimpleNameExpression -> mainReference + this is JetReferenceExpression -> mainReference this is KDocName -> mainReference else -> getReferences().firstIsInstanceOrNull() } diff --git a/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt b/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt index bfad110447f..72f81972745 100644 --- a/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt +++ b/idea/idea-completion/testData/basic/common/extensions/DoNotHideGetterWhenExtensionCannotBeUsed.kt @@ -1,8 +1,8 @@ import java.io.File -fun File.foo(absolutePath: String) { +fun File.foo(absolutePath: String?) { } // EXIST_JAVA_ONLY: getAbsolutePath -// ABSENT: { itemText: "absolutePath", tailText: " for File" } +// ABSENT: { itemText: "absolutePath", typeText: "String" } diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt index e9225f8c1c6..23e5d3af082 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/JetAddImportAction.kt @@ -107,7 +107,7 @@ public class JetAddImportAction( // TODO: Validate resolution variants. See AddImportAction.execute() if (variants.size() == 1 || ApplicationManager.getApplication().isUnitTestMode()) { - addImport(element, project, variants.first()) + addImport(variants.first()) } else { chooseCandidateAndImport() @@ -124,7 +124,7 @@ public class JetAddImportAction( if (selectedValue == null) return null if (finalChoice) { - addImport(element, project, selectedValue) + addImport(selectedValue) return null } @@ -156,23 +156,20 @@ public class JetAddImportAction( JBPopupFactory.getInstance().createListPopup(getImportSelectionPopup()).showInBestPositionFor(editor) } - companion object { + private fun addImport(selectedVariant: Variant) { + PsiDocumentManager.getInstance(project).commitAllDocuments() - protected fun addImport(element: PsiElement, project: Project, selectedVariant: Variant) { - PsiDocumentManager.getInstance(project).commitAllDocuments() + project.executeWriteCommand(QuickFixBundle.message("add.import")) { + if (!element.isValid()) return@executeWriteCommand - project.executeWriteCommand(QuickFixBundle.message("add.import")) { - if (!element.isValid()) return@executeWriteCommand - - val file = element.getContainingFile() as JetFile - val descriptor = selectedVariant.descriptorToImport - // for class or package we use ShortenReferences because we not necessary insert an import but may want to insert partly qualified name - if (element is JetSimpleNameExpression && (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor)) { - element.mainReference.bindToFqName(descriptor.importableFqNameSafe, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING) - } - else { - ImportInsertHelper.getInstance(project).importDescriptor(file, descriptor) - } + val file = element.getContainingFile() as JetFile + val descriptor = selectedVariant.descriptorToImport + // for class or package we use ShortenReferences because we not necessary insert an import but may want to insert partly qualified name + if (descriptor is ClassDescriptor || descriptor is PackageViewDescriptor) { + element.mainReference.bindToFqName(descriptor.importableFqNameSafe, JetSimpleNameReference.ShorteningMode.FORCED_SHORTENING) + } + else { + ImportInsertHelper.getInstance(project).importDescriptor(file, descriptor) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt index b07a053380a..2cb8b806d32 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinCopyPasteReferenceProcessor.kt @@ -50,6 +50,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.elementsInRange import org.jetbrains.kotlin.psi.psiUtil.forEachDescendantOfType import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression +import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.scopes.JetScope @@ -217,16 +218,14 @@ public class KotlinCopyPasteReferenceProcessor() : CopyPastePostProcessor Date: Wed, 15 Jul 2015 22:38:39 +0300 Subject: [PATCH 346/450] All JetReferenceExpression's should have a reference (see JetReferenceExpression.mainReference extension) - made JetPackageDirective not a JetReferenceExpression --- .../src/org/jetbrains/kotlin/psi/JetPackageDirective.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java index c471010cf73..d745d9e0f49 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java @@ -32,9 +32,7 @@ import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; import java.util.Collections; import java.util.List; -public class JetPackageDirective - extends JetModifierListOwnerStub> - implements JetReferenceExpression { +public class JetPackageDirective extends JetModifierListOwnerStub> implements JetExpression { private String qualifiedNameCache = null; public JetPackageDirective(@NotNull ASTNode node) { From 82c9cd790e90ec48e336417969eb2a15aabfc571 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 15 Jul 2015 20:06:17 +0300 Subject: [PATCH 347/450] After dot completion optimization: do not ask for packages and classes when searching extensions --- .../kotlin/idea/codeInsight/ReferenceVariantsHelper.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index b877da621df..1d68a7b7fa9 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -221,7 +221,9 @@ public class ReferenceVariantsHelper( nameFilter: (Name) -> Boolean ) { if (kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) return - val extensionsFilter = kindFilter.exclude(DescriptorKindExclude.NonExtensions) + val extensionsFilter = kindFilter + .restrictedToKinds(DescriptorKindFilter.FUNCTIONS_MASK or DescriptorKindFilter.VARIABLES_MASK) + .exclude(DescriptorKindExclude.NonExtensions) fun processExtension(descriptor: DeclarationDescriptor) { addAll((descriptor as CallableDescriptor).substituteExtensionIfCallable(receiver, callType, context, dataFlowInfo, resolutionScope.getContainingDeclaration())) From c1b2ea0b4874101bbc618ca7bbfa8d66a208aa9b Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 16 Jul 2015 00:41:54 +0300 Subject: [PATCH 348/450] More elegant way to achieve the same + fixed KT-7746 Top level package name completion does not work inside class body #KT-7746 Fixed --- .../load/java/descriptors/SamConstructorDescriptor.kt | 2 ++ .../org/jetbrains/kotlin/resolve/scopes/JetScope.kt | 11 ++++++++++- .../idea/codeInsight/ReferenceVariantsHelper.kt | 4 +--- .../kotlin/idea/completion/BasicCompletionSession.kt | 8 ++++---- .../basic/common/TopLevelPackageInClassBody.kt | 5 +++++ .../test/JSBasicCompletionTestGenerated.java | 6 ++++++ .../test/JvmBasicCompletionTestGenerated.java | 6 ++++++ 7 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt index aa76c4a5ac8..5d755f6c8fc 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/descriptors/SamConstructorDescriptor.kt @@ -35,4 +35,6 @@ public class SamConstructorDescriptor( public object SamConstructorDescriptorKindExclude : DescriptorKindExclude { override fun matches(descriptor: DeclarationDescriptor) = descriptor is SamConstructorDescriptor + + override val fullyExcludedDescriptorKinds: Int get() = 0 } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index 102d79a2f7a..6e117e28ff2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -110,7 +110,7 @@ public class DescriptorKindFilter( = kindMask and kinds != 0 public fun exclude(exclude: DescriptorKindExclude): DescriptorKindFilter - = DescriptorKindFilter(kindMask, excludes + listOf(exclude)) + = DescriptorKindFilter(kindMask and exclude.fullyExcludedDescriptorKinds.inv(), excludes + listOf(exclude)) public fun withoutKinds(kinds: Int): DescriptorKindFilter = DescriptorKindFilter(kindMask and kinds.inv(), excludes) @@ -196,20 +196,29 @@ public class DescriptorKindFilter( public trait DescriptorKindExclude { public fun matches(descriptor: DeclarationDescriptor): Boolean + public val fullyExcludedDescriptorKinds: Int + override fun toString() = this.javaClass.getSimpleName() public object Extensions : DescriptorKindExclude { override fun matches(descriptor: DeclarationDescriptor) = descriptor is CallableDescriptor && descriptor.getExtensionReceiverParameter() != null + + override val fullyExcludedDescriptorKinds: Int get() = 0 } public object NonExtensions : DescriptorKindExclude { override fun matches(descriptor: DeclarationDescriptor) = descriptor !is CallableDescriptor || descriptor.getExtensionReceiverParameter() == null + + override val fullyExcludedDescriptorKinds: Int + get() = DescriptorKindFilter.ALL_KINDS_MASK and (DescriptorKindFilter.FUNCTIONS_MASK or DescriptorKindFilter.VARIABLES_MASK).inv() } public object EnumEntry : DescriptorKindExclude { override fun matches(descriptor: DeclarationDescriptor) = descriptor is ClassDescriptor && descriptor.getKind() == ClassKind.ENUM_ENTRY + + override val fullyExcludedDescriptorKinds: Int get() = 0 } } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 1d68a7b7fa9..b877da621df 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -221,9 +221,7 @@ public class ReferenceVariantsHelper( nameFilter: (Name) -> Boolean ) { if (kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) return - val extensionsFilter = kindFilter - .restrictedToKinds(DescriptorKindFilter.FUNCTIONS_MASK or DescriptorKindFilter.VARIABLES_MASK) - .exclude(DescriptorKindExclude.NonExtensions) + val extensionsFilter = kindFilter.exclude(DescriptorKindExclude.NonExtensions) fun processExtension(descriptor: DeclarationDescriptor) { addAll((descriptor as CallableDescriptor).substituteExtensionIfCallable(receiver, callType, context, dataFlowInfo, resolutionScope.getContainingDeclaration())) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 7193af5162b..c653e5f406e 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -233,11 +233,11 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, private companion object { object NonAnnotationClassifierExclude : DescriptorKindExclude { override fun matches(descriptor: DeclarationDescriptor): Boolean { - return if (descriptor is ClassDescriptor) - descriptor.getKind() != ClassKind.ANNOTATION_CLASS - else - descriptor !is ClassifierDescriptor + if (descriptor !is ClassifierDescriptor) return false + return descriptor !is ClassDescriptor || descriptor.getKind() != ClassKind.ANNOTATION_CLASS } + + override val fullyExcludedDescriptorKinds: Int get() = 0 } val ANNOTATION_TYPES_FILTER = DescriptorKindFilter(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS_MASK or DescriptorKindFilter.PACKAGES_MASK) exclude NonAnnotationClassifierExclude diff --git a/idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt b/idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt new file mode 100644 index 00000000000..adf75a918cf --- /dev/null +++ b/idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt @@ -0,0 +1,5 @@ +class A { + kot +} + +// EXIST: "kotlin" diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 210106ae8d0..4873ed301ac 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -865,6 +865,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("TopLevelPackageInClassBody.kt") + public void testTopLevelPackageInClassBody() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt"); + doTest(fileName); + } + @TestMetadata("TypeParameterFromOuterClass.kt") public void testTypeParameterFromOuterClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/TypeParameterFromOuterClass.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index d149189acfa..2d1a2a7d9af 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -865,6 +865,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("TopLevelPackageInClassBody.kt") + public void testTopLevelPackageInClassBody() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/TopLevelPackageInClassBody.kt"); + doTest(fileName); + } + @TestMetadata("TypeParameterFromOuterClass.kt") public void testTypeParameterFromOuterClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/TypeParameterFromOuterClass.kt"); From 10b59425373282174d38405c1114d8113a232f22 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 15 Jul 2015 20:18:39 +0300 Subject: [PATCH 349/450] Formatting --- .../kotlin/idea/completion/SmartCompletionSession.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt index 38f42d0e95e..cf55743eb26 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/SmartCompletionSession.kt @@ -51,8 +51,8 @@ class SmartCompletionSession(configuration: CompletionSessionConfiguration, para addFunctionLiteralArgumentCompletions() val completion = SmartCompletion(expression, resolutionFacade, moduleDescriptor, - bindingContext, isVisibleFilter, inDescriptor, prefixMatcher, originalSearchScope, - mapper, lookupElementFactory) + bindingContext, isVisibleFilter, inDescriptor, prefixMatcher, originalSearchScope, + mapper, lookupElementFactory) val result = completion.execute() if (result != null) { collector.addElements(result.additionalItems) From 136af1cd60559c84583eec979568233ac9c4993c Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 15 Jul 2015 21:48:19 +0300 Subject: [PATCH 350/450] Optimization in completion: don't spend too much time calculating root packages --- .../idea/completion/BasicCompletionSession.kt | 30 ++++++++++++++++++- .../idea/completion/CompletionSession.kt | 3 +- .../idea/completion/CompletionSorting.kt | 7 ++--- .../completion/DeclarationLookupObjectImpl.kt | 16 ++++++++++ ...cludeFromCompletionLookupActionProvider.kt | 8 +---- .../idea/completion/LookupElementFactory.kt | 26 ++++++++++++++++ .../handlers/BaseDeclarationInsertHandler.kt | 5 ++-- .../completion/DeclarationLookupObject.kt | 4 +++ 8 files changed, 83 insertions(+), 16 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index c653e5f406e..78b43a12356 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -19,12 +19,17 @@ package org.jetbrains.kotlin.idea.completion import com.intellij.codeInsight.completion.* import com.intellij.patterns.PatternCondition import com.intellij.patterns.StandardPatterns +import com.intellij.psi.JavaPsiFacade import com.intellij.psi.util.PsiTreeUtil import com.intellij.util.ProcessingContext import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.idea.project.ProjectStructureUtil +import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType @@ -70,7 +75,10 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, private val completionKind = calcCompletionKind() - override val descriptorKindFilter = completionKind.descriptorKindFilter + override val descriptorKindFilter = if (isNoQualifierContext()) + completionKind.descriptorKindFilter?.withoutKinds(DescriptorKindFilter.PACKAGES_MASK) + else + completionKind.descriptorKindFilter private val parameterNameAndTypeCompletion = if (shouldCompleteParameterNameAndType()) ParameterNameAndTypeCompletion(collector, lookupElementFactory, prefixMatcher, resolutionFacade) @@ -193,6 +201,26 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, } } + // getting root packages from scope is very slow so we do this in alternative way + if (isNoQualifierContext() && (completionKind.descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.PACKAGES_MASK) != 0) { + //TODO: move this code somewhere else + //TODO: filter by prefix for better performance? + val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project) + .map { it.shortName() } + .toMutableSet() + + if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) { + JavaPsiFacade.getInstance(project).findPackage("")?.getSubPackages(originalSearchScope)?.forEach { psiPackage -> + val name = psiPackage.getName() + if (Name.isValidIdentifier(name!!)) { + packageNames.add(Name.identifier(name)) + } + } + } + + packageNames.forEach { collector.addElement(lookupElementFactory.createLookupElementForPackage(it)) } + } + if (completionKind != CompletionKind.KEYWORDS_ONLY) { flushToResultSet() diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt index 019630f52db..5d1cf31aa7a 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSession.kt @@ -238,7 +238,8 @@ abstract class CompletionSession(protected val configuration: CompletionSessionC } protected fun getRuntimeReceiverTypeReferenceVariants(): Collection { - val descriptors = referenceVariantsHelper.getReferenceVariants(nameExpression!!, descriptorKindFilter!!, prefixMatcher.asNameFilter(), useRuntimeReceiverType = true) + val restrictedKindFilter = descriptorKindFilter!!.restrictedToKinds(DescriptorKindFilter.FUNCTIONS_MASK or DescriptorKindFilter.VARIABLES_MASK) // optimization + val descriptors = referenceVariantsHelper.getReferenceVariants(nameExpression!!, restrictedKindFilter, prefixMatcher.asNameFilter(), useRuntimeReceiverType = true) return descriptors.filter { descriptor -> referenceVariants.none { comparePossiblyOverridingDescriptors(project, it, descriptor) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt index 6371f9ae533..892eed26ee8 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionSorting.kt @@ -143,11 +143,10 @@ private class DeclarationRemotenessWeigher(private val file: JetFile) : LookupEl return Weight.thisFile } - val qualifiedName = o.qualifiedName() + val fqName = o.importableFqName // Invalid name can be met for companion object descriptor: Test.MyTest.A..testOther - if (qualifiedName != null && isValidJavaFqName(qualifiedName)) { - val importPath = ImportPath(qualifiedName) - val fqName = importPath.fqnPart() + if (fqName != null) { + val importPath = ImportPath(fqName, false) return when { JavaToKotlinClassMap.INSTANCE.mapPlatformClass(fqName).isNotEmpty() -> Weight.notToBeUsedInKotlin ImportInsertHelper.getInstance(file.getProject()).isImportedWithDefault(importPath, file) -> Weight.kotlinDefaultImport diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt index 82fc10112bc..0b81c5d001f 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/DeclarationLookupObjectImpl.kt @@ -18,12 +18,17 @@ package org.jetbrains.kotlin.idea.completion import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.util.Iconable +import com.intellij.psi.PsiClass import com.intellij.psi.PsiDocCommentOwner import com.intellij.psi.PsiElement +import com.intellij.psi.PsiNamedElement import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject +import org.jetbrains.kotlin.idea.imports.importableFqName +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.util.descriptorsEqualWithSubstitution import javax.swing.Icon @@ -40,6 +45,17 @@ public abstract class DeclarationLookupObjectImpl( assert(descriptor != null || psiElement != null) } + override val name: Name? + get() = descriptor?.getName() ?: (psiElement as? PsiNamedElement)?.getName()?.let { Name.identifier(it) } + + override val importableFqName: FqName? + get() { + return if (descriptor != null) + descriptor.importableFqName + else + (psiElement as? PsiClass)?.getQualifiedName()?.let { FqName(it) } + } + override fun toString() = super.toString() + " " + (descriptor ?: psiElement) override fun hashCode(): Int { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt index 2277782fa35..079030bd870 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinExcludeFromCompletionLookupActionProvider.kt @@ -35,16 +35,10 @@ public class KotlinExcludeFromCompletionLookupActionProvider : LookupActionProvi val project = lookup.getPsiFile().getProject() - lookupObject.descriptor?.importableFqName?.let { + lookupObject.importableFqName?.let { addExcludes(consumer, project, it.asString()) return } - - val psiElement = lookupObject.psiElement - if (psiElement is PsiClass) { - val qualifiedName = psiElement.getQualifiedName() ?: return - addExcludes(consumer, project, qualifiedName) - } } private fun addExcludes(consumer: Consumer, project: Project, fqName: String) { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 2a5d7d25f20..8563e7e7b0b 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -21,15 +21,18 @@ import com.intellij.codeInsight.lookup.* import com.intellij.codeInsight.lookup.impl.LookupCellRenderer import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement +import com.intellij.util.PlatformIcons import org.jetbrains.kotlin.asJava.KotlinLightClass import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.idea.JetDescriptorIconProvider import org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacade import org.jetbrains.kotlin.idea.completion.handlers.* +import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject import org.jetbrains.kotlin.types.typeUtil.TypeNullability import org.jetbrains.kotlin.types.typeUtil.nullability import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils @@ -37,6 +40,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils +import javax.swing.Icon public class LookupElementFactory( private val resolutionFacade: ResolutionFacade, @@ -137,6 +141,24 @@ public class LookupElementFactory( return element.withIconFromLookupObject() } + public fun createLookupElementForPackage(shortName: Name): LookupElement { + return LookupElementBuilder.create(PackageLookupObject(shortName), shortName.asString()) + .withInsertHandler(BaseDeclarationInsertHandler()) + .withIconFromLookupObject() + } + + private data class PackageLookupObject(override val name: Name) : DeclarationLookupObject { + override val psiElement: PsiElement? get() = null + + override val descriptor: DeclarationDescriptor? get() = null + + override val importableFqName: FqName? get() = null + + override val isDeprecated: Boolean get() = false + + override fun getIcon(flags: Int) = PlatformIcons.PACKAGE_ICON + } + private fun createLookupElement( descriptor: DeclarationDescriptor, declaration: PsiElement?, @@ -152,6 +174,10 @@ public class LookupElementFactory( return createLookupElementForJavaClass(declaration, qualifyNestedClasses, includeClassTypeArguments) } + if (descriptor is PackageViewDescriptor || descriptor is PackageFragmentDescriptor) { + return createLookupElementForPackage(descriptor.getName()) + } + // for constructor use name and icon of containing class val nameAndIconDescriptor: DeclarationDescriptor val iconDeclaration: PsiElement? diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/BaseDeclarationInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/BaseDeclarationInsertHandler.kt index 83b231a7145..c5e97cceca3 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/BaseDeclarationInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/BaseDeclarationInsertHandler.kt @@ -26,9 +26,8 @@ import org.jetbrains.kotlin.renderer.render open class BaseDeclarationInsertHandler : InsertHandler { override fun handleInsert(context: InsertionContext, item: LookupElement) { - val descriptor = (item.getObject() as? DeclarationLookupObject)?.descriptor - if (descriptor != null) { - val name = descriptor.getName() + val name = (item.getObject() as? DeclarationLookupObject)?.name + if (name != null) { val nameInCode = name.render() val document = context.getDocument() val needEscaping = nameInCode != name.asString() diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt index 654eafb4247..d775f073b8f 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/completion/DeclarationLookupObject.kt @@ -19,9 +19,13 @@ package org.jetbrains.kotlin.idea.core.completion import com.intellij.openapi.util.Iconable import com.intellij.psi.PsiElement import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name public interface DeclarationLookupObject : Iconable { public val psiElement: PsiElement? public val descriptor: DeclarationDescriptor? + public val name: Name? + public val importableFqName: FqName? public val isDeprecated: Boolean } From 16d503aed07e7bcb46fdbaf95a64b8af6f0d47b7 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Wed, 15 Jul 2015 22:06:33 +0300 Subject: [PATCH 351/450] Even faster completion of root packages --- .../jvm/repl/DelegatePackageMemberDeclarationProvider.kt | 2 +- .../org/jetbrains/kotlin/resolve/lazy/ResolveSession.java | 2 +- .../CombinedPackageMemberDeclarationProvider.kt | 2 +- .../FileBasedPackageMemberDeclarationProvider.kt | 3 ++- .../lazy/declarations/PackageMemberDeclarationProvider.kt | 3 ++- .../caches/resolve/IDELightClassGenerationSupport.java | 3 ++- .../jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt | 6 ++++-- .../kotlin/idea/stubindex/SubpackagesIndexService.kt | 7 +++---- .../resolve/StubBasedPackageMemberDeclarationProvider.kt | 4 ++-- .../kotlin/idea/completion/BasicCompletionSession.kt | 3 +-- 10 files changed, 19 insertions(+), 16 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt index 0253d888110..18eff93dde9 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/DelegatePackageMemberDeclarationProvider.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter open class DelegatePackageMemberDeclarationProvider(var delegate: PackageMemberDeclarationProvider) : PackageMemberDeclarationProvider { // Can't use Kotlin delegate feature because of inability to change delegate object in runtime (KT-5870) - override fun getAllDeclaredSubPackages() = delegate.getAllDeclaredSubPackages() + override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean) = delegate.getAllDeclaredSubPackages(nameFilter) override fun getPackageFiles() = delegate.getPackageFiles() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java index bfe286bb530..eac97c6719c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/ResolveSession.java @@ -168,7 +168,7 @@ public class ResolveSession implements KotlinCodeAnalyzer, LazyClassContext { if (packageDescriptor == null) { return Collections.emptyList(); } - return packageDescriptor.getDeclarationProvider().getAllDeclaredSubPackages(); + return packageDescriptor.getDeclarationProvider().getAllDeclaredSubPackages(nameFilter); } }; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt index 8b56cd67db2..a70311559be 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/CombinedPackageMemberDeclarationProvider.kt @@ -20,7 +20,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter public class CombinedPackageMemberDeclarationProvider(val providers: Collection) : PackageMemberDeclarationProvider { - override fun getAllDeclaredSubPackages() = providers.flatMap { it.getAllDeclaredSubPackages() } + override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean) = providers.flatMap { it.getAllDeclaredSubPackages(nameFilter) } override fun getPackageFiles() = providers.flatMap { it.getPackageFiles() } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/FileBasedPackageMemberDeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/FileBasedPackageMemberDeclarationProvider.kt index e2b899946bf..c9d9eb272f7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/FileBasedPackageMemberDeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/FileBasedPackageMemberDeclarationProvider.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.lazy.declarations import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.storage.StorageManager public class FileBasedPackageMemberDeclarationProvider internal constructor( @@ -40,7 +41,7 @@ public class FileBasedPackageMemberDeclarationProvider internal constructor( } } - override fun getAllDeclaredSubPackages(): Collection = allDeclaredSubPackages() + override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection = allDeclaredSubPackages() override fun getPackageFiles() = packageFiles diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/PackageMemberDeclarationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/PackageMemberDeclarationProvider.kt index fdd4170e82a..7f200b7b119 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/PackageMemberDeclarationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/declarations/PackageMemberDeclarationProvider.kt @@ -19,9 +19,10 @@ package org.jetbrains.kotlin.resolve.lazy.declarations import org.jetbrains.annotations.ReadOnly import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name public trait PackageMemberDeclarationProvider : DeclarationProvider { - public fun getAllDeclaredSubPackages(): Collection + public fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection public fun getPackageFiles(): Collection } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java index cb1b09ccf46..d88993b8072 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java @@ -59,6 +59,7 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer; +import org.jetbrains.kotlin.resolve.scopes.JetScope; import java.io.IOException; import java.util.*; @@ -204,7 +205,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport @NotNull @Override public Collection getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope) { - return PackageIndexUtil.getSubPackageFqNames(fqn, kotlinSourceAndClassFiles(scope, project), project); + return PackageIndexUtil.getSubPackageFqNames(fqn, kotlinSourceAndClassFiles(scope, project), project, JetScope.ALL_NAME_FILTER); } @Nullable diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt index 77c83de0381..556258abbbb 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/PackageIndexUtil.kt @@ -27,14 +27,16 @@ import org.jetbrains.kotlin.load.kotlin.PackageClassUtils import com.intellij.psi.util.CachedValuesManager import com.intellij.psi.util.CachedValueProvider.Result import com.intellij.psi.util.PsiModificationTracker +import org.jetbrains.kotlin.name.Name public object PackageIndexUtil { platformStatic public fun getSubPackageFqNames( packageFqName: FqName, scope: GlobalSearchScope, - project: Project + project: Project, + nameFilter: (Name) -> Boolean ): Collection { - return SubpackagesIndexService.getInstance(project).getSubpackages(packageFqName, scope) + return SubpackagesIndexService.getInstance(project).getSubpackages(packageFqName, scope, nameFilter) } platformStatic public fun findFilesWithExactPackage( diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt index 5da45903c66..4669e5f2b5c 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/SubpackagesIndexService.kt @@ -59,15 +59,14 @@ public class SubpackagesIndexService(private val project: Project) { } } - public fun getSubpackages(fqName: FqName, scope: GlobalSearchScope): Collection { + public fun getSubpackages(fqName: FqName, scope: GlobalSearchScope, nameFilter: (Name) -> Boolean): Collection { val possibleFilesFqNames = fqNameByPrefix[fqName] val existingSubPackagesShortNames = HashSet() val len = fqName.pathSegments().size() for (filesFqName in possibleFilesFqNames) { val candidateSubPackageShortName = filesFqName.pathSegments()[len] - if (candidateSubPackageShortName in existingSubPackagesShortNames) { - continue - } + if (candidateSubPackageShortName in existingSubPackagesShortNames || !nameFilter(candidateSubPackageShortName)) continue + val existsInThisScope = PackageIndexUtil.containsFilesWithExactPackage(filesFqName, scope, project) if (existsInThisScope) { existingSubPackagesShortNames.add(candidateSubPackageShortName) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt index 1c8af0c3552..c9372752aa6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/stubindex/resolve/StubBasedPackageMemberDeclarationProvider.kt @@ -77,8 +77,8 @@ public class StubBasedPackageMemberDeclarationProvider( return JetTopLevelPropertyFqnNameIndex.getInstance().get(childName(name), project, searchScope) } - override fun getAllDeclaredSubPackages(): Collection { - return PackageIndexUtil.getSubPackageFqNames(fqName, searchScope, project) + override fun getAllDeclaredSubPackages(nameFilter: (Name) -> Boolean): Collection { + return PackageIndexUtil.getSubPackageFqNames(fqName, searchScope, project, nameFilter) } override fun getPackageFiles(): Collection { diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 78b43a12356..52e3314746c 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -204,8 +204,7 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, // getting root packages from scope is very slow so we do this in alternative way if (isNoQualifierContext() && (completionKind.descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.PACKAGES_MASK) != 0) { //TODO: move this code somewhere else - //TODO: filter by prefix for better performance? - val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project) + val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project, prefixMatcher.asNameFilter()) .map { it.shortName() } .toMutableSet() From 4226b0b2b7043eca606a41b87ec1ff40b79123c4 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 16 Jul 2015 14:20:50 +0300 Subject: [PATCH 352/450] Better presentation for non-root packages in completion --- .../idea/completion/BasicCompletionSession.kt | 3 +-- .../idea/completion/LookupElementFactory.kt | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt index 52e3314746c..b2b77ba55a1 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicCompletionSession.kt @@ -205,14 +205,13 @@ class BasicCompletionSession(configuration: CompletionSessionConfiguration, if (isNoQualifierContext() && (completionKind.descriptorKindFilter?.kindMask ?: 0).and(DescriptorKindFilter.PACKAGES_MASK) != 0) { //TODO: move this code somewhere else val packageNames = PackageIndexUtil.getSubPackageFqNames(FqName.ROOT, originalSearchScope, project, prefixMatcher.asNameFilter()) - .map { it.shortName() } .toMutableSet() if (!ProjectStructureUtil.isJsKotlinModule(parameters.getOriginalFile() as JetFile)) { JavaPsiFacade.getInstance(project).findPackage("")?.getSubPackages(originalSearchScope)?.forEach { psiPackage -> val name = psiPackage.getName() if (Name.isValidIdentifier(name!!)) { - packageNames.add(Name.identifier(name)) + packageNames.add(FqName(name)) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 8563e7e7b0b..09f2be940a9 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -141,10 +141,17 @@ public class LookupElementFactory( return element.withIconFromLookupObject() } - public fun createLookupElementForPackage(shortName: Name): LookupElement { - return LookupElementBuilder.create(PackageLookupObject(shortName), shortName.asString()) - .withInsertHandler(BaseDeclarationInsertHandler()) - .withIconFromLookupObject() + public fun createLookupElementForPackage(name: FqName): LookupElement { + val shortName = name.shortName() + var element = LookupElementBuilder.create(PackageLookupObject(shortName), shortName.asString()) + + element = element.withInsertHandler(BaseDeclarationInsertHandler()) + + if (!name.parent().isRoot()) { + element = element.appendTailText(" (${name.asString()})", true) + } + + return element.withIconFromLookupObject() } private data class PackageLookupObject(override val name: Name) : DeclarationLookupObject { @@ -174,8 +181,11 @@ public class LookupElementFactory( return createLookupElementForJavaClass(declaration, qualifyNestedClasses, includeClassTypeArguments) } - if (descriptor is PackageViewDescriptor || descriptor is PackageFragmentDescriptor) { - return createLookupElementForPackage(descriptor.getName()) + if (descriptor is PackageViewDescriptor) { + return createLookupElementForPackage(descriptor.fqName) + } + if (descriptor is PackageFragmentDescriptor) { + return createLookupElementForPackage(descriptor.fqName) } // for constructor use name and icon of containing class From de947788462933bda1ba4ed6237474e785e0bce6 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 16 Jul 2015 14:59:05 +0300 Subject: [PATCH 353/450] Restore deprecated K*Function classes for compatibility The code compiled with old compiler will work with the new runtime, but not vice versa --- .../src/kotlin/reflect/_Deprecated.kt | 29 +++++++++++++++++++ .../reflect/jvm/internal/KFunctionImpl.kt | 9 +++--- .../jvm/internal/FunctionReference.java | 12 ++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 core/builtins/src/kotlin/reflect/_Deprecated.kt diff --git a/core/builtins/src/kotlin/reflect/_Deprecated.kt b/core/builtins/src/kotlin/reflect/_Deprecated.kt new file mode 100644 index 00000000000..04a023bbf52 --- /dev/null +++ b/core/builtins/src/kotlin/reflect/_Deprecated.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package kotlin.reflect + +@deprecated("This class will be dropped in M13 because it was a part of an overly complex API. Use KFunction instead") +public interface KTopLevelFunction : KFunction + +@deprecated("This class will be dropped in M13 because it was a part of an overly complex API. Use KFunction instead") +public interface KTopLevelExtensionFunction + +@deprecated("This class will be dropped in M13 because it was a part of an overly complex API. Use KFunction instead") +public interface KMemberFunction : KFunction + +@deprecated("This class will be dropped in M13 because it was a part of an overly complex API. Use KFunction instead") +public interface KLocalFunction : KFunction diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt index 69d3ad41ad9..875804fcd52 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.kt @@ -18,17 +18,18 @@ package kotlin.reflect.jvm.internal import org.jetbrains.kotlin.descriptors.FunctionDescriptor import kotlin.jvm.internal.FunctionImpl -import kotlin.reflect.KFunction +import kotlin.reflect.* open class KFunctionImpl protected constructor( container: KCallableContainerImpl, name: String, signature: String, descriptorInitialValue: FunctionDescriptor? -) : KFunction, FunctionImpl() { - constructor(container: KCallableContainerImpl, name: String, signature: String): this(container, name, signature, null) +) : KFunction, FunctionImpl(), + KLocalFunction, KMemberFunction, KTopLevelExtensionFunction, KTopLevelFunction { + constructor(container: KCallableContainerImpl, name: String, signature: String) : this(container, name, signature, null) - constructor(container: KCallableContainerImpl, descriptor: FunctionDescriptor): this( + constructor(container: KCallableContainerImpl, descriptor: FunctionDescriptor) : this( container, descriptor.getName().asString(), RuntimeTypeMapper.mapSignature(descriptor), descriptor ) diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java index 6aff6021d97..bdf895a0a43 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/FunctionReference.java @@ -17,10 +17,16 @@ package kotlin.jvm.internal; import kotlin.jvm.KotlinReflectionNotSupportedError; -import kotlin.reflect.KDeclarationContainer; -import kotlin.reflect.KFunction; +import kotlin.reflect.*; -public class FunctionReference extends FunctionImpl implements KFunction { +@SuppressWarnings("deprecation") +public class FunctionReference + extends FunctionImpl + implements KFunction, + KTopLevelFunction, + KMemberFunction, + KTopLevelExtensionFunction, + KLocalFunction { private final int arity; public FunctionReference(int arity) { From 3966db343072f1fd6d5d50d32aae5dff259eb6a7 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 20:32:28 +0200 Subject: [PATCH 354/450] KotlinFindUsagesHandler: rename to .kt --- .../{KotlinFindUsagesHandler.java => KotlinFindUsagesHandler.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/{KotlinFindUsagesHandler.java => KotlinFindUsagesHandler.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.java rename to idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt From 6b2ea56b76823bbbb267a49f6b9372273bb24026 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 20:35:14 +0200 Subject: [PATCH 355/450] KotlinFindUsagesHandler: J2K --- .../handlers/KotlinFindClassUsagesHandler.kt | 4 +- .../KotlinFindMemberUsagesHandler.java | 6 +- .../handlers/KotlinFindUsagesHandler.kt | 160 +++++++----------- .../KotlinTypeParameterFindUsagesHandler.kt | 2 +- 4 files changed, 68 insertions(+), 104 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt index fd838b0fad0..4a273b7cc20 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindClassUsagesHandler.kt @@ -57,7 +57,7 @@ public class KotlinFindClassUsagesHandler( ): AbstractFindUsagesDialog { return KotlinFindClassUsagesDialog(getElement(), getProject(), - getFactory().findClassOptions, + factory.findClassOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, @@ -131,6 +131,6 @@ public class KotlinFindClassUsagesHandler( } public override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { - return getFactory().findClassOptions + return factory.findClassOptions } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java index ba2e0e4f8cd..9bc78600691 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java @@ -157,7 +157,7 @@ public abstract class KotlinFindMemberUsagesHandler(processor); for (PsiReference ref : UsagesSearch.INSTANCE$.search(request)) { - processUsage(uniqueProcessor, ref); + Companion.processUsage(uniqueProcessor, ref); } PsiMethod psiMethod = @@ -168,7 +168,7 @@ public abstract class KotlinFindMemberUsagesHandler() { @Override public boolean execute(@NotNull PsiMethod method) { - return processUsage(uniqueProcessor, method.getNavigationElement()); + return Companion.processUsage(uniqueProcessor, method.getNavigationElement()); } } ) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index d1d67c216a4..ebdc63496dc 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -14,127 +14,91 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.findUsages.handlers; +package org.jetbrains.kotlin.idea.findUsages.handlers -import com.intellij.find.findUsages.FindUsagesHandler; -import com.intellij.find.findUsages.FindUsagesOptions; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.SearchScope; -import com.intellij.usageView.UsageInfo; -import com.intellij.util.Processor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory; -import org.jetbrains.kotlin.idea.findUsages.KotlinReferenceUsageInfo; +import com.intellij.find.findUsages.FindUsagesHandler +import com.intellij.find.findUsages.FindUsagesOptions +import com.intellij.openapi.util.TextRange +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiReference +import com.intellij.psi.search.GlobalSearchScope +import com.intellij.psi.search.SearchScope +import com.intellij.usageView.UsageInfo +import com.intellij.util.Processor +import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; +import java.util.ArrayList +import java.util.Collections -public abstract class KotlinFindUsagesHandler extends FindUsagesHandler { - private final KotlinFindUsagesHandlerFactory factory; - private final Collection elementsToSearch; +public abstract class KotlinFindUsagesHandler(psiElement: T, private val elementsToSearch: Collection, public val factory: KotlinFindUsagesHandlerFactory) : FindUsagesHandler(psiElement) { - public KotlinFindUsagesHandler( - @NotNull T psiElement, - @NotNull Collection elementsToSearch, - @NotNull KotlinFindUsagesHandlerFactory factory - ) { - super(psiElement); - this.factory = factory; - this.elementsToSearch = elementsToSearch; + @suppress("UNCHECKED_CAST") + public fun getElement(): T { + return getPsiElement() as T } - @SuppressWarnings("unchecked") - @NotNull - public T getElement() { - return (T)getPsiElement(); + public constructor(psiElement: T, factory: KotlinFindUsagesHandlerFactory) : this(psiElement, emptyList(), factory) { } - public KotlinFindUsagesHandler(@NotNull T psiElement, @NotNull KotlinFindUsagesHandlerFactory factory) { - this(psiElement, Collections.emptyList(), factory); + override fun getPrimaryElements(): Array { + return if (elementsToSearch.isEmpty()) + arrayOf(getPsiElement()) + else + elementsToSearch.toTypedArray() } - @NotNull - public final KotlinFindUsagesHandlerFactory getFactory() { - return factory; - } + protected fun searchTextOccurrences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { + val scope = options.searchScope - protected static boolean processUsage(@NotNull Processor processor, @NotNull PsiReference ref) { - return processor.process(new KotlinReferenceUsageInfo(ref)); - } - - protected static boolean processUsage(@NotNull Processor processor, @NotNull PsiElement element) { - return processor.process(new UsageInfo(element)); - } - - @NotNull - @Override - public PsiElement[] getPrimaryElements() { - return elementsToSearch.isEmpty() - ? new PsiElement[] {getPsiElement()} - : elementsToSearch.toArray(new PsiElement[elementsToSearch.size()]); - } - - protected boolean searchTextOccurrences( - @NotNull final PsiElement element, - @NotNull final Processor processor, - @NotNull FindUsagesOptions options - ) { - final SearchScope scope = options.searchScope; - - boolean searchText = options.isSearchForTextOccurrences && scope instanceof GlobalSearchScope; + val searchText = options.isSearchForTextOccurrences && scope is GlobalSearchScope if (searchText) { if (options.fastTrack != null) { - options.fastTrack.searchCustom(new Processor>() { - @Override - public boolean process(Processor consumer) { - return processUsagesInText(element, processor, (GlobalSearchScope)scope); + options.fastTrack.searchCustom(object : Processor> { + override fun process(consumer: Processor): Boolean { + return processUsagesInText(element, processor, scope as GlobalSearchScope) } - }); + }) } else { - return processUsagesInText(element, processor, (GlobalSearchScope)scope); + return processUsagesInText(element, processor, scope as GlobalSearchScope) } } - return true; + return true } - @Override - public boolean processElementUsages( - @NotNull PsiElement element, - @NotNull Processor processor, - @NotNull FindUsagesOptions options - ) { - return searchReferences(element, processor, options) && searchTextOccurrences(element, processor, options); + override fun processElementUsages(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { + return searchReferences(element, processor, options) && searchTextOccurrences(element, processor, options) } - protected abstract boolean searchReferences( - @NotNull PsiElement element, @NotNull Processor processor, @NotNull FindUsagesOptions options - ); + protected abstract fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean - @NotNull - @Override - public Collection findReferencesToHighlight(@NotNull PsiElement target, @NotNull SearchScope searchScope - ) { - final List results = new ArrayList(); - FindUsagesOptions options = getFindUsagesOptions(); - options.searchScope = searchScope; - searchReferences(target, - new Processor() { - @Override - public boolean process(UsageInfo info) { - PsiReference reference = info.getReference(); - if (reference != null) { - results.add(reference); - } - return true; - } - }, - options); - return results; + override fun findReferencesToHighlight(target: PsiElement, searchScope: SearchScope): Collection { + val results = ArrayList() + val options = getFindUsagesOptions() + options.searchScope = searchScope + searchReferences(target, object : Processor { + override fun process(info: UsageInfo): Boolean { + val reference = info.getReference() + if (reference != null) { + results.add(reference) + } + return true + } + }, options) + return results + } + + companion object { + + protected fun processUsage(processor: Processor, ref: PsiReference?): Boolean { + if (ref == null) return true + val rangeInElement = ref.getRangeInElement() + return processor.process(UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false)) + } + + protected fun processUsage(processor: Processor, element: PsiElement): Boolean { + return processor.process(UsageInfo(element)) + } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt index d8b9e691f58..f0bef34f4f1 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinTypeParameterFindUsagesHandler.kt @@ -51,6 +51,6 @@ public class KotlinTypeParameterFindUsagesHandler( } public override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions { - return getFactory().defaultOptions + return factory.defaultOptions } } From fbf7fa727783177a432edefed31eb73412793171 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 20:38:35 +0200 Subject: [PATCH 356/450] KotlinFindUsagesHandler: cleanup after J2K --- .../handlers/KotlinFindUsagesHandler.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index ebdc63496dc..bb499f466ff 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -30,14 +30,17 @@ import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory import java.util.ArrayList import java.util.Collections -public abstract class KotlinFindUsagesHandler(psiElement: T, private val elementsToSearch: Collection, public val factory: KotlinFindUsagesHandlerFactory) : FindUsagesHandler(psiElement) { +public abstract class KotlinFindUsagesHandler(psiElement: T, + private val elementsToSearch: Collection, + public val factory: KotlinFindUsagesHandlerFactory) + : FindUsagesHandler(psiElement) { @suppress("UNCHECKED_CAST") public fun getElement(): T { return getPsiElement() as T } - public constructor(psiElement: T, factory: KotlinFindUsagesHandlerFactory) : this(psiElement, emptyList(), factory) { + public constructor(psiElement: T, factory: KotlinFindUsagesHandlerFactory) : this(psiElement, emptyList(), factory) { } override fun getPrimaryElements(): Array { @@ -54,11 +57,9 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, pri if (searchText) { if (options.fastTrack != null) { - options.fastTrack.searchCustom(object : Processor> { - override fun process(consumer: Processor): Boolean { - return processUsagesInText(element, processor, scope as GlobalSearchScope) - } - }) + options.fastTrack.searchCustom { + processUsagesInText(element, processor, scope as GlobalSearchScope) + } } else { return processUsagesInText(element, processor, scope as GlobalSearchScope) From c91b6dfe8bb460b702dd1d862bed94b69e62e1d2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 20:39:03 +0200 Subject: [PATCH 357/450] KotlinFindMemberUsagesHandler.java : rename to .kt --- ...dMemberUsagesHandler.java => KotlinFindMemberUsagesHandler.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/{KotlinFindMemberUsagesHandler.java => KotlinFindMemberUsagesHandler.kt} (100%) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt similarity index 100% rename from idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.java rename to idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt From f0296bc1c1cb23345142151b55f37e89288ff947 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 21:03:18 +0200 Subject: [PATCH 358/450] KotlinFindMemberUsagesHandler: J2K and some cleanup --- .../handlers/KotlinFindMemberUsagesHandler.kt | 279 +++++++----------- 1 file changed, 109 insertions(+), 170 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt index 9bc78600691..b90db7e2561 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt @@ -14,204 +14,143 @@ * limitations under the License. */ -package org.jetbrains.kotlin.idea.findUsages.handlers; +package org.jetbrains.kotlin.idea.findUsages.handlers -import com.intellij.find.findUsages.AbstractFindUsagesDialog; -import com.intellij.find.findUsages.FindUsagesOptions; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.util.Computable; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiReference; -import com.intellij.psi.search.PsiElementProcessor; -import com.intellij.psi.search.PsiElementProcessorAdapter; -import com.intellij.psi.search.searches.MethodReferencesSearch; -import com.intellij.usageView.UsageInfo; -import com.intellij.util.CommonProcessors; -import com.intellij.util.Processor; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.asJava.LightClassUtil; -import org.jetbrains.kotlin.idea.findUsages.*; -import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindFunctionUsagesDialog; -import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindPropertyUsagesDialog; -import org.jetbrains.kotlin.idea.search.declarationsSearch.DeclarationsSearchPackage; -import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest; -import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearch; -import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchHelper; -import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchRequest; -import org.jetbrains.kotlin.psi.*; +import com.intellij.find.findUsages.AbstractFindUsagesDialog +import com.intellij.find.findUsages.FindUsagesOptions +import com.intellij.openapi.actionSystem.DataContext +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.util.Computable +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiMethod +import com.intellij.psi.PsiReference +import com.intellij.psi.search.PsiElementProcessor +import com.intellij.psi.search.PsiElementProcessorAdapter +import com.intellij.psi.search.searches.MethodReferencesSearch +import com.intellij.usageView.UsageInfo +import com.intellij.util.CommonProcessors +import com.intellij.util.Processor +import org.jetbrains.kotlin.asJava.LightClassUtil +import org.jetbrains.kotlin.idea.findUsages.* +import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindFunctionUsagesDialog +import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindPropertyUsagesDialog +import org.jetbrains.kotlin.idea.search.declarationsSearch.* +import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchRequest +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearch +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchHelper +import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchRequest +import org.jetbrains.kotlin.psi.* +import java.util.Collections -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; +public abstract class KotlinFindMemberUsagesHandler + protected constructor(declaration: T, elementsToSearch: Collection, factory: KotlinFindUsagesHandlerFactory) + : KotlinFindUsagesHandler(declaration, elementsToSearch, factory) { -public abstract class KotlinFindMemberUsagesHandler extends KotlinFindUsagesHandler { - private static class Function extends KotlinFindMemberUsagesHandler { - public Function( - @NotNull JetFunction declaration, - @NotNull Collection elementsToSearch, - @NotNull KotlinFindUsagesHandlerFactory factory - ) { - super(declaration, elementsToSearch, factory); + private class Function(declaration: JetFunction, + elementsToSearch: Collection, + factory: KotlinFindUsagesHandlerFactory) : KotlinFindMemberUsagesHandler(declaration, elementsToSearch, factory) { + + override fun getSearchHelper(options: KotlinCallableFindUsagesOptions): UsagesSearchHelper { + return (options as KotlinFunctionFindUsagesOptions).toHelper() } - @Override - protected UsagesSearchHelper getSearchHelper(KotlinCallableFindUsagesOptions options) { - return FindUsagesPackage.toHelper((KotlinFunctionFindUsagesOptions) options); - } + override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions = factory.findFunctionOptions - @NotNull - @Override - public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) { - return getFactory().getFindFunctionOptions(); - } - - @NotNull - @Override - public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) { - KotlinFunctionFindUsagesOptions options = getFactory().getFindFunctionOptions(); - Iterator lightMethods = getLightMethods(getElement()).iterator(); + override fun getFindUsagesDialog(isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean): AbstractFindUsagesDialog { + val options = factory.findFunctionOptions + val lightMethods = getLightMethods(getElement())!!.iterator() if (lightMethods.hasNext()) { - return new KotlinFindFunctionUsagesDialog( - lightMethods.next(), getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this - ); + return KotlinFindFunctionUsagesDialog(lightMethods.next(), getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) } - return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab); + return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) } } - private static class Property extends KotlinFindMemberUsagesHandler { - public Property( - @NotNull JetNamedDeclaration declaration, - @NotNull Collection elementsToSearch, - @NotNull KotlinFindUsagesHandlerFactory factory - ) { - super(declaration, elementsToSearch, factory); + private class Property(declaration: JetNamedDeclaration, elementsToSearch: Collection, factory: KotlinFindUsagesHandlerFactory) : KotlinFindMemberUsagesHandler(declaration, elementsToSearch, factory) { + + override fun getSearchHelper(options: KotlinCallableFindUsagesOptions): UsagesSearchHelper { + return (options as KotlinPropertyFindUsagesOptions).toHelper() } - @Override - protected UsagesSearchHelper getSearchHelper(KotlinCallableFindUsagesOptions options) { - return FindUsagesPackage.toHelper((KotlinPropertyFindUsagesOptions) options); - } + override fun getFindUsagesOptions(dataContext: DataContext?): FindUsagesOptions = factory.findPropertyOptions - @NotNull - @Override - public FindUsagesOptions getFindUsagesOptions(@Nullable DataContext dataContext) { - return getFactory().getFindPropertyOptions(); - } - - @NotNull - @Override - public AbstractFindUsagesDialog getFindUsagesDialog(boolean isSingleFile, boolean toShowInNewTab, boolean mustOpenInNewTab) { - return new KotlinFindPropertyUsagesDialog( - getElement(), getProject(), getFactory().getFindPropertyOptions(), toShowInNewTab, mustOpenInNewTab, isSingleFile, this - ); + override fun getFindUsagesDialog(isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean): AbstractFindUsagesDialog { + return KotlinFindPropertyUsagesDialog(getElement(), getProject(), factory.findPropertyOptions, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) } } - protected KotlinFindMemberUsagesHandler( - @NotNull T declaration, - @NotNull Collection elementsToSearch, - @NotNull KotlinFindUsagesHandlerFactory factory - ) { - super(declaration, elementsToSearch, factory); - } + protected abstract fun getSearchHelper(options: KotlinCallableFindUsagesOptions): UsagesSearchHelper - protected abstract UsagesSearchHelper getSearchHelper(KotlinCallableFindUsagesOptions options); + override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { + return ApplicationManager.getApplication().runReadAction(object : Computable { + override fun compute(): Boolean? { + val kotlinOptions = options as KotlinCallableFindUsagesOptions - private static Iterable getLightMethods(JetNamedDeclaration element) { - if (element instanceof JetFunction) { - PsiMethod method = LightClassUtil.getLightClassMethod((JetFunction) element); - return method != null ? Collections.singletonList(method) : Collections.emptyList(); - } + @SuppressWarnings("unchecked") + val request = getSearchHelper(kotlinOptions).newRequest(options.toSearchTarget(element as T, true)) - if (element instanceof JetProperty) { - return LightClassUtil.getLightClassPropertyMethods((JetProperty) element); - } + val uniqueProcessor = CommonProcessors.UniqueProcessor(processor) - if (element instanceof JetParameter) { - return LightClassUtil.getLightClassPropertyMethods((JetParameter) element); - } + for (ref in UsagesSearch.search(request)) { + KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, ref) + } - return null; - } - - @Override - protected boolean searchReferences( - @NotNull final PsiElement element, @NotNull final Processor processor, @NotNull final FindUsagesOptions options - ) { - return ApplicationManager.getApplication().runReadAction( - new Computable() { - @Override - public Boolean compute() { - KotlinCallableFindUsagesOptions kotlinOptions = (KotlinCallableFindUsagesOptions) options; - - @SuppressWarnings("unchecked") - UsagesSearchRequest request = - getSearchHelper(kotlinOptions).newRequest(FindUsagesPackage.toSearchTarget(options, (T) element, true)); - - final CommonProcessors.UniqueProcessor uniqueProcessor = - new CommonProcessors.UniqueProcessor(processor); - - for (PsiReference ref : UsagesSearch.INSTANCE$.search(request)) { - Companion.processUsage(uniqueProcessor, ref); - } - - PsiMethod psiMethod = - element instanceof PsiMethod - ? (PsiMethod) element - : element instanceof JetConstructor - ? LightClassUtil.getLightClassMethod((JetFunction) element) - : null; - if (psiMethod != null) { - for (PsiReference ref : MethodReferencesSearch.search(psiMethod, options.searchScope, true)) { - Companion.processUsage(uniqueProcessor, ref); - } - } - - if (kotlinOptions.getSearchOverrides()) { - DeclarationsSearchPackage.searchOverriders( - new HierarchySearchRequest(element, options.searchScope, true) - ).forEach( - new PsiElementProcessorAdapter( - new PsiElementProcessor() { - @Override - public boolean execute(@NotNull PsiMethod method) { - return Companion.processUsage(uniqueProcessor, method.getNavigationElement()); - } - } - ) - ); - } - - return true; + val psiMethod = if (element is PsiMethod) + element + else if (element is JetConstructor<*>) + LightClassUtil.getLightClassMethod(element as JetFunction) + else + null + if (psiMethod != null) { + for (ref in MethodReferencesSearch.search(psiMethod, options.searchScope, true)) { + KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, ref.getElement()) } } - ); + + if (kotlinOptions.searchOverrides) { + HierarchySearchRequest(element, options.searchScope, true).searchOverriders().forEach(PsiElementProcessorAdapter(object : PsiElementProcessor { + override fun execute(method: PsiMethod): Boolean { + return KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, method.getNavigationElement()) + } + })) + } + + return true + } + }) } - @Override - protected boolean isSearchForTextOccurencesAvailable(@NotNull PsiElement psiElement, boolean isSingleFile) { - return !isSingleFile; - } + override fun isSearchForTextOccurencesAvailable(psiElement: PsiElement, isSingleFile: Boolean): Boolean = !isSingleFile - @NotNull - public static KotlinFindMemberUsagesHandler getInstance( - @NotNull JetNamedDeclaration declaration, - @NotNull Collection elementsToSearch, - @NotNull KotlinFindUsagesHandlerFactory factory) { - return declaration instanceof JetFunction - ? new Function((JetFunction) declaration, elementsToSearch, factory) - : new Property(declaration, elementsToSearch, factory); - } + companion object { - @NotNull - public static KotlinFindMemberUsagesHandler getInstance( - @NotNull JetNamedDeclaration declaration, - @NotNull KotlinFindUsagesHandlerFactory factory) { - return getInstance(declaration, Collections.emptyList(), factory); + internal fun getLightMethods(element: JetNamedDeclaration): Iterable? = when(element) { + is JetFunction -> { + val method = LightClassUtil.getLightClassMethod(element) + if (method != null) listOf(method) else emptyList() + } + + is JetProperty -> + LightClassUtil.getLightClassPropertyMethods(element) + + is JetParameter -> + LightClassUtil.getLightClassPropertyMethods(element) + + else -> null + } + + public fun getInstance(declaration: JetNamedDeclaration, + elementsToSearch: Collection, + factory: KotlinFindUsagesHandlerFactory): KotlinFindMemberUsagesHandler { + return if (declaration is JetFunction) + Function(declaration, elementsToSearch, factory) + else + Property(declaration, elementsToSearch, factory) + } + + public fun getInstance(declaration: JetNamedDeclaration, factory: KotlinFindUsagesHandlerFactory): KotlinFindMemberUsagesHandler { + return getInstance(declaration, emptyList(), factory) + } } } From 811f75f0627be289e004c7bddc60d215c6493d47 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 13 Jul 2015 21:16:00 +0200 Subject: [PATCH 359/450] remove enclosing read action around the entire method references search, use more fine-grained read actions (KT-7917); more cleanup --- .../idea/search/usagesSearch/usagesSearch.kt | 3 +- .../KotlinFindUsagesHandlerFactory.kt | 4 +- .../handlers/KotlinFindMemberUsagesHandler.kt | 86 +++++++------------ .../handlers/KotlinFindUsagesHandler.kt | 26 +++--- 4 files changed, 48 insertions(+), 71 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/usagesSearch.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/usagesSearch.kt index 292919bf1ad..e7431fc9b94 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/usagesSearch.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/search/usagesSearch/usagesSearch.kt @@ -153,9 +153,10 @@ public class KotlinPsiSearchHelper(private val project: Project): PsiSearchHelpe } public fun processFilesWithText(item: UsagesSearchRequestItem, consumer: Processor): Boolean { + val scope = runReadAction { item.target.effectiveScope } return item.words.all { word -> val textProcessor = ResultTextProcessorImpl(item, consumer) - processElementsWithWord(textProcessor, item.target.effectiveScope, word, item.target.location.searchContext, true) + processElementsWithWord(textProcessor, scope, word, item.target.location.searchContext, true) } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt index 85110ddf11b..227be3946fa 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/KotlinFindUsagesHandlerFactory.kt @@ -56,14 +56,14 @@ public class KotlinFindUsagesHandlerFactory(project: Project) : FindUsagesHandle is JetNamedFunction, is JetProperty, is JetParameter, is JetConstructor<*> -> { val declaration = element as JetNamedDeclaration - if (forHighlightUsages) return KotlinFindMemberUsagesHandler.getInstance(declaration, this) + if (forHighlightUsages) return KotlinFindMemberUsagesHandler.getInstance(declaration, factory = this) JetRefactoringUtil.checkSuperMethods(declaration, null, "super.methods.action.key.find.usages")?.let { callables -> when (callables.size()) { 0 -> FindUsagesHandler.NULL_HANDLER 1 -> { val target = callables.first().unwrapped ?: return FindUsagesHandler.NULL_HANDLER if (target is JetNamedDeclaration) { - KotlinFindMemberUsagesHandler.getInstance(target, this) + KotlinFindMemberUsagesHandler.getInstance(target, factory = this) } else { javaHandlerFactory.createFindUsagesHandler(target, false) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt index b90db7e2561..f3f8b207d11 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindMemberUsagesHandler.kt @@ -31,6 +31,7 @@ import com.intellij.usageView.UsageInfo import com.intellij.util.CommonProcessors import com.intellij.util.Processor import org.jetbrains.kotlin.asJava.LightClassUtil +import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.idea.findUsages.* import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindFunctionUsagesDialog import org.jetbrains.kotlin.idea.findUsages.dialogs.KotlinFindPropertyUsagesDialog @@ -39,6 +40,7 @@ import org.jetbrains.kotlin.idea.search.declarationsSearch.HierarchySearchReques import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearch import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchHelper import org.jetbrains.kotlin.idea.search.usagesSearch.UsagesSearchRequest +import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.psi.* import java.util.Collections @@ -58,9 +60,9 @@ public abstract class KotlinFindMemberUsagesHandler override fun getFindUsagesDialog(isSingleFile: Boolean, toShowInNewTab: Boolean, mustOpenInNewTab: Boolean): AbstractFindUsagesDialog { val options = factory.findFunctionOptions - val lightMethods = getLightMethods(getElement())!!.iterator() - if (lightMethods.hasNext()) { - return KotlinFindFunctionUsagesDialog(lightMethods.next(), getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) + val lightMethod = getElement().toLightMethods().firstOrNull() + if (lightMethod != null) { + return KotlinFindFunctionUsagesDialog(lightMethod, getProject(), options, toShowInNewTab, mustOpenInNewTab, isSingleFile, this) } return super.getFindUsagesDialog(isSingleFile, toShowInNewTab, mustOpenInNewTab) @@ -83,74 +85,50 @@ public abstract class KotlinFindMemberUsagesHandler protected abstract fun getSearchHelper(options: KotlinCallableFindUsagesOptions): UsagesSearchHelper override fun searchReferences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { - return ApplicationManager.getApplication().runReadAction(object : Computable { - override fun compute(): Boolean? { - val kotlinOptions = options as KotlinCallableFindUsagesOptions + val kotlinOptions = options as KotlinCallableFindUsagesOptions - @SuppressWarnings("unchecked") - val request = getSearchHelper(kotlinOptions).newRequest(options.toSearchTarget(element as T, true)) + val request = runReadAction { + @suppress("UNCHECKED_CAST") + getSearchHelper(kotlinOptions).newRequest(options.toSearchTarget(element as T, true)) + } - val uniqueProcessor = CommonProcessors.UniqueProcessor(processor) + val uniqueProcessor = CommonProcessors.UniqueProcessor(processor) - for (ref in UsagesSearch.search(request)) { - KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, ref) - } + for (ref in UsagesSearch.search(request)) { + KotlinFindUsagesHandler.processUsage(uniqueProcessor, ref) + } - val psiMethod = if (element is PsiMethod) - element - else if (element is JetConstructor<*>) - LightClassUtil.getLightClassMethod(element as JetFunction) - else - null - if (psiMethod != null) { - for (ref in MethodReferencesSearch.search(psiMethod, options.searchScope, true)) { - KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, ref.getElement()) - } - } - - if (kotlinOptions.searchOverrides) { - HierarchySearchRequest(element, options.searchScope, true).searchOverriders().forEach(PsiElementProcessorAdapter(object : PsiElementProcessor { - override fun execute(method: PsiMethod): Boolean { - return KotlinFindUsagesHandler.Companion.processUsage(uniqueProcessor, method.getNavigationElement()) - } - })) - } - - return true + val psiMethod: PsiMethod? = when (element) { + is PsiMethod -> element + is JetConstructor<*> -> LightClassUtil.getLightClassMethod(element as JetFunction) + else -> null + } + if (psiMethod != null) { + for (ref in MethodReferencesSearch.search(psiMethod, options.searchScope, true)) { + KotlinFindUsagesHandler.processUsage(uniqueProcessor, ref) } - }) + } + + if (kotlinOptions.searchOverrides) { + for (method in HierarchySearchRequest(element, options.searchScope, true).searchOverriders()) { + if (!KotlinFindUsagesHandler.processUsage(uniqueProcessor, method.getNavigationElement())) break + } + } + + return true } override fun isSearchForTextOccurencesAvailable(psiElement: PsiElement, isSingleFile: Boolean): Boolean = !isSingleFile companion object { - internal fun getLightMethods(element: JetNamedDeclaration): Iterable? = when(element) { - is JetFunction -> { - val method = LightClassUtil.getLightClassMethod(element) - if (method != null) listOf(method) else emptyList() - } - - is JetProperty -> - LightClassUtil.getLightClassPropertyMethods(element) - - is JetParameter -> - LightClassUtil.getLightClassPropertyMethods(element) - - else -> null - } - public fun getInstance(declaration: JetNamedDeclaration, - elementsToSearch: Collection, + elementsToSearch: Collection = emptyList(), factory: KotlinFindUsagesHandlerFactory): KotlinFindMemberUsagesHandler { return if (declaration is JetFunction) Function(declaration, elementsToSearch, factory) else Property(declaration, elementsToSearch, factory) } - - public fun getInstance(declaration: JetNamedDeclaration, factory: KotlinFindUsagesHandlerFactory): KotlinFindMemberUsagesHandler { - return getInstance(declaration, emptyList(), factory) - } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index bb499f466ff..61cc0402e5b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -26,6 +26,7 @@ import com.intellij.psi.search.SearchScope import com.intellij.usageView.UsageInfo import com.intellij.util.Processor import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory +import org.jetbrains.kotlin.idea.util.application.runReadAction import java.util.ArrayList import java.util.Collections @@ -53,16 +54,12 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, protected fun searchTextOccurrences(element: PsiElement, processor: Processor, options: FindUsagesOptions): Boolean { val scope = options.searchScope - val searchText = options.isSearchForTextOccurrences && scope is GlobalSearchScope - - if (searchText) { - if (options.fastTrack != null) { - options.fastTrack.searchCustom { - processUsagesInText(element, processor, scope as GlobalSearchScope) - } + if (options.isSearchForTextOccurrences && scope is GlobalSearchScope) { + if (options.fastTrack == null) { + return processUsagesInText(element, processor, scope) } - else { - return processUsagesInText(element, processor, scope as GlobalSearchScope) + options.fastTrack.searchCustom { + processUsagesInText(element, processor, scope) } } return true @@ -94,12 +91,13 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, protected fun processUsage(processor: Processor, ref: PsiReference?): Boolean { if (ref == null) return true - val rangeInElement = ref.getRangeInElement() - return processor.process(UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false)) + val usageInfo = runReadAction { + val rangeInElement = ref.getRangeInElement() + UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false) + } + return processor.process(usageInfo) } - protected fun processUsage(processor: Processor, element: PsiElement): Boolean { - return processor.process(UsageInfo(element)) - } + protected fun processUsage(processor: Processor, element: PsiElement): Boolean = processor.process(UsageInfo(element)) } } From 649287b689f52a117cc7bdf7725817d4575e441f Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 20 Mar 2015 16:07:21 +0100 Subject: [PATCH 360/450] remove KDoc support in Kotlin Gradle plugin --- .../tools/kotlin-gradle-plugin-core/pom.xml | 5 -- .../jetbrains/kotlin/gradle/tasks/Tasks.kt | 63 ------------------- libraries/tools/kotlin-gradle-plugin/pom.xml | 6 -- .../kotlin/gradle/plugin/KotlinPlugin.kt | 18 ------ .../kotlin/gradle/tasks/TasksProvider.kt | 7 --- .../gradle/BasicKotlinGradlePluginIT.kt | 8 --- .../testProject/kdocProject/build.gradle | 40 ------------ .../com/google/common/base/annotations.xml | 11 ---- .../kdocProject/src/main/kotlin/helloWorld.kt | 15 ----- 9 files changed, 173 deletions(-) delete mode 100644 libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/externalAnnotations/com/google/common/base/annotations.xml delete mode 100644 libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/src/main/kotlin/helloWorld.kt diff --git a/libraries/tools/kotlin-gradle-plugin-core/pom.xml b/libraries/tools/kotlin-gradle-plugin-core/pom.xml index feab21cc14c..8636d5d7c2a 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/pom.xml +++ b/libraries/tools/kotlin-gradle-plugin-core/pom.xml @@ -52,11 +52,6 @@ kotlin-jdk-annotations ${project.version} - - org.jetbrains.kotlin - kdoc - ${project.version} - org.jetbrains.kotlin kotlin-stdlib diff --git a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt index 7808697de49..f4216a08c85 100644 --- a/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt +++ b/libraries/tools/kotlin-gradle-plugin-core/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/Tasks.kt @@ -284,69 +284,6 @@ public open class Kotlin2JsCompile() : AbstractKotlinCompile throw GradleException("Failed to generate kdoc. See log for more details") - ExitCode.INTERNAL_ERROR -> throw GradleException("Internal generation error. See log for more details") - } - - } -} - private fun ExtraPropertiesExtension.getOrNull(id: String): T? { try { @suppress("UNCHECKED_CAST") diff --git a/libraries/tools/kotlin-gradle-plugin/pom.xml b/libraries/tools/kotlin-gradle-plugin/pom.xml index 35b74e84c00..9252c989dd8 100644 --- a/libraries/tools/kotlin-gradle-plugin/pom.xml +++ b/libraries/tools/kotlin-gradle-plugin/pom.xml @@ -37,12 +37,6 @@ 2.2 provided - - org.jetbrains.kotlin - kdoc - ${project.version} - test - org.jetbrains.kotlin kotlin-gradle-plugin-core diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index bc462afbd93..5d3f5da4ba1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -247,7 +247,6 @@ abstract class AbstractKotlinPlugin @Inject constructor(val scriptHandler: Scrip project.getPlugins().apply(javaClass()) configureSourceSetDefaults(project as ProjectInternal, javaBasePlugin, javaPluginConvention) - configureKDoc(project, javaPluginConvention) val gradleUtils = GradleUtils(scriptHandler, project) project.getExtensions().add(DEFAULT_ANNOTATIONS, gradleUtils.resolveKotlinPluginDependency("kotlin-jdk-annotations")) @@ -262,23 +261,6 @@ abstract class AbstractKotlinPlugin @Inject constructor(val scriptHandler: Scrip } }) } - - open protected fun configureKDoc(project: Project, javaPluginConvention: JavaPluginConvention) { - val mainSourceSet = javaPluginConvention.getSourceSets()?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) as HasConvention? - - if (mainSourceSet != null) { - - val kdoc = tasksProvider.createKDocTask(project, KDOC_TASK_NAME) - - kdoc.setDescription("Generates KDoc API documentation for the main source code.") - kdoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP) - kdoc.setSource(mainSourceSet.getConvention().getExtensionsAsDynamicObject().getProperty("kotlin")) - } - - project.getTasks().withType(tasksProvider.kDocTaskClass) { it!!.setProperty("destinationDir", File(javaPluginConvention.getDocsDir(), "kdoc")) } - } - - public val KDOC_TASK_NAME: String = "kdoc" } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/TasksProvider.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/TasksProvider.kt index 26aeff3dbc1..a739f60ec0c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/TasksProvider.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/tasks/TasksProvider.kt @@ -19,9 +19,6 @@ public open class KotlinTasksProvider(val tasksLoader: ClassLoader) { val kotlinJSCompileTaskClass: Class = tasksLoader.loadClass("org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile") as Class - val kDocTaskClass: Class = - tasksLoader.loadClass("org.jetbrains.kotlin.gradle.tasks.KDoc") as Class - val kotlinJVMOptionsClass: Class = tasksLoader.loadClass("org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments") as Class @@ -33,8 +30,4 @@ public open class KotlinTasksProvider(val tasksLoader: ClassLoader) { public fun createKotlinJSTask(project: Project, name: String): AbstractCompile { return project.getTasks().create(name, kotlinJSCompileTaskClass) } - - public fun createKDocTask(project: Project, name: String): SourceTask { - return project.getTasks().create(name, kDocTaskClass) - } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt index 02855e22d77..f4eba9f4a71 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/BasicKotlinGradlePluginIT.kt @@ -66,14 +66,6 @@ class SimpleKotlinGradleIT : BaseGradleIT() { } } - Test fun testSimpleKDoc() { - Project("kdocProject", "1.6").build("kdoc") { - assertSuccessful() - assertReportExists("build/docs/kdoc/demo/MyClass.html") - assertContains(":kdoc", "Generating kdoc to") - } - } - Test fun testKotlinExtraJavaSrc() { Project("additionalJavaSrc", "1.6").build("build") { assertSuccessful() diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/build.gradle b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/build.gradle deleted file mode 100644 index a5193474c83..00000000000 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/build.gradle +++ /dev/null @@ -1,40 +0,0 @@ -buildscript { - repositories { - mavenCentral() - maven { - url 'file://' + pathToKotlinPlugin - } - } - dependencies { - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT' - } -} - - - -apply plugin: "kotlin" - -repositories { - maven { - url 'file://' + pathToKotlinPlugin - } - mavenCentral() -} - -dependencies { - testCompile 'org.testng:testng:6.8' - compile 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT' -} - -test { - useTestNG() -} - -compileKotlin { - kotlinOptions.annotations = "externalAnnotations" -} - - -task wrapper(type: Wrapper) { - gradleVersion="1.4" -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/externalAnnotations/com/google/common/base/annotations.xml b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/externalAnnotations/com/google/common/base/annotations.xml deleted file mode 100644 index fd541a7e6e5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/externalAnnotations/com/google/common/base/annotations.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/src/main/kotlin/helloWorld.kt b/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/src/main/kotlin/helloWorld.kt deleted file mode 100644 index a844b9fe15d..00000000000 --- a/libraries/tools/kotlin-gradle-plugin/src/test/resources/testProject/kdocProject/src/main/kotlin/helloWorld.kt +++ /dev/null @@ -1,15 +0,0 @@ -package demo - -/** - * This is **bold** - * - * New paragraph using newlines. - * - * We can also support wiki links notation - * for example [[List]] and [[Collection]] and [[java.util.Collection.size()]] will - * generate hypertext links to classes - */ -public class MyClass() { - val i: Int = 0 -} - From fdbd5efd1cbd6f62d005075e1bcef32934c56fe7 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Mon, 13 Jul 2015 15:55:05 +0300 Subject: [PATCH 361/450] Minor. remove static keywords --- .../resolve/calls/CandidateResolver.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java index 15ea32feb42..6705fe650c0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java @@ -177,7 +177,7 @@ public class CandidateResolver { checkNonExtensionCalledWithReceiver(context); } - private static void checkExtensionReceiver(@NotNull CallCandidateResolutionContext context) { + private void checkExtensionReceiver(@NotNull CallCandidateResolutionContext context) { MutableResolvedCall candidateCall = context.candidateCall; ReceiverParameterDescriptor receiverParameter = candidateCall.getCandidateDescriptor().getExtensionReceiverParameter(); ReceiverValue receiverArgument = candidateCall.getExtensionReceiver(); @@ -196,7 +196,7 @@ public class CandidateResolver { } } - private static boolean checkDispatchReceiver(@NotNull CallCandidateResolutionContext context) { + private boolean checkDispatchReceiver(@NotNull CallCandidateResolutionContext context) { MutableResolvedCall candidateCall = context.candidateCall; CallableDescriptor candidateDescriptor = candidateCall.getCandidateDescriptor(); ReceiverValue dispatchReceiver = candidateCall.getDispatchReceiver(); @@ -221,7 +221,7 @@ public class CandidateResolver { return true; } - private static boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext context) { + private boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext context) { // In "this@Outer.foo()" the error will be reported on "this@Outer" instead if (context.call.getExplicitReceiver().exists() || context.call.getDispatchReceiver().exists()) return true; @@ -231,7 +231,7 @@ public class CandidateResolver { return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis); } - private static void checkAbstractAndSuper(@NotNull CallCandidateResolutionContext context) { + private void checkAbstractAndSuper(@NotNull CallCandidateResolutionContext context) { MutableResolvedCall candidateCall = context.candidateCall; CallableDescriptor descriptor = candidateCall.getCandidateDescriptor(); JetExpression expression = context.candidateCall.getCall().getCalleeExpression(); @@ -263,7 +263,7 @@ public class CandidateResolver { } } - private static void checkNonExtensionCalledWithReceiver(@NotNull CallCandidateResolutionContext context) { + private void checkNonExtensionCalledWithReceiver(@NotNull CallCandidateResolutionContext context) { MutableResolvedCall candidateCall = context.candidateCall; if (TasksPackage.isSynthesizedInvoke(candidateCall.getCandidateDescriptor()) && @@ -274,7 +274,7 @@ public class CandidateResolver { } @Nullable - private static JetSuperExpression getReceiverSuper(@NotNull ReceiverValue receiver) { + private JetSuperExpression getReceiverSuper(@NotNull ReceiverValue receiver) { if (receiver instanceof ExpressionReceiver) { ExpressionReceiver expressionReceiver = (ExpressionReceiver) receiver; JetExpression expression = expressionReceiver.getExpression(); @@ -286,7 +286,7 @@ public class CandidateResolver { } @Nullable - private static ClassDescriptor getDeclaringClass(@NotNull CallableDescriptor candidate) { + private ClassDescriptor getDeclaringClass(@NotNull CallableDescriptor candidate) { ReceiverParameterDescriptor expectedThis = candidate.getDispatchReceiverParameter(); if (expectedThis == null) return null; DeclarationDescriptor descriptor = expectedThis.getContainingDeclaration(); @@ -314,7 +314,7 @@ public class CandidateResolver { return new ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes); } - private static ResolutionStatus checkReceivers( + private ResolutionStatus checkReceivers( @NotNull CallCandidateResolutionContext context, @NotNull BindingTrace trace ) { @@ -397,7 +397,7 @@ public class CandidateResolver { } @Nullable - private static JetType smartCastValueArgumentTypeIfPossible( + private JetType smartCastValueArgumentTypeIfPossible( @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull JetType actualType, @@ -413,7 +413,7 @@ public class CandidateResolver { return null; } - private static ResolutionStatus checkReceiverTypeError( + private ResolutionStatus checkReceiverTypeError( @NotNull CallCandidateResolutionContext context ) { MutableResolvedCall candidateCall = context.candidateCall; @@ -431,7 +431,7 @@ public class CandidateResolver { return status; } - private static ResolutionStatus checkReceiverTypeError( + private ResolutionStatus checkReceiverTypeError( @NotNull CallCandidateResolutionContext context, @Nullable ReceiverParameterDescriptor receiverParameterDescriptor, @NotNull ReceiverValue receiverArgument @@ -450,7 +450,7 @@ public class CandidateResolver { return SUCCESS; } - private static ResolutionStatus checkReceiver( + private ResolutionStatus checkReceiver( @NotNull CallCandidateResolutionContext context, @NotNull ResolvedCall candidateCall, @NotNull BindingTrace trace, @@ -493,7 +493,7 @@ public class CandidateResolver { return SUCCESS; } - public static class ValueArgumentsCheckingResult { + public class ValueArgumentsCheckingResult { @NotNull public final List argumentTypes; @NotNull @@ -505,7 +505,7 @@ public class CandidateResolver { } } - private static void checkGenericBoundsInAFunctionCall( + private void checkGenericBoundsInAFunctionCall( @NotNull List jetTypeArguments, @NotNull List typeArguments, @NotNull CallableDescriptor functionDescriptor, From ce80773419bbb0a871dcfa18769cf350b641f2d0 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 16:55:05 +0300 Subject: [PATCH 362/450] Minor. Convert CandidateResolver to kt --- .../resolve/calls/CandidateResolver.java | 585 ++++++++---------- 1 file changed, 266 insertions(+), 319 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java index 6705fe650c0..041922436d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java @@ -14,314 +14,280 @@ * limitations under the License. */ -package org.jetbrains.kotlin.resolve.calls; +package org.jetbrains.kotlin.resolve.calls -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; -import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus; -import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.*; -import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; -import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode; -import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; -import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext; -import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext; -import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode; -import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext; -import org.jetbrains.kotlin.resolve.calls.model.*; -import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus; -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue; -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory; -import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils; -import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask; -import org.jetbrains.kotlin.resolve.calls.tasks.TasksPackage; -import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject; -import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; -import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver; -import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.types.*; -import org.jetbrains.kotlin.types.checker.JetTypeChecker; -import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils; -import org.jetbrains.kotlin.types.expressions.JetTypeInfo; +import com.google.common.collect.Lists +import com.google.common.collect.Sets +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.* +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.* +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode +import org.jetbrains.kotlin.resolve.calls.callUtil.* +import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext +import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils +import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask +import org.jetbrains.kotlin.resolve.calls.tasks.* +import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject +import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil +import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils +import org.jetbrains.kotlin.types.expressions.JetTypeInfo -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import javax.inject.Inject +import java.util.ArrayList -import static org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT; -import static org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER; -import static org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke; -import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage.getEffectiveExpectedType; -import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; -import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*; -import static org.jetbrains.kotlin.types.TypeUtils.noExpectedType; +import org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT +import org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER +import org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.* +import org.jetbrains.kotlin.types.TypeUtils.noExpectedType -public class CandidateResolver { - @NotNull - private ArgumentTypeResolver argumentTypeResolver; - @NotNull - private GenericCandidateResolver genericCandidateResolver; +public class CandidateResolver( + private val argumentTypeResolver: ArgumentTypeResolver, + private val genericCandidateResolver: GenericCandidateResolver +){ - @Inject - public void setArgumentTypeResolver(@NotNull ArgumentTypeResolver argumentTypeResolver) { - this.argumentTypeResolver = argumentTypeResolver; - } + public fun performResolutionForCandidateCall( + context: CallCandidateResolutionContext, + task: ResolutionTask) { - @Inject - public void setGenericCandidateResolver(@NotNull GenericCandidateResolver genericCandidateResolver) { - this.genericCandidateResolver = genericCandidateResolver; - } + ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() - public void performResolutionForCandidateCall( - @NotNull CallCandidateResolutionContext context, - @NotNull ResolutionTask task) { + val candidateCall = context.candidateCall + val candidate = candidateCall.getCandidateDescriptor() - ProgressIndicatorAndCompilationCanceledStatus.checkCanceled(); - - MutableResolvedCall candidateCall = context.candidateCall; - D candidate = candidateCall.getCandidateDescriptor(); - - candidateCall.addStatus(checkReceiverTypeError(context)); + candidateCall.addStatus(checkReceiverTypeError(context)) if (ErrorUtils.isError(candidate)) { - candidateCall.addStatus(SUCCESS); - return; + candidateCall.addStatus(SUCCESS) + return } if (!checkOuterClassMemberIsAccessible(context)) { - candidateCall.addStatus(OTHER_ERROR); - return; + candidateCall.addStatus(OTHER_ERROR) + return } - ReceiverValue receiverValue = ExpressionTypingUtils.normalizeReceiverValueForVisibility(candidateCall.getDispatchReceiver(), context.trace.getBindingContext()); - DeclarationDescriptorWithVisibility invisibleMember = - Visibilities.findInvisibleMember(receiverValue, candidate, context.scope.getContainingDeclaration()); + val receiverValue = ExpressionTypingUtils.normalizeReceiverValueForVisibility(candidateCall.getDispatchReceiver(), context.trace.getBindingContext()) + val invisibleMember = Visibilities.findInvisibleMember(receiverValue, candidate, context.scope.getContainingDeclaration()) if (invisibleMember != null) { - candidateCall.addStatus(OTHER_ERROR); - context.tracing.invisibleMember(context.trace, invisibleMember); + candidateCall.addStatus(OTHER_ERROR) + context.tracing.invisibleMember(context.trace, invisibleMember) } if (task.checkArguments == CheckValueArgumentsMode.ENABLED) { - ValueArgumentsToParametersMapper.Status argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters( - context.call, context.tracing, candidateCall, Sets.newLinkedHashSet() - ); + val argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters( + context.call, context.tracing, candidateCall, Sets.newLinkedHashSet()) if (!argumentMappingStatus.isSuccess()) { - candidateCall.addStatus(OTHER_ERROR); + candidateCall.addStatus(OTHER_ERROR) } } - checkExtensionReceiver(context); + checkExtensionReceiver(context) if (!checkDispatchReceiver(context)) { - candidateCall.addStatus(OTHER_ERROR); + candidateCall.addStatus(OTHER_ERROR) } - List jetTypeArguments = context.call.getTypeArguments(); + val jetTypeArguments = context.call.getTypeArguments() if (!jetTypeArguments.isEmpty()) { // Explicit type arguments passed - List typeArguments = new ArrayList(); - for (JetTypeProjection projection : jetTypeArguments) { + val typeArguments = ArrayList() + for (projection in jetTypeArguments) { if (projection.getProjectionKind() != JetProjectionKind.NONE) { - context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection)); - ModifiersChecker.checkIncompatibleVarianceModifiers(projection.getModifierList(), context.trace); + context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection)) + ModifiersChecker.checkIncompatibleVarianceModifiers(projection.getModifierList(), context.trace) } - JetType type = argumentTypeResolver.resolveTypeRefWithDefault( + val type = argumentTypeResolver.resolveTypeRefWithDefault( projection.getTypeReference(), context.scope, context.trace, - ErrorUtils.createErrorType("Star projection in a call") - ); - ForceResolveUtil.forceResolveAllContents(type); - typeArguments.add(type); + ErrorUtils.createErrorType("Star projection in a call"))!! + ForceResolveUtil.forceResolveAllContents(type) + typeArguments.add(type) } - int expectedTypeArgumentCount = candidate.getTypeParameters().size(); - for (int index = jetTypeArguments.size(); index < expectedTypeArgumentCount; index++) { + val expectedTypeArgumentCount = candidate.getTypeParameters().size() + for (index in jetTypeArguments.size()..expectedTypeArgumentCount - 1) { typeArguments.add(ErrorUtils.createErrorType( - "Explicit type argument expected for " + candidate.getTypeParameters().get(index).getName())); + "Explicit type argument expected for " + candidate.getTypeParameters().get(index).getName())) } - Map substitutionContext = - FunctionDescriptorUtil.createSubstitutionContext((FunctionDescriptor) candidate, typeArguments); - TypeSubstitutor substitutor = TypeSubstitutor.create(substitutionContext); + val substitutionContext = FunctionDescriptorUtil.createSubstitutionContext(candidate as FunctionDescriptor, typeArguments) + val substitutor = TypeSubstitutor.create(substitutionContext) if (expectedTypeArgumentCount != jetTypeArguments.size()) { - candidateCall.addStatus(OTHER_ERROR); - context.tracing.wrongNumberOfTypeArguments(context.trace, expectedTypeArgumentCount); + candidateCall.addStatus(OTHER_ERROR) + context.tracing.wrongNumberOfTypeArguments(context.trace, expectedTypeArgumentCount) } else { - checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidate, substitutor, context.trace); + checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidate, substitutor, context.trace) } - candidateCall.setResultingSubstitutor(substitutor); + candidateCall.setResultingSubstitutor(substitutor) } else if (candidateCall.getKnownTypeParametersSubstitutor() != null) { - candidateCall.setResultingSubstitutor(candidateCall.getKnownTypeParametersSubstitutor()); + candidateCall.setResultingSubstitutor(candidateCall.getKnownTypeParametersSubstitutor()!!) } - if (jetTypeArguments.isEmpty() && - !candidate.getTypeParameters().isEmpty() && - candidateCall.getKnownTypeParametersSubstitutor() == null) { - candidateCall.addStatus(genericCandidateResolver.inferTypeArguments(context)); + if (jetTypeArguments.isEmpty() && !candidate.getTypeParameters().isEmpty() && candidateCall.getKnownTypeParametersSubstitutor() == null) { + candidateCall.addStatus(genericCandidateResolver.inferTypeArguments(context)) } else { - candidateCall.addStatus(checkAllValueArguments(context, SHAPE_FUNCTION_ARGUMENTS).status); + candidateCall.addStatus(checkAllValueArguments(context, SHAPE_FUNCTION_ARGUMENTS).status) } - checkAbstractAndSuper(context); + checkAbstractAndSuper(context) - checkNonExtensionCalledWithReceiver(context); + checkNonExtensionCalledWithReceiver(context) } - private void checkExtensionReceiver(@NotNull CallCandidateResolutionContext context) { - MutableResolvedCall candidateCall = context.candidateCall; - ReceiverParameterDescriptor receiverParameter = candidateCall.getCandidateDescriptor().getExtensionReceiverParameter(); - ReceiverValue receiverArgument = candidateCall.getExtensionReceiver(); - if (receiverParameter != null &&!receiverArgument.exists()) { - context.tracing.missingReceiver(candidateCall.getTrace(), receiverParameter); - candidateCall.addStatus(OTHER_ERROR); + private fun checkExtensionReceiver(context: CallCandidateResolutionContext) { + val candidateCall = context.candidateCall + val receiverParameter = candidateCall.getCandidateDescriptor().getExtensionReceiverParameter() + val receiverArgument = candidateCall.getExtensionReceiver() + if (receiverParameter != null && !receiverArgument.exists()) { + context.tracing.missingReceiver(candidateCall.getTrace(), receiverParameter) + candidateCall.addStatus(OTHER_ERROR) } if (receiverParameter == null && receiverArgument.exists()) { - context.tracing.noReceiverAllowed(candidateCall.getTrace()); - if (context.call.getCalleeExpression() instanceof JetSimpleNameExpression) { - candidateCall.addStatus(RECEIVER_PRESENCE_ERROR); + context.tracing.noReceiverAllowed(candidateCall.getTrace()) + if (context.call.getCalleeExpression() is JetSimpleNameExpression) { + candidateCall.addStatus(RECEIVER_PRESENCE_ERROR) } else { - candidateCall.addStatus(OTHER_ERROR); + candidateCall.addStatus(OTHER_ERROR) } } } - private boolean checkDispatchReceiver(@NotNull CallCandidateResolutionContext context) { - MutableResolvedCall candidateCall = context.candidateCall; - CallableDescriptor candidateDescriptor = candidateCall.getCandidateDescriptor(); - ReceiverValue dispatchReceiver = candidateCall.getDispatchReceiver(); + private fun checkDispatchReceiver(context: CallCandidateResolutionContext<*>): Boolean { + val candidateCall = context.candidateCall + val candidateDescriptor = candidateCall.getCandidateDescriptor() + val dispatchReceiver = candidateCall.getDispatchReceiver() if (dispatchReceiver.exists()) { - ClassDescriptor nestedClass = null; - if (candidateDescriptor instanceof ConstructorDescriptor - && DescriptorUtils.isStaticNestedClass(candidateDescriptor.getContainingDeclaration())) { - nestedClass = (ClassDescriptor) candidateDescriptor.getContainingDeclaration(); + var nestedClass: ClassDescriptor? = null + if (candidateDescriptor is ConstructorDescriptor && DescriptorUtils.isStaticNestedClass(candidateDescriptor.getContainingDeclaration())) { + nestedClass = candidateDescriptor.getContainingDeclaration() } - else if (candidateDescriptor instanceof FakeCallableDescriptorForObject) { - nestedClass = ((FakeCallableDescriptorForObject) candidateDescriptor).getReferencedDescriptor(); + else if (candidateDescriptor is FakeCallableDescriptorForObject) { + nestedClass = candidateDescriptor.getReferencedDescriptor() } if (nestedClass != null) { - context.tracing.nestedClassAccessViaInstanceReference(context.trace, nestedClass, candidateCall.getExplicitReceiverKind()); - return false; + context.tracing.nestedClassAccessViaInstanceReference(context.trace, nestedClass, candidateCall.getExplicitReceiverKind()) + return false } } - assert (dispatchReceiver.exists() == (candidateCall.getResultingDescriptor().getDispatchReceiverParameter() != null)) - : "Shouldn't happen because of TaskPrioritizer: " + candidateDescriptor; + assert((dispatchReceiver.exists() == (candidateCall.getResultingDescriptor().getDispatchReceiverParameter() != null))) { "Shouldn't happen because of TaskPrioritizer: $candidateDescriptor" } - return true; + return true } - private boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext context) { + private fun checkOuterClassMemberIsAccessible(context: CallCandidateResolutionContext<*>): Boolean { // In "this@Outer.foo()" the error will be reported on "this@Outer" instead - if (context.call.getExplicitReceiver().exists() || context.call.getDispatchReceiver().exists()) return true; + if (context.call.getExplicitReceiver().exists() || context.call.getDispatchReceiver().exists()) return true - ClassDescriptor candidateThis = getDeclaringClass(context.candidateCall.getCandidateDescriptor()); - if (candidateThis == null || candidateThis.getKind().isSingleton()) return true; + val candidateThis = getDeclaringClass(context.candidateCall.getCandidateDescriptor()) + if (candidateThis == null || candidateThis.getKind().isSingleton()) return true - return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis); + return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis) } - private void checkAbstractAndSuper(@NotNull CallCandidateResolutionContext context) { - MutableResolvedCall candidateCall = context.candidateCall; - CallableDescriptor descriptor = candidateCall.getCandidateDescriptor(); - JetExpression expression = context.candidateCall.getCall().getCalleeExpression(); + private fun checkAbstractAndSuper(context: CallCandidateResolutionContext) { + val candidateCall = context.candidateCall + val descriptor = candidateCall.getCandidateDescriptor() + val expression = context.candidateCall.getCall().getCalleeExpression() - if (expression instanceof JetSimpleNameExpression) { + if (expression is JetSimpleNameExpression) { // 'B' in 'class A: B()' is JetConstructorCalleeExpression - if (descriptor instanceof ConstructorDescriptor) { - Modality modality = ((ConstructorDescriptor) descriptor).getContainingDeclaration().getModality(); + if (descriptor is ConstructorDescriptor) { + val modality = descriptor.getContainingDeclaration().getModality() if (modality == Modality.ABSTRACT) { - context.tracing.instantiationOfAbstractClass(context.trace); + context.tracing.instantiationOfAbstractClass(context.trace) } } } - JetSuperExpression superDispatchReceiver = getReceiverSuper(candidateCall.getDispatchReceiver()); + val superDispatchReceiver = getReceiverSuper(candidateCall.getDispatchReceiver()) if (superDispatchReceiver != null) { - if (descriptor instanceof MemberDescriptor && ((MemberDescriptor) descriptor).getModality() == Modality.ABSTRACT) { - context.tracing.abstractSuperCall(context.trace); - candidateCall.addStatus(OTHER_ERROR); + if (descriptor is MemberDescriptor && descriptor.getModality() == Modality.ABSTRACT) { + context.tracing.abstractSuperCall(context.trace) + candidateCall.addStatus(OTHER_ERROR) } } // 'super' cannot be passed as an argument, for receiver arguments expression typer does not track this // See TaskPrioritizer for more - JetSuperExpression superExtensionReceiver = getReceiverSuper(candidateCall.getExtensionReceiver()); + val superExtensionReceiver = getReceiverSuper(candidateCall.getExtensionReceiver()) if (superExtensionReceiver != null) { - context.trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText())); - candidateCall.addStatus(OTHER_ERROR); + context.trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText())) + candidateCall.addStatus(OTHER_ERROR) } } - private void checkNonExtensionCalledWithReceiver(@NotNull CallCandidateResolutionContext context) { - MutableResolvedCall candidateCall = context.candidateCall; + private fun checkNonExtensionCalledWithReceiver(context: CallCandidateResolutionContext<*>) { + val candidateCall = context.candidateCall - if (TasksPackage.isSynthesizedInvoke(candidateCall.getCandidateDescriptor()) && - !KotlinBuiltIns.isExtensionFunctionType(candidateCall.getDispatchReceiver().getType())) { - context.tracing.freeFunctionCalledAsExtension(context.trace); - candidateCall.addStatus(OTHER_ERROR); + if (isSynthesizedInvoke(candidateCall.getCandidateDescriptor()) && !KotlinBuiltIns.isExtensionFunctionType(candidateCall.getDispatchReceiver().getType())) { + context.tracing.freeFunctionCalledAsExtension(context.trace) + candidateCall.addStatus(OTHER_ERROR) } } - @Nullable - private JetSuperExpression getReceiverSuper(@NotNull ReceiverValue receiver) { - if (receiver instanceof ExpressionReceiver) { - ExpressionReceiver expressionReceiver = (ExpressionReceiver) receiver; - JetExpression expression = expressionReceiver.getExpression(); - if (expression instanceof JetSuperExpression) { - return (JetSuperExpression) expression; + private fun getReceiverSuper(receiver: ReceiverValue): JetSuperExpression? { + if (receiver is ExpressionReceiver) { + val expression = receiver.getExpression() + if (expression is JetSuperExpression) { + return expression } } - return null; + return null } - @Nullable - private ClassDescriptor getDeclaringClass(@NotNull CallableDescriptor candidate) { - ReceiverParameterDescriptor expectedThis = candidate.getDispatchReceiverParameter(); - if (expectedThis == null) return null; - DeclarationDescriptor descriptor = expectedThis.getContainingDeclaration(); - return descriptor instanceof ClassDescriptor ? (ClassDescriptor) descriptor : null; + private fun getDeclaringClass(candidate: CallableDescriptor): ClassDescriptor? { + val expectedThis = candidate.getDispatchReceiverParameter() ?: return null + val descriptor = expectedThis.getContainingDeclaration() + return if (descriptor is ClassDescriptor) descriptor else null } - @NotNull - private ValueArgumentsCheckingResult checkAllValueArguments( - @NotNull CallCandidateResolutionContext context, - @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies) { - return checkAllValueArguments(context, context.candidateCall.getTrace(), resolveFunctionArgumentBodies); + private fun checkAllValueArguments( + context: CallCandidateResolutionContext, + resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { + return checkAllValueArguments(context, context.candidateCall.getTrace(), resolveFunctionArgumentBodies) } - @NotNull - public ValueArgumentsCheckingResult checkAllValueArguments( - @NotNull CallCandidateResolutionContext context, - @NotNull BindingTrace trace, - @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies - ) { - ValueArgumentsCheckingResult checkingResult = checkValueArgumentTypes( - context, context.candidateCall, trace, resolveFunctionArgumentBodies); - ResolutionStatus resultStatus = checkingResult.status; - resultStatus = resultStatus.combine(checkReceivers(context, trace)); + public fun checkAllValueArguments( + context: CallCandidateResolutionContext, + trace: BindingTrace, + resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { + val checkingResult = checkValueArgumentTypes( + context, context.candidateCall, trace, resolveFunctionArgumentBodies) + var resultStatus = checkingResult.status + resultStatus = resultStatus.combine(checkReceivers(context, trace)) - return new ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes); + return ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes) } - private ResolutionStatus checkReceivers( - @NotNull CallCandidateResolutionContext context, - @NotNull BindingTrace trace - ) { - ResolutionStatus resultStatus = SUCCESS; - ResolvedCall candidateCall = context.candidateCall; + private fun checkReceivers( + context: CallCandidateResolutionContext, + trace: BindingTrace): ResolutionStatus { + var resultStatus = SUCCESS + val candidateCall = context.candidateCall - resultStatus = resultStatus.combine(checkReceiverTypeError(context)); + resultStatus = resultStatus.combine(checkReceiverTypeError(context)) // Comment about a very special case. // Call 'b.foo(1)' where class 'Foo' has an extension member 'fun B.invoke(Int)' should be checked two times for safe call (in 'checkReceiver'), because @@ -331,194 +297,175 @@ public class CandidateResolver { resultStatus = resultStatus.combine(checkReceiver( context, candidateCall, trace, candidateCall.getResultingDescriptor().getExtensionReceiverParameter(), - candidateCall.getExtensionReceiver(), candidateCall.getExplicitReceiverKind().isExtensionReceiver(), false)); + candidateCall.getExtensionReceiver(), candidateCall.getExplicitReceiverKind().isExtensionReceiver(), false)) resultStatus = resultStatus.combine(checkReceiver( context, candidateCall, trace, candidateCall.getResultingDescriptor().getDispatchReceiverParameter(), candidateCall.getDispatchReceiver(), candidateCall.getExplicitReceiverKind().isDispatchReceiver(), // for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error - context.call instanceof CallForImplicitInvoke)); - return resultStatus; + context.call is CallForImplicitInvoke)) + return resultStatus } - @NotNull - private > ValueArgumentsCheckingResult checkValueArgumentTypes( - @NotNull CallResolutionContext context, - @NotNull MutableResolvedCall candidateCall, - @NotNull BindingTrace trace, - @NotNull ResolveArgumentsMode resolveFunctionArgumentBodies) { - ResolutionStatus resultStatus = SUCCESS; - List argumentTypes = Lists.newArrayList(); - MutableDataFlowInfoForArguments infoForArguments = candidateCall.getDataFlowInfoForArguments(); - for (Map.Entry entry : candidateCall.getValueArguments().entrySet()) { - ValueParameterDescriptor parameterDescriptor = entry.getKey(); - ResolvedValueArgument resolvedArgument = entry.getValue(); + private fun > checkValueArgumentTypes( + context: CallResolutionContext, + candidateCall: MutableResolvedCall, + trace: BindingTrace, + resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { + var resultStatus = SUCCESS + val argumentTypes = Lists.newArrayList() + val infoForArguments = candidateCall.getDataFlowInfoForArguments() + for (entry in candidateCall.getValueArguments().entrySet()) { + val parameterDescriptor = entry.getKey() + val resolvedArgument = entry.getValue() - for (ValueArgument argument : resolvedArgument.getArguments()) { - JetExpression expression = argument.getArgumentExpression(); - if (expression == null) continue; + for (argument in resolvedArgument.getArguments()) { + val expression = argument.getArgumentExpression() ?: continue - JetType expectedType = getEffectiveExpectedType(parameterDescriptor, argument); + val expectedType = getEffectiveExpectedType(parameterDescriptor, argument) - CallResolutionContext newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)) - .replaceBindingTrace(trace).replaceExpectedType(expectedType); - JetTypeInfo typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo( - expression, newContext, resolveFunctionArgumentBodies); - JetType type = typeInfoForCall.getType(); - infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo()); + val newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)).replaceBindingTrace(trace).replaceExpectedType(expectedType) + val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo( + expression, newContext, resolveFunctionArgumentBodies) + val type = typeInfoForCall.type + infoForArguments.updateInfo(argument, typeInfoForCall.dataFlowInfo) - ArgumentMatchStatus matchStatus = ArgumentMatchStatus.SUCCESS; - JetType resultingType = type; + var matchStatus = ArgumentMatchStatus.SUCCESS + var resultingType: JetType? = type if (type == null || (type.isError() && !ErrorUtils.isFunctionPlaceholder(type))) { - matchStatus = ArgumentMatchStatus.ARGUMENT_HAS_NO_TYPE; + matchStatus = ArgumentMatchStatus.ARGUMENT_HAS_NO_TYPE } else if (!noExpectedType(expectedType)) { if (!ArgumentTypeResolver.isSubtypeOfForArgumentType(type, expectedType)) { - JetType smartCast = smartCastValueArgumentTypeIfPossible(expression, newContext.expectedType, type, newContext); + val smartCast = smartCastValueArgumentTypeIfPossible(expression, newContext.expectedType, type, newContext) if (smartCast == null) { - resultStatus = OTHER_ERROR; - matchStatus = ArgumentMatchStatus.TYPE_MISMATCH; + resultStatus = OTHER_ERROR + matchStatus = ArgumentMatchStatus.TYPE_MISMATCH } else { - resultingType = smartCast; + resultingType = smartCast } } else if (ErrorUtils.containsUninferredParameter(expectedType)) { - matchStatus = ArgumentMatchStatus.MATCH_MODULO_UNINFERRED_TYPES; + matchStatus = ArgumentMatchStatus.MATCH_MODULO_UNINFERRED_TYPES } } - argumentTypes.add(resultingType); - candidateCall.recordArgumentMatchStatus(argument, matchStatus); + argumentTypes.add(resultingType) + candidateCall.recordArgumentMatchStatus(argument, matchStatus) } } - return new ValueArgumentsCheckingResult(resultStatus, argumentTypes); + return ValueArgumentsCheckingResult(resultStatus, argumentTypes) } - @Nullable - private JetType smartCastValueArgumentTypeIfPossible( - @NotNull JetExpression expression, - @NotNull JetType expectedType, - @NotNull JetType actualType, - @NotNull ResolutionContext context - ) { - ExpressionReceiver receiverToCast = new ExpressionReceiver(JetPsiUtil.safeDeparenthesize(expression, false), actualType); - Collection variants = SmartCastUtils.getSmartCastVariantsExcludingReceiver(context, receiverToCast); - for (JetType possibleType : variants) { + private fun smartCastValueArgumentTypeIfPossible( + expression: JetExpression, + expectedType: JetType, + actualType: JetType, + context: ResolutionContext<*>): JetType? { + val receiverToCast = ExpressionReceiver(JetPsiUtil.safeDeparenthesize(expression, false), actualType) + val variants = SmartCastUtils.getSmartCastVariantsExcludingReceiver(context, receiverToCast) + for (possibleType in variants) { if (JetTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) { - return possibleType; + return possibleType } } - return null; + return null } - private ResolutionStatus checkReceiverTypeError( - @NotNull CallCandidateResolutionContext context - ) { - MutableResolvedCall candidateCall = context.candidateCall; - D candidateDescriptor = candidateCall.getCandidateDescriptor(); + private fun checkReceiverTypeError( + context: CallCandidateResolutionContext): ResolutionStatus { + val candidateCall = context.candidateCall + val candidateDescriptor = candidateCall.getCandidateDescriptor() - ReceiverParameterDescriptor extensionReceiver = candidateDescriptor.getExtensionReceiverParameter(); - ReceiverParameterDescriptor dispatchReceiver = candidateDescriptor.getDispatchReceiverParameter(); - ResolutionStatus status = SUCCESS; + val extensionReceiver = candidateDescriptor.getExtensionReceiverParameter() + val dispatchReceiver = candidateDescriptor.getDispatchReceiverParameter() + var status = SUCCESS // For the expressions like '42.(f)()' where f: String.() -> Unit we'd like to generate a type mismatch error on '1', // not to throw away the candidate, so the following check is skipped. - if (!CallResolverUtilPackage.isInvokeCallOnExpressionWithBothReceivers(context.call)) { - status = status.combine(checkReceiverTypeError(context, extensionReceiver, candidateCall.getExtensionReceiver())); + if (!isInvokeCallOnExpressionWithBothReceivers(context.call)) { + status = status.combine(checkReceiverTypeError(context, extensionReceiver, candidateCall.getExtensionReceiver())) } - status = status.combine(checkReceiverTypeError(context, dispatchReceiver, candidateCall.getDispatchReceiver())); - return status; + status = status.combine(checkReceiverTypeError(context, dispatchReceiver, candidateCall.getDispatchReceiver())) + return status } - private ResolutionStatus checkReceiverTypeError( - @NotNull CallCandidateResolutionContext context, - @Nullable ReceiverParameterDescriptor receiverParameterDescriptor, - @NotNull ReceiverValue receiverArgument - ) { - if (receiverParameterDescriptor == null || !receiverArgument.exists()) return SUCCESS; + private fun checkReceiverTypeError( + context: CallCandidateResolutionContext, + receiverParameterDescriptor: ReceiverParameterDescriptor?, + receiverArgument: ReceiverValue): ResolutionStatus { + if (receiverParameterDescriptor == null || !receiverArgument.exists()) return SUCCESS - D candidateDescriptor = context.candidateCall.getCandidateDescriptor(); + val candidateDescriptor = context.candidateCall.getCandidateDescriptor() - JetType erasedReceiverType = CallResolverUtilPackage.getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor); + val erasedReceiverType = getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor) - boolean isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, context); + val isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, context) if (!isSubtypeBySmartCast) { - return RECEIVER_TYPE_ERROR; + return RECEIVER_TYPE_ERROR } - return SUCCESS; + return SUCCESS } - private ResolutionStatus checkReceiver( - @NotNull CallCandidateResolutionContext context, - @NotNull ResolvedCall candidateCall, - @NotNull BindingTrace trace, - @Nullable ReceiverParameterDescriptor receiverParameter, - @NotNull ReceiverValue receiverArgument, - boolean isExplicitReceiver, - boolean implicitInvokeCheck - ) { - if (receiverParameter == null || !receiverArgument.exists()) return SUCCESS; - D candidateDescriptor = candidateCall.getCandidateDescriptor(); - if (TypeUtils.dependsOnTypeParameters(receiverParameter.getType(), candidateDescriptor.getTypeParameters())) return SUCCESS; + private fun checkReceiver( + context: CallCandidateResolutionContext, + candidateCall: ResolvedCall, + trace: BindingTrace, + receiverParameter: ReceiverParameterDescriptor?, + receiverArgument: ReceiverValue, + isExplicitReceiver: Boolean, + implicitInvokeCheck: Boolean): ResolutionStatus { + if (receiverParameter == null || !receiverArgument.exists()) return SUCCESS + val candidateDescriptor = candidateCall.getCandidateDescriptor() + if (TypeUtils.dependsOnTypeParameters(receiverParameter.getType(), candidateDescriptor.getTypeParameters())) return SUCCESS - boolean safeAccess = isExplicitReceiver && !implicitInvokeCheck && CallUtilPackage.isExplicitSafeCall(candidateCall.getCall()); - boolean isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability( - receiverArgument, receiverParameter.getType(), context); + val safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.getCall().isExplicitSafeCall() + val isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability( + receiverArgument, receiverParameter.getType(), context) if (!isSubtypeBySmartCast) { - context.tracing.wrongReceiverType(trace, receiverParameter, receiverArgument); - return OTHER_ERROR; + context.tracing.wrongReceiverType(trace, receiverParameter, receiverArgument) + return OTHER_ERROR } if (!SmartCastUtils.recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess)) { - return OTHER_ERROR; + return OTHER_ERROR } - JetType receiverArgumentType = receiverArgument.getType(); + val receiverArgumentType = receiverArgument.getType() - BindingContext bindingContext = trace.getBindingContext(); + val bindingContext = trace.getBindingContext() if (!safeAccess && !receiverParameter.getType().isMarkedNullable() && receiverArgumentType.isMarkedNullable()) { if (!SmartCastUtils.canBeSmartCast(receiverParameter, receiverArgument, context)) { - context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck); - return UNSAFE_CALL_ERROR; + context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck) + return UNSAFE_CALL_ERROR } } - DataFlowValue receiverValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, bindingContext, context.scope.getContainingDeclaration()); + val receiverValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, bindingContext, context.scope.getContainingDeclaration()) if (safeAccess && !context.dataFlowInfo.getNullability(receiverValue).canBeNull()) { - context.tracing.unnecessarySafeCall(trace, receiverArgumentType); + context.tracing.unnecessarySafeCall(trace, receiverArgumentType) } - context.additionalTypeChecker.checkReceiver(receiverParameter, receiverArgument, safeAccess, context); + context.additionalTypeChecker.checkReceiver(receiverParameter, receiverArgument, safeAccess, context) - return SUCCESS; + return SUCCESS } - public class ValueArgumentsCheckingResult { - @NotNull - public final List argumentTypes; - @NotNull - public final ResolutionStatus status; + public inner class ValueArgumentsCheckingResult(public val status: ResolutionStatus, public val argumentTypes: List) - private ValueArgumentsCheckingResult(@NotNull ResolutionStatus status, @NotNull List argumentTypes) { - this.status = status; - this.argumentTypes = argumentTypes; - } - } - - private void checkGenericBoundsInAFunctionCall( - @NotNull List jetTypeArguments, - @NotNull List typeArguments, - @NotNull CallableDescriptor functionDescriptor, - @NotNull TypeSubstitutor substitutor, - @NotNull BindingTrace trace - ) { - List typeParameters = functionDescriptor.getTypeParameters(); - for (int i = 0; i < Math.min(typeParameters.size(), jetTypeArguments.size()); i++) { - TypeParameterDescriptor typeParameterDescriptor = typeParameters.get(i); - JetType typeArgument = typeArguments.get(i); - JetTypeReference typeReference = jetTypeArguments.get(i).getTypeReference(); + private fun checkGenericBoundsInAFunctionCall( + jetTypeArguments: List, + typeArguments: List, + functionDescriptor: CallableDescriptor, + substitutor: TypeSubstitutor, + trace: BindingTrace) { + val typeParameters = functionDescriptor.getTypeParameters() + for (i in 0..Math.min(typeParameters.size(), jetTypeArguments.size()) - 1) { + val typeParameterDescriptor = typeParameters.get(i) + val typeArgument = typeArguments.get(i) + val typeReference = jetTypeArguments.get(i).getTypeReference() if (typeReference != null) { - DescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace); + DescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace) } } } From 3c56787514e6322f6eaee2aeb8562b9ab95a344c Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 16:55:38 +0300 Subject: [PATCH 363/450] Minor. .java -> .kt --- .../calls/{CandidateResolver.java => CandidateResolver.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/{CandidateResolver.java => CandidateResolver.kt} (100%) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt similarity index 100% rename from compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.java rename to compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt From b00dab0db54cec9e034621dff5270d2d263bd071 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 17:02:23 +0300 Subject: [PATCH 364/450] Minor. Created CandidateResolveMode in CallCandidateResolutionContext. --- .../kotlin/resolve/calls/CallResolver.java | 3 ++- .../kotlin/resolve/calls/CallTransformer.java | 26 ++++++++++++------- .../CallCandidateResolutionContext.java | 26 +++++++------------ .../calls/context/CandidateResolveMode.java | 22 ++++++++++++++++ 4 files changed, 50 insertions(+), 27 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CandidateResolveMode.java diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 950460736c4..316f9bbe55f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -575,7 +575,8 @@ public class CallResolver { public Unit invoke() { TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create( task.trace, "trace to resolve candidate"); - Collection> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace); + Collection> contexts = + callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace, CandidateResolveMode.FULLY); for (CallCandidateResolutionContext context : contexts) { candidateResolver.performResolutionForCandidateCall(context, task); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java index c30606d5a0c..f87fb75d18d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallTransformer.java @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.DelegatingBindingTrace; import org.jetbrains.kotlin.resolve.TemporaryBindingTrace; import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext; import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext; +import org.jetbrains.kotlin.resolve.calls.context.CandidateResolveMode; import org.jetbrains.kotlin.resolve.calls.context.ContextDependency; import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCallImpl; @@ -73,10 +74,12 @@ public class CallTransformer { @NotNull public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, @NotNull ResolutionTask task, - @NotNull TemporaryBindingTrace candidateTrace + @NotNull TemporaryBindingTrace candidateTrace, + @NotNull CandidateResolveMode candidateResolveMode ) { ResolvedCallImpl candidateCall = ResolvedCallImpl.create(candidate, candidateTrace, task.tracing, task.dataFlowInfoForArguments); - return Collections.singleton(CallCandidateResolutionContext.create(candidateCall, task, candidateTrace, task.tracing)); + return Collections.singleton(CallCandidateResolutionContext.create(candidateCall, task, candidateTrace, task.tracing, task.call, + ReceiverValue.NO_RECEIVER, candidateResolveMode)); } /** @@ -100,10 +103,12 @@ public class CallTransformer { @NotNull @Override public Collection> createCallContexts(@NotNull ResolutionCandidate candidate, - @NotNull ResolutionTask task, @NotNull TemporaryBindingTrace candidateTrace) { + @NotNull ResolutionTask task, @NotNull TemporaryBindingTrace candidateTrace, + @NotNull CandidateResolveMode candidateResolveMode + ) { if (candidate.getDescriptor() instanceof FunctionDescriptor) { - return super.createCallContexts(candidate, task, candidateTrace); + return super.createCallContexts(candidate, task, candidateTrace, candidateResolveMode); } assert candidate.getDescriptor() instanceof VariableDescriptor; @@ -120,11 +125,11 @@ public class CallTransformer { if (!hasReceiver) { CallCandidateResolutionContext context = CallCandidateResolutionContext.create( ResolvedCallImpl.create(variableCandidate, candidateTrace, task.tracing, task.dataFlowInfoForArguments), - task, candidateTrace, task.tracing, variableCall); + task, candidateTrace, task.tracing, variableCall, ReceiverValue.NO_RECEIVER, candidateResolveMode); return Collections.singleton(context); } CallCandidateResolutionContext contextWithReceiver = createContextWithChainedTrace( - variableCandidate, variableCall, candidateTrace, task, ReceiverValue.NO_RECEIVER); + variableCandidate, variableCall, candidateTrace, task, ReceiverValue.NO_RECEIVER, candidateResolveMode); Call variableCallWithoutReceiver = stripReceiver(variableCall); ResolutionCandidate candidateWithoutReceiver = ResolutionCandidate.create( @@ -135,18 +140,21 @@ public class CallTransformer { ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null); CallCandidateResolutionContext contextWithoutReceiver = createContextWithChainedTrace( - candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task, variableCall.getExplicitReceiver()); + candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task, variableCall.getExplicitReceiver(), + candidateResolveMode); return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver); } private CallCandidateResolutionContext createContextWithChainedTrace( @NotNull ResolutionCandidate candidate, @NotNull Call call, @NotNull TemporaryBindingTrace temporaryTrace, - @NotNull ResolutionTask task, @NotNull ReceiverValue receiverValue + @NotNull ResolutionTask task, @NotNull ReceiverValue receiverValue, + @NotNull CandidateResolveMode candidateResolveMode ) { ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate); ResolvedCallImpl resolvedCall = ResolvedCallImpl.create(candidate, chainedTrace, task.tracing, task.dataFlowInfoForArguments); - return CallCandidateResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call, receiverValue); + return CallCandidateResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call, receiverValue, + candidateResolveMode); } private Call stripCallArguments(@NotNull Call call) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java index c33ae1c6f91..afd630c4cee 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CallCandidateResolutionContext.java @@ -40,6 +40,8 @@ public final class CallCandidateResolutionContext public final TracingStrategy tracing; @NotNull public final ReceiverValue explicitExtensionReceiverForInvoke; + @NotNull + public final CandidateResolveMode candidateResolveMode; private CallCandidateResolutionContext( @NotNull MutableResolvedCall candidateCall, @@ -58,6 +60,7 @@ public final class CallCandidateResolutionContext @NotNull AdditionalTypeChecker additionalTypeChecker, @NotNull StatementFilter statementFilter, @NotNull ReceiverValue explicitExtensionReceiverForInvoke, + @NotNull CandidateResolveMode candidateResolveMode, boolean isAnnotationContext, boolean collectAllCandidates, boolean insideSafeCallChain @@ -68,11 +71,13 @@ public final class CallCandidateResolutionContext this.candidateCall = candidateCall; this.tracing = tracing; this.explicitExtensionReceiverForInvoke = explicitExtensionReceiverForInvoke; + this.candidateResolveMode = candidateResolveMode; } public static CallCandidateResolutionContext create( @NotNull MutableResolvedCall candidateCall, @NotNull CallResolutionContext context, @NotNull BindingTrace trace, - @NotNull TracingStrategy tracing, @NotNull Call call, @NotNull ReceiverValue explicitExtensionReceiverForInvoke + @NotNull TracingStrategy tracing, @NotNull Call call, @NotNull ReceiverValue explicitExtensionReceiverForInvoke, + @NotNull CandidateResolveMode candidateResolveMode ) { candidateCall.getDataFlowInfoForArguments().setInitialDataFlowInfo(context.dataFlowInfo); return new CallCandidateResolutionContext( @@ -80,20 +85,7 @@ public final class CallCandidateResolutionContext context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.symbolUsageValidator, context.additionalTypeChecker, context.statementFilter, explicitExtensionReceiverForInvoke, - context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain); - } - - public static CallCandidateResolutionContext create( - @NotNull MutableResolvedCall candidateCall, @NotNull CallResolutionContext context, @NotNull BindingTrace trace, - @NotNull TracingStrategy tracing, @NotNull Call call - ) { - return create(candidateCall, context, trace, tracing, call, ReceiverValue.NO_RECEIVER); - } - - public static CallCandidateResolutionContext create( - @NotNull MutableResolvedCall candidateCall, @NotNull CallResolutionContext context, @NotNull BindingTrace trace, - @NotNull TracingStrategy tracing) { - return create(candidateCall, context, trace, tracing, context.call); + candidateResolveMode, context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain); } @NotNull @@ -104,7 +96,7 @@ public final class CallCandidateResolutionContext candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType, context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache, context.dataFlowInfoForArguments, context.callChecker, context.symbolUsageValidator, context.additionalTypeChecker, context.statementFilter, - ReceiverValue.NO_RECEIVER, context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain); + ReceiverValue.NO_RECEIVER, CandidateResolveMode.FULLY, context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain); } @Override @@ -122,6 +114,6 @@ public final class CallCandidateResolutionContext return new CallCandidateResolutionContext( candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, dataFlowInfoForArguments, callChecker, symbolUsageValidator, additionalTypeChecker, statementFilter, - explicitExtensionReceiverForInvoke, isAnnotationContext, collectAllCandidates, insideSafeCallChain); + explicitExtensionReceiverForInvoke, candidateResolveMode, isAnnotationContext, collectAllCandidates, insideSafeCallChain); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CandidateResolveMode.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CandidateResolveMode.java new file mode 100644 index 00000000000..7e2ac6fb467 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/context/CandidateResolveMode.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.resolve.calls.context; + +public enum CandidateResolveMode { + FULLY, + EXIT_ON_FIRST_ERROR +} From 7038b9d8493b5dfe82d09cb29ef8c8fd9a7f6456 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 18:05:33 +0300 Subject: [PATCH 365/450] Add correct way for CallResolver to process CandidateResolveMode --- .../kotlin/resolve/calls/CallResolver.java | 92 +++++++++++++------ .../calls/results/ResolutionStatus.java | 4 + 2 files changed, 66 insertions(+), 30 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index 316f9bbe55f..c3b1edc1349 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.resolve.calls; import com.google.common.collect.Lists; +import com.intellij.openapi.util.Condition; +import com.intellij.util.containers.ContainerUtil; import kotlin.Unit; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; @@ -62,6 +64,8 @@ import static org.jetbrains.kotlin.diagnostics.Errors.*; import static org.jetbrains.kotlin.resolve.bindingContextUtil.BindingContextUtilPackage.recordScopeAndDataFlowInfo; import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS; import static org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS; +import static org.jetbrains.kotlin.resolve.calls.context.CandidateResolveMode.EXIT_ON_FIRST_ERROR; +import static org.jetbrains.kotlin.resolve.calls.context.CandidateResolveMode.FULLY; import static org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.CANDIDATES_WITH_WRONG_RECEIVER; import static org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.INCOMPLETE_TYPE_INFERENCE; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; @@ -565,38 +569,22 @@ public class CallResolver { @NotNull private OverloadResolutionResultsImpl performResolution( - @NotNull final ResolutionTask task, - @NotNull final CallTransformer callTransformer + @NotNull ResolutionTask task, + @NotNull CallTransformer callTransformer ) { + List> contexts = collectCallCandidateContext(task, callTransformer, EXIT_ON_FIRST_ERROR); + boolean isSuccess = ContainerUtil.exists(contexts, new Condition>() { + @Override + public boolean value(CallCandidateResolutionContext context) { + return context.candidateCall.getStatus().possibleTransformToSuccess(); + } + }); + if (!isSuccess) { + contexts = collectCallCandidateContext(task, callTransformer, FULLY); + } - for (final ResolutionCandidate resolutionCandidate : task.getCandidates()) { - candidatePerfCounter.time(new Function0() { - @Override - public Unit invoke() { - TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create( - task.trace, "trace to resolve candidate"); - Collection> contexts = - callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace, CandidateResolveMode.FULLY); - for (CallCandidateResolutionContext context : contexts) { - - candidateResolver.performResolutionForCandidateCall(context, task); - - /* important for 'variable as function case': temporary bind reference to descriptor (will be rewritten) - to have a binding to variable while 'invoke' call resolve */ - task.tracing.bindReference(context.candidateCall.getTrace(), context.candidateCall); - - Collection> resolvedCalls = callTransformer.transformCall(context, CallResolver.this, task); - - for (MutableResolvedCall resolvedCall : resolvedCalls) { - BindingTrace trace = resolvedCall.getTrace(); - task.tracing.bindReference(trace, resolvedCall); - task.tracing.bindResolvedCall(trace, resolvedCall); - task.addResolvedCall(resolvedCall); - } - } - return Unit.INSTANCE$; - } - }); + for (CallCandidateResolutionContext context : contexts) { + addResolvedCall(task, callTransformer, context); } OverloadResolutionResultsImpl results = ResolutionResultsHandler.INSTANCE.computeResultAndReportErrors( @@ -606,4 +594,48 @@ public class CallResolver { } return results; } + + @NotNull + private List> collectCallCandidateContext( + @NotNull final ResolutionTask task, + @NotNull final CallTransformer callTransformer, + @NotNull final CandidateResolveMode candidateResolveMode + ) { + final List> candidateResolutionContexts = ContainerUtil.newArrayList(); + for (final ResolutionCandidate resolutionCandidate : task.getCandidates()) { + candidatePerfCounter.time(new Function0() { + @Override + public Unit invoke() { + TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create( + task.trace, "trace to resolve candidate"); + Collection> contexts = + callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace, candidateResolveMode); + for (CallCandidateResolutionContext context : contexts) { + candidateResolver.performResolutionForCandidateCall(context, task); + candidateResolutionContexts.add(context); + } + return Unit.INSTANCE$; + } + }); + } + return candidateResolutionContexts; + } + + private void addResolvedCall( + @NotNull ResolutionTask task, + @NotNull CallTransformer callTransformer, + @NotNull CallCandidateResolutionContext context) { + /* important for 'variable as function case': temporary bind reference to descriptor (will be rewritten) + to have a binding to variable while 'invoke' call resolve */ + task.tracing.bindReference(context.candidateCall.getTrace(), context.candidateCall); + + Collection> resolvedCalls = callTransformer.transformCall(context, this, task); + + for (MutableResolvedCall resolvedCall : resolvedCalls) { + BindingTrace trace = resolvedCall.getTrace(); + task.tracing.bindReference(trace, resolvedCall); + task.tracing.bindResolvedCall(trace, resolvedCall); + task.addResolvedCall(resolvedCall); + } + } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionStatus.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionStatus.java index e3dc280c23b..389f754689a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionStatus.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionStatus.java @@ -57,6 +57,10 @@ public enum ResolutionStatus { return success; } + public boolean possibleTransformToSuccess() { + return this == UNKNOWN_STATUS || this == INCOMPLETE_TYPE_INFERENCE || this == SUCCESS; + } + @NotNull public ResolutionStatus combine(ResolutionStatus other) { if (this == UNKNOWN_STATUS) return other; From 97d41be42e655a27e9aeef7decfe39f0827e6b61 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 18:39:13 +0300 Subject: [PATCH 366/450] Support lazy perform for candidates --- .../kotlin/resolve/calls/CandidateResolver.kt | 289 ++++++++++-------- 1 file changed, 156 insertions(+), 133 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 041922436d0..6840e6680c4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -19,121 +19,121 @@ package org.jetbrains.kotlin.resolve.calls import com.google.common.collect.Lists import com.google.common.collect.Sets import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT +import org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER +import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.* -import org.jetbrains.kotlin.resolve.calls.callResolverUtil.* +import org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode -import org.jetbrains.kotlin.resolve.calls.callUtil.* -import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext -import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext -import org.jetbrains.kotlin.resolve.calls.context.CheckValueArgumentsMode -import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext -import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getEffectiveExpectedType +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getErasedReceiverType +import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInvokeCallOnExpressionWithBothReceivers +import org.jetbrains.kotlin.resolve.calls.callUtil.isExplicitSafeCall +import org.jetbrains.kotlin.resolve.calls.context.* +import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatchStatus +import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus -import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue +import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.* import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory -import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils.canBeSmartCast +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils.getSmartCastVariantsExcludingReceiver +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils.isSubTypeBySmartCastIgnoringNullability +import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils.recordSmartCastIfNecessary import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask -import org.jetbrains.kotlin.resolve.calls.tasks.* +import org.jetbrains.kotlin.resolve.calls.tasks.isSynthesizedInvoke import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.types.* +import org.jetbrains.kotlin.types.ErrorUtils +import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.TypeUtils.noExpectedType import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils -import org.jetbrains.kotlin.types.expressions.JetTypeInfo - -import javax.inject.Inject import java.util.ArrayList -import org.jetbrains.kotlin.diagnostics.Errors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT -import org.jetbrains.kotlin.diagnostics.Errors.SUPER_CANT_BE_EXTENSION_RECEIVER -import org.jetbrains.kotlin.resolve.calls.CallTransformer.CallForImplicitInvoke -import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS -import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.* -import org.jetbrains.kotlin.types.TypeUtils.noExpectedType - public class CandidateResolver( private val argumentTypeResolver: ArgumentTypeResolver, private val genericCandidateResolver: GenericCandidateResolver ){ - public fun performResolutionForCandidateCall( - context: CallCandidateResolutionContext, - task: ResolutionTask) { - + public fun performResolutionForCandidateCall(context: CallCandidateResolutionContext, + task: ResolutionTask): Unit = with(context) { ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() - val candidateCall = context.candidateCall - val candidate = candidateCall.getCandidateDescriptor() - - candidateCall.addStatus(checkReceiverTypeError(context)) - - if (ErrorUtils.isError(candidate)) { + if (ErrorUtils.isError(candidateDescriptor)) { candidateCall.addStatus(SUCCESS) return } - if (!checkOuterClassMemberIsAccessible(context)) { + if (!checkOuterClassMemberIsAccessible(this)) { candidateCall.addStatus(OTHER_ERROR) return } + checkVisibility() + mapArguments(task) - val receiverValue = ExpressionTypingUtils.normalizeReceiverValueForVisibility(candidateCall.getDispatchReceiver(), context.trace.getBindingContext()) - val invisibleMember = Visibilities.findInvisibleMember(receiverValue, candidate, context.scope.getContainingDeclaration()) - if (invisibleMember != null) { - candidateCall.addStatus(OTHER_ERROR) - context.tracing.invisibleMember(context.trace, invisibleMember) + checkReceiverTypeError() + checkExtensionReceiver() + checkDispatchReceiver() + + processTypeArguments() + checkValueArguments() + + checkAbstractAndSuper() + checkNonExtensionCalledWithReceiver() + } + + private fun CallCandidateResolutionContext<*>.checkValueArguments() = checkAndReport { + if (call.getTypeArguments().isEmpty() + && !candidateDescriptor.getTypeParameters().isEmpty() + && candidateCall.getKnownTypeParametersSubstitutor() == null + ) { + genericCandidateResolver.inferTypeArguments(this) } - - if (task.checkArguments == CheckValueArgumentsMode.ENABLED) { - val argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters( - context.call, context.tracing, candidateCall, Sets.newLinkedHashSet()) - if (!argumentMappingStatus.isSuccess()) { - candidateCall.addStatus(OTHER_ERROR) - } + else { + checkAllValueArguments(this, SHAPE_FUNCTION_ARGUMENTS).status } + } - checkExtensionReceiver(context) - - if (!checkDispatchReceiver(context)) { - candidateCall.addStatus(OTHER_ERROR) - } - - val jetTypeArguments = context.call.getTypeArguments() + private fun CallCandidateResolutionContext<*>.processTypeArguments() = check { + val jetTypeArguments = call.getTypeArguments() if (!jetTypeArguments.isEmpty()) { // Explicit type arguments passed val typeArguments = ArrayList() for (projection in jetTypeArguments) { if (projection.getProjectionKind() != JetProjectionKind.NONE) { - context.trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection)) - ModifiersChecker.checkIncompatibleVarianceModifiers(projection.getModifierList(), context.trace) + trace.report(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT.on(projection)) + ModifiersChecker.checkIncompatibleVarianceModifiers(projection.getModifierList(), trace) } val type = argumentTypeResolver.resolveTypeRefWithDefault( - projection.getTypeReference(), context.scope, context.trace, + projection.getTypeReference(), scope, trace, ErrorUtils.createErrorType("Star projection in a call"))!! ForceResolveUtil.forceResolveAllContents(type) typeArguments.add(type) } - val expectedTypeArgumentCount = candidate.getTypeParameters().size() + val expectedTypeArgumentCount = candidateDescriptor.getTypeParameters().size() for (index in jetTypeArguments.size()..expectedTypeArgumentCount - 1) { typeArguments.add(ErrorUtils.createErrorType( - "Explicit type argument expected for " + candidate.getTypeParameters().get(index).getName())) + "Explicit type argument expected for " + candidateDescriptor.getTypeParameters().get(index).getName())) } - val substitutionContext = FunctionDescriptorUtil.createSubstitutionContext(candidate as FunctionDescriptor, typeArguments) + val substitutionContext = FunctionDescriptorUtil.createSubstitutionContext(candidateDescriptor as FunctionDescriptor, typeArguments) val substitutor = TypeSubstitutor.create(substitutionContext) if (expectedTypeArgumentCount != jetTypeArguments.size()) { candidateCall.addStatus(OTHER_ERROR) - context.tracing.wrongNumberOfTypeArguments(context.trace, expectedTypeArgumentCount) + tracing.wrongNumberOfTypeArguments(trace, expectedTypeArgumentCount) } else { - checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidate, substitutor, context.trace) + checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidateDescriptor, substitutor, trace) } candidateCall.setResultingSubstitutor(substitutor) @@ -141,59 +141,75 @@ public class CandidateResolver( else if (candidateCall.getKnownTypeParametersSubstitutor() != null) { candidateCall.setResultingSubstitutor(candidateCall.getKnownTypeParametersSubstitutor()!!) } - - if (jetTypeArguments.isEmpty() && !candidate.getTypeParameters().isEmpty() && candidateCall.getKnownTypeParametersSubstitutor() == null) { - candidateCall.addStatus(genericCandidateResolver.inferTypeArguments(context)) - } - else { - candidateCall.addStatus(checkAllValueArguments(context, SHAPE_FUNCTION_ARGUMENTS).status) - } - - checkAbstractAndSuper(context) - - checkNonExtensionCalledWithReceiver(context) } - private fun checkExtensionReceiver(context: CallCandidateResolutionContext) { - val candidateCall = context.candidateCall - val receiverParameter = candidateCall.getCandidateDescriptor().getExtensionReceiverParameter() - val receiverArgument = candidateCall.getExtensionReceiver() - if (receiverParameter != null && !receiverArgument.exists()) { - context.tracing.missingReceiver(candidateCall.getTrace(), receiverParameter) - candidateCall.addStatus(OTHER_ERROR) - } - if (receiverParameter == null && receiverArgument.exists()) { - context.tracing.noReceiverAllowed(candidateCall.getTrace()) - if (context.call.getCalleeExpression() is JetSimpleNameExpression) { - candidateCall.addStatus(RECEIVER_PRESENCE_ERROR) - } - else { + private fun CallCandidateResolutionContext.mapArguments(task: ResolutionTask) = check { + if (task.checkArguments == CheckValueArgumentsMode.ENABLED) { + val argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters( + call, tracing, candidateCall, Sets.newLinkedHashSet()) + if (!argumentMappingStatus.isSuccess()) { candidateCall.addStatus(OTHER_ERROR) } } } - private fun checkDispatchReceiver(context: CallCandidateResolutionContext<*>): Boolean { - val candidateCall = context.candidateCall - val candidateDescriptor = candidateCall.getCandidateDescriptor() + private fun CallCandidateResolutionContext<*>.checkVisibility() = checkAndReport { + val receiverValue = ExpressionTypingUtils.normalizeReceiverValueForVisibility(candidateCall.getDispatchReceiver(), + trace.getBindingContext()) + val invisibleMember = Visibilities.findInvisibleMember(receiverValue, candidateDescriptor, scope.getContainingDeclaration()) + if (invisibleMember != null) { + tracing.invisibleMember(trace, invisibleMember) + OTHER_ERROR + } else { + SUCCESS + } + } + + private fun CallCandidateResolutionContext<*>.checkExtensionReceiver() = checkAndReport { + val receiverParameter = candidateCall.getCandidateDescriptor().getExtensionReceiverParameter() + val receiverArgument = candidateCall.getExtensionReceiver() + if (receiverParameter != null && !receiverArgument.exists()) { + tracing.missingReceiver(candidateCall.getTrace(), receiverParameter) + OTHER_ERROR + } + else if (receiverParameter == null && receiverArgument.exists()) { + tracing.noReceiverAllowed(candidateCall.getTrace()) + if (call.getCalleeExpression() is JetSimpleNameExpression) { + RECEIVER_PRESENCE_ERROR + } + else { + OTHER_ERROR + } + } + else { + SUCCESS + } + } + + private fun CallCandidateResolutionContext<*>.checkDispatchReceiver() = checkAndReport { + val candidateDescriptor = candidateDescriptor val dispatchReceiver = candidateCall.getDispatchReceiver() if (dispatchReceiver.exists()) { var nestedClass: ClassDescriptor? = null - if (candidateDescriptor is ConstructorDescriptor && DescriptorUtils.isStaticNestedClass(candidateDescriptor.getContainingDeclaration())) { + if (candidateDescriptor is ConstructorDescriptor + && DescriptorUtils.isStaticNestedClass(candidateDescriptor.getContainingDeclaration()) + ) { nestedClass = candidateDescriptor.getContainingDeclaration() } else if (candidateDescriptor is FakeCallableDescriptorForObject) { nestedClass = candidateDescriptor.getReferencedDescriptor() } if (nestedClass != null) { - context.tracing.nestedClassAccessViaInstanceReference(context.trace, nestedClass, candidateCall.getExplicitReceiverKind()) - return false + tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.getExplicitReceiverKind()) + return@checkAndReport OTHER_ERROR } } - assert((dispatchReceiver.exists() == (candidateCall.getResultingDescriptor().getDispatchReceiverParameter() != null))) { "Shouldn't happen because of TaskPrioritizer: $candidateDescriptor" } + assert((dispatchReceiver.exists() == (candidateCall.getResultingDescriptor().getDispatchReceiverParameter() != null))) { + "Shouldn't happen because of TaskPrioritizer: $candidateDescriptor" + } - return true + SUCCESS } private fun checkOuterClassMemberIsAccessible(context: CallCandidateResolutionContext<*>): Boolean { @@ -206,17 +222,16 @@ public class CandidateResolver( return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis) } - private fun checkAbstractAndSuper(context: CallCandidateResolutionContext) { - val candidateCall = context.candidateCall - val descriptor = candidateCall.getCandidateDescriptor() - val expression = context.candidateCall.getCall().getCalleeExpression() + private fun CallCandidateResolutionContext<*>.checkAbstractAndSuper() = check { + val descriptor = candidateDescriptor + val expression = candidateCall.getCall().getCalleeExpression() if (expression is JetSimpleNameExpression) { // 'B' in 'class A: B()' is JetConstructorCalleeExpression if (descriptor is ConstructorDescriptor) { val modality = descriptor.getContainingDeclaration().getModality() if (modality == Modality.ABSTRACT) { - context.tracing.instantiationOfAbstractClass(context.trace) + tracing.instantiationOfAbstractClass(trace) } } } @@ -224,7 +239,7 @@ public class CandidateResolver( val superDispatchReceiver = getReceiverSuper(candidateCall.getDispatchReceiver()) if (superDispatchReceiver != null) { if (descriptor is MemberDescriptor && descriptor.getModality() == Modality.ABSTRACT) { - context.tracing.abstractSuperCall(context.trace) + tracing.abstractSuperCall(trace) candidateCall.addStatus(OTHER_ERROR) } } @@ -233,17 +248,19 @@ public class CandidateResolver( // See TaskPrioritizer for more val superExtensionReceiver = getReceiverSuper(candidateCall.getExtensionReceiver()) if (superExtensionReceiver != null) { - context.trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText())) + trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText())) candidateCall.addStatus(OTHER_ERROR) } } - private fun checkNonExtensionCalledWithReceiver(context: CallCandidateResolutionContext<*>) { - val candidateCall = context.candidateCall - - if (isSynthesizedInvoke(candidateCall.getCandidateDescriptor()) && !KotlinBuiltIns.isExtensionFunctionType(candidateCall.getDispatchReceiver().getType())) { - context.tracing.freeFunctionCalledAsExtension(context.trace) - candidateCall.addStatus(OTHER_ERROR) + private fun CallCandidateResolutionContext<*>.checkNonExtensionCalledWithReceiver() = checkAndReport { + if (isSynthesizedInvoke(candidateCall.getCandidateDescriptor()) + && !KotlinBuiltIns.isExtensionFunctionType(candidateCall.getDispatchReceiver().getType()) + ) { + tracing.freeFunctionCalledAsExtension(trace) + OTHER_ERROR + } else { + SUCCESS } } @@ -287,8 +304,6 @@ public class CandidateResolver( var resultStatus = SUCCESS val candidateCall = context.candidateCall - resultStatus = resultStatus.combine(checkReceiverTypeError(context)) - // Comment about a very special case. // Call 'b.foo(1)' where class 'Foo' has an extension member 'fun B.invoke(Int)' should be checked two times for safe call (in 'checkReceiver'), because // both 'b' (receiver) and 'foo' (this object) might be nullable. In the first case we mark dot, in the second 'foo'. @@ -365,7 +380,7 @@ public class CandidateResolver( actualType: JetType, context: ResolutionContext<*>): JetType? { val receiverToCast = ExpressionReceiver(JetPsiUtil.safeDeparenthesize(expression, false), actualType) - val variants = SmartCastUtils.getSmartCastVariantsExcludingReceiver(context, receiverToCast) + val variants = getSmartCastVariantsExcludingReceiver(context, receiverToCast) for (possibleType in variants) { if (JetTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) { return possibleType @@ -374,39 +389,31 @@ public class CandidateResolver( return null } - private fun checkReceiverTypeError( - context: CallCandidateResolutionContext): ResolutionStatus { - val candidateCall = context.candidateCall - val candidateDescriptor = candidateCall.getCandidateDescriptor() - + private fun CallCandidateResolutionContext<*>.checkReceiverTypeError(): Unit = check { val extensionReceiver = candidateDescriptor.getExtensionReceiverParameter() val dispatchReceiver = candidateDescriptor.getDispatchReceiverParameter() - var status = SUCCESS + // For the expressions like '42.(f)()' where f: String.() -> Unit we'd like to generate a type mismatch error on '1', // not to throw away the candidate, so the following check is skipped. - if (!isInvokeCallOnExpressionWithBothReceivers(context.call)) { - status = status.combine(checkReceiverTypeError(context, extensionReceiver, candidateCall.getExtensionReceiver())) + if (!isInvokeCallOnExpressionWithBothReceivers(call)) { + checkReceiverTypeError(extensionReceiver, candidateCall.getExtensionReceiver()) } - status = status.combine(checkReceiverTypeError(context, dispatchReceiver, candidateCall.getDispatchReceiver())) - return status + checkReceiverTypeError(dispatchReceiver, candidateCall.getDispatchReceiver()) } - private fun checkReceiverTypeError( - context: CallCandidateResolutionContext, + private fun CallCandidateResolutionContext<*>.checkReceiverTypeError( receiverParameterDescriptor: ReceiverParameterDescriptor?, - receiverArgument: ReceiverValue): ResolutionStatus { - if (receiverParameterDescriptor == null || !receiverArgument.exists()) return SUCCESS - - val candidateDescriptor = context.candidateCall.getCandidateDescriptor() + receiverArgument: ReceiverValue + ) = checkAndReport { + if (receiverParameterDescriptor == null || !receiverArgument.exists()) return@checkAndReport SUCCESS val erasedReceiverType = getErasedReceiverType(receiverParameterDescriptor, candidateDescriptor) - val isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, context) - if (!isSubtypeBySmartCast) { - return RECEIVER_TYPE_ERROR + if (!isSubTypeBySmartCastIgnoringNullability(receiverArgument, erasedReceiverType, this)) { + RECEIVER_TYPE_ERROR + } else { + SUCCESS } - - return SUCCESS } private fun checkReceiver( @@ -422,13 +429,13 @@ public class CandidateResolver( if (TypeUtils.dependsOnTypeParameters(receiverParameter.getType(), candidateDescriptor.getTypeParameters())) return SUCCESS val safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.getCall().isExplicitSafeCall() - val isSubtypeBySmartCast = SmartCastUtils.isSubTypeBySmartCastIgnoringNullability( + val isSubtypeBySmartCast = isSubTypeBySmartCastIgnoringNullability( receiverArgument, receiverParameter.getType(), context) if (!isSubtypeBySmartCast) { context.tracing.wrongReceiverType(trace, receiverParameter, receiverArgument) return OTHER_ERROR } - if (!SmartCastUtils.recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess)) { + if (!recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess)) { return OTHER_ERROR } @@ -436,7 +443,7 @@ public class CandidateResolver( val bindingContext = trace.getBindingContext() if (!safeAccess && !receiverParameter.getType().isMarkedNullable() && receiverArgumentType.isMarkedNullable()) { - if (!SmartCastUtils.canBeSmartCast(receiverParameter, receiverArgument, context)) { + if (!canBeSmartCast(receiverParameter, receiverArgument, context)) { context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck) return UNSAFE_CALL_ERROR } @@ -469,4 +476,20 @@ public class CandidateResolver( } } } + + private fun CallCandidateResolutionContext.shouldContinue() = + candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.getStatus().possibleTransformToSuccess() + + private inline fun CallCandidateResolutionContext + .check(checker: CallCandidateResolutionContext.() -> Unit): Unit = if (shouldContinue()) checker() + + private inline fun CallCandidateResolutionContext. + checkAndReport(checker: CallCandidateResolutionContext.() -> ResolutionStatus) { + if (shouldContinue()) { + candidateCall.addStatus(checker()) + } + } + + private val CallCandidateResolutionContext<*>.candidateDescriptor: CallableDescriptor get() = candidateCall.getCandidateDescriptor() + } From d5f7fc52e07ddd45dde8b606b6d8bfc2f80e9947 Mon Sep 17 00:00:00 2001 From: Stanislav Erokhin Date: Wed, 15 Jul 2015 23:46:34 +0300 Subject: [PATCH 367/450] Minor. Remove unnecessary trace parameter --- .../kotlin/resolve/calls/CallCompleter.kt | 3 +- .../kotlin/resolve/calls/CandidateResolver.kt | 48 +++++++------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index bcf7feb5529..91023046e3f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -171,8 +171,7 @@ public class CallCompleter( tracing: TracingStrategy ) { val contextWithResolvedCall = CallCandidateResolutionContext.createForCallBeingAnalyzed(this, context, tracing) - val valueArgumentsCheckingResult = candidateResolver.checkAllValueArguments( - contextWithResolvedCall, context.trace, RESOLVE_FUNCTION_ARGUMENTS) + val valueArgumentsCheckingResult = candidateResolver.checkAllValueArguments(contextWithResolvedCall, RESOLVE_FUNCTION_ARGUMENTS) val status = getStatus() if (getConstraintSystem()!!.getStatus().isSuccessful()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 6840e6680c4..812ec018040 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -280,27 +280,17 @@ public class CandidateResolver( return if (descriptor is ClassDescriptor) descriptor else null } - private fun checkAllValueArguments( - context: CallCandidateResolutionContext, - resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { - return checkAllValueArguments(context, context.candidateCall.getTrace(), resolveFunctionArgumentBodies) - } - public fun checkAllValueArguments( context: CallCandidateResolutionContext, - trace: BindingTrace, resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { - val checkingResult = checkValueArgumentTypes( - context, context.candidateCall, trace, resolveFunctionArgumentBodies) + val checkingResult = checkValueArgumentTypes(context, context.candidateCall, resolveFunctionArgumentBodies) var resultStatus = checkingResult.status - resultStatus = resultStatus.combine(checkReceivers(context, trace)) + resultStatus = resultStatus.combine(checkReceivers(context)) return ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes) } - private fun checkReceivers( - context: CallCandidateResolutionContext, - trace: BindingTrace): ResolutionStatus { + private fun checkReceivers(context: CallCandidateResolutionContext): ResolutionStatus { var resultStatus = SUCCESS val candidateCall = context.candidateCall @@ -309,13 +299,12 @@ public class CandidateResolver( // both 'b' (receiver) and 'foo' (this object) might be nullable. In the first case we mark dot, in the second 'foo'. // Class 'CallForImplicitInvoke' helps up to recognise this case, and parameter 'implicitInvokeCheck' helps us to distinguish whether we check receiver or this object. - resultStatus = resultStatus.combine(checkReceiver( - context, candidateCall, trace, + resultStatus = resultStatus.combine(context.checkReceiver( + candidateCall, candidateCall.getResultingDescriptor().getExtensionReceiverParameter(), candidateCall.getExtensionReceiver(), candidateCall.getExplicitReceiverKind().isExtensionReceiver(), false)) - resultStatus = resultStatus.combine(checkReceiver( - context, candidateCall, trace, + resultStatus = resultStatus.combine(context.checkReceiver(candidateCall, candidateCall.getResultingDescriptor().getDispatchReceiverParameter(), candidateCall.getDispatchReceiver(), candidateCall.getExplicitReceiverKind().isDispatchReceiver(), // for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error @@ -326,7 +315,6 @@ public class CandidateResolver( private fun > checkValueArgumentTypes( context: CallResolutionContext, candidateCall: MutableResolvedCall, - trace: BindingTrace, resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult { var resultStatus = SUCCESS val argumentTypes = Lists.newArrayList() @@ -341,7 +329,7 @@ public class CandidateResolver( val expectedType = getEffectiveExpectedType(parameterDescriptor, argument) - val newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)).replaceBindingTrace(trace).replaceExpectedType(expectedType) + val newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)).replaceExpectedType(expectedType) val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo( expression, newContext, resolveFunctionArgumentBodies) val type = typeInfoForCall.type @@ -416,10 +404,8 @@ public class CandidateResolver( } } - private fun checkReceiver( - context: CallCandidateResolutionContext, + private fun CallCandidateResolutionContext.checkReceiver( candidateCall: ResolvedCall, - trace: BindingTrace, receiverParameter: ReceiverParameterDescriptor?, receiverArgument: ReceiverValue, isExplicitReceiver: Boolean, @@ -430,12 +416,12 @@ public class CandidateResolver( val safeAccess = isExplicitReceiver && !implicitInvokeCheck && candidateCall.getCall().isExplicitSafeCall() val isSubtypeBySmartCast = isSubTypeBySmartCastIgnoringNullability( - receiverArgument, receiverParameter.getType(), context) + receiverArgument, receiverParameter.getType(), this) if (!isSubtypeBySmartCast) { - context.tracing.wrongReceiverType(trace, receiverParameter, receiverArgument) + tracing.wrongReceiverType(trace, receiverParameter, receiverArgument) return OTHER_ERROR } - if (!recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), context, safeAccess)) { + if (!recordSmartCastIfNecessary(receiverArgument, receiverParameter.getType(), this, safeAccess)) { return OTHER_ERROR } @@ -443,17 +429,17 @@ public class CandidateResolver( val bindingContext = trace.getBindingContext() if (!safeAccess && !receiverParameter.getType().isMarkedNullable() && receiverArgumentType.isMarkedNullable()) { - if (!canBeSmartCast(receiverParameter, receiverArgument, context)) { - context.tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck) + if (!canBeSmartCast(receiverParameter, receiverArgument, this)) { + tracing.unsafeCall(trace, receiverArgumentType, implicitInvokeCheck) return UNSAFE_CALL_ERROR } } - val receiverValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, bindingContext, context.scope.getContainingDeclaration()) - if (safeAccess && !context.dataFlowInfo.getNullability(receiverValue).canBeNull()) { - context.tracing.unnecessarySafeCall(trace, receiverArgumentType) + val receiverValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, bindingContext, scope.getContainingDeclaration()) + if (safeAccess && !dataFlowInfo.getNullability(receiverValue).canBeNull()) { + tracing.unnecessarySafeCall(trace, receiverArgumentType) } - context.additionalTypeChecker.checkReceiver(receiverParameter, receiverArgument, safeAccess, context) + additionalTypeChecker.checkReceiver(receiverParameter, receiverArgument, safeAccess, this) return SUCCESS } From 796e05983ce3438350a52fd467671266d1509434 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 9 Jul 2015 14:58:48 +0300 Subject: [PATCH 368/450] Move kotlin runtime jars to separate folder and attach them during debug idea start Now we only attach runtime. It will be possible to attach two jars when it becomes possible to separate paths in system-independent way. --- .idea/runConfigurations/IDEA.xml | 2 +- .../IDEA__No_ProcessCanceledException_.xml | 2 +- update_dependencies.xml | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.idea/runConfigurations/IDEA.xml b/.idea/runConfigurations/IDEA.xml index ef1e614119f..a1d214d79a0 100644 --- a/.idea/runConfigurations/IDEA.xml +++ b/.idea/runConfigurations/IDEA.xml @@ -2,7 +2,7 @@

  • Boolean): Pair< } /** - * Splits original collection into pair of collections, + * Splits the original collection into pair of collections, * where *first* collection contains elements for which [predicate] yielded `true`, * while *second* collection contains elements for which [predicate] yielded `false`. */ @@ -563,7 +563,7 @@ public inline fun ByteArray.partition(predicate: (Byte) -> Boolean): Pair Boolean): Pair Boolean): Pair
  • Boolean): Pair Boolean): Pair Boolean): Pair Boolean): Pair Iterable.partition(predicate: (T) -> Boolean): Pair Sequence.partition(predicate: (T) -> Boolean): Pair Boolean): Pair { val first = StringBuilder() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index f50e82f4211..74fc7d794ca 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -339,7 +339,7 @@ fun generators(): List { doc { """ - Splits original collection into pair of collections, + Splits the original collection into pair of collections, where *first* collection contains elements for which [predicate] yielded `true`, while *second* collection contains elements for which [predicate] yielded `false`. """ @@ -361,6 +361,13 @@ fun generators(): List { """ } + doc(Strings) { + """ + Splits the original string into pair of strings, + where *first* string contains characters for which [predicate] yielded `true`, + while *second* string contains characters for which [predicate] yielded `false`. + """ + } returns(Strings) { "Pair" } body(Strings) { """ From 2c396cf28edc1a20069ef7b92bf8a88bbcdbbaeb Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 16 Jul 2015 16:14:37 +0300 Subject: [PATCH 399/450] Add clarification about the lazy nature of Sequence.plus and Sequence.minus operations. --- libraries/stdlib/src/generated/_Generators.kt | 12 +++++ .../src/templates/Generators.kt | 54 ++++++++++++++++--- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/libraries/stdlib/src/generated/_Generators.kt b/libraries/stdlib/src/generated/_Generators.kt index 77acb0b7327..51ba432eb21 100644 --- a/libraries/stdlib/src/generated/_Generators.kt +++ b/libraries/stdlib/src/generated/_Generators.kt @@ -385,6 +385,8 @@ public fun Iterable.minus(array: Array): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [array]. + * Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(array: Array): Sequence { if (array.isEmpty()) return this @@ -417,6 +419,8 @@ public fun Iterable.minus(collection: Iterable): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]. + * Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(collection: Iterable): Sequence { return object: Sequence { @@ -486,6 +490,8 @@ public fun Iterable.minus(sequence: Sequence): List { /** * Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]. + * Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.minus(sequence: Sequence): Sequence { return object: Sequence { @@ -747,6 +753,8 @@ public fun Iterable.plus(array: Array): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [array]. + * Note that the source sequence and the array being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(array: Array): Sequence { return this.plus(array.asList()) @@ -791,6 +799,8 @@ public fun Iterable.plus(collection: Iterable): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [collection]. + * Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(collection: Iterable): Sequence { return sequenceOf(this, collection.asSequence()).flatten() @@ -866,6 +876,8 @@ public fun Iterable.plus(sequence: Sequence): List { /** * Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]. + * Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from + * the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. */ public fun Sequence.plus(sequence: Sequence): Sequence { return sequenceOf(this, sequence).flatten() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 74fc7d794ca..8e2a0f7f31b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -88,7 +88,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [collection]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [collection]. + + Note that the source sequence and the collection being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return sequenceOf(this, collection.asSequence()).flatten() @@ -127,7 +134,14 @@ fun generators(): List { return result """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [array]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [array]. + + Note that the source sequence and the array being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return this.plus(array.asList()) @@ -169,7 +183,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]. + + Note that the source sequence and the sequence being added are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return sequenceOf(this, sequence).flatten() @@ -244,7 +265,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [collection]. + + Note that the source sequence and the collection being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return object: Sequence { @@ -281,7 +309,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [array]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [array]. + + Note that the source sequence and the array being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ if (array.isEmpty()) return this @@ -318,7 +353,14 @@ fun generators(): List { """ } - doc(Sequences) { "Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]." } + doc(Sequences) { + """ + Returns a sequence containing all elements of original sequence except the elements contained in the given [sequence]. + + Note that the source sequence and the sequence being subtracted are iterated only when an `iterator` is requested from + the resulting sequence. Changing any of them between successive calls to `iterator` may affect the result. + """ + } body(Sequences) { """ return object: Sequence { From 7f12965741fe7cffda6828f4a29a0ece69089d73 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 15 Jul 2015 10:56:43 +0300 Subject: [PATCH 400/450] Suppress test corrected --- .../diagnostics/tests/annotations/options/targets/suppress.kt | 4 ++++ .../tests/annotations/options/targets/suppress.txt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt index 4c0ce521946..066006b3085 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.kt @@ -1 +1,5 @@ @file:suppress("abc") + +fun foo(): Int { + @suppress("xyz") return 1 +} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt index ba3bd787383..de1d6f17577 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/suppress.txt @@ -1 +1,3 @@ package + +internal fun foo(): kotlin.Int From 2a1058ed632822d387218e2716637eeedb8f8b96 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 14 Jul 2015 16:01:40 +0300 Subject: [PATCH 401/450] Some usages of JetClassOrObject.isAnnotation() are removed. Related test fixed. --- .../jetbrains/kotlin/codegen/ClassBodyCodegen.java | 11 ++++------- .../kotlin/codegen/ImplementationBodyCodegen.java | 2 +- .../kotlin/resolve/AnnotationTargetChecker.kt | 14 ++++++++++---- .../kotlin/resolve/DeclarationsChecker.java | 8 ++++---- .../kotlin/resolve/DescriptorResolver.java | 6 +++--- .../jetbrains/kotlin/resolve/ModifiersChecker.java | 6 ++++-- .../tests/annotations/annotationModifier.kt | 6 +++--- .../tests/annotations/annotationModifier.txt | 2 +- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java index 10526eae4df..0078f6ec432 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClassBodyCodegen.java @@ -21,10 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.backend.common.bridges.BridgesPackage; import org.jetbrains.kotlin.codegen.context.ClassContext; import org.jetbrains.kotlin.codegen.state.GenerationState; -import org.jetbrains.kotlin.descriptors.ClassDescriptor; -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; -import org.jetbrains.kotlin.descriptors.FunctionDescriptor; -import org.jetbrains.kotlin.descriptors.PropertyDescriptor; +import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.DescriptorUtils; @@ -80,7 +77,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen { } } - generatePrimaryConstructorProperties(propertyCodegen, myClass); + generatePrimaryConstructorProperties(); } private static boolean shouldProcessFirst(JetDeclaration declaration) { @@ -101,8 +98,8 @@ public abstract class ClassBodyCodegen extends MemberCodegen { } } - private void generatePrimaryConstructorProperties(PropertyCodegen propertyCodegen, JetClassOrObject origin) { - boolean isAnnotation = origin instanceof JetClass && ((JetClass) origin).isAnnotation(); + private void generatePrimaryConstructorProperties() { + boolean isAnnotation = descriptor.getKind() == ClassKind.ANNOTATION_CLASS; for (JetParameter p : getPrimaryConstructorParameters()) { if (p.hasValOrVar()) { PropertyDescriptor propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 83258ee3ce4..b64af0caa0b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -138,7 +138,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { isAbstract = true; isInterface = true; } - else if (jetClass.isAnnotation()) { + else if (descriptor.getKind() == ClassKind.ANNOTATION_CLASS) { isAbstract = true; isInterface = true; isAnnotation = true; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt index 6878b9d8088..889bd290abc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.psi.* @@ -53,9 +54,9 @@ public object AnnotationTargetChecker { private val ALL_TARGET_LIST = Target.values().map { it.name() } - public fun check(annotated: JetAnnotated, trace: BindingTrace) { + public fun check(annotated: JetAnnotated, trace: BindingTrace, descriptor: ClassDescriptor? = null) { if (annotated is JetTypeParameter) return // TODO: support type parameter annotations - val actualTargets = getActualTargetList(annotated) + val actualTargets = getActualTargetList(annotated, descriptor) for (entry in annotated.getAnnotationEntries()) { checkAnnotationEntry(entry, actualTargets, trace) } @@ -110,10 +111,15 @@ public object AnnotationTargetChecker { trace.report(Errors.WRONG_ANNOTATION_TARGET.on(entry, actualTargets.firstOrNull()?.description ?: "unidentified target")) } - private fun getActualTargetList(annotated: JetAnnotated): List { + private fun getActualTargetList(annotated: JetAnnotated, descriptor: ClassDescriptor?): List { if (annotated is JetClassOrObject) { if (annotated is JetEnumEntry) return listOf(Target.PROPERTY, Target.FIELD) - return if (annotated.isAnnotation()) listOf(Target.ANNOTATION_CLASS, Target.CLASSIFIER) else listOf(Target.CLASSIFIER) + return if (descriptor?.getKind() == ClassKind.ANNOTATION_CLASS) { + listOf(Target.ANNOTATION_CLASS, Target.CLASSIFIER) + } + else { + listOf(Target.CLASSIFIER) + } } if (annotated is JetProperty) { return if (annotated.isLocal()) listOf(Target.LOCAL_VARIABLE) else listOf(Target.PROPERTY, Target.FIELD) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index 75268351eab..0ef598639a6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -67,7 +67,7 @@ public class DeclarationsChecker { public void process(@NotNull BodiesResolveContext bodiesResolveContext) { for (JetFile file : bodiesResolveContext.getFiles()) { checkModifiersAndAnnotationsInPackageDirective(file); - AnnotationTargetChecker.INSTANCE$.check(file, trace); + AnnotationTargetChecker.INSTANCE$.check(file, trace, null); } Map classes = bodiesResolveContext.getDeclaredClasses(); @@ -147,7 +147,7 @@ public class DeclarationsChecker { } } } - AnnotationTargetChecker.INSTANCE$.check(packageDirective, trace); + AnnotationTargetChecker.INSTANCE$.check(packageDirective, trace, null); ModifiersChecker.reportIllegalModifiers(modifierList, Arrays.asList(JetTokens.MODIFIER_KEYWORDS_ARRAY), trace); } @@ -254,7 +254,7 @@ public class DeclarationsChecker { checkTraitModifiers(aClass); checkConstructorInTrait(aClass); } - else if (aClass.isAnnotation()) { + else if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { checkAnnotationClassWithBody(aClass); checkValOnAnnotationParameter(aClass); } @@ -304,7 +304,7 @@ public class DeclarationsChecker { if (typeParameter != null) { DescriptorResolver.checkConflictingUpperBounds(trace, typeParameter, jetTypeParameter); } - AnnotationTargetChecker.INSTANCE$.check(jetTypeParameter, trace); + AnnotationTargetChecker.INSTANCE$.check(jetTypeParameter, trace, null); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index ca3dc003652..7266aab9ce9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -131,7 +131,7 @@ public class DescriptorResolver { } if (supertypes.isEmpty()) { - JetType defaultSupertype = getDefaultSupertype(jetClass, trace); + JetType defaultSupertype = getDefaultSupertype(jetClass, trace, classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS); addValidSupertype(supertypes, defaultSupertype); } @@ -154,7 +154,7 @@ public class DescriptorResolver { return false; } - private JetType getDefaultSupertype(JetClassOrObject jetClass, BindingTrace trace) { + private JetType getDefaultSupertype(JetClassOrObject jetClass, BindingTrace trace, boolean isAnnotation) { // TODO : beautify if (jetClass instanceof JetEnumEntry) { JetClassOrObject parent = JetStubbedPsiUtil.getContainingDeclaration(jetClass, JetClassOrObject.class); @@ -167,7 +167,7 @@ public class DescriptorResolver { return ErrorUtils.createErrorType("Supertype not specified"); } } - else if (jetClass instanceof JetClass && ((JetClass) jetClass).isAnnotation()) { + else if (isAnnotation) { return builtIns.getAnnotationType(); } return builtIns.getAnyType(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java index 1fe0859d64e..eefa3944fb5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.java @@ -150,7 +150,8 @@ public class ModifiersChecker { } checkPlatformNameApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); - AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace); + AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace, + descriptor instanceof ClassDescriptor ? (ClassDescriptor) descriptor : null); } private void checkVarargsModifiers(@NotNull JetDeclaration owner, @NotNull MemberDescriptor descriptor) { @@ -164,7 +165,8 @@ public class ModifiersChecker { reportIllegalVisibilityModifiers(modifierListOwner); checkPlatformNameApplicability(descriptor); runDeclarationCheckers(modifierListOwner, descriptor); - AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace); + AnnotationTargetChecker.INSTANCE$.check(modifierListOwner, trace, + descriptor instanceof ClassDescriptor ? (ClassDescriptor) descriptor : null); } public void reportIllegalModalityModifiers(@NotNull JetModifierListOwner modifierListOwner) { diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt index c6d58e791c3..46d4acfba75 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.kt @@ -1,12 +1,12 @@ annotation class B class A { - annotation companion object {} + annotation companion object {} } -annotation object O {} +annotation object O {} -annotation interface T {} +annotation interface T {} annotation fun f() = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt index 07873eeeea1..de139ac73c1 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt +++ b/compiler/testData/diagnostics/tests/annotations/annotationModifier.txt @@ -32,7 +32,7 @@ kotlin.annotation.annotation() internal object O { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() internal interface T : kotlin.Annotation { +kotlin.annotation.annotation() internal interface T { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String From af5e7f58daaf34bbf8371f2c3e6e1a5883a943fc Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 14 Jul 2015 19:42:05 +0300 Subject: [PATCH 402/450] Implementation of Kotlin's 'target' annotation mapping to Java's 'Target' annotation + tests --- .../kotlin/codegen/AnnotationCodegen.java | 78 +++++++++++++++- .../kotlin/resolve/AnnotationTargetChecker.kt | 84 +++++++---------- .../targets/annotation.java | 9 ++ .../targets/annotation.javaerr.txt | 2 + .../targets/annotation.kt | 4 + .../targets/annotation.txt | 9 ++ .../targets/base.java | 8 ++ .../compileJavaAgainstKotlin/targets/base.kt | 3 + .../compileJavaAgainstKotlin/targets/base.txt | 10 ++ .../targets/classifier.java | 8 ++ .../targets/classifier.javaerr.txt | 1 + .../targets/classifier.kt | 4 + .../targets/classifier.txt | 5 + .../targets/constructor.java | 10 ++ .../targets/constructor.javaerr.txt | 3 + .../targets/constructor.kt | 4 + .../targets/constructor.txt | 5 + .../targets/empty.java | 8 ++ .../targets/empty.javaerr.txt | 4 + .../compileJavaAgainstKotlin/targets/empty.kt | 4 + .../targets/empty.txt | 5 + .../targets/field.java | 7 ++ .../targets/field.javaerr.txt | 4 + .../compileJavaAgainstKotlin/targets/field.kt | 4 + .../targets/field.txt | 5 + .../targets/function.java | 8 ++ .../targets/function.javaerr.txt | 2 + .../targets/function.kt | 4 + .../targets/function.txt | 5 + .../targets/getter.java | 8 ++ .../targets/getter.javaerr.txt | 3 + .../targets/getter.kt | 4 + .../targets/getter.txt | 5 + .../targets/local.java | 9 ++ .../targets/local.javaerr.txt | 3 + .../compileJavaAgainstKotlin/targets/local.kt | 4 + .../targets/local.txt | 5 + .../targets/multiple.java | 8 ++ .../targets/multiple.javaerr.txt | 2 + .../targets/multiple.kt | 4 + .../targets/multiple.txt | 5 + .../targets/package-info.java | 5 + .../targets/package-info.javaerr.txt | 2 + .../targets/package-info.kt | 4 + .../targets/package-info.txt | 8 ++ .../targets/parameter.java | 8 ++ .../targets/parameter.javaerr.txt | 2 + .../targets/parameter.kt | 4 + .../targets/parameter.txt | 5 + .../targets/property.java | 7 ++ .../targets/property.javaerr.txt | 4 + .../targets/property.kt | 4 + .../targets/property.txt | 5 + .../targets/setter.java | 8 ++ .../targets/setter.javaerr.txt | 3 + .../targets/setter.kt | 4 + .../targets/setter.txt | 5 + .../JavaAnnotationConstructors.txt | 2 +- .../annotations/ArrayOfEnumInParam.txt | 2 +- ...CompileJavaAgainstKotlinTestGenerated.java | 93 +++++++++++++++++++ .../util/RecursiveDescriptorComparator.java | 2 + .../annotations/AnnotationTarget.kt | 57 ++++++++++++ 62 files changed, 547 insertions(+), 54 deletions(-) create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/annotation.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/annotation.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/annotation.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/annotation.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/base.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/base.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/base.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/classifier.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/classifier.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/classifier.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/classifier.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/constructor.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/constructor.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/constructor.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/constructor.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/empty.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/empty.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/empty.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/empty.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/field.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/field.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/field.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/field.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/function.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/function.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/function.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/function.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/getter.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/getter.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/getter.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/getter.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/local.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/local.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/local.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/local.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/multiple.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/multiple.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/multiple.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/multiple.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/package-info.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/package-info.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/package-info.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/package-info.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/parameter.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/parameter.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/parameter.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/parameter.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/property.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/property.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/property.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/property.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/setter.java create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/setter.javaerr.txt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/setter.kt create mode 100644 compiler/testData/compileJavaAgainstKotlin/targets/setter.txt create mode 100644 core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationTarget.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java index 2f176994840..3f25b4e3422 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AnnotationCodegen.java @@ -24,8 +24,10 @@ import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotated; import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.kotlin.descriptors.annotations.AnnotationTarget; import org.jetbrains.kotlin.load.java.JvmAnnotationNames; import org.jetbrains.kotlin.name.FqName; +import org.jetbrains.kotlin.resolve.AnnotationTargetChecker; import org.jetbrains.kotlin.resolve.constants.*; import org.jetbrains.kotlin.resolve.constants.StringValue; import org.jetbrains.kotlin.types.Flexibility; @@ -34,8 +36,10 @@ import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.kotlin.types.TypesPackage; import org.jetbrains.org.objectweb.asm.*; +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.*; import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage.getClassObjectType; @@ -123,6 +127,7 @@ public abstract class AnnotationCodegen { ClassDescriptor classDescriptor = (ClassDescriptor) annotated; if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { generateRetentionAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent); + generateTargetAnnotation(classDescriptor, annotationDescriptorsAlreadyPresent); } } } @@ -166,6 +171,47 @@ public abstract class AnnotationCodegen { generateAnnotationIfNotPresent(annotationDescriptorsAlreadyPresent, annotationClass); } + private static final Map annotationTargetMap = + new EnumMap(AnnotationTarget.class); + + static { + annotationTargetMap.put(AnnotationTarget.PACKAGE, ElementType.PACKAGE); + annotationTargetMap.put(AnnotationTarget.CLASSIFIER, ElementType.TYPE); + annotationTargetMap.put(AnnotationTarget.ANNOTATION_CLASS, ElementType.ANNOTATION_TYPE); + annotationTargetMap.put(AnnotationTarget.CONSTRUCTOR, ElementType.CONSTRUCTOR); + annotationTargetMap.put(AnnotationTarget.LOCAL_VARIABLE, ElementType.LOCAL_VARIABLE); + annotationTargetMap.put(AnnotationTarget.FUNCTION, ElementType.METHOD); + annotationTargetMap.put(AnnotationTarget.PROPERTY_GETTER, ElementType.METHOD); + annotationTargetMap.put(AnnotationTarget.PROPERTY_SETTER, ElementType.METHOD); + annotationTargetMap.put(AnnotationTarget.FIELD, ElementType.FIELD); + annotationTargetMap.put(AnnotationTarget.VALUE_PARAMETER, ElementType.PARAMETER); + } + + private void generateTargetAnnotation(@NotNull ClassDescriptor classDescriptor, @NotNull Set annotationDescriptorsAlreadyPresent) { + String descriptor = Type.getType(Target.class).getDescriptor(); + if (!annotationDescriptorsAlreadyPresent.add(descriptor)) return; + Set targets = AnnotationTargetChecker.INSTANCE$.possibleTargetSet(classDescriptor); + Set javaTargets; + if (targets == null) { + javaTargets = getJavaTargetList(classDescriptor); + if (javaTargets == null) return; + } + else { + javaTargets = EnumSet.noneOf(ElementType.class); + for (AnnotationTarget target : targets) { + if (annotationTargetMap.get(target) == null) continue; + javaTargets.add(annotationTargetMap.get(target)); + } + } + AnnotationVisitor visitor = visitAnnotation(descriptor, true); + AnnotationVisitor arrayVisitor = visitor.visitArray("value"); + for (ElementType javaTarget : javaTargets) { + arrayVisitor.visitEnum(null, Type.getType(ElementType.class).getDescriptor(), javaTarget.name()); + } + arrayVisitor.visitEnd(); + visitor.visitEnd(); + } + private void generateRetentionAnnotation(@NotNull ClassDescriptor classDescriptor, @NotNull Set annotationDescriptorsAlreadyPresent) { RetentionPolicy policy = getRetentionPolicy(classDescriptor); String descriptor = Type.getType(Retention.class).getDescriptor(); @@ -337,18 +383,46 @@ public abstract class AnnotationCodegen { } } + @Nullable + private Set getJavaTargetList(ClassDescriptor descriptor) { + AnnotationDescriptor targetAnnotation = descriptor.getAnnotations().findAnnotation(new FqName(Target.class.getName())); + if (targetAnnotation != null) { + Collection> valueArguments = targetAnnotation.getAllValueArguments().values(); + if (!valueArguments.isEmpty()) { + ConstantValue compileTimeConstant = valueArguments.iterator().next(); + if (compileTimeConstant instanceof ArrayValue) { + List> values = ((ArrayValue) compileTimeConstant).getValue(); + Set result = EnumSet.noneOf(ElementType.class); + for (ConstantValue value : values) { + if (value instanceof EnumValue) { + ClassDescriptor enumEntry = ((EnumValue) value).getValue(); + JetType classObjectType = getClassObjectType(enumEntry); + if (classObjectType != null) { + if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) { + result.add(ElementType.valueOf(enumEntry.getName().asString())); + } + } + } + } + return result; + } + } + } + return null; + } + @NotNull private RetentionPolicy getRetentionPolicy(@NotNull Annotated descriptor) { AnnotationDescriptor kotlinAnnotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.annotation); if (kotlinAnnotation != null) { - for (Map.Entry> argument: kotlinAnnotation.getAllValueArguments().entrySet()) { + for (Map.Entry> argument : kotlinAnnotation.getAllValueArguments().entrySet()) { if ("retention".equals(argument.getKey().getName().asString()) && argument.getValue() instanceof EnumValue) { ClassDescriptor enumEntry = ((EnumValue) argument.getValue()).getValue(); JetType classObjectType = getClassObjectType(enumEntry); if (classObjectType != null) { if ("kotlin/annotation/AnnotationRetention".equals(typeMapper.mapType(classObjectType).getInternalName())) { String entryName = enumEntry.getName().asString(); - for (KotlinRetention retention: KotlinRetention.values()) { + for (KotlinRetention retention : KotlinRetention.values()) { if (retention.name().equals(entryName)) return retention.mapped; } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt index 889bd290abc..598685f938b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationTargetChecker.kt @@ -27,33 +27,13 @@ import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.EnumValue import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils +import java.lang.annotation.ElementType import java.util.* +import org.jetbrains.kotlin.descriptors.annotations.AnnotationTarget +import kotlin.annotation public object AnnotationTargetChecker { - // NOTE: this enum must have the same entries with kotlin.annotation.AnnotationTarget - public enum class Target(val description: String, val isDefault: Boolean = true) { - PACKAGE("package"), - CLASSIFIER("classifier"), - ANNOTATION_CLASS("annotation class"), - TYPE_PARAMETER("type parameter", false), - PROPERTY("property"), - FIELD("field"), - LOCAL_VARIABLE("local variable"), - VALUE_PARAMETER("value parameter"), - CONSTRUCTOR("constructor"), - FUNCTION("function"), - PROPERTY_GETTER("getter"), - PROPERTY_SETTER("setter"), - TYPE("type usage", false), - EXPRESSION("expression", false), - FILE("file", false) - } - - private val DEFAULT_TARGET_LIST = Target.values().filter { it.isDefault }.map { it.name() } - - private val ALL_TARGET_LIST = Target.values().map { it.name() } - public fun check(annotated: JetAnnotated, trace: BindingTrace, descriptor: ClassDescriptor? = null) { if (annotated is JetTypeParameter) return // TODO: support type parameter annotations val actualTargets = getActualTargetList(annotated, descriptor) @@ -82,7 +62,7 @@ public object AnnotationTargetChecker { public fun checkExpression(expression: JetExpression, trace: BindingTrace) { for (entry in expression.getAnnotationEntries()) { - checkAnnotationEntry(entry, listOf(Target.EXPRESSION), trace) + checkAnnotationEntry(entry, listOf(AnnotationTarget.EXPRESSION), trace) } if (expression is JetFunctionLiteralExpression) { for (parameter in expression.getValueParameters()) { @@ -91,51 +71,55 @@ public object AnnotationTargetChecker { } } - private fun possibleTargetList(entry: JetAnnotationEntry, trace: BindingTrace): List { - val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return DEFAULT_TARGET_LIST - // For descriptor with error type, all targets are considered as possible - if (descriptor.getType().isError()) return ALL_TARGET_LIST - val classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType()) ?: return DEFAULT_TARGET_LIST + public fun possibleTargetSet(classDescriptor: ClassDescriptor): Set? { val targetEntryDescriptor = classDescriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.target) - ?: return DEFAULT_TARGET_LIST + ?: return null val valueArguments = targetEntryDescriptor.getAllValueArguments() - val valueArgument = valueArguments.entrySet().firstOrNull()?.getValue() as? ArrayValue ?: return DEFAULT_TARGET_LIST - return valueArgument.value.filterIsInstance().map { it.value.getName().asString() } + val valueArgument = valueArguments.entrySet().firstOrNull()?.getValue() as? ArrayValue ?: return null + return valueArgument.value.filterIsInstance().map { + AnnotationTarget.valueOrNull(it.value.getName().asString()) + }.filterNotNull().toSet() } - private fun checkAnnotationEntry(entry: JetAnnotationEntry, actualTargets: List, trace: BindingTrace) { - val possibleTargets = possibleTargetList(entry, trace) - for (actualTarget in actualTargets) { - if (actualTarget.name() in possibleTargets) return - } + private fun possibleTargetSet(entry: JetAnnotationEntry, trace: BindingTrace): Set { + val descriptor = trace.get(BindingContext.ANNOTATION, entry) ?: return AnnotationTarget.DEFAULT_TARGET_SET + // For descriptor with error type, all targets are considered as possible + if (descriptor.getType().isError()) return AnnotationTarget.ALL_TARGET_SET + val classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType()) ?: return AnnotationTarget.DEFAULT_TARGET_SET + return possibleTargetSet(classDescriptor) ?: AnnotationTarget.DEFAULT_TARGET_SET + } + + private fun checkAnnotationEntry(entry: JetAnnotationEntry, actualTargets: List, trace: BindingTrace) { + val possibleTargets = possibleTargetSet(entry, trace) + if (actualTargets.any { it in possibleTargets }) return trace.report(Errors.WRONG_ANNOTATION_TARGET.on(entry, actualTargets.firstOrNull()?.description ?: "unidentified target")) } - private fun getActualTargetList(annotated: JetAnnotated, descriptor: ClassDescriptor?): List { + private fun getActualTargetList(annotated: JetAnnotated, descriptor: ClassDescriptor?): List { if (annotated is JetClassOrObject) { - if (annotated is JetEnumEntry) return listOf(Target.PROPERTY, Target.FIELD) + if (annotated is JetEnumEntry) return listOf(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD) return if (descriptor?.getKind() == ClassKind.ANNOTATION_CLASS) { - listOf(Target.ANNOTATION_CLASS, Target.CLASSIFIER) + listOf(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CLASSIFIER) } else { - listOf(Target.CLASSIFIER) + listOf(AnnotationTarget.CLASSIFIER) } } if (annotated is JetProperty) { - return if (annotated.isLocal()) listOf(Target.LOCAL_VARIABLE) else listOf(Target.PROPERTY, Target.FIELD) + return if (annotated.isLocal()) listOf(AnnotationTarget.LOCAL_VARIABLE) else listOf(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD) } if (annotated is JetParameter) { - return if (annotated.hasValOrVar()) listOf(Target.PROPERTY, Target.FIELD) else listOf(Target.VALUE_PARAMETER) + return if (annotated.hasValOrVar()) listOf(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD) else listOf(AnnotationTarget.VALUE_PARAMETER) } - if (annotated is JetConstructor<*>) return listOf(Target.CONSTRUCTOR) - if (annotated is JetFunction) return listOf(Target.FUNCTION) + if (annotated is JetConstructor<*>) return listOf(AnnotationTarget.CONSTRUCTOR) + if (annotated is JetFunction) return listOf(AnnotationTarget.FUNCTION) if (annotated is JetPropertyAccessor) { - return if (annotated.isGetter()) listOf(Target.PROPERTY_GETTER) else listOf(Target.PROPERTY_SETTER) + return if (annotated.isGetter()) listOf(AnnotationTarget.PROPERTY_GETTER) else listOf(AnnotationTarget.PROPERTY_SETTER) } - if (annotated is JetPackageDirective) return listOf(Target.PACKAGE) - if (annotated is JetTypeReference) return listOf(Target.TYPE) - if (annotated is JetFile) return listOf(Target.FILE) - if (annotated is JetTypeParameter) return listOf(Target.TYPE_PARAMETER) + if (annotated is JetPackageDirective) return listOf(AnnotationTarget.PACKAGE) + if (annotated is JetTypeReference) return listOf(AnnotationTarget.TYPE) + if (annotated is JetFile) return listOf(AnnotationTarget.FILE) + if (annotated is JetTypeParameter) return listOf(AnnotationTarget.TYPE_PARAMETER) return listOf() } } \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/annotation.java b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.java new file mode 100644 index 00000000000..af701eeac59 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.java @@ -0,0 +1,9 @@ +package test; + +@meta @interface MyAnn { + +} + +@meta class My { + +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/annotation.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.javaerr.txt new file mode 100644 index 00000000000..496546b7bf8 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.javaerr.txt @@ -0,0 +1,2 @@ +annotation.java:7:1:compiler.err.annotation.type.not.applicable + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/annotation.kt b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.kt new file mode 100644 index 00000000000..a560c088c9e --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.ANNOTATION_CLASS) +annotation class meta \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/annotation.txt b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.txt new file mode 100644 index 00000000000..c67a9aad096 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/annotation.txt @@ -0,0 +1,9 @@ +package test + +test.meta() public/*package*/ final class MyAnn : kotlin.Annotation { + public/*package*/ constructor MyAnn() +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE}) internal final class meta : kotlin.Annotation { + public constructor meta() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/base.java b/compiler/testData/compileJavaAgainstKotlin/targets/base.java new file mode 100644 index 00000000000..afa45c0c6ab --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/base.java @@ -0,0 +1,8 @@ +package test; + +@base class My { + + @base int foo(@base int i) { + return i + 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/base.kt b/compiler/testData/compileJavaAgainstKotlin/targets/base.kt new file mode 100644 index 00000000000..b0691602b5e --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/base.kt @@ -0,0 +1,3 @@ +package test + +annotation class base \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/base.txt b/compiler/testData/compileJavaAgainstKotlin/targets/base.txt new file mode 100644 index 00000000000..13302e3e361 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/base.txt @@ -0,0 +1,10 @@ +package test + +test.base() public/*package*/ open class My { + public/*package*/ constructor My() + test.base() public/*package*/ open fun foo(/*0*/ test.base() kotlin.Int): kotlin.Int +} + +kotlin.annotation.annotation() internal final class base : kotlin.Annotation { + public constructor base() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/classifier.java b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.java new file mode 100644 index 00000000000..786a75cace4 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.java @@ -0,0 +1,8 @@ +package test; + +@classifier class My { + + @classifier int foo() { + return 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/classifier.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.javaerr.txt new file mode 100644 index 00000000000..f935f54bbca --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.javaerr.txt @@ -0,0 +1 @@ +classifier.java:5:5:compiler.err.annotation.type.not.applicable diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/classifier.kt b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.kt new file mode 100644 index 00000000000..42ed393d490 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.CLASSIFIER) +annotation class classifier \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/classifier.txt b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.txt new file mode 100644 index 00000000000..e78c36e3bfa --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/classifier.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.TYPE}) internal final class classifier : kotlin.Annotation { + public constructor classifier() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/constructor.java b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.java new file mode 100644 index 00000000000..5e7c693be7f --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.java @@ -0,0 +1,10 @@ +package test; + +class My { + + @constructor My() {} + + @constructor int foo() { + return 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/constructor.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.javaerr.txt new file mode 100644 index 00000000000..7a80dcd0a10 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.javaerr.txt @@ -0,0 +1,3 @@ +constructor.java:7:5:compiler.err.annotation.type.not.applicable + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/constructor.kt b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.kt new file mode 100644 index 00000000000..f30855bce29 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.CONSTRUCTOR) +annotation class constructor \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/constructor.txt b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.txt new file mode 100644 index 00000000000..ce1e8b0164d --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/constructor.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CONSTRUCTOR}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.CONSTRUCTOR}) internal final class constructor : kotlin.Annotation { + public constructor constructor() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/empty.java b/compiler/testData/compileJavaAgainstKotlin/targets/empty.java new file mode 100644 index 00000000000..3ba7c8f7e80 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/empty.java @@ -0,0 +1,8 @@ +package test; + +@empty class My { + + @empty int foo(@empty int i) { + return i + 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/empty.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/empty.javaerr.txt new file mode 100644 index 00000000000..b48349025fb --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/empty.javaerr.txt @@ -0,0 +1,4 @@ +empty.java:3:1:compiler.err.annotation.type.not.applicable +empty.java:5:20:compiler.err.annotation.type.not.applicable +empty.java:5:5:compiler.err.annotation.type.not.applicable + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/empty.kt b/compiler/testData/compileJavaAgainstKotlin/targets/empty.kt new file mode 100644 index 00000000000..baf723a676d --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/empty.kt @@ -0,0 +1,4 @@ +package test + +target() +annotation class empty diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/empty.txt b/compiler/testData/compileJavaAgainstKotlin/targets/empty.txt new file mode 100644 index 00000000000..0dd05225d23 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/empty.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {}) internal final class empty : kotlin.Annotation { + public constructor empty() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/field.java b/compiler/testData/compileJavaAgainstKotlin/targets/field.java new file mode 100644 index 00000000000..cca6d2eb004 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/field.java @@ -0,0 +1,7 @@ +package test; + +class My { + @field int prop; + + @field int get() { return prop; } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/field.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/field.javaerr.txt new file mode 100644 index 00000000000..75d28283491 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/field.javaerr.txt @@ -0,0 +1,4 @@ +field.java:6:5:compiler.err.annotation.type.not.applicable + + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/field.kt b/compiler/testData/compileJavaAgainstKotlin/targets/field.kt new file mode 100644 index 00000000000..121f11551c2 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/field.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.FIELD) +annotation class field diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/field.txt b/compiler/testData/compileJavaAgainstKotlin/targets/field.txt new file mode 100644 index 00000000000..65c95f1a64a --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/field.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FIELD}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.FIELD}) internal final class field : kotlin.Annotation { + public constructor field() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/function.java b/compiler/testData/compileJavaAgainstKotlin/targets/function.java new file mode 100644 index 00000000000..e7c96c8b5db --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/function.java @@ -0,0 +1,8 @@ +package test; + +@function class My { + + @function int foo() { + return 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/function.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/function.javaerr.txt new file mode 100644 index 00000000000..68ddefc0953 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/function.javaerr.txt @@ -0,0 +1,2 @@ +function.java:3:1:compiler.err.annotation.type.not.applicable + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/function.kt b/compiler/testData/compileJavaAgainstKotlin/targets/function.kt new file mode 100644 index 00000000000..149d5a6feb5 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/function.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.FUNCTION) +annotation class function \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/function.txt b/compiler/testData/compileJavaAgainstKotlin/targets/function.txt new file mode 100644 index 00000000000..89291920462 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/function.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.METHOD}) internal final class function : kotlin.Annotation { + public constructor function() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/getter.java b/compiler/testData/compileJavaAgainstKotlin/targets/getter.java new file mode 100644 index 00000000000..2e1ad2d6d59 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/getter.java @@ -0,0 +1,8 @@ +package test; + +@getter class My { + + @getter int foo() { + return 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/getter.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/getter.javaerr.txt new file mode 100644 index 00000000000..4bd2d1e6808 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/getter.javaerr.txt @@ -0,0 +1,3 @@ +getter.java:3:1:compiler.err.annotation.type.not.applicable + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/getter.kt b/compiler/testData/compileJavaAgainstKotlin/targets/getter.kt new file mode 100644 index 00000000000..d4f36ed4e5b --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/getter.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.PROPERTY_GETTER) +annotation class getter \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/getter.txt b/compiler/testData/compileJavaAgainstKotlin/targets/getter.txt new file mode 100644 index 00000000000..2cb31f08715 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/getter.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_GETTER}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.METHOD}) internal final class getter : kotlin.Annotation { + public constructor getter() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/local.java b/compiler/testData/compileJavaAgainstKotlin/targets/local.java new file mode 100644 index 00000000000..5ee8a3ada6d --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/local.java @@ -0,0 +1,9 @@ +package test; + +class My { + + int foo(@local int i) { + @local int j = i + 1; + return j; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/local.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/local.javaerr.txt new file mode 100644 index 00000000000..f63c7f473bc --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/local.javaerr.txt @@ -0,0 +1,3 @@ +local.java:5:13:compiler.err.annotation.type.not.applicable + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/local.kt b/compiler/testData/compileJavaAgainstKotlin/targets/local.kt new file mode 100644 index 00000000000..22315fd2751 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/local.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.LOCAL_VARIABLE) +annotation class local diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/local.txt b/compiler/testData/compileJavaAgainstKotlin/targets/local.txt new file mode 100644 index 00000000000..7731a09f388 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/local.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.LOCAL_VARIABLE}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.LOCAL_VARIABLE}) internal final class local : kotlin.Annotation { + public constructor local() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/multiple.java b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.java new file mode 100644 index 00000000000..d0de4cf9b3a --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.java @@ -0,0 +1,8 @@ +package test; + +@multiple class My { + + @multiple int foo(@multiple int i) { + return i + 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/multiple.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.javaerr.txt new file mode 100644 index 00000000000..0cf4373322b --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.javaerr.txt @@ -0,0 +1,2 @@ +multiple.java:5:23:compiler.err.annotation.type.not.applicable + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/multiple.kt b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.kt new file mode 100644 index 00000000000..e6917422932 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION) +annotation class multiple diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/multiple.txt b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.txt new file mode 100644 index 00000000000..2a3a8c4e794 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/multiple.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.TYPE, ElementType.METHOD}) internal final class multiple : kotlin.Annotation { + public constructor multiple() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/package-info.java b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.java new file mode 100644 index 00000000000..660755836c1 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.java @@ -0,0 +1,5 @@ +@pck package test; + +@pck class My { + +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/package-info.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.javaerr.txt new file mode 100644 index 00000000000..c4f5202f765 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.javaerr.txt @@ -0,0 +1,2 @@ +package-info.java:3:1:compiler.err.annotation.type.not.applicable + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/package-info.kt b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.kt new file mode 100644 index 00000000000..4cddc103b42 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.PACKAGE) +annotation class pck \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/package-info.txt b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.txt new file mode 100644 index 00000000000..e1012210dd7 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/package-info.txt @@ -0,0 +1,8 @@ +package test + +test.pck() public/*package*/ interface `package-info` { +} + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PACKAGE}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.PACKAGE}) internal final class pck : kotlin.Annotation { + public constructor pck() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/parameter.java b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.java new file mode 100644 index 00000000000..7b6579c617c --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.java @@ -0,0 +1,8 @@ +package test; + +@parameter class My { + + @parameter int foo(@parameter int i) { + return i + 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/parameter.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.javaerr.txt new file mode 100644 index 00000000000..b69bcb7eec8 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.javaerr.txt @@ -0,0 +1,2 @@ +parameter.java:3:1:compiler.err.annotation.type.not.applicable +parameter.java:5:5:compiler.err.annotation.type.not.applicable diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/parameter.kt b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.kt new file mode 100644 index 00000000000..a0480e339b7 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.VALUE_PARAMETER) +annotation class parameter diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/parameter.txt b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.txt new file mode 100644 index 00000000000..b96cb99dc91 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/parameter.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.PARAMETER}) internal final class parameter : kotlin.Annotation { + public constructor parameter() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/property.java b/compiler/testData/compileJavaAgainstKotlin/targets/property.java new file mode 100644 index 00000000000..d283ecf8802 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/property.java @@ -0,0 +1,7 @@ +package test; + +class My { + @property int prop; + + @property int get() { return prop; } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/property.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/property.javaerr.txt new file mode 100644 index 00000000000..254a611f5cb --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/property.javaerr.txt @@ -0,0 +1,4 @@ +property.java:4:5:compiler.err.annotation.type.not.applicable +property.java:6:5:compiler.err.annotation.type.not.applicable + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/property.kt b/compiler/testData/compileJavaAgainstKotlin/targets/property.kt new file mode 100644 index 00000000000..8dfbeda314f --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/property.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.PROPERTY) +annotation class property diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/property.txt b/compiler/testData/compileJavaAgainstKotlin/targets/property.txt new file mode 100644 index 00000000000..636e36d33b1 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/property.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {}) internal final class property : kotlin.Annotation { + public constructor property() +} diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/setter.java b/compiler/testData/compileJavaAgainstKotlin/targets/setter.java new file mode 100644 index 00000000000..d92426551b7 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/setter.java @@ -0,0 +1,8 @@ +package test; + +@setter class My { + + @setter int foo() { + return 1; + } +} \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/setter.javaerr.txt b/compiler/testData/compileJavaAgainstKotlin/targets/setter.javaerr.txt new file mode 100644 index 00000000000..7147fea29cc --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/setter.javaerr.txt @@ -0,0 +1,3 @@ +setter.java:3:1:compiler.err.annotation.type.not.applicable + + diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/setter.kt b/compiler/testData/compileJavaAgainstKotlin/targets/setter.kt new file mode 100644 index 00000000000..8d1a40ba08a --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/setter.kt @@ -0,0 +1,4 @@ +package test + +target(AnnotationTarget.PROPERTY_SETTER) +annotation class setter \ No newline at end of file diff --git a/compiler/testData/compileJavaAgainstKotlin/targets/setter.txt b/compiler/testData/compileJavaAgainstKotlin/targets/setter.txt new file mode 100644 index 00000000000..a9afdf028d3 --- /dev/null +++ b/compiler/testData/compileJavaAgainstKotlin/targets/setter.txt @@ -0,0 +1,5 @@ +package test + +kotlin.annotation.target(allowedTargets = {AnnotationTarget.PROPERTY_SETTER}) kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.METHOD}) internal final class setter : kotlin.Annotation { + public constructor setter() +} diff --git a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt index bb382d11bd2..873cccd65d5 100644 --- a/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt +++ b/compiler/testData/diagnostics/tests/annotations/JavaAnnotationConstructors.txt @@ -7,7 +7,7 @@ kotlin.annotation.annotation() internal final class my : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -kotlin.annotation.annotation() java.lang.annotation.Target(value = {ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR}) internal final class my1 : kotlin.Annotation { +kotlin.annotation.annotation() internal final class my1 : kotlin.Annotation { public constructor my1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt index b1052c7af49..08cd4f72ffe 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/ArrayOfEnumInParam.txt @@ -2,7 +2,7 @@ package test public interface ArrayOfEnumInParam { - java.lang.annotation.Target(value = {ElementType.FIELD, ElementType.CONSTRUCTOR}) public final class targetAnnotation : kotlin.Annotation { + public final class targetAnnotation : kotlin.Annotation { public constructor targetAnnotation(/*0*/ value: kotlin.String) public final val value: kotlin.String public abstract fun value(): kotlin.String diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java index 3498cf44ba1..c460efef005 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileJavaAgainstKotlinTestGenerated.java @@ -553,4 +553,97 @@ public class CompileJavaAgainstKotlinTestGenerated extends AbstractCompileJavaAg doTest(fileName); } } + + @TestMetadata("compiler/testData/compileJavaAgainstKotlin/targets") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Targets extends AbstractCompileJavaAgainstKotlinTest { + public void testAllFilesPresentInTargets() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/compileJavaAgainstKotlin/targets"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("annotation.kt") + public void testAnnotation() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/annotation.kt"); + doTest(fileName); + } + + @TestMetadata("base.kt") + public void testBase() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/base.kt"); + doTest(fileName); + } + + @TestMetadata("classifier.kt") + public void testClassifier() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/classifier.kt"); + doTest(fileName); + } + + @TestMetadata("constructor.kt") + public void testConstructor() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/constructor.kt"); + doTest(fileName); + } + + @TestMetadata("empty.kt") + public void testEmpty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/empty.kt"); + doTest(fileName); + } + + @TestMetadata("field.kt") + public void testField() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/field.kt"); + doTest(fileName); + } + + @TestMetadata("function.kt") + public void testFunction() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/function.kt"); + doTest(fileName); + } + + @TestMetadata("getter.kt") + public void testGetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/getter.kt"); + doTest(fileName); + } + + @TestMetadata("local.kt") + public void testLocal() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/local.kt"); + doTest(fileName); + } + + @TestMetadata("multiple.kt") + public void testMultiple() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/multiple.kt"); + doTest(fileName); + } + + @TestMetadata("package-info.kt") + public void testPackage_info() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/package-info.kt"); + doTest(fileName); + } + + @TestMetadata("parameter.kt") + public void testParameter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/parameter.kt"); + doTest(fileName); + } + + @TestMetadata("property.kt") + public void testProperty() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/property.kt"); + doTest(fileName); + } + + @TestMetadata("setter.kt") + public void testSetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/compileJavaAgainstKotlin/targets/setter.kt"); + doTest(fileName); + } + } } diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java b/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java index b43c957a1b4..7d4d4802e98 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/RecursiveDescriptorComparator.java @@ -41,6 +41,7 @@ import org.junit.Assert; import java.io.File; import java.lang.annotation.Retention; +import java.lang.annotation.Target; import java.util.*; import static org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry; @@ -52,6 +53,7 @@ public class RecursiveDescriptorComparator { static { excludedAnnotations.add(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)); excludedAnnotations.add(new FqName(Retention.class.getName())); + excludedAnnotations.add(new FqName(Target.class.getName())); } private static final DescriptorRenderer DEFAULT_RENDERER = DescriptorRenderer.Companion.withOptions( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationTarget.kt new file mode 100644 index 00000000000..b28ae42d64e --- /dev/null +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/AnnotationTarget.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.descriptors.annotations + +import java.util.* +import kotlin.annotation + +// NOTE: this enum must have the same entries with kotlin.annotation.AnnotationTarget +public enum class AnnotationTarget(val description: String, val isDefault: Boolean = true) { + PACKAGE("package"), + CLASSIFIER("classifier"), + ANNOTATION_CLASS("annotation class"), + TYPE_PARAMETER("type parameter", false), + PROPERTY("property"), + FIELD("field"), + LOCAL_VARIABLE("local variable"), + VALUE_PARAMETER("value parameter"), + CONSTRUCTOR("constructor"), + FUNCTION("function"), + PROPERTY_GETTER("getter"), + PROPERTY_SETTER("setter"), + TYPE("type usage", false), + EXPRESSION("expression", false), + FILE("file", false); + + companion object { + + private val map = HashMap() + + init { + for (target in AnnotationTarget.values()) { + map[target.name()] = target + } + } + + public fun valueOrNull(name: String): AnnotationTarget? = map[name] + + public val DEFAULT_TARGET_SET: Set = values().filter { it.isDefault }.toSet() + + public val ALL_TARGET_SET: Set = values().toSet() + + } +} \ No newline at end of file From 0d0fc2802fe4892cda4fca0f46495e6cca3b887a Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 17 Jul 2015 13:26:49 +0300 Subject: [PATCH 403/450] Built-in test fixed --- compiler/testData/builtin-classes.txt | 180 ++------------------------ 1 file changed, 9 insertions(+), 171 deletions(-) diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index f161e456fa9..18247418e80 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -8,154 +8,6 @@ public fun kotlin.Any?.toString(): kotlin.String public interface Annotation { } -public final enum class AnnotationRetention : kotlin.Enum { - public enum entry SOURCE : kotlin.annotation.AnnotationRetention { - /*primary*/ private constructor SOURCE() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry BINARY : kotlin.annotation.AnnotationRetention { - /*primary*/ private constructor BINARY() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry RUNTIME : kotlin.annotation.AnnotationRetention { - /*primary*/ private constructor RUNTIME() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - /*primary*/ private constructor AnnotationRetention() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationRetention): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - - // Static members - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): kotlin.AnnotationRetention - public final /*synthesized*/ fun values(): kotlin.Array -} - -public final enum class AnnotationTarget : kotlin.Enum { - public enum entry PACKAGE : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor PACKAGE() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry CLASSIFIER : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor CLASSIFIER() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry ANNOTATION_CLASS : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor ANNOTATION_CLASS() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry TYPE_PARAMETER : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor TYPE_PARAMETER() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry PROPERTY : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor PROPERTY() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry FIELD : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor FIELD() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry LOCAL_VARIABLE : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor LOCAL_VARIABLE() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry VALUE_PARAMETER : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor VALUE_PARAMETER() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry CONSTRUCTOR : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor CONSTRUCTOR() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry FUNCTION : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor FUNCTION() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry PROPERTY_GETTER : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor PROPERTY_GETTER() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry PROPERTY_SETTER : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor PROPERTY_SETTER() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry TYPE : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor TYPE() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry EXPRESSION : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor EXPRESSION() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - public enum entry FILE : kotlin.annotation.AnnotationTarget { - /*primary*/ private constructor FILE() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - } - - /*primary*/ private constructor AnnotationTarget() - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: kotlin.AnnotationTarget): kotlin.Int - public final override /*1*/ /*fake_override*/ fun name(): kotlin.String - public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int - - // Static members - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): kotlin.AnnotationTarget - public final /*synthesized*/ fun values(): kotlin.Array -} - public open class Any { /*primary*/ public constructor Any() } @@ -1239,7 +1091,7 @@ public interface Range> { public open fun isEmpty(): kotlin.Boolean } -public final annotation class ReplaceWith : kotlin.Annotation { +kotlin.annotation.annotation() public final class ReplaceWith : kotlin.Annotation { /*primary*/ public constructor ReplaceWith(/*0*/ expression: kotlin.String, /*1*/ vararg imports: kotlin.String /*kotlin.Array*/) internal final val expression: kotlin.String internal final fun (): kotlin.String @@ -1409,19 +1261,11 @@ public object Unit { /*primary*/ private constructor Unit() } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) public final annotation class annotation : kotlin.Annotation { - /*primary*/ public constructor __annotation(/*0*/ retention: kotlin.AnnotationRetention = ..., /*1*/ repeatable: kotlin.Boolean = ...) - internal final val repeatable: kotlin.Boolean - internal final fun (): kotlin.Boolean - internal final val retention: kotlin.AnnotationRetention - internal final fun (): kotlin.AnnotationRetention -} - -kotlin.annotation.target(allowedTargets = {AnnotationTarget.ANNOTATION_CLASS}) public final annotation class data : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) kotlin.annotation.annotation() public final class data : kotlin.Annotation { /*primary*/ public constructor data() } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER}) public final annotation class deprecated : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER}) kotlin.annotation.annotation() public final class deprecated : kotlin.Annotation { /*primary*/ public constructor deprecated(/*0*/ value: kotlin.String, /*1*/ replaceWith: kotlin.ReplaceWith = ...) internal final val replaceWith: kotlin.ReplaceWith internal final fun (): kotlin.ReplaceWith @@ -1429,38 +1273,32 @@ kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, Annotati internal final fun (): kotlin.String } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class extension : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.TYPE}) kotlin.annotation.annotation() public final class extension : kotlin.Annotation { /*primary*/ public constructor extension() } -public final annotation class inline : kotlin.Annotation { +kotlin.annotation.annotation() public final class inline : kotlin.Annotation { /*primary*/ public constructor inline(/*0*/ strategy: kotlin.InlineStrategy = ...) public final val strategy: kotlin.InlineStrategy public final fun (): kotlin.InlineStrategy } -public final annotation class inlineOptions : kotlin.Annotation { +kotlin.annotation.annotation() public final class inlineOptions : kotlin.Annotation { /*primary*/ public constructor inlineOptions(/*0*/ vararg value: kotlin.InlineOption /*kotlin.Array*/) internal final val value: kotlin.Array internal final fun (): kotlin.Array } -public final annotation class noinline : kotlin.Annotation { +kotlin.annotation.annotation() public final class noinline : kotlin.Annotation { /*primary*/ public constructor noinline() } -kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE}) public final annotation class suppress : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.CLASSIFIER, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE}) kotlin.annotation.annotation() public final class suppress : kotlin.Annotation { /*primary*/ public constructor suppress(/*0*/ vararg names: kotlin.String /*kotlin.Array*/) internal final val names: kotlin.Array internal final fun (): kotlin.Array } -kotlin.target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class tailRecursive : kotlin.Annotation { +kotlin.annotation.target(allowedTargets = {AnnotationTarget.FUNCTION}) kotlin.annotation.annotation() public final class tailRecursive : kotlin.Annotation { /*primary*/ public constructor tailRecursive() } - -kotlin.target(allowedTargets = {AnnotationTarget.CLASSIFIER}) public final annotation class target : kotlin.Annotation { - /*primary*/ public constructor target(/*0*/ vararg allowedTargets: kotlin.AnnotationTarget /*kotlin.Array*/) - internal final val allowedTargets: kotlin.Array - internal final fun (): kotlin.Array -} From 3412febe59ff54c6e2268a2eb36a6853c3d67088 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 17 Jul 2015 16:06:17 +0300 Subject: [PATCH 404/450] Minor: better message in assertion --- .../caches/resolve/IDELightClassGenerationSupport.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java index d88993b8072..41347685827 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/IDELightClassGenerationSupport.java @@ -238,8 +238,8 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport @NotNull JetClassOrObject decompiledClassOrObject, @NotNull PsiClass rootLightClassForDecompiledFile ) { - List relativeClassNameSegments = getClassRelativeName(decompiledClassOrObject).pathSegments(); - Iterator iterator = relativeClassNameSegments.iterator(); + FqName relativeFqName = getClassRelativeName(decompiledClassOrObject); + Iterator iterator = relativeFqName.pathSegments().iterator(); Name base = iterator.next(); assert rootLightClassForDecompiledFile.getName().equals(base.asString()) : "Light class for file:\n" + decompiledClassOrObject.getContainingJetFile().getVirtualFile().getCanonicalPath() @@ -248,7 +248,8 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport while (iterator.hasNext()) { Name name = iterator.next(); PsiClass innerClass = current.findInnerClassByName(name.asString(), false); - assert innerClass != null : "Inner class should be found"; + assert innerClass != null : "Could not find corresponding inner/nested class " + relativeFqName + "in class " + decompiledClassOrObject.getName() + "\n" + + "File: " + decompiledClassOrObject.getContainingJetFile().getVirtualFile().getName(); current = innerClass; } return current; From 936665253703f1bb55dbc76d07f7de38ab1191a1 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 15 Jul 2015 21:50:56 +0300 Subject: [PATCH 405/450] Disable annotation check for Android Studio and non-android sdk Android studio always creates that sdk from scratch so no configuration will be stored after restart (KT-7517) --- .../ui/AbsentJdkAnnotationsComponent.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java index d0010673d7f..ead2a3b9047 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java @@ -32,6 +32,7 @@ import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.events.*; import com.intellij.util.Alarm; +import com.intellij.util.PlatformUtils; import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.idea.configuration.AbsentSdkAnnotationsNotificationManager; @@ -133,8 +134,19 @@ public class AbsentJdkAnnotationsComponent extends AbstractProjectComponent { } private static boolean areAnnotationsCorrect(@NotNull Sdk sdk) { - return NotificationsPackage.isAndroidSdk(sdk) - ? KotlinRuntimeLibraryUtil.androidSdkAnnotationsArePresent(sdk) && !KotlinRuntimeLibraryUtil.jdkAnnotationsArePresent(sdk) - : KotlinRuntimeLibraryUtil.jdkAnnotationsArePresent(sdk); + if (NotificationsPackage.isAndroidSdk(sdk)) { + return KotlinRuntimeLibraryUtil.androidSdkAnnotationsArePresent(sdk) && !KotlinRuntimeLibraryUtil.jdkAnnotationsArePresent(sdk); + } + else if (!isAndroidStudio()) { + return KotlinRuntimeLibraryUtil.jdkAnnotationsArePresent(sdk); + } + else { + // Android studio always recreates standard sdk from scratch so any addition configuration will be lost + return true; + } + } + + private static boolean isAndroidStudio() { + return "AndroidStudio".equals(PlatformUtils.getPlatformPrefix()); } } From 67492ad5dd7d74bb21ce09134b2f5988e79ab809 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 15 Jul 2015 22:05:53 +0300 Subject: [PATCH 406/450] Disable kotlin sdk annotation check #KT-7517 Fixed --- idea/src/META-INF/plugin.xml | 5 +---- .../idea/configuration/ConfigureKotlinNotificationManager.kt | 1 + .../idea/configuration/ui/AbsentJdkAnnotationsComponent.java | 4 ++++ .../ui/notifications/AbsentSdkAnnotationsNotification.kt | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index d3edb629a19..c800597d000 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -34,11 +34,8 @@ org.jetbrains.kotlin.idea.ktSignature.KotlinSignatureInJavaMarkerUpdater - org.jetbrains.kotlin.idea.configuration.ui.AbsentJdkAnnotationsComponent + org.jetbrains.kotlin.idea.js.KotlinJavaScriptLibraryManager - - org.jetbrains.kotlin.idea.js.KotlinJavaScriptLibraryManager - diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt index 2964160cc6c..a0907626655 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinNotificationManager.kt @@ -28,6 +28,7 @@ object ConfigureKotlinNotificationManager: KotlinSingleNotificationManager { fun notify(project: Project, sdks: Collection) { notify(project, AbsentSdkAnnotationsNotification(sdks, getNotificationTitle(sdks), getNotificationString(sdks))) diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java index ead2a3b9047..c24a1586937 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/AbsentJdkAnnotationsComponent.java @@ -46,6 +46,10 @@ import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +/** + * Deprecated after moving to platform types. + */ +@Deprecated public class AbsentJdkAnnotationsComponent extends AbstractProjectComponent { public static final String EXTERNAL_ANNOTATIONS_GROUP_ID = "Kotlin External annotations"; private volatile Alarm notificationAlarm; diff --git a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/notifications/AbsentSdkAnnotationsNotification.kt b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/notifications/AbsentSdkAnnotationsNotification.kt index 13737e4f4a5..8794b72870f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/configuration/ui/notifications/AbsentSdkAnnotationsNotification.kt +++ b/idea/src/org/jetbrains/kotlin/idea/configuration/ui/notifications/AbsentSdkAnnotationsNotification.kt @@ -20,9 +20,9 @@ import com.intellij.notification.Notification import com.intellij.notification.NotificationListener import com.intellij.notification.NotificationType import com.intellij.openapi.projectRoots.Sdk +import org.jetbrains.kotlin.idea.configuration.ui.AbsentJdkAnnotationsComponent import org.jetbrains.kotlin.idea.versions.KotlinRuntimeLibraryUtil import javax.swing.event.HyperlinkEvent -import org.jetbrains.kotlin.idea.configuration.ui.AbsentJdkAnnotationsComponent public class AbsentSdkAnnotationsNotification(sdks: Collection, title: String, val text: String) : Notification( From 5ba2cda95d0bb7dc3500ba8681a2ba13896c4f42 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 19:35:51 +0300 Subject: [PATCH 407/450] Minor refactor: Extract visitor from ConstantExpressionEvaluator into a separate class --- .../evaluate/ConstantExpressionEvaluator.kt | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 1f9a01c1061..61c8f108a95 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -40,13 +40,11 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.math.BigInteger import kotlin.platform.platformStatic -public class ConstantExpressionEvaluator private constructor(val trace: BindingTrace) : JetVisitor, JetType>() { - private val factory = ConstantValueFactory(KotlinBuiltIns.getInstance()) - +public class ConstantExpressionEvaluator private constructor() { companion object { platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { - val evaluator = ConstantExpressionEvaluator(trace) - val constant = evaluator.evaluate(expression, expectedType) ?: return null + val visitor = ConstantExpressionEvaluatorVisitor(trace, KotlinBuiltIns.getInstance()) + val constant = visitor.evaluate(expression, expectedType) ?: return null return if (!constant.isError) constant else null } @@ -63,13 +61,17 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return if (!constant.isError) constant else null } - platformStatic private fun getPossiblyErrorConstant(expression: JetExpression, bindingContext: BindingContext): CompileTimeConstant<*>? { + platformStatic fun getPossiblyErrorConstant(expression: JetExpression, bindingContext: BindingContext): CompileTimeConstant<*>? { return bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression) } } +} - private fun evaluate(expression: JetExpression, expectedType: JetType?): CompileTimeConstant<*>? { - val recordedCompileTimeConstant = getPossiblyErrorConstant(expression, trace.getBindingContext()) +private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace, private val builtIns: KotlinBuiltIns) : JetVisitor?, JetType>() { + private val factory = ConstantValueFactory(builtIns) + + fun evaluate(expression: JetExpression, expectedType: JetType?): CompileTimeConstant<*>? { + val recordedCompileTimeConstant = ConstantExpressionEvaluator.getPossiblyErrorConstant(expression, trace.getBindingContext()) if (recordedCompileTimeConstant != null) { return recordedCompileTimeConstant } @@ -99,7 +101,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT override fun visitStringTemplateEntryWithExpression(entry: JetStringTemplateEntryWithExpression, data: Nothing?): TypedCompileTimeConstant? { val expression = entry.getExpression() ?: return null - return this@ConstantExpressionEvaluator.evaluate(expression, KotlinBuiltIns.getInstance().getStringType())?.let { + return evaluate(expression, builtIns.getStringType())?.let { createStringConstant(it) } } @@ -181,7 +183,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT val operationToken = expression.getOperationToken() if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationToken)) { - val booleanType = KotlinBuiltIns.getInstance().getBooleanType() + val booleanType = builtIns.getBooleanType() val leftConstant = evaluate(leftExpression, booleanType) if (leftConstant == null) return null @@ -268,11 +270,11 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT return null } - private fun usesVariableAsConstant(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.usesVariableAsConstant ?: false + private fun usesVariableAsConstant(expression: JetExpression) = ConstantExpressionEvaluator.getConstant(expression, trace.getBindingContext())?.usesVariableAsConstant ?: false - private fun canBeUsedInAnnotation(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.canBeUsedInAnnotations ?: false + private fun canBeUsedInAnnotation(expression: JetExpression) = ConstantExpressionEvaluator.getConstant(expression, trace.getBindingContext())?.canBeUsedInAnnotations ?: false - private fun isPureConstant(expression: JetExpression) = getConstant(expression, trace.getBindingContext())?.isPure ?: false + private fun isPureConstant(expression: JetExpression) = ConstantExpressionEvaluator.getConstant(expression, trace.getBindingContext())?.isPure ?: false private fun evaluateUnaryAndCheck(receiver: OperationArgument, name: String, callExpression: JetExpression): Any? { val functions = unaryOperations[UnaryOperationKey(receiver.ctcType, name)] @@ -483,7 +485,7 @@ public class ConstantExpressionEvaluator private constructor(val trace: BindingT } private fun createOperationArgument(expression: JetExpression, expressionType: JetType, compileTimeType: CompileTimeType<*>): OperationArgument? { - val compileTimeConstant = evaluate(expression, trace, expressionType) ?: return null + val compileTimeConstant = constantExpressionEvaluator.evaluateExpression(expression, trace, expressionType) ?: return null val evaluationResult = compileTimeConstant.getValue(expressionType) ?: return null return OperationArgument(evaluationResult, compileTimeType, expression) } From f2016c8033ad72f1d3261735b5ee60f90fb583d3 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 19:37:16 +0300 Subject: [PATCH 408/450] Minor: remove usage of KotlinBuiltins.getInstance() --- .../kotlin/resolve/calls/inference/ConstraintSystemImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt index daf81d3b5f3..d8a20bd174d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemImpl.kt @@ -151,7 +151,7 @@ public class ConstraintSystemImpl : ConstraintSystem { } for ((typeVariable, typeBounds) in allTypeParameterBounds) { for (declaredUpperBound in typeVariable.getUpperBounds()) { - if (KotlinBuiltIns.getInstance().getNullableAnyType() == declaredUpperBound) continue //todo remove this line (?) + if (KotlinBuiltIns.isNullableAny(declaredUpperBound)) continue //todo remove this line (?) val position = TYPE_BOUND_POSITION.position(typeVariable.getIndex()) addBound(typeVariable, declaredUpperBound, UPPER_BOUND, position) } From a84da2bb0c57832870550182ec30a1fe5da8d9e8 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 19:37:48 +0300 Subject: [PATCH 409/450] Minor: move utilities closer to their only usage --- .../constants/evaluate/ConstantExpressionEvaluator.kt | 10 ++++++++++ .../kotlin/resolve/constants/CompileTimeConstant.kt | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 61c8f108a95..1fdccda7bff 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -531,6 +531,16 @@ private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace else -> factory.createLongValue(value) }.wrap(parameters) } + + private fun ConstantValue.wrap(parameters: CompileTimeConstant.Parameters): TypedCompileTimeConstant + = TypedCompileTimeConstant(this, parameters) + + private fun ConstantValue.wrap( + canBeUsedInAnnotation: Boolean = this !is NullValue, + isPure: Boolean = false, + usesVariableAsConstant: Boolean = false + ): TypedCompileTimeConstant + = wrap(CompileTimeConstant.Parameters(canBeUsedInAnnotation, isPure, usesVariableAsConstant)) } private fun hasLongSuffix(text: String) = text.endsWith('l') || text.endsWith('L') diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt index 7769ae1ab53..c81dfbe4400 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/CompileTimeConstant.kt @@ -55,16 +55,6 @@ public class TypedCompileTimeConstant( override fun toConstantValue(expectedType: JetType): ConstantValue = constantValue } -public fun ConstantValue.wrap(parameters: CompileTimeConstant.Parameters): TypedCompileTimeConstant - = TypedCompileTimeConstant(this, parameters) - -public fun ConstantValue.wrap( - canBeUsedInAnnotation: Boolean = this !is NullValue, - isPure: Boolean = false, - usesVariableAsConstant: Boolean = false -): TypedCompileTimeConstant - = wrap(CompileTimeConstant.Parameters(canBeUsedInAnnotation, isPure, usesVariableAsConstant)) - public class IntegerValueTypeConstant( private val value: Number, override val parameters: CompileTimeConstant.Parameters From 855bff39fe345ff9792dde86ba2f9eeff214161d Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 19:52:37 +0300 Subject: [PATCH 410/450] Refactor: move annotation arguments resolve related utils from AnnotationResolver to ConstantExpressionEvaluator --- .../kotlin/resolve/AnnotationResolver.java | 180 ++---------------- .../evaluate/ConstantExpressionEvaluator.kt | 163 +++++++++++++++- .../lazy/descriptors/LazyAnnotations.kt | 7 +- 3 files changed, 169 insertions(+), 181 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 0ad61eb1e58..94ab977b442 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -17,51 +17,35 @@ package org.jetbrains.kotlin.resolve; import com.google.common.collect.Lists; -import com.intellij.openapi.util.Pair; -import kotlin.KotlinPackage; -import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.annotations.AnnotationsImpl; import org.jetbrains.kotlin.diagnostics.Errors; -import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver; +import org.jetbrains.kotlin.psi.JetAnnotationEntry; +import org.jetbrains.kotlin.psi.JetModifierList; +import org.jetbrains.kotlin.psi.JetTypeParameter; +import org.jetbrains.kotlin.psi.JetTypeReference; import org.jetbrains.kotlin.resolve.calls.CallResolver; -import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage; -import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker; -import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker; -import org.jetbrains.kotlin.resolve.calls.checkers.CompositeChecker; -import org.jetbrains.kotlin.resolve.calls.context.ContextDependency; -import org.jetbrains.kotlin.resolve.calls.context.SimpleResolutionContext; -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument; import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults; import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.calls.util.CallMaker; -import org.jetbrains.kotlin.resolve.constants.ArrayValue; -import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant; import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant; import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationDescriptor; import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyAnnotationsContextImpl; import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; -import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; import org.jetbrains.kotlin.storage.StorageManager; import org.jetbrains.kotlin.types.ErrorUtils; import org.jetbrains.kotlin.types.JetType; -import org.jetbrains.kotlin.types.checker.JetTypeChecker; import javax.inject.Inject; -import java.util.HashMap; import java.util.List; -import java.util.Map; import static org.jetbrains.kotlin.diagnostics.Errors.NOT_AN_ANNOTATION_CLASS; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; @@ -210,153 +194,6 @@ public class AnnotationResolver { ); } - @NotNull - public static Map> resolveAnnotationArguments( - @NotNull ResolvedCall resolvedCall, - @NotNull BindingTrace trace - ) { - Map> arguments = new HashMap>(); - for (Map.Entry descriptorToArgument : resolvedCall.getValueArguments().entrySet()) { - ValueParameterDescriptor parameterDescriptor = descriptorToArgument.getKey(); - ResolvedValueArgument resolvedArgument = descriptorToArgument.getValue(); - - ConstantValue value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument); - if (value != null) { - arguments.put(parameterDescriptor, value); - } - } - return arguments; - } - - @Nullable - public static ConstantValue getAnnotationArgumentValue( - BindingTrace trace, - ValueParameterDescriptor parameterDescriptor, - ResolvedValueArgument resolvedArgument - ) { - JetType varargElementType = parameterDescriptor.getVarargElementType(); - boolean argumentsAsVararg = varargElementType != null && !hasSpread(resolvedArgument); - final JetType constantType = argumentsAsVararg ? varargElementType : parameterDescriptor.getType(); - List> compileTimeConstants = resolveValueArguments(resolvedArgument, constantType, trace); - List> constants = KotlinPackage.map(compileTimeConstants, new Function1, ConstantValue>() { - @Override - public ConstantValue invoke(CompileTimeConstant constant) { - return constant.toConstantValue(constantType); - } - }); - - if (argumentsAsVararg) { - if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null; - - return new ArrayValue(constants, parameterDescriptor.getType()); - } - else { - // we should actually get only one element, but just in case of getting many, we take the last one - return KotlinPackage.lastOrNull(constants); - } - } - - private static void checkCompileTimeConstant( - @NotNull JetExpression argumentExpression, - @NotNull JetType expectedType, - @NotNull BindingTrace trace - ) { - JetType expressionType = trace.getType(argumentExpression); - - if (expressionType == null || !JetTypeChecker.DEFAULT.isSubtypeOf(expressionType, expectedType)) { - // TYPE_MISMATCH should be reported otherwise - return; - } - - // array(1, null, 3) - error should be reported on inner expression - if (argumentExpression instanceof JetCallExpression) { - Pair, JetType> arrayArgument = getArgumentExpressionsForArrayCall((JetCallExpression) argumentExpression, trace); - if (arrayArgument != null) { - for (JetExpression expression : arrayArgument.getFirst()) { - checkCompileTimeConstant(expression, arrayArgument.getSecond(), trace); - } - } - } - - CompileTimeConstant constant = ConstantExpressionEvaluator.getConstant(argumentExpression, trace.getBindingContext()); - if (constant != null && constant.getCanBeUsedInAnnotations()) { - return; - } - - ClassifierDescriptor descriptor = expressionType.getConstructor().getDeclarationDescriptor(); - if (descriptor != null && DescriptorUtils.isEnumClass(descriptor)) { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST.on(argumentExpression)); - } - else if (descriptor instanceof ClassDescriptor && KotlinBuiltIns.isKClass((ClassDescriptor) descriptor)) { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL.on(argumentExpression)); - } - else { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_CONST.on(argumentExpression)); - } - } - - @Nullable - private static Pair, JetType> getArgumentExpressionsForArrayCall( - @NotNull JetCallExpression expression, - @NotNull BindingTrace trace - ) { - ResolvedCall resolvedCall = CallUtilPackage.getResolvedCall(expression, trace.getBindingContext()); - if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) { - return null; - } - - assert resolvedCall.getValueArguments().size() == 1 : "Array function should have only one vararg parameter"; - Map.Entry argumentEntry = resolvedCall.getValueArguments().entrySet().iterator().next(); - - List result = Lists.newArrayList(); - JetType elementType = argumentEntry.getKey().getVarargElementType(); - for (ValueArgument valueArgument : argumentEntry.getValue().getArguments()) { - JetExpression valueArgumentExpression = valueArgument.getArgumentExpression(); - if (valueArgumentExpression != null) { - if (elementType != null) { - result.add(valueArgumentExpression); - } - } - } - return new Pair, JetType>(result, elementType); - } - - private static boolean hasSpread(@NotNull ResolvedValueArgument argument) { - List arguments = argument.getArguments(); - return arguments.size() == 1 && arguments.get(0).getSpreadElement() != null; - } - - @NotNull - private static List> resolveValueArguments( - @NotNull ResolvedValueArgument resolvedValueArgument, - @NotNull JetType expectedType, - @NotNull BindingTrace trace - ) { - List> constants = Lists.newArrayList(); - for (ValueArgument argument : resolvedValueArgument.getArguments()) { - JetExpression argumentExpression = argument.getArgumentExpression(); - if (argumentExpression != null) { - CompileTimeConstant constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType); - if (constant instanceof IntegerValueTypeConstant) { - JetType defaultType = ((IntegerValueTypeConstant) constant).getType(expectedType); - SimpleResolutionContext context = - new SimpleResolutionContext(trace, JetScope.Empty.INSTANCE$, NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, - ContextDependency.INDEPENDENT, - new CompositeChecker(Lists.newArrayList()), - SymbolUsageValidator.Empty, - new AdditionalTypeChecker.Composite(Lists.newArrayList()), - StatementFilter.NONE); - ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context); - } - if (constant != null) { - constants.add(constant); - } - checkCompileTimeConstant(argumentExpression, expectedType, trace); - } - } - return constants; - } - public static void reportUnsupportedAnnotationForTypeParameter(@NotNull JetTypeParameter jetTypeParameter, @NotNull BindingTrace trace) { JetModifierList modifierList = jetTypeParameter.getModifierList(); if (modifierList == null) return; @@ -365,4 +202,13 @@ public class AnnotationResolver { trace.report(Errors.UNSUPPORTED.on(annotationEntry, "Annotations for type parameters are not supported yet")); } } + + @Nullable + public ConstantValue getAnnotationArgumentValue( + @NotNull BindingTrace trace, + @NotNull ValueParameterDescriptor valueParameter, + @NotNull ResolvedValueArgument resolvedArgument + ) { + return ConstantExpressionEvaluator.getAnnotationArgumentValue(trace, valueParameter, resolvedArgument); + } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 1fdccda7bff..5a48adfa2ea 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.resolve.constants.evaluate +import com.google.common.collect.Lists import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.JetNodeTypes import org.jetbrains.kotlin.builtins.KotlinBuiltIns @@ -29,19 +30,163 @@ import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.* +import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall +import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker +import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker +import org.jetbrains.kotlin.resolve.calls.checkers.CompositeChecker +import org.jetbrains.kotlin.resolve.calls.context.ContextDependency +import org.jetbrains.kotlin.resolve.calls.context.SimpleResolutionContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument +import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils +import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.math.BigInteger +import java.util.HashMap import kotlin.platform.platformStatic -public class ConstantExpressionEvaluator private constructor() { +public class ConstantExpressionEvaluator private constructor() { companion object { + + platformStatic public fun resolveAnnotationArguments( + resolvedCall: ResolvedCall<*>, + trace: BindingTrace + ): Map> { + val arguments = HashMap>() + for ((parameterDescriptor, resolvedArgument) in resolvedCall.getValueArguments().entrySet()) { + val value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument) + if (value != null) { + arguments.put(parameterDescriptor, value) + } + } + return arguments + } + + platformStatic public fun getAnnotationArgumentValue( + trace: BindingTrace, + parameterDescriptor: ValueParameterDescriptor, + resolvedArgument: ResolvedValueArgument + ): ConstantValue<*>? { + val varargElementType = parameterDescriptor.getVarargElementType() + val argumentsAsVararg = varargElementType != null && !hasSpread(resolvedArgument) + val constantType = if (argumentsAsVararg) varargElementType else parameterDescriptor.getType() + val compileTimeConstants = resolveValueArguments(resolvedArgument, constantType!!, trace) + val constants = compileTimeConstants.map { it.toConstantValue(constantType) } + + if (argumentsAsVararg) { + if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null + + return ArrayValue(constants, parameterDescriptor.getType()) + } + else { + // we should actually get only one element, but just in case of getting many, we take the last one + return constants.lastOrNull() + } + } + + private fun checkCompileTimeConstant( + argumentExpression: JetExpression, + expectedType: JetType, + trace: BindingTrace + ) { + val expressionType = trace.getType(argumentExpression) + + if (expressionType == null || !JetTypeChecker.DEFAULT.isSubtypeOf(expressionType, expectedType)) { + // TYPE_MISMATCH should be reported otherwise + return + } + + // array(1, null, 3) - error should be reported on inner expression + if (argumentExpression is JetCallExpression) { + val arrayArgument = getArgumentExpressionsForArrayCall(argumentExpression, trace) + if (arrayArgument != null) { + for (expression in arrayArgument.first) { + checkCompileTimeConstant(expression, arrayArgument.second!!, trace) + } + } + } + + val constant = ConstantExpressionEvaluator.getConstant(argumentExpression, trace.getBindingContext()) + if (constant != null && constant.canBeUsedInAnnotations) { + return + } + + val descriptor = expressionType.getConstructor().getDeclarationDescriptor() + if (descriptor != null && DescriptorUtils.isEnumClass(descriptor)) { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST.on(argumentExpression)) + } + else if (descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor)) { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL.on(argumentExpression)) + } + else { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_CONST.on(argumentExpression)) + } + } + + private fun getArgumentExpressionsForArrayCall( + expression: JetCallExpression, + trace: BindingTrace + ): Pair, JetType?>? { + val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) + if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) { + return null + } + + assert(resolvedCall.getValueArguments().size() == 1, "Array function should have only one vararg parameter") + + val argumentEntry = resolvedCall.getValueArguments().entrySet().iterator().next() + + val elementType = argumentEntry.getKey().getVarargElementType() ?: return null + + val result = arrayListOf() + for (valueArgument in argumentEntry.getValue().getArguments()) { + val valueArgumentExpression = valueArgument.getArgumentExpression() + if (valueArgumentExpression != null) { + result.add(valueArgumentExpression) + } + } + + return Pair, JetType>(result, elementType) + } + + private fun hasSpread(argument: ResolvedValueArgument): Boolean { + val arguments = argument.getArguments() + return arguments.size() == 1 && arguments.get(0).getSpreadElement() != null + } + + private fun resolveValueArguments( + resolvedValueArgument: ResolvedValueArgument, + expectedType: JetType, + trace: BindingTrace): List> { + val constants = Lists.newArrayList>() + for (argument in resolvedValueArgument.getArguments()) { + val argumentExpression = argument.getArgumentExpression() ?: continue + val constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType) + if (constant is IntegerValueTypeConstant) { + val defaultType = constant.getType(expectedType) + val context = SimpleResolutionContext(trace, JetScope.Empty, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, + ContextDependency.INDEPENDENT, + CompositeChecker(Lists.newArrayList()), + SymbolUsageValidator.Empty, + AdditionalTypeChecker.Composite(Lists.newArrayList()), + StatementFilter.NONE) + ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context) + } + if (constant != null) { + constants.add(constant) + } + checkCompileTimeConstant(argumentExpression, expectedType, trace) + } + return constants + } + platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { val visitor = ConstantExpressionEvaluatorVisitor(trace, KotlinBuiltIns.getInstance()) val constant = visitor.evaluate(expression, expectedType) ?: return null @@ -118,12 +263,12 @@ private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace if (nodeElementType == JetNodeTypes.NULL) return factory.createNullValue().wrap() val result: Any? = when (nodeElementType) { - JetNodeTypes.INTEGER_CONSTANT -> parseLong(text) - JetNodeTypes.FLOAT_CONSTANT -> parseFloatingLiteral(text) - JetNodeTypes.BOOLEAN_CONSTANT -> parseBoolean(text) - JetNodeTypes.CHARACTER_CONSTANT -> CompileTimeConstantChecker.parseChar(expression) - else -> throw IllegalArgumentException("Unsupported constant: " + expression) - } ?: return null + JetNodeTypes.INTEGER_CONSTANT -> parseLong(text) + JetNodeTypes.FLOAT_CONSTANT -> parseFloatingLiteral(text) + JetNodeTypes.BOOLEAN_CONSTANT -> parseBoolean(text) + JetNodeTypes.CHARACTER_CONSTANT -> CompileTimeConstantChecker.parseChar(expression) + else -> throw IllegalArgumentException("Unsupported constant: " + expression) + } ?: return null fun isLongWithSuffix() = nodeElementType == JetNodeTypes.INTEGER_CONSTANT && hasLongSuffix(text) return createConstant(result, expectedType, CompileTimeConstant.Parameters(true, !isLongWithSuffix(), false)) @@ -427,7 +572,7 @@ private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace if (DescriptorUtils.isAnnotationClass(classDescriptor)) { val descriptor = AnnotationDescriptorImpl( classDescriptor.getDefaultType(), - AnnotationResolver.resolveAnnotationArguments(call, trace) + ConstantExpressionEvaluator.resolveAnnotationArguments(call, trace) ) return AnnotationValue(descriptor).wrap() } @@ -536,7 +681,7 @@ private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace = TypedCompileTimeConstant(this, parameters) private fun ConstantValue.wrap( - canBeUsedInAnnotation: Boolean = this !is NullValue, + canBeUsedInAnnotation: Boolean = this !is NullValue, isPure: Boolean = false, usesVariableAsConstant: Boolean = false ): TypedCompileTimeConstant diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt index 48868f41499..68fbd9bd134 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt @@ -21,10 +21,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.JetAnnotationEntry -import org.jetbrains.kotlin.resolve.AnnotationResolver -import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.BindingTrace -import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.lazy.LazyEntity @@ -119,7 +116,7 @@ public class LazyAnnotationDescriptor( return resolutionResults.getResultingCall().getValueArguments() .mapValues { val (valueParameter, resolvedArgument) = it; if (resolvedArgument == null) null - else AnnotationResolver.getAnnotationArgumentValue(c.trace, valueParameter, resolvedArgument) + else c.annotationResolver.getAnnotationArgumentValue(c.trace, valueParameter, resolvedArgument) } .filterValues { it != null } as Map> } From 92161370f13fe1825542c0c3a1a4de13f6e1dc31 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 21:47:51 +0300 Subject: [PATCH 411/450] Refactor: Make some of utils in ConstantExpressionEvaluator non static --- .../kotlin/resolve/AnnotationResolver.java | 8 +- .../evaluate/ConstantExpressionEvaluator.kt | 290 +++++++++--------- 2 files changed, 158 insertions(+), 140 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 94ab977b442..e03f12eced9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -55,6 +55,7 @@ public class AnnotationResolver { private CallResolver callResolver; private StorageManager storageManager; private TypeResolver typeResolver; + private ConstantExpressionEvaluator constantExpressionEvaluator; @Inject public void setCallResolver(CallResolver callResolver) { @@ -71,6 +72,11 @@ public class AnnotationResolver { this.typeResolver = typeResolver; } + @Inject + public void setConstantExpressionEvaluator(ConstantExpressionEvaluator constantExpressionEvaluator) { + this.constantExpressionEvaluator = constantExpressionEvaluator; + } + @NotNull public Annotations resolveAnnotationsWithoutArguments( @NotNull JetScope scope, @@ -209,6 +215,6 @@ public class AnnotationResolver { @NotNull ValueParameterDescriptor valueParameter, @NotNull ResolvedValueArgument resolvedArgument ) { - return ConstantExpressionEvaluator.getAnnotationArgumentValue(trace, valueParameter, resolvedArgument); + return constantExpressionEvaluator.getAnnotationArgumentValue(trace, valueParameter, resolvedArgument); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 5a48adfa2ea..c09f3bae657 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -52,145 +52,153 @@ import java.math.BigInteger import java.util.HashMap import kotlin.platform.platformStatic -public class ConstantExpressionEvaluator private constructor() { +public class ConstantExpressionEvaluator(private val builtIns: KotlinBuiltIns) { + + internal fun resolveAnnotationArguments( + resolvedCall: ResolvedCall<*>, + trace: BindingTrace + ): Map> { + val arguments = HashMap>() + for ((parameterDescriptor, resolvedArgument) in resolvedCall.getValueArguments().entrySet()) { + val value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument) + if (value != null) { + arguments.put(parameterDescriptor, value) + } + } + return arguments + } + + public fun getAnnotationArgumentValue( + trace: BindingTrace, + parameterDescriptor: ValueParameterDescriptor, + resolvedArgument: ResolvedValueArgument + ): ConstantValue<*>? { + val varargElementType = parameterDescriptor.getVarargElementType() + val argumentsAsVararg = varargElementType != null && !hasSpread(resolvedArgument) + val constantType = if (argumentsAsVararg) varargElementType else parameterDescriptor.getType() + val compileTimeConstants = resolveValueArguments(resolvedArgument, constantType!!, trace) + val constants = compileTimeConstants.map { it.toConstantValue(constantType) } + + if (argumentsAsVararg) { + if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null + + return ArrayValue(constants, parameterDescriptor.getType()) + } + else { + // we should actually get only one element, but just in case of getting many, we take the last one + return constants.lastOrNull() + } + } + + private fun checkCompileTimeConstant( + argumentExpression: JetExpression, + expectedType: JetType, + trace: BindingTrace + ) { + val expressionType = trace.getType(argumentExpression) + + if (expressionType == null || !JetTypeChecker.DEFAULT.isSubtypeOf(expressionType, expectedType)) { + // TYPE_MISMATCH should be reported otherwise + return + } + + // array(1, null, 3) - error should be reported on inner expression + if (argumentExpression is JetCallExpression) { + val arrayArgument = getArgumentExpressionsForArrayCall(argumentExpression, trace) + if (arrayArgument != null) { + for (expression in arrayArgument.first) { + checkCompileTimeConstant(expression, arrayArgument.second!!, trace) + } + } + } + + val constant = ConstantExpressionEvaluator.getConstant(argumentExpression, trace.getBindingContext()) + if (constant != null && constant.canBeUsedInAnnotations) { + return + } + + val descriptor = expressionType.getConstructor().getDeclarationDescriptor() + if (descriptor != null && DescriptorUtils.isEnumClass(descriptor)) { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST.on(argumentExpression)) + } + else if (descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor)) { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL.on(argumentExpression)) + } + else { + trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_CONST.on(argumentExpression)) + } + } + + private fun getArgumentExpressionsForArrayCall( + expression: JetCallExpression, + trace: BindingTrace + ): Pair, JetType?>? { + val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) + if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) { + return null + } + + assert(resolvedCall.getValueArguments().size() == 1, "Array function should have only one vararg parameter") + + val argumentEntry = resolvedCall.getValueArguments().entrySet().iterator().next() + + val elementType = argumentEntry.getKey().getVarargElementType() ?: return null + + val result = arrayListOf() + for (valueArgument in argumentEntry.getValue().getArguments()) { + val valueArgumentExpression = valueArgument.getArgumentExpression() + if (valueArgumentExpression != null) { + result.add(valueArgumentExpression) + } + } + + return Pair, JetType>(result, elementType) + } + + private fun hasSpread(argument: ResolvedValueArgument): Boolean { + val arguments = argument.getArguments() + return arguments.size() == 1 && arguments.get(0).getSpreadElement() != null + } + + private fun resolveValueArguments( + resolvedValueArgument: ResolvedValueArgument, + expectedType: JetType, + trace: BindingTrace): List> { + val constants = Lists.newArrayList>() + for (argument in resolvedValueArgument.getArguments()) { + val argumentExpression = argument.getArgumentExpression() ?: continue + val constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType) + if (constant is IntegerValueTypeConstant) { + val defaultType = constant.getType(expectedType) + val context = SimpleResolutionContext(trace, JetScope.Empty, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, + ContextDependency.INDEPENDENT, + CompositeChecker(Lists.newArrayList()), + SymbolUsageValidator.Empty, + AdditionalTypeChecker.Composite(Lists.newArrayList()), + StatementFilter.NONE) + ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context) + } + if (constant != null) { + constants.add(constant) + } + checkCompileTimeConstant(argumentExpression, expectedType, trace) + } + return constants + } + + public fun evaluateExpression( + expression: JetExpression, + trace: BindingTrace, + expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE + ): CompileTimeConstant<*>? { + val visitor = ConstantExpressionEvaluatorVisitor(this, trace, builtIns) + val constant = visitor.evaluate(expression, expectedType) ?: return null + return if (!constant.isError) constant else null + } + companion object { - - platformStatic public fun resolveAnnotationArguments( - resolvedCall: ResolvedCall<*>, - trace: BindingTrace - ): Map> { - val arguments = HashMap>() - for ((parameterDescriptor, resolvedArgument) in resolvedCall.getValueArguments().entrySet()) { - val value = getAnnotationArgumentValue(trace, parameterDescriptor, resolvedArgument) - if (value != null) { - arguments.put(parameterDescriptor, value) - } - } - return arguments - } - - platformStatic public fun getAnnotationArgumentValue( - trace: BindingTrace, - parameterDescriptor: ValueParameterDescriptor, - resolvedArgument: ResolvedValueArgument - ): ConstantValue<*>? { - val varargElementType = parameterDescriptor.getVarargElementType() - val argumentsAsVararg = varargElementType != null && !hasSpread(resolvedArgument) - val constantType = if (argumentsAsVararg) varargElementType else parameterDescriptor.getType() - val compileTimeConstants = resolveValueArguments(resolvedArgument, constantType!!, trace) - val constants = compileTimeConstants.map { it.toConstantValue(constantType) } - - if (argumentsAsVararg) { - if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null - - return ArrayValue(constants, parameterDescriptor.getType()) - } - else { - // we should actually get only one element, but just in case of getting many, we take the last one - return constants.lastOrNull() - } - } - - private fun checkCompileTimeConstant( - argumentExpression: JetExpression, - expectedType: JetType, - trace: BindingTrace - ) { - val expressionType = trace.getType(argumentExpression) - - if (expressionType == null || !JetTypeChecker.DEFAULT.isSubtypeOf(expressionType, expectedType)) { - // TYPE_MISMATCH should be reported otherwise - return - } - - // array(1, null, 3) - error should be reported on inner expression - if (argumentExpression is JetCallExpression) { - val arrayArgument = getArgumentExpressionsForArrayCall(argumentExpression, trace) - if (arrayArgument != null) { - for (expression in arrayArgument.first) { - checkCompileTimeConstant(expression, arrayArgument.second!!, trace) - } - } - } - - val constant = ConstantExpressionEvaluator.getConstant(argumentExpression, trace.getBindingContext()) - if (constant != null && constant.canBeUsedInAnnotations) { - return - } - - val descriptor = expressionType.getConstructor().getDeclarationDescriptor() - if (descriptor != null && DescriptorUtils.isEnumClass(descriptor)) { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST.on(argumentExpression)) - } - else if (descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor)) { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL.on(argumentExpression)) - } - else { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_CONST.on(argumentExpression)) - } - } - - private fun getArgumentExpressionsForArrayCall( - expression: JetCallExpression, - trace: BindingTrace - ): Pair, JetType?>? { - val resolvedCall = expression.getResolvedCall(trace.getBindingContext()) - if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) { - return null - } - - assert(resolvedCall.getValueArguments().size() == 1, "Array function should have only one vararg parameter") - - val argumentEntry = resolvedCall.getValueArguments().entrySet().iterator().next() - - val elementType = argumentEntry.getKey().getVarargElementType() ?: return null - - val result = arrayListOf() - for (valueArgument in argumentEntry.getValue().getArguments()) { - val valueArgumentExpression = valueArgument.getArgumentExpression() - if (valueArgumentExpression != null) { - result.add(valueArgumentExpression) - } - } - - return Pair, JetType>(result, elementType) - } - - private fun hasSpread(argument: ResolvedValueArgument): Boolean { - val arguments = argument.getArguments() - return arguments.size() == 1 && arguments.get(0).getSpreadElement() != null - } - - private fun resolveValueArguments( - resolvedValueArgument: ResolvedValueArgument, - expectedType: JetType, - trace: BindingTrace): List> { - val constants = Lists.newArrayList>() - for (argument in resolvedValueArgument.getArguments()) { - val argumentExpression = argument.getArgumentExpression() ?: continue - val constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType) - if (constant is IntegerValueTypeConstant) { - val defaultType = constant.getType(expectedType) - val context = SimpleResolutionContext(trace, JetScope.Empty, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, - ContextDependency.INDEPENDENT, - CompositeChecker(Lists.newArrayList()), - SymbolUsageValidator.Empty, - AdditionalTypeChecker.Composite(Lists.newArrayList()), - StatementFilter.NONE) - ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context) - } - if (constant != null) { - constants.add(constant) - } - checkCompileTimeConstant(argumentExpression, expectedType, trace) - } - return constants - } - platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { - val visitor = ConstantExpressionEvaluatorVisitor(trace, KotlinBuiltIns.getInstance()) - val constant = visitor.evaluate(expression, expectedType) ?: return null - return if (!constant.isError) constant else null + return ConstantExpressionEvaluator(KotlinBuiltIns.getInstance()).evaluateExpression(expression, trace, expectedType) } platformStatic public fun evaluateToConstantValue( @@ -212,7 +220,11 @@ public class ConstantExpressionEvaluator private constructor() { } } -private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace, private val builtIns: KotlinBuiltIns) : JetVisitor?, JetType>() { +private class ConstantExpressionEvaluatorVisitor( + private val constantExpressionEvaluator: ConstantExpressionEvaluator, + private val trace: BindingTrace, + private val builtIns: KotlinBuiltIns +) : JetVisitor?, JetType>() { private val factory = ConstantValueFactory(builtIns) fun evaluate(expression: JetExpression, expectedType: JetType?): CompileTimeConstant<*>? { @@ -572,7 +584,7 @@ private class ConstantExpressionEvaluatorVisitor(private val trace: BindingTrace if (DescriptorUtils.isAnnotationClass(classDescriptor)) { val descriptor = AnnotationDescriptorImpl( classDescriptor.getDefaultType(), - ConstantExpressionEvaluator.resolveAnnotationArguments(call, trace) + constantExpressionEvaluator.resolveAnnotationArguments(call, trace) ) return AnnotationValue(descriptor).wrap() } From 251ebc7ca8ee01d9b9dd87874783c2e10ca12766 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Thu, 16 Jul 2015 21:54:00 +0300 Subject: [PATCH 412/450] Inject ConstantExpressionEvaluator to some points of usage --- .../kotlin/resolve/calls/CallExpressionResolver.java | 6 ++++-- .../types/expressions/ValueParameterResolver.kt | 11 +++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index a2fc4c7b3c5..21447bd2e64 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -60,9 +60,11 @@ import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class CallExpressionResolver { private final CallResolver callResolver; + private final ConstantExpressionEvaluator constantExpressionEvaluator; - public CallExpressionResolver(@NotNull CallResolver callResolver) { + public CallExpressionResolver(@NotNull CallResolver callResolver, @NotNull ConstantExpressionEvaluator constantExpressionEvaluator) { this.callResolver = callResolver; + this.constantExpressionEvaluator = constantExpressionEvaluator; } private ExpressionTypingServices expressionTypingServices; @@ -367,7 +369,7 @@ public class CallExpressionResolver { context.trace.recordType(selectorExpression, selectorReturnType); } - CompileTimeConstant value = ConstantExpressionEvaluator.evaluate(expression, context.trace, context.expectedType); + CompileTimeConstant value = constantExpressionEvaluator.evaluateExpression(expression, context.trace, context.expectedType); if (value != null && value.getIsPure()) { return ExpressionTypingUtils.createCompileTimeConstantTypeInfo(value, expression, context); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt index 43706b62fb4..d71dd0935df 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ValueParameterResolver.kt @@ -19,17 +19,20 @@ package org.jetbrains.kotlin.types.expressions import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.psi.JetParameter -import org.jetbrains.kotlin.resolve.* +import org.jetbrains.kotlin.resolve.AdditionalCheckerProvider +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.DescriptorResolver +import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator import org.jetbrains.kotlin.types.TypeUtils public class ValueParameterResolver( private val additionalCheckerProvider: AdditionalCheckerProvider, - private val expressionTypingServices: ExpressionTypingServices + private val expressionTypingServices: ExpressionTypingServices, + private val constantExpressionEvaluator: ConstantExpressionEvaluator ) { public fun resolveValueParameters( valueParameters: List, @@ -66,7 +69,7 @@ public class ValueParameterResolver( val defaultValue = jetParameter.getDefaultValue() ?: return expressionTypingServices.getTypeInfo(defaultValue, context.replaceExpectedType(valueParameterDescriptor.getType())) if (DescriptorUtils.isAnnotationClass(DescriptorResolver.getContainingClass(context.scope))) { - ConstantExpressionEvaluator.evaluate(defaultValue, context.trace, valueParameterDescriptor.getType()) + constantExpressionEvaluator.evaluateExpression(defaultValue, context.trace, valueParameterDescriptor.getType()) ?: context.trace.report(Errors.ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT.on(defaultValue)) } } From aae8ccfd5794f76799717091d3167d4484e6018c Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 17 Jul 2015 15:35:03 +0300 Subject: [PATCH 413/450] Refactor: AnnotationSerializer does not depend on bultins --- .../codegen/JvmSerializerExtension.java | 3 +-- .../builtins/BuiltInsSerializer.kt | 2 +- .../evaluate/ConstantExpressionEvaluator.kt | 24 +++++++++++-------- .../serialization/AnnotationSerializer.kt | 5 ++-- .../builtins/BuiltInsSerializerExtension.kt | 12 +++------- .../resolve/constants/ConstantValueFactory.kt | 2 +- .../resolve/constants/constantValues.kt | 6 ++++- .../js/KotlinJavascriptSerializerExtension.kt | 3 +-- 8 files changed, 28 insertions(+), 29 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java index 5c30d9271c2..566e5b9426b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmSerializerExtension.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen; import com.intellij.openapi.util.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.codegen.state.JetTypeMapper; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; @@ -46,7 +45,7 @@ import static org.jetbrains.kotlin.codegen.JvmSerializationBindings.*; public class JvmSerializerExtension extends SerializerExtension { private final JvmSerializationBindings bindings; private final JetTypeMapper typeMapper; - private final AnnotationSerializer annotationSerializer = new AnnotationSerializer(KotlinBuiltIns.getInstance()); + private final AnnotationSerializer annotationSerializer = new AnnotationSerializer(); public JvmSerializerExtension(@NotNull JvmSerializationBindings bindings, @NotNull JetTypeMapper typeMapper) { this.bindings = bindings; diff --git a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt index 49b048795e6..cbb9c3cbcf7 100644 --- a/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt +++ b/compiler/builtins-serializer/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializer.kt @@ -113,7 +113,7 @@ public class BuiltInsSerializer(private val dependOnOldBuiltIns: Boolean) { // TODO: perform some kind of validation? At the moment not possible because DescriptorValidator is in compiler-tests // DescriptorValidator.validate(packageView) - val serializer = DescriptorSerializer.createTopLevel(BuiltInsSerializerExtension(module)) + val serializer = DescriptorSerializer.createTopLevel(BuiltInsSerializerExtension()) val classifierDescriptors = DescriptorSerializer.sort(packageView.memberScope.getDescriptors(DescriptorKindFilter.CLASSIFIERS)) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index c09f3bae657..f51e8a89030 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -52,7 +52,10 @@ import java.math.BigInteger import java.util.HashMap import kotlin.platform.platformStatic -public class ConstantExpressionEvaluator(private val builtIns: KotlinBuiltIns) { +public class ConstantExpressionEvaluator( + internal val constantValueFactory: ConstantValueFactory, + internal val builtIns: KotlinBuiltIns +) { internal fun resolveAnnotationArguments( resolvedCall: ResolvedCall<*>, @@ -82,7 +85,7 @@ public class ConstantExpressionEvaluator(private val builtIns: KotlinBuiltIns) { if (argumentsAsVararg) { if (parameterDescriptor.declaresDefaultValue() && compileTimeConstants.isEmpty()) return null - return ArrayValue(constants, parameterDescriptor.getType()) + return constantValueFactory.createArrayValue(constants, parameterDescriptor.getType()) } else { // we should actually get only one element, but just in case of getting many, we take the last one @@ -191,14 +194,15 @@ public class ConstantExpressionEvaluator(private val builtIns: KotlinBuiltIns) { trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE ): CompileTimeConstant<*>? { - val visitor = ConstantExpressionEvaluatorVisitor(this, trace, builtIns) + val visitor = ConstantExpressionEvaluatorVisitor(this, trace) val constant = visitor.evaluate(expression, expectedType) ?: return null return if (!constant.isError) constant else null } companion object { platformStatic public fun evaluate(expression: JetExpression, trace: BindingTrace, expectedType: JetType? = TypeUtils.NO_EXPECTED_TYPE): CompileTimeConstant<*>? { - return ConstantExpressionEvaluator(KotlinBuiltIns.getInstance()).evaluateExpression(expression, trace, expectedType) + val builtIns = KotlinBuiltIns.getInstance() + return ConstantExpressionEvaluator(ConstantValueFactory(builtIns), builtIns).evaluateExpression(expression, trace, expectedType) } platformStatic public fun evaluateToConstantValue( @@ -222,10 +226,10 @@ public class ConstantExpressionEvaluator(private val builtIns: KotlinBuiltIns) { private class ConstantExpressionEvaluatorVisitor( private val constantExpressionEvaluator: ConstantExpressionEvaluator, - private val trace: BindingTrace, - private val builtIns: KotlinBuiltIns + private val trace: BindingTrace ) : JetVisitor?, JetType>() { - private val factory = ConstantValueFactory(builtIns) + + private val factory = constantExpressionEvaluator.constantValueFactory fun evaluate(expression: JetExpression, expectedType: JetType?): CompileTimeConstant<*>? { val recordedCompileTimeConstant = ConstantExpressionEvaluator.getPossiblyErrorConstant(expression, trace.getBindingContext()) @@ -258,7 +262,7 @@ private class ConstantExpressionEvaluatorVisitor( override fun visitStringTemplateEntryWithExpression(entry: JetStringTemplateEntryWithExpression, data: Nothing?): TypedCompileTimeConstant? { val expression = entry.getExpression() ?: return null - return evaluate(expression, builtIns.getStringType())?.let { + return evaluate(expression, constantExpressionEvaluator.builtIns.getStringType())?.let { createStringConstant(it) } } @@ -340,7 +344,7 @@ private class ConstantExpressionEvaluatorVisitor( val operationToken = expression.getOperationToken() if (OperatorConventions.BOOLEAN_OPERATIONS.containsKey(operationToken)) { - val booleanType = builtIns.getBooleanType() + val booleanType = constantExpressionEvaluator.builtIns.getBooleanType() val leftConstant = evaluate(leftExpression, booleanType) if (leftConstant == null) return null @@ -572,7 +576,7 @@ private class ConstantExpressionEvaluatorVisitor( val arguments = call.getValueArguments().values().flatMap { resolveArguments(it.getArguments(), varargType) } - return ArrayValue(arguments.map { it.toConstantValue(varargType) }, resultingDescriptor.getReturnType()!!). + return factory.createArrayValue(arguments.map { it.toConstantValue(varargType) }, resultingDescriptor.getReturnType()!!). wrap( usesVariableAsConstant = arguments.any { it.usesVariableAsConstant } ) diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt index e47482a3466..fb56b522f35 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/AnnotationSerializer.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.serialization -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationArgumentVisitor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor @@ -26,7 +25,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.Argument.Value.Typ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType -public class AnnotationSerializer(builtIns: KotlinBuiltIns) { +public class AnnotationSerializer() { public fun serializeAnnotation(annotation: AnnotationDescriptor, stringTable: StringTable): ProtoBuf.Annotation { return with(ProtoBuf.Annotation.newBuilder()) { @@ -59,7 +58,7 @@ public class AnnotationSerializer(builtIns: KotlinBuiltIns) { override fun visitArrayValue(value: ArrayValue, data: Unit) { setType(Type.ARRAY) for (element in value.value) { - addArrayElement(valueProto(element, KotlinBuiltIns.getInstance().getArrayElementType(type), nameTable).build()) + addArrayElement(valueProto(element, value.elementType, nameTable).build()) } } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt index 73f22d9608e..623a46d10ed 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/builtins/BuiltInsSerializerExtension.kt @@ -16,20 +16,14 @@ package org.jetbrains.kotlin.serialization.builtins -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.resolve.constants.NullValue -import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.serialization.AnnotationSerializer -import org.jetbrains.kotlin.serialization.DescriptorSerializer -import org.jetbrains.kotlin.serialization.ProtoBuf -import org.jetbrains.kotlin.serialization.SerializerExtension -import org.jetbrains.kotlin.serialization.StringTable +import org.jetbrains.kotlin.serialization.* -public class BuiltInsSerializerExtension(module: ModuleDescriptor) : SerializerExtension() { +public class BuiltInsSerializerExtension() : SerializerExtension() { - private val annotationSerializer = AnnotationSerializer(module.builtIns) + private val annotationSerializer = AnnotationSerializer() override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) { for (annotation in descriptor.getAnnotations()) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt index fddef729080..6fab30172fb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/ConstantValueFactory.kt @@ -52,7 +52,7 @@ public class ConstantValueFactory( fun createArrayValue( value: List>, type: JetType - ) = ArrayValue(value, type) + ) = ArrayValue(value, type, builtins) fun createAnnotationValue(value: AnnotationDescriptor) = AnnotationValue(value) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt index aa46776f23f..3122f021ebe 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt @@ -46,7 +46,8 @@ public class AnnotationValue(value: AnnotationDescriptor) : ConstantValue>, - override val type: JetType + override val type: JetType, + private val builtIns: KotlinBuiltIns ) : ConstantValue>>(value) { init { @@ -55,6 +56,9 @@ public class ArrayValue( override fun accept(visitor: AnnotationArgumentVisitor, data: D) = visitor.visitArrayValue(this, data) + public val elementType: JetType + get() = builtIns.getArrayElementType(type) + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index 2f7271c7281..1d260058e72 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.serialization.js -import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor @@ -30,7 +29,7 @@ import org.jetbrains.kotlin.types.JetType public object KotlinJavascriptSerializerExtension : SerializerExtension() { - private val annotationSerializer = AnnotationSerializer(KotlinBuiltIns.getInstance()) + private val annotationSerializer = AnnotationSerializer() override fun serializeClass(descriptor: ClassDescriptor, proto: ProtoBuf.Class.Builder, stringTable: StringTable) { for (annotation in descriptor.getAnnotations()) { From b2b8f1aabb015a03461ac47b892e522b5001c948 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 17 Jul 2015 19:20:57 +0300 Subject: [PATCH 414/450] Minor: prettify converted code a little bit --- .../evaluate/ConstantExpressionEvaluator.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index f51e8a89030..63b80d5aa04 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.resolve.constants.evaluate -import com.google.common.collect.Lists import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.JetNodeTypes import org.jetbrains.kotlin.builtins.KotlinBuiltIns @@ -33,7 +32,6 @@ import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker -import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CompositeChecker import org.jetbrains.kotlin.resolve.calls.context.ContextDependency import org.jetbrains.kotlin.resolve.calls.context.SimpleResolutionContext @@ -49,6 +47,7 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.expressions.OperatorConventions import java.math.BigInteger +import java.util.ArrayList import java.util.HashMap import kotlin.platform.platformStatic @@ -141,9 +140,7 @@ public class ConstantExpressionEvaluator( return null } - assert(resolvedCall.getValueArguments().size() == 1, "Array function should have only one vararg parameter") - - val argumentEntry = resolvedCall.getValueArguments().entrySet().iterator().next() + val argumentEntry = resolvedCall.getValueArguments().entrySet().single() val elementType = argumentEntry.getKey().getVarargElementType() ?: return null @@ -167,7 +164,7 @@ public class ConstantExpressionEvaluator( resolvedValueArgument: ResolvedValueArgument, expectedType: JetType, trace: BindingTrace): List> { - val constants = Lists.newArrayList>() + val constants = ArrayList>() for (argument in resolvedValueArgument.getArguments()) { val argumentExpression = argument.getArgumentExpression() ?: continue val constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType) @@ -175,9 +172,9 @@ public class ConstantExpressionEvaluator( val defaultType = constant.getType(expectedType) val context = SimpleResolutionContext(trace, JetScope.Empty, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, ContextDependency.INDEPENDENT, - CompositeChecker(Lists.newArrayList()), + CompositeChecker(emptyList()), SymbolUsageValidator.Empty, - AdditionalTypeChecker.Composite(Lists.newArrayList()), + AdditionalTypeChecker.Composite(emptyList()), StatementFilter.NONE) ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context) } From 71b406d792c9b1faafd415ce2e2d81357ddfd591 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Thu, 16 Jul 2015 15:29:19 +0300 Subject: [PATCH 415/450] Fix class kind detector: prioritize enum over annotations. Introduce new error about enum annotations classes. --- .../jetbrains/kotlin/psi/JetClassOrObject.kt | 14 +++-- .../kotlin/resolve/DeclarationsChecker.java | 13 +++-- .../resolve/lazy/data/JetClassInfo.java | 12 ++-- .../tests/enum/enumWithAnnotationKeyword.kt | 3 + .../tests/enum/enumWithAnnotationKeyword.txt | 27 +++++++++ .../testData/psi/EnumWithAnnotationKeyword.kt | 3 + .../psi/EnumWithAnnotationKeyword.txt | 35 ++++++++++++ .../testData/psi/InterfaceWithEnumKeyword.kt | 7 +++ .../testData/psi/InterfaceWithEnumKeyword.txt | 57 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++ .../parsing/JetParsingTestGenerated.java | 12 ++++ 11 files changed, 173 insertions(+), 16 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt create mode 100644 compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt create mode 100644 compiler/testData/psi/EnumWithAnnotationKeyword.kt create mode 100644 compiler/testData/psi/EnumWithAnnotationKeyword.txt create mode 100644 compiler/testData/psi/InterfaceWithEnumKeyword.kt create mode 100644 compiler/testData/psi/InterfaceWithEnumKeyword.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt index e41a4a0e9f1..ccd7a473169 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetClassOrObject.kt @@ -66,15 +66,17 @@ abstract public class JetClassOrObject : JetTypeParameterListOwnerStub = getBody()?.getSecondaryConstructors().orEmpty() deprecated(value = "It's no more possible to determine it exactly using AST. Use ClassDescriptor methods instead, e.g. getKind()") - public fun isAnnotation(): Boolean = hasAnnotation(KotlinBuiltIns.FQ_NAMES.annotation.shortName().asString()) + public fun isAnnotation(): Boolean = getBuiltInAnnotationEntry() != null - private fun hasAnnotation(name: String): Boolean { - for (entry in getAnnotationEntries()) { + public fun getBuiltInAnnotationEntry(): JetAnnotationEntry? = getAnnotation(KotlinBuiltIns.FQ_NAMES.annotation.shortName().asString()) + + private fun getAnnotation(name: String): JetAnnotationEntry? { + return getAnnotationEntries().firstOrNull() { entry -> val typeReference = entry.getTypeReference() - val userType = typeReference?.getStubOrPsiChild(JetStubElementTypes.USER_TYPE) ?: continue - if (name == userType.getReferencedName()) return true + val userType = typeReference?.getStubOrPsiChild(JetStubElementTypes.USER_TYPE) + + name == userType?.getReferencedName() } - return false } public override fun delete() { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index 0ef598639a6..d79a2ce185b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -254,15 +254,20 @@ public class DeclarationsChecker { checkTraitModifiers(aClass); checkConstructorInTrait(aClass); } - else if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { - checkAnnotationClassWithBody(aClass); - checkValOnAnnotationParameter(aClass); - } else if (aClass.isEnum()) { checkEnumModifiers(aClass); if (aClass.isLocal()) { trace.report(LOCAL_ENUM_NOT_ALLOWED.on(aClass, classDescriptor)); } + if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { + JetAnnotationEntry entry = aClass.getBuiltInAnnotationEntry(); + assert entry != null : "getBuiltinAnnotationEntry() should be synchronized with isAnnotation()"; + trace.report(WRONG_ANNOTATION_TARGET.on(entry, "enum class")); + } + } + else if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { + checkAnnotationClassWithBody(aClass); + checkValOnAnnotationParameter(aClass); } else if (aClass.hasModifier(JetTokens.SEALED_KEYWORD)) { checkSealedModifiers(aClass); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/JetClassInfo.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/JetClassInfo.java index 2e5d0a5898d..5c8e8ff6215 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/JetClassInfo.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/data/JetClassInfo.java @@ -19,9 +19,9 @@ package org.jetbrains.kotlin.resolve.lazy.data; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.ClassKind; -import org.jetbrains.kotlin.psi.*; - -import java.util.List; +import org.jetbrains.kotlin.psi.JetClass; +import org.jetbrains.kotlin.psi.JetEnumEntry; +import org.jetbrains.kotlin.psi.JetTypeParameterList; public class JetClassInfo extends JetClassOrObjectInfo { private final ClassKind kind; @@ -34,12 +34,12 @@ public class JetClassInfo extends JetClassOrObjectInfo { else if (element.isInterface()) { this.kind = ClassKind.INTERFACE; } - else if (element.isAnnotation()) { - this.kind = ClassKind.ANNOTATION_CLASS; - } else if (element.isEnum()) { this.kind = ClassKind.ENUM_CLASS; } + else if (element.isAnnotation()) { + this.kind = ClassKind.ANNOTATION_CLASS; + } else { this.kind = ClassKind.CLASS; } diff --git a/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt new file mode 100644 index 00000000000..2405fd9523a --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt @@ -0,0 +1,3 @@ +data annotation enum class E { + D +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt new file mode 100644 index 00000000000..68956113db3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.txt @@ -0,0 +1,27 @@ +package + +kotlin.data() kotlin.annotation.annotation() internal final enum class E : kotlin.Enum { + public enum entry D : E { + private constructor D() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final override /*1*/ /*fake_override*/ fun copy(): E + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + private constructor E() + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final /*synthesized*/ fun copy(): E + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun name(): kotlin.String + public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/psi/EnumWithAnnotationKeyword.kt b/compiler/testData/psi/EnumWithAnnotationKeyword.kt new file mode 100644 index 00000000000..d0db8d9d964 --- /dev/null +++ b/compiler/testData/psi/EnumWithAnnotationKeyword.kt @@ -0,0 +1,3 @@ +data annotation enum class E { + D +} \ No newline at end of file diff --git a/compiler/testData/psi/EnumWithAnnotationKeyword.txt b/compiler/testData/psi/EnumWithAnnotationKeyword.txt new file mode 100644 index 00000000000..55d95c601bc --- /dev/null +++ b/compiler/testData/psi/EnumWithAnnotationKeyword.txt @@ -0,0 +1,35 @@ +JetFile: EnumWithAnnotationKeyword.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('data') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' ') + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('E') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('D') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/InterfaceWithEnumKeyword.kt b/compiler/testData/psi/InterfaceWithEnumKeyword.kt new file mode 100644 index 00000000000..1cca818e525 --- /dev/null +++ b/compiler/testData/psi/InterfaceWithEnumKeyword.kt @@ -0,0 +1,7 @@ +enum interface class E1 { + D +} + +interface enum class E2 { + D +} \ No newline at end of file diff --git a/compiler/testData/psi/InterfaceWithEnumKeyword.txt b/compiler/testData/psi/InterfaceWithEnumKeyword.txt new file mode 100644 index 00000000000..68312e43b83 --- /dev/null +++ b/compiler/testData/psi/InterfaceWithEnumKeyword.txt @@ -0,0 +1,57 @@ +JetFile: InterfaceWithEnumKeyword.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(interface)('interface') + PsiErrorElement:Name expected + + PsiWhiteSpace(' ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('E1') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('D') + PsiErrorElement:Expecting member declaration + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + PsiElement(interface)('interface') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('enum') + PsiWhiteSpace(' ') + CLASS + PsiElement(class)('class') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('E2') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('D') + PsiErrorElement:Expecting member declaration + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index c0dda0e8434..531d101c161 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -5133,6 +5133,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("enumWithAnnotationKeyword.kt") + public void testEnumWithAnnotationKeyword() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumWithAnnotationKeyword.kt"); + doTest(fileName); + } + @TestMetadata("enumWithEmptyName.kt") public void testEnumWithEmptyName() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumWithEmptyName.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java index c08487d9191..defaa843337 100644 --- a/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/parsing/JetParsingTestGenerated.java @@ -259,6 +259,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("EnumWithAnnotationKeyword.kt") + public void testEnumWithAnnotationKeyword() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/EnumWithAnnotationKeyword.kt"); + doParsingTest(fileName); + } + @TestMetadata("Enums.kt") public void testEnums() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Enums.kt"); @@ -415,6 +421,12 @@ public class JetParsingTestGenerated extends AbstractJetParsingTest { doParsingTest(fileName); } + @TestMetadata("InterfaceWithEnumKeyword.kt") + public void testInterfaceWithEnumKeyword() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/InterfaceWithEnumKeyword.kt"); + doParsingTest(fileName); + } + @TestMetadata("Labels.kt") public void testLabels() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/psi/Labels.kt"); From 9648338b19519e6b8b5f4d1a259b7cd11ae61d3a Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Tue, 14 Jul 2015 15:55:01 +0300 Subject: [PATCH 416/450] Enum with interface keywords leads to fail in DeclarationChecker --- .../kotlin/resolve/DeclarationsChecker.java | 41 +++++++++++-------- .../tests/enum/interfaceWithEnumKeyword.kt | 8 ++++ .../tests/enum/interfaceWithEnumKeyword.txt | 18 ++++++++ .../testData/psi/EnumWithAnnotationKeyword.kt | 4 ++ .../psi/EnumWithAnnotationKeyword.txt | 28 +++++++++++++ .../testData/psi/InterfaceWithEnumKeyword.kt | 4 ++ .../testData/psi/InterfaceWithEnumKeyword.txt | 17 ++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 +++ 8 files changed, 109 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.kt create mode 100644 compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index d79a2ce185b..b89e99b8bb5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -635,10 +635,6 @@ public class DeclarationsChecker { } private void checkEnumEntry(@NotNull JetEnumEntry enumEntry, @NotNull ClassDescriptor classDescriptor) { - DeclarationDescriptor declaration = classDescriptor.getContainingDeclaration(); - assert DescriptorUtils.isEnumClass(declaration) : "Enum entry should be declared in enum class: " + classDescriptor; - ClassDescriptor enumClass = (ClassDescriptor) declaration; - if (enumEntryUsesDeprecatedSuperConstructor(enumEntry)) { trace.report(Errors.ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR.on(enumEntry, classDescriptor)); } @@ -650,23 +646,34 @@ public class DeclarationsChecker { trace.report(Errors.ENUM_ENTRY_AFTER_ENUM_MEMBER.on(enumEntry, classDescriptor)); } - List delegationSpecifiers = enumEntry.getDelegationSpecifiers(); - ConstructorDescriptor constructor = enumClass.getUnsubstitutedPrimaryConstructor(); - if ((constructor == null || !constructor.getValueParameters().isEmpty()) && delegationSpecifiers.isEmpty()) { - trace.report(ENUM_ENTRY_SHOULD_BE_INITIALIZED.on(enumEntry, enumClass)); - } + DeclarationDescriptor declaration = classDescriptor.getContainingDeclaration(); + if (DescriptorUtils.isEnumClass(declaration)) { + ClassDescriptor enumClass = (ClassDescriptor) declaration; - for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) { - JetTypeReference typeReference = delegationSpecifier.getTypeReference(); - if (typeReference != null) { - JetType type = trace.getBindingContext().get(TYPE, typeReference); - if (type != null) { - JetType enumType = enumClass.getDefaultType(); - if (!type.getConstructor().equals(enumType.getConstructor())) { - trace.report(ENUM_ENTRY_ILLEGAL_TYPE.on(typeReference, enumClass)); + List delegationSpecifiers = enumEntry.getDelegationSpecifiers(); + ConstructorDescriptor constructor = enumClass.getUnsubstitutedPrimaryConstructor(); + if ((constructor == null || !constructor.getValueParameters().isEmpty()) && delegationSpecifiers.isEmpty()) { + trace.report(ENUM_ENTRY_SHOULD_BE_INITIALIZED.on(enumEntry, enumClass)); + } + + for (JetDelegationSpecifier delegationSpecifier : delegationSpecifiers) { + JetTypeReference typeReference = delegationSpecifier.getTypeReference(); + if (typeReference != null) { + JetType type = trace.getBindingContext().get(TYPE, typeReference); + if (type != null) { + JetType enumType = enumClass.getDefaultType(); + if (!type.getConstructor().equals(enumType.getConstructor())) { + trace.report(ENUM_ENTRY_ILLEGAL_TYPE.on(typeReference, enumClass)); + } } } } } + else { + assert DescriptorUtils.isTrait(declaration) : "Enum entry should be declared in enum class: " + + classDescriptor + " " + + classDescriptor.getKind(); + } } + } diff --git a/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.kt b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.kt new file mode 100644 index 00000000000..2bc34f6a387 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.kt @@ -0,0 +1,8 @@ +enum interface Some { + // Enum part + D + + // Interface like part + fun test() + val foo: Int +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.txt b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.txt new file mode 100644 index 00000000000..77763a6a677 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.txt @@ -0,0 +1,18 @@ +package + +internal interface Some { + public enum entry D : Some { + private constructor D() + internal abstract override /*1*/ /*fake_override*/ val foo: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal abstract override /*1*/ /*fake_override*/ fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + internal abstract val foo: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal abstract fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/psi/EnumWithAnnotationKeyword.kt b/compiler/testData/psi/EnumWithAnnotationKeyword.kt index d0db8d9d964..009686dd353 100644 --- a/compiler/testData/psi/EnumWithAnnotationKeyword.kt +++ b/compiler/testData/psi/EnumWithAnnotationKeyword.kt @@ -1,3 +1,7 @@ data annotation enum class E { D +} + +enum annotation E1 { + D } \ No newline at end of file diff --git a/compiler/testData/psi/EnumWithAnnotationKeyword.txt b/compiler/testData/psi/EnumWithAnnotationKeyword.txt index 55d95c601bc..7a124338c7f 100644 --- a/compiler/testData/psi/EnumWithAnnotationKeyword.txt +++ b/compiler/testData/psi/EnumWithAnnotationKeyword.txt @@ -32,4 +32,32 @@ JetFile: EnumWithAnnotationKeyword.kt OBJECT_DECLARATION_NAME PsiElement(IDENTIFIER)('D') PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + FUN + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('annotation') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('E1') + PsiErrorElement:Expecting a top level declaration + + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('D') + PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/InterfaceWithEnumKeyword.kt b/compiler/testData/psi/InterfaceWithEnumKeyword.kt index 1cca818e525..31ee2f6e2bc 100644 --- a/compiler/testData/psi/InterfaceWithEnumKeyword.kt +++ b/compiler/testData/psi/InterfaceWithEnumKeyword.kt @@ -4,4 +4,8 @@ enum interface class E1 { interface enum class E2 { D +} + +enum interface E3 { + D } \ No newline at end of file diff --git a/compiler/testData/psi/InterfaceWithEnumKeyword.txt b/compiler/testData/psi/InterfaceWithEnumKeyword.txt index 68312e43b83..a7700037e02 100644 --- a/compiler/testData/psi/InterfaceWithEnumKeyword.txt +++ b/compiler/testData/psi/InterfaceWithEnumKeyword.txt @@ -54,4 +54,21 @@ JetFile: InterfaceWithEnumKeyword.kt PsiErrorElement:Expecting member declaration PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n') + CLASS + MODIFIER_LIST + PsiElement(enum)('enum') + PsiWhiteSpace(' ') + PsiElement(interface)('interface') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('E3') + PsiWhiteSpace(' ') + CLASS_BODY + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + ENUM_ENTRY + OBJECT_DECLARATION_NAME + PsiElement(IDENTIFIER)('D') + PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 531d101c161..1563eeaba42 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -5193,6 +5193,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("interfaceWithEnumKeyword.kt") + public void testInterfaceWithEnumKeyword() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/interfaceWithEnumKeyword.kt"); + doTest(fileName); + } + @TestMetadata("isEnumEntry.kt") public void testIsEnumEntry() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/isEnumEntry.kt"); From f3c2de52878302496807fe42f4f1ee66b56ab2af Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 17 Jul 2015 02:08:35 +0300 Subject: [PATCH 417/450] Update to idea 142.3230.1 --- update_dependencies.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update_dependencies.xml b/update_dependencies.xml index 0061b12a04a..63d8cdec3ae 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -1,5 +1,5 @@ - + From cac62fe4c8b16be4c8abeedfc35b8d2a3f23e6fa Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 17 Jul 2015 13:56:36 +0300 Subject: [PATCH 418/450] Test fix after idea update --- .../changeSignature/JavaParameterPropagationAfter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java index 1fd062377c9..e3b2880e5f1 100644 --- a/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java +++ b/idea/testData/refactoring/changeSignature/JavaParameterPropagationAfter.java @@ -19,7 +19,7 @@ class B extends A { } public void bar(boolean b, int n, String s) { - foo(1, "abc"); + foo(n, s); } public void baz() { From 87e94aa20b1655df57897a8724cce2cb2936dd18 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Fri, 17 Jul 2015 14:02:16 +0300 Subject: [PATCH 419/450] Minor test data update after moving to new idea --- .../lambdaWithLambdaAsParam.kt.after | 2 +- .../lambdaWithLambdaAsParam.kt.after | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/testData/intentions/removeExplicitLambdaParameterTypes/lambdaWithLambdaAsParam.kt.after b/idea/testData/intentions/removeExplicitLambdaParameterTypes/lambdaWithLambdaAsParam.kt.after index 42d2af38748..1f9d8c45f46 100644 --- a/idea/testData/intentions/removeExplicitLambdaParameterTypes/lambdaWithLambdaAsParam.kt.after +++ b/idea/testData/intentions/removeExplicitLambdaParameterTypes/lambdaWithLambdaAsParam.kt.after @@ -4,5 +4,5 @@ public class TestingUse { } fun main() { - val funcInfunc = TestingUse().test6({ f -> f(5) > 20}, {x -> x + 2}) + val funcInfunc = TestingUse().test6({ f -> f(5) > 20}, { x -> x + 2}) } diff --git a/idea/testData/intentions/specifyExplicitLambdaSignature/lambdaWithLambdaAsParam.kt.after b/idea/testData/intentions/specifyExplicitLambdaSignature/lambdaWithLambdaAsParam.kt.after index 7b53a0a3306..f829687af69 100644 --- a/idea/testData/intentions/specifyExplicitLambdaSignature/lambdaWithLambdaAsParam.kt.after +++ b/idea/testData/intentions/specifyExplicitLambdaSignature/lambdaWithLambdaAsParam.kt.after @@ -4,5 +4,5 @@ public class TestingUse { } fun main() { - val funcInfunc = TestingUse().test6({ f: (Int) -> Int -> f(5) > 20}, {x -> x + 2}) + val funcInfunc = TestingUse().test6({ f: (Int) -> Int -> f(5) > 20}, { x -> x + 2}) } From 41aed73ebd16fd9dc64dc44aba5b11b635bfbec0 Mon Sep 17 00:00:00 2001 From: Alexey Sedunov Date: Fri, 17 Jul 2015 16:41:13 +0300 Subject: [PATCH 420/450] Find Usages: Copy options used for highlighting (to prevent spoiling of default search scope used in the full usage search) --- .../kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index 61cc0402e5b..71fb83e1c72 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -73,7 +73,7 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, override fun findReferencesToHighlight(target: PsiElement, searchScope: SearchScope): Collection { val results = ArrayList() - val options = getFindUsagesOptions() + val options = getFindUsagesOptions().clone() options.searchScope = searchScope searchReferences(target, object : Processor { override fun process(info: UsageInfo): Boolean { From 21ee2c1cfd7a2d4e08223d4730984581fa01a8ae Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 19 Jul 2015 14:06:04 +0300 Subject: [PATCH 421/450] Cleanup Array.plus usages after bootstrap. --- .../org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt | 2 +- .../kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt index 7191e796cc4..940897fd9a5 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/PropertyReferenceCodegen.kt @@ -172,7 +172,7 @@ public class PropertyReferenceCodegen( if (!target.isVar()) return - val setterParameters = (getterParameters + arrayOf(OBJECT_TYPE)).toList().toTypedArray() + val setterParameters = (getterParameters + arrayOf(OBJECT_TYPE)) generateAccessor(method("set", Type.VOID_TYPE, *setterParameters)) { value -> // Hard-coded 1 or 2 is safe here because there's only java/lang/Object in the signature, no double/long parameters value.store(StackValue.local(if (receiverType != null) 2 else 1, OBJECT_TYPE), this) diff --git a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt index 32b725b7929..69d4b94a0e7 100644 --- a/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/debugger/filter/DebuggerFiltersUtil.kt @@ -25,8 +25,7 @@ private val KOTLIN_STDLIB_FILTER = "kotlin.*" public fun addKotlinStdlibDebugFilterIfNeeded() { if (!KotlinDebuggerSettings.getInstance().DEBUG_IS_FILTER_FOR_STDLIB_ALREADY_ADDED) { val settings = DebuggerSettings.getInstance()!! - // TODO: Remove toList().toTypedArray() after bootstrap - val newFilters = (settings.getSteppingFilters() + ClassFilter(KOTLIN_STDLIB_FILTER)).toList().toTypedArray() + val newFilters = (settings.getSteppingFilters() + ClassFilter(KOTLIN_STDLIB_FILTER)) settings.setSteppingFilters(newFilters) From 3e231f2e44cc95cc653a655b0d9510ccaa394834 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 1 Jun 2015 22:58:02 +0300 Subject: [PATCH 422/450] Generalize run() scope function. #KT-5235 Fixed --- libraries/stdlib/src/kotlin/util/Standard.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index 7409886605a..aaf246af0a2 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -11,7 +11,12 @@ public fun A.to(that: B): Pair = Pair(this, that) /** * Calls the specified function. */ -public inline fun run(f: () -> T): T = f() +public inline fun run(f: () -> R): R = f() + +/** + * Calls the specified function with this value as its receiver. + */ +public inline fun T.run(f: T.() -> R): R = f() /** * Execute f with given receiver From 8a578a46f686b691320da2f7524f752fa573ee67 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 1 Jun 2015 23:53:50 +0300 Subject: [PATCH 423/450] Introduce apply() scope function. #KT-6903 Fixed --- libraries/stdlib/src/kotlin/util/Standard.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index aaf246af0a2..477b46c149b 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -23,6 +23,8 @@ public inline fun T.run(f: T.() -> R): R = f() */ public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() +public inline fun T.apply(f: T.() -> Unit): T { f(); return this } + /** * Converts receiver to body parameter */ From 18577256290ed136f4499db11ab9534213947501 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 17 Jul 2015 17:52:18 +0300 Subject: [PATCH 424/450] Unify documentation for scope functions. --- libraries/stdlib/src/kotlin/util/Standard.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/stdlib/src/kotlin/util/Standard.kt b/libraries/stdlib/src/kotlin/util/Standard.kt index 477b46c149b..6155ff3407d 100644 --- a/libraries/stdlib/src/kotlin/util/Standard.kt +++ b/libraries/stdlib/src/kotlin/util/Standard.kt @@ -9,23 +9,26 @@ package kotlin public fun A.to(that: B): Pair = Pair(this, that) /** - * Calls the specified function. + * Calls the specified function [f] and returns its result. */ public inline fun run(f: () -> R): R = f() /** - * Calls the specified function with this value as its receiver. + * Calls the specified function [f] with `this` value as its receiver and returns its result. */ public inline fun T.run(f: T.() -> R): R = f() /** - * Execute f with given receiver + * Calls the specified function [f] with the given [receiver] as its receiver and returns its result. */ public inline fun with(receiver: T, f: T.() -> R): R = receiver.f() +/** + * Calls the specified function [f] with `this` value as its receiver and returns `this` value. + */ public inline fun T.apply(f: T.() -> Unit): T { f(); return this } /** - * Converts receiver to body parameter + * Calls the specified function [f] with `this` value as its argument and returns its result. */ public inline fun T.let(f: (T) -> R): R = f(this) From 78b4c13d8fb4cc6c80e6a9b5edb9e30d32f6036c Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sat, 18 Jul 2015 01:05:22 +0300 Subject: [PATCH 425/450] apply() got to smart completion where `this` was expected. --- idea/idea-completion/testData/weighers/smart/SmartPriority.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/idea/idea-completion/testData/weighers/smart/SmartPriority.kt b/idea/idea-completion/testData/weighers/smart/SmartPriority.kt index 6db78fb1537..e207c075655 100644 --- a/idea/idea-completion/testData/weighers/smart/SmartPriority.kt +++ b/idea/idea-completion/testData/weighers/smart/SmartPriority.kt @@ -16,6 +16,7 @@ class C { // ORDER: nullableFoo // ORDER: this // ORDER: local +// ORDER: apply // ORDER: nonNullable // ORDER: nullableX // ORDER: nullableX From 973fa21fe99f9a531cc088d9a0d7c1c3ea5ad2db Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Mon, 20 Jul 2015 12:36:24 +0300 Subject: [PATCH 426/450] Include snappy-in-java-0.3.1.jar in kotlin-compiler --- compiler/compiler.pro | 1 - update_dependencies.xml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/compiler.pro b/compiler/compiler.pro index fa96e072b9c..bb7697b895f 100644 --- a/compiler/compiler.pro +++ b/compiler/compiler.pro @@ -30,7 +30,6 @@ messages/**) -dontwarn org.xerial.snappy.SnappyBundleActivator -dontwarn com.intellij.util.CompressionUtil -dontwarn com.intellij.util.SnappyInitializer --dontwarn org.iq80.snappy.Snappy -dontwarn net.sf.cglib.** -dontwarn org.objectweb.asm.** # this is ASM3, the old version that we do not use diff --git a/update_dependencies.xml b/update_dependencies.xml index 63d8cdec3ae..3c79eb3682b 100644 --- a/update_dependencies.xml +++ b/update_dependencies.xml @@ -692,6 +692,7 @@ + From 3718a7dd44267a973a5086ec7d9b05be145d59b1 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 20 Jul 2015 18:03:05 +0200 Subject: [PATCH 427/450] code cleanup for JS modules --- .../src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt | 2 +- .../js/resolve/diagnostics/DefaultErrorMessagesJs.kt | 2 +- .../jetbrains/kotlin/js/inline/ExpressionDecomposer.kt | 2 +- .../jetbrains/kotlin/js/inline/FunctionInlineMutator.kt | 4 ++-- .../kotlin/js/inline/clean/removeDefaultInitializers.kt | 2 +- .../jetbrains/kotlin/js/inline/context/FunctionContext.kt | 2 +- .../jetbrains/kotlin/js/inline/context/InliningContext.kt | 2 +- .../jetbrains/kotlin/js/inline/util/invocationUtils.kt | 4 ++-- .../kotlin/serialization/js/ClassSerializationUtil.kt | 2 +- .../kotlin/js/translate/callTranslator/CallInfo.kt | 8 ++++---- .../js/translate/callTranslator/CallInfoExtensions.kt | 2 +- .../kotlin/js/translate/callTranslator/CallTranslator.kt | 8 ++++---- .../kotlin/js/translate/declaration/FileDeclaration.kt | 2 +- .../translate/expression/MultiDeclarationTranslator.java | 2 +- .../js/translate/intrinsic/objects/objectsIntrinsics.kt | 2 +- .../intrinsic/operation/binaryOperationIntrinsics.kt | 4 ++-- .../operation/OverloadedAssignmentTranslator.java | 2 +- .../operation/OverloadedIncrementTranslator.java | 2 +- .../js/translate/operation/UnaryOperationTranslator.java | 2 +- .../js/translate/reference/ArrayAccessTranslator.java | 2 +- .../js/translate/reference/CallArgumentTranslator.kt | 6 +++--- .../js/translate/reference/CallExpressionTranslator.java | 2 +- .../org/jetbrains/kotlin/js/translate/utils/PsiUtils.java | 2 +- 23 files changed, 34 insertions(+), 34 deletions(-) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt index 1f0aa70c6f0..c7a3ae65c42 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt @@ -30,6 +30,6 @@ public enum class PredefinedAnnotation(fqName: String) { companion object { // TODO: replace with straight assignment when KT-5761 will be fixed - val WITH_CUSTOM_NAME by Delegates.lazy { setOf(LIBRARY, NATIVE) } + val WITH_CUSTOM_NAME by lazy { setOf(LIBRARY, NATIVE) } } } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt index d36ed24be5b..8a55776e65c 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap import org.jetbrains.kotlin.diagnostics.rendering.Renderers import kotlin.properties.Delegates -private val DIAGNOSTIC_FACTORY_TO_RENDERER by Delegates.lazy { +private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy { with(DiagnosticFactoryToRendererMap()) { put(ErrorsJs.NATIVE_ANNOTATIONS_ALLOWED_ONLY_ON_MEMBER_OR_EXTENSION_FUN, diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt index c32c8037caf..fa61a61fb26 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt @@ -324,7 +324,7 @@ class ExpressionDecomposer private constructor( private inner class Temporary(val value: JsExpression? = null) { val name: JsName = scope.declareTemporary() - val variable: JsVars by Delegates.lazy { + val variable: JsVars by lazy { newVar(name, value) } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionInlineMutator.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionInlineMutator.kt index 23504491288..b77f5d82c33 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionInlineMutator.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionInlineMutator.kt @@ -74,13 +74,13 @@ private constructor( var thisReplacement = getThisReplacement(call) if (thisReplacement == null || thisReplacement is JsLiteral.JsThisRef) return - if (thisReplacement!!.needToAlias()) { + if (thisReplacement.needToAlias()) { val thisName = namingContext.getFreshName(getThisAlias()) namingContext.newVar(thisName, thisReplacement) thisReplacement = thisName.makeRef() } - replaceThisReference(body, thisReplacement!!) + replaceThisReference(body, thisReplacement) } private fun removeStatementsAfterTopReturn() { diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeDefaultInitializers.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeDefaultInitializers.kt index 081abe92ef6..192094d6ad7 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeDefaultInitializers.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/clean/removeDefaultInitializers.kt @@ -97,7 +97,7 @@ private fun isNameInitialized( val expr = (lastThenStmt as? JsExpressionStatement)?.getExpression() if (expr !is JsBinaryOperation) return false - val op = expr.getOperator()!! + val op = expr.getOperator() if (!op.isAssignment()) return false val arg1 = expr.getArg1() diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/FunctionContext.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/FunctionContext.kt index 7b46a926b60..a9337127d60 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/FunctionContext.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/FunctionContext.kt @@ -121,7 +121,7 @@ abstract class FunctionContext( /** in case 4, 5 get ref (reduce 4, 5 to 2, 3 accordingly) */ if (callQualifier is JsNameRef) { - val staticRef = (callQualifier as JsNameRef).getName()?.staticRef + val staticRef = callQualifier.getName()?.staticRef callQualifier = when (staticRef) { is JsNameRef -> staticRef diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/InliningContext.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/InliningContext.kt index a7eccc37387..6cf196b0c3e 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/InliningContext.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/context/InliningContext.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.js.inline.context import com.google.dart.compiler.backend.js.ast.JsContext import com.google.dart.compiler.backend.js.ast.JsStatement -trait InliningContext { +interface InliningContext { public val statementContext: JsContext public val functionContext: FunctionContext diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/invocationUtils.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/invocationUtils.kt index 337ade0890c..ec6199d3caa 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/invocationUtils.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/invocationUtils.kt @@ -47,14 +47,14 @@ public fun getSimpleIdent(call: JsInvocation): String? { qualifiers@ while (qualifier != null) { when (qualifier) { is JsInvocation -> { - val callableQualifier = qualifier as JsInvocation + val callableQualifier = qualifier qualifier = callableQualifier.getQualifier() if (isCallInvocation(callableQualifier)) { qualifier = (qualifier as? JsNameRef)?.getQualifier() } } - is HasName -> return (qualifier as HasName).getName()?.getIdent() + is HasName -> return qualifier.getName()?.getIdent() else -> break@qualifiers } } diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt index 2c3ca566442..efa03d072ed 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/ClassSerializationUtil.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer import org.jetbrains.kotlin.serialization.ProtoBuf public object ClassSerializationUtil { - public trait Sink { + public interface Sink { fun writeClass(classDescriptor: ClassDescriptor, classProto: ProtoBuf.Class) } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt index ebedcd05af7..1ccae4fe2a7 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfo.kt @@ -32,7 +32,7 @@ import com.google.dart.compiler.backend.js.ast.JsLiteral import com.google.dart.compiler.backend.js.ast.JsConditional import com.google.dart.compiler.backend.js.ast.JsBlock -trait CallInfo { +interface CallInfo { val context: TranslationContext val resolvedCall: ResolvedCall @@ -87,7 +87,7 @@ fun TranslationContext.getCallInfo(resolvedCall: ResolvedCall { notNullConditional = TranslationUtils.notNullConditional(extensionReceiver!!, JsLiteral.NULL, this) - extensionReceiver = notNullConditional!!.getThenExpression() + extensionReceiver = notNullConditional.getThenExpression() } else -> { notNullConditional = TranslationUtils.notNullConditional(dispatchReceiver!!, JsLiteral.NULL, this) - dispatchReceiver = notNullConditional!!.getThenExpression() + dispatchReceiver = notNullConditional.getThenExpression() } } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt index 7560e306f60..da728341415 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallInfoExtensions.kt @@ -59,7 +59,7 @@ fun VariableAccessInfo.getAccessFunctionName(): String { return context.getNameForDescriptor(propertyAccessorDescriptor!!).getIdent() } else { - return Namer.getNameForAccessor(variableName.getIdent()!!, isGetAccess(), false) + return Namer.getNameForAccessor(variableName.getIdent(), isGetAccess(), false) } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt index ffb71b7b279..8400503a556 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/callTranslator/CallTranslator.kt @@ -154,7 +154,7 @@ fun computeExplicitReceiversForInvoke( } } -trait CallCase { +interface CallCase { protected fun I.unsupported(message: String = "") : Nothing = throw IllegalStateException("this case unsupported. $this") @@ -183,11 +183,11 @@ trait CallCase { } } -trait FunctionCallCase : CallCase +interface FunctionCallCase : CallCase -trait VariableAccessCase : CallCase +interface VariableAccessCase : CallCase -trait DelegateIntrinsic { +interface DelegateIntrinsic { fun I.canBeApply(): Boolean = true fun I.getDescriptor(): CallableDescriptor fun I.getArgs(): List diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/FileDeclaration.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/FileDeclaration.kt index 937600e9e31..4d9aa5d1148 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/FileDeclaration.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/FileDeclaration.kt @@ -39,7 +39,7 @@ class FileDeclarationVisitor( private val initializer = JsAstUtils.createFunctionWithEmptyBody(context.scope()) private val initializerContext = context.contextWithScope(initializer) - private val initializerStatements = initializer.getBody()!!.getStatements()!! + private val initializerStatements = initializer.getBody().getStatements() private val initializerVisitor = InitializerVisitor(initializerStatements) fun computeInitializer(): JsFunction? { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/MultiDeclarationTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/MultiDeclarationTranslator.java index 81a07830247..d98c0bbb095 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/MultiDeclarationTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/expression/MultiDeclarationTranslator.java @@ -82,7 +82,7 @@ public class MultiDeclarationTranslator extends AbstractTranslator { for (JetMultiDeclarationEntry entry : multiDeclaration.getEntries()) { ResolvedCall entryInitCall = context().bindingContext().get(BindingContext.COMPONENT_RESOLVED_CALL, entry); assert entryInitCall != null : "Entry init call must be not null"; - JsExpression entryInitializer = CallTranslator.INSTANCE$.translate(context(), entryInitCall, multiObjNameRef); + JsExpression entryInitializer = CallTranslator.translate(context(), entryInitCall, multiObjNameRef); FunctionDescriptor candidateDescriptor = entryInitCall.getCandidateDescriptor(); if (CallExpressionTranslator.shouldBeInlined(candidateDescriptor)) { setInlineCallMetadata(entryInitializer, entry, entryInitCall, context()); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt index 50ab97646e8..2040087319f 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt @@ -46,7 +46,7 @@ public class ObjectIntrinsics { } } -public trait ObjectIntrinsic { +public interface ObjectIntrinsic { fun apply(context: TranslationContext): JsExpression fun exists(): Boolean = true } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/operation/binaryOperationIntrinsics.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/operation/binaryOperationIntrinsics.kt index c2fa42d5cba..135187f6467 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/operation/binaryOperationIntrinsics.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/operation/binaryOperationIntrinsics.kt @@ -26,7 +26,7 @@ import gnu.trove.THashMap import com.google.dart.compiler.backend.js.ast.JsExpression import com.google.common.collect.ImmutableSet -public trait BinaryOperationIntrinsic { +public interface BinaryOperationIntrinsic { fun apply(expression: JetBinaryExpression, left: JsExpression, right: JsExpression, context: TranslationContext): JsExpression @@ -71,7 +71,7 @@ public class BinaryOperationIntrinsics { } } -trait BinaryOperationIntrinsicFactory { +interface BinaryOperationIntrinsicFactory { public fun getSupportTokens(): ImmutableSet diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedAssignmentTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedAssignmentTranslator.java index b40f6b10e23..964be2b7ff2 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedAssignmentTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedAssignmentTranslator.java @@ -57,6 +57,6 @@ public final class OverloadedAssignmentTranslator extends AssignmentTranslator { @NotNull private JsExpression overloadedMethodInvocation() { - return CallTranslator.INSTANCE$.translate(context(), resolvedCall, accessTranslator.translateAsGet()); + return CallTranslator.translate(context(), resolvedCall, accessTranslator.translateAsGet()); } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedIncrementTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedIncrementTranslator.java index 5b45c120384..390d31a538a 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedIncrementTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/OverloadedIncrementTranslator.java @@ -42,7 +42,7 @@ public final class OverloadedIncrementTranslator extends IncrementTranslator { @Override @NotNull protected JsExpression operationExpression(@NotNull JsExpression receiver) { - return CallTranslator.INSTANCE$.translate(context(), resolvedCall, receiver); + return CallTranslator.translate(context(), resolvedCall, receiver); } } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java index ac8f2397703..73b1e1ced05 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/operation/UnaryOperationTranslator.java @@ -82,7 +82,7 @@ public final class UnaryOperationTranslator { } ResolvedCall resolvedCall = getFunctionResolvedCallWithAssert(expression, context.bindingContext()); - return CallTranslator.INSTANCE$.translate(context, resolvedCall, baseExpression); + return CallTranslator.translate(context, resolvedCall, baseExpression); } private static boolean isExclForBinaryEqualLikeExpr(@NotNull JetUnaryExpression expression, @NotNull JsExpression baseExpression) { diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ArrayAccessTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ArrayAccessTranslator.java index c3f8fa03a4b..4e79ee539f0 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ArrayAccessTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ArrayAccessTranslator.java @@ -82,7 +82,7 @@ public class ArrayAccessTranslator extends AbstractTranslator implements AccessT if (!isGetter) { context = contextWithValueParameterAliasInArrayGetAccess(toSetTo); } - return CallTranslator.INSTANCE$.translate(context, resolvedCall, arrayExpression); + return CallTranslator.translate(context, resolvedCall, arrayExpression); } @NotNull diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt index dc22d6a8c7a..9a6a2a01d69 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallArgumentTranslator.kt @@ -150,14 +150,14 @@ public class CallArgumentTranslator private constructor( concatArguments!!.addAll(result) if (!argsBeforeVararg!!.isEmpty()) { - concatArguments!!.add(0, JsArrayLiteral(argsBeforeVararg)) + concatArguments.add(0, JsArrayLiteral(argsBeforeVararg)) } - result = SmartList(concatArgumentsIfNeeded(concatArguments!!)) + result = SmartList(concatArgumentsIfNeeded(concatArguments)) if (receiver != null) { cachedReceiver = context().getOrDeclareTemporaryConstVariable(receiver) - result.add(0, cachedReceiver!!.reference()) + result.add(0, cachedReceiver.reference()) } else { result.add(0, JsLiteral.NULL) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java index 950d877fed8..235ff76853d 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallExpressionTranslator.java @@ -97,7 +97,7 @@ public final class CallExpressionTranslator extends AbstractCallExpressionTransl @NotNull private JsExpression translate() { - return CallTranslator.INSTANCE$.translate(context(), resolvedCall, receiver); + return CallTranslator.translate(context(), resolvedCall, receiver); } @NotNull diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java index 62cc3b86bf3..67e695c204c 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/PsiUtils.java @@ -119,7 +119,7 @@ public final class PsiUtils { @NotNull public static List getPrimaryConstructorParameters(@NotNull JetClassOrObject classDeclaration) { if (classDeclaration instanceof JetClass) { - return ((JetClass) classDeclaration).getPrimaryConstructorParameters(); + return classDeclaration.getPrimaryConstructorParameters(); } return Collections.emptyList(); } From 708513ce4cf260345afb2a65d20fe35c64713e88 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 20 Jul 2015 18:16:29 +0200 Subject: [PATCH 428/450] optimize imports --- .../js/resolve/diagnostics/DefaultErrorMessagesJs.kt | 1 - .../org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt index 8a55776e65c..23be132b183 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/resolve/diagnostics/DefaultErrorMessagesJs.kt @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.js.resolve.diagnostics import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap import org.jetbrains.kotlin.diagnostics.rendering.Renderers -import kotlin.properties.Delegates private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy { with(DiagnosticFactoryToRendererMap()) { diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt index fa61a61fb26..9f7dafd40c1 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/ExpressionDecomposer.kt @@ -17,15 +17,10 @@ package org.jetbrains.kotlin.js.inline.util import com.google.dart.compiler.backend.js.ast.* -import com.google.dart.compiler.backend.js.ast.metadata.* +import com.intellij.util.SmartList import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.* import org.jetbrains.kotlin.js.translate.utils.jsAstUtils.* - import kotlin.platform.platformStatic -import kotlin.properties.Delegates - -import com.intellij.util.SmartList -import org.jetbrains.kotlin.js.translate.context.Namer /** * If inline function consists of multiple statements, From 7192bc8798be42cdc007e438e4b6e1c7a7113ea2 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 20 Jul 2015 17:02:03 +0200 Subject: [PATCH 429/450] restore fix for highlight usages which was lost during merge against J2K --- .../findUsages/handlers/KotlinFindUsagesHandler.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt index 71fb83e1c72..6318c323845 100644 --- a/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/findUsages/handlers/KotlinFindUsagesHandler.kt @@ -26,6 +26,7 @@ import com.intellij.psi.search.SearchScope import com.intellij.usageView.UsageInfo import com.intellij.util.Processor import org.jetbrains.kotlin.idea.findUsages.KotlinFindUsagesHandlerFactory +import org.jetbrains.kotlin.idea.findUsages.KotlinReferenceUsageInfo import org.jetbrains.kotlin.idea.util.application.runReadAction import java.util.ArrayList @@ -89,15 +90,10 @@ public abstract class KotlinFindUsagesHandler(psiElement: T, companion object { - protected fun processUsage(processor: Processor, ref: PsiReference?): Boolean { - if (ref == null) return true - val usageInfo = runReadAction { - val rangeInElement = ref.getRangeInElement() - UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false) - } - return processor.process(usageInfo) - } + protected fun processUsage(processor: Processor, ref: PsiReference): Boolean + = processor.process(KotlinReferenceUsageInfo(ref)) - protected fun processUsage(processor: Processor, element: PsiElement): Boolean = processor.process(UsageInfo(element)) + protected fun processUsage(processor: Processor, element: PsiElement): Boolean + = processor.process(UsageInfo(element)) } } From 5398de22f935ab18911c7eb7072ade1e06da4cf9 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 17 Jul 2015 19:45:25 +0300 Subject: [PATCH 430/450] Container structure dump facilities. --- .../jetbrains/kotlin/container/Components.kt | 4 ++ .../jetbrains/kotlin/container/Container.kt | 11 ++++-- .../kotlin/container/DataStructures.kt | 2 +- .../jetbrains/kotlin/container/Descriptors.kt | 2 + .../jetbrains/kotlin/container/Singletons.kt | 2 + .../org/jetbrains/kotlin/container/Storage.kt | 38 +++++++++++++++---- 6 files changed, 48 insertions(+), 11 deletions(-) diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Components.kt b/compiler/container/src/org/jetbrains/kotlin/container/Components.kt index 67ac04e9e7e..ed46308acdd 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Components.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Components.kt @@ -24,5 +24,9 @@ public class InstanceComponentDescriptor(val instance: Any) : ComponentDescripto override fun getRegistrations(): Iterable = instance.javaClass.getInfo().registrations override fun getDependencies(context: ValueResolveContext): Collection> = emptyList() + + override fun toString(): String { + return "Instance: ${instance.javaClass.getSimpleName()}" + } } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Container.kt b/compiler/container/src/org/jetbrains/kotlin/container/Container.kt index 26942661084..d7e265ef3b4 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Container.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Container.kt @@ -17,6 +17,8 @@ package org.jetbrains.kotlin.container import java.io.Closeable +import java.io.PrintStream +import java.io.Writer import java.lang.reflect.ParameterizedType import java.lang.reflect.Type import java.lang.reflect.WildcardType @@ -28,10 +30,9 @@ public interface ComponentContainer { fun createResolveContext(requestingDescriptor: ValueDescriptor): ValueResolveContext } -object DynamicComponentDescriptor : ComponentDescriptor { - override fun getDependencies(context: ValueResolveContext): Collection> = throw UnsupportedOperationException() - override fun getRegistrations(): Iterable> = throw UnsupportedOperationException() +object DynamicComponentDescriptor : ValueDescriptor { override fun getValue(): Any = throw UnsupportedOperationException() + override fun toString(): String = "Dynamic" } public class StorageComponentContainer(id: String) : ComponentContainer, Closeable { @@ -49,6 +50,10 @@ public class StorageComponentContainer(id: String) : ComponentContainer, Closeab return this } + fun dump(printer: PrintStream) { + componentStorage.dump(printer) + } + override fun close() = componentStorage.dispose() jvmOverloads public fun resolve(request: Type, context: ValueResolveContext = unknownContext): ValueDescriptor? { diff --git a/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt b/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt index 34c51f56042..83d71231c72 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/DataStructures.kt @@ -29,7 +29,7 @@ public fun topologicalSort(items: Iterable, dependencies: (T) -> Iterable< return if (item in itemsInProgress) - throw CycleInTopoSortException() + return //throw CycleInTopoSortException() itemsInProgress.add(item) diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt b/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt index 5bf625f999f..41fb2eef21d 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Descriptors.kt @@ -33,4 +33,6 @@ public class IterableDescriptor(val descriptors: Iterable) : Va override fun getValue(): Any { return descriptors.map { it.getValue() } } + + override fun toString(): String = "Iterable: $descriptors" } \ No newline at end of file diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt b/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt index 8593baeea75..4e25fe61d1c 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Singletons.kt @@ -117,6 +117,8 @@ public abstract class SingletonDescriptor(val container: ComponentContainer) : C } public abstract class SingletonComponentDescriptor(container: ComponentContainer, val klass: Class<*>) : SingletonDescriptor(container) { + override fun toString(): String = "Singleton: ${klass.getSimpleName()}" + public override fun getRegistrations(): Iterable = klass.getInfo().registrations } diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt b/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt index 8c39aa62a4d..cfba964bf03 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Storage.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.container import com.intellij.util.containers.MultiMap import java.io.Closeable +import java.io.PrintStream import java.lang.reflect.Modifier import java.lang.reflect.ParameterizedType import java.lang.reflect.Type @@ -64,6 +65,29 @@ public class ComponentStorage(val myId: String) : ValueResolver { } } + public fun dump(printer: PrintStream): Unit = with (printer) { + val heading = "Container: $myId" + println(heading) + println("=".repeat(heading.length())) + println() + getDescriptorsInDisposeOrder().forEach { descriptor -> + println(descriptor) + dependencies[descriptor].forEach { + print(" -> ") + val typeName = it.toString() + print(typeName.substringBefore(" ")) // interface, class + print(" ") + print(typeName.substringAfterLast(".")) // name + val resolve = registry.tryGetEntry(it) + print(" as ") + print(resolve) + println() + } + println() + } + } + + public fun resolveMultiple(request: Type, context: ValueResolveContext): Iterable { registerDependency(request, context) return registry.tryGetEntry(request) @@ -103,7 +127,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { private fun injectProperties(context: ComponentResolveContext, components: Collection) { for (component in components) { if (component.shouldInjectProperties) { - injectProperties(component.getValue(), context) + injectProperties(component.getValue(), context.container.createResolveContext(component)) } } } @@ -119,7 +143,7 @@ public class ComponentStorage(val myId: String) : ValueResolver { } private fun collectAdhocComponents(context: ComponentResolveContext, descriptor: ComponentDescriptor, - visitedTypes: HashSet, adhocDescriptors: LinkedHashSet + visitedTypes: HashSet, adhocDescriptors: LinkedHashSet ) { val dependencies = descriptor.getDependencies(context) for (type in dependencies) { @@ -128,11 +152,11 @@ public class ComponentStorage(val myId: String) : ValueResolver { val entry = registry.tryGetEntry(type) if (entry.isEmpty()) { - val rawType : Class<*>? = when(type){ - is Class<*> -> type - is ParameterizedType -> type.getRawType() as? Class<*> - else -> null - } + val rawType: Class<*>? = when (type) { + is Class<*> -> type + is ParameterizedType -> type.getRawType() as? Class<*> + else -> null + } if (rawType == null) continue From 04e71234a1b77aac656803e8bd462c5185f964dd Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 17 Jul 2015 20:00:34 +0300 Subject: [PATCH 431/450] LocalClassifierAnalyzer dependencies --- .../expressions/BasicExpressionTypingVisitor.java | 7 ++----- .../ExpressionTypingVisitorForStatements.java | 14 ++++++-------- .../types/expressions/LocalClassifierAnalyzer.kt | 13 +++++++------ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 06383a6cec7..32cd8428878 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -642,13 +642,10 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { }; ObservableBindingTrace traceAdapter = new ObservableBindingTrace(temporaryTrace); traceAdapter.addHandler(CLASS, handler); - components.localClassifierAnalyzer.processClassOrObject(components.globalContext, - null, // don't need to add classifier of object literal to any scope + components.localClassifierAnalyzer.processClassOrObject(null, // don't need to add classifier of object literal to any scope context.replaceBindingTrace(traceAdapter).replaceContextDependency(INDEPENDENT), context.scope.getContainingDeclaration(), - expression.getObjectDeclaration(), - components.additionalCheckerProvider, - components.dynamicTypesSettings); + expression.getObjectDeclaration()); temporaryTrace.commit(); DataFlowInfo resultFlowInfo = context.dataFlowInfo; for (JetDelegationSpecifier specifier: expression.getObjectDeclaration().getDelegationSpecifiers()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java index 97ec9f84144..30e12e7e517 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java @@ -96,10 +96,9 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito @Override public JetTypeInfo visitObjectDeclaration(@NotNull JetObjectDeclaration declaration, ExpressionTypingContext context) { components.localClassifierAnalyzer.processClassOrObject( - components.globalContext, - scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT), scope.getContainingDeclaration(), declaration, - components.additionalCheckerProvider, - components.dynamicTypesSettings); + scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT), + scope.getContainingDeclaration(), + declaration); return TypeInfoFactoryPackage.createTypeInfo(DataFlowUtils.checkStatementType(declaration, context), context); } @@ -195,10 +194,9 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito @Override public JetTypeInfo visitClass(@NotNull JetClass klass, ExpressionTypingContext context) { components.localClassifierAnalyzer.processClassOrObject( - components.globalContext, - scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT), scope.getContainingDeclaration(), klass, - components.additionalCheckerProvider, - components.dynamicTypesSettings); + scope, context.replaceScope(scope).replaceContextDependency(INDEPENDENT), + scope.getContainingDeclaration(), + klass); return TypeInfoFactoryPackage.createTypeInfo(DataFlowUtils.checkStatementType(klass, context), context); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt index 242c0f514e3..ac2cc72943e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt @@ -45,19 +45,20 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.DynamicTypesSettings public class LocalClassifierAnalyzer( + val globalContext: GlobalContext, + val storageManager: StorageManager, val descriptorResolver: DescriptorResolver, val funcionDescriptorResolver: FunctionDescriptorResolver, val typeResolver: TypeResolver, - val annotationResolver: AnnotationResolver + val annotationResolver: AnnotationResolver, + val additionalCheckerProvider: AdditionalCheckerProvider, + val dynamicTypesSettings: DynamicTypesSettings ) { fun processClassOrObject( - globalContext: GlobalContext, scope: WritableScope?, context: ExpressionTypingContext, containingDeclaration: DeclarationDescriptor, - classOrObject: JetClassOrObject, - additionalCheckerProvider: AdditionalCheckerProvider, - dynamicTypesSettings: DynamicTypesSettings + classOrObject: JetClassOrObject ) { val module = DescriptorUtils.getContainingModule(containingDeclaration) val moduleContext = globalContext.withProject(classOrObject.getProject()).withModule(module) @@ -70,7 +71,7 @@ public class LocalClassifierAnalyzer( scope, classOrObject, containingDeclaration, - globalContext.storageManager, + storageManager, context, module, descriptorResolver, From 76b9ac0f636738b89f29bc7c424d145acdf92b8b Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 17 Jul 2015 21:13:51 +0300 Subject: [PATCH 432/450] FileScopeProviderImpl dependencies --- .../synthetic/JavaBeansExtensionsScope.kt | 2 +- .../kotlin/resolve/lazy/FileScopeProvider.kt | 6 +- .../resolve/lazy/FileScopeProviderImpl.kt | 66 ++++++++++++++++--- .../kotlin/resolve/lazy/LazyFileScope.kt | 51 ++------------ .../kotlin/resolve/lazy/LazyImportScope.kt | 23 ++++--- 5 files changed, 76 insertions(+), 72 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt index 3c019f06ba5..c5deca72822 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt @@ -72,7 +72,7 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { } } -class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes() { +class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes { private val scope = JavaBeansExtensionsScope(storageManager) override fun scopes(file: JetFile) = listOf(scope) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProvider.kt index 03e916e2f31..29854c8b2dc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProvider.kt @@ -28,10 +28,8 @@ public interface FileScopeProvider { } } - public open class AdditionalScopes { - public open fun scopes(file: JetFile): List { - return emptyList() - } + public interface AdditionalScopes { + public fun scopes(file: JetFile): List } } 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 42a5d6769e3..7e48e22b22e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/FileScopeProviderImpl.kt @@ -16,29 +16,75 @@ package org.jetbrains.kotlin.resolve.lazy +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.impl.SubpackagesScope +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.JetCodeFragment import org.jetbrains.kotlin.psi.JetFile +import org.jetbrains.kotlin.psi.JetImportsFactory +import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.resolve.NoSubpackagesInPackageScope +import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver import org.jetbrains.kotlin.resolve.TemporaryBindingTrace +import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.storage.get +import org.jetbrains.kotlin.utils.sure +import java.util.* public class FileScopeProviderImpl( - private val resolveSession: ResolveSession, + private val topLevelDescriptorProvider: TopLevelDescriptorProvider, + private val storageManager: StorageManager, + private val moduleDescriptor: ModuleDescriptor, + private val qualifiedExpressionResolver: QualifiedExpressionResolver, + private val bindingTrace: BindingTrace, + private val jetImportsFactory: JetImportsFactory, private val additionalScopes: Iterable ) : FileScopeProvider { - private val defaultImports by resolveSession.getStorageManager().createLazyValue { - val defaultImports = resolveSession.getModuleDescriptor().defaultImports - resolveSession.getJetImportsFactory().createImportDirectives(defaultImports) + private val defaultImports by storageManager.createLazyValue { + jetImportsFactory.createImportDirectives(moduleDescriptor.defaultImports) } - private val fileScopes = resolveSession.getStorageManager().createMemoizedFunction { file: JetFile -> createFileScope(file) } + private val fileScopes = storageManager.createMemoizedFunction { file: JetFile -> createFileScope(file) } override fun getFileScope(file: JetFile) = fileScopes(file) 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.flatMap { it.scopes(file) }, - resolveSession.getTrace(), tempTrace, "LazyFileScope for file " + file.getName() - ) + val debugName = "LazyFileScope for file " + file.getName() + val tempTrace = TemporaryBindingTrace.create(bindingTrace, "Transient trace for default imports lazy resolve") + + val imports = if (file is JetCodeFragment) + file.importsAsImportList()?.getImports() ?: listOf() + else + file.getImportDirectives() + + val packageView = moduleDescriptor.getPackage(file.getPackageFqName()) + val packageFragment = topLevelDescriptorProvider.getPackageFragment(file.getPackageFqName()) + .sure { "Could not find fragment ${file.getPackageFqName()} for file ${file.getName()}" } + + val aliasImportResolver = LazyImportResolver(storageManager, qualifiedExpressionResolver, this, moduleDescriptor, AliasImportsIndexed(imports), bindingTrace) + val allUnderImportResolver = LazyImportResolver(storageManager, qualifiedExpressionResolver, this, moduleDescriptor, AllUnderImportsIndexed(imports), bindingTrace) + val defaultAliasImportResolver = LazyImportResolver(storageManager, qualifiedExpressionResolver, this, moduleDescriptor, AliasImportsIndexed(defaultImports), tempTrace) + val defaultAllUnderImportResolver = LazyImportResolver(storageManager, qualifiedExpressionResolver, this, moduleDescriptor, AllUnderImportsIndexed(defaultImports), tempTrace) + + val scopeChain = ArrayList() + + scopeChain.add(LazyImportScope(packageFragment, aliasImportResolver, LazyImportScope.FilteringKind.ALL, "Alias imports in $debugName")) + + scopeChain.add(NoSubpackagesInPackageScope(packageView)) //TODO: problems with visibility too + scopeChain.add(SubpackagesScope(moduleDescriptor, FqName.ROOT)) + + scopeChain.add(LazyImportScope(packageFragment, defaultAliasImportResolver, LazyImportScope.FilteringKind.ALL, "Default alias imports in $debugName")) + + scopeChain.add(LazyImportScope(packageFragment, defaultAllUnderImportResolver, LazyImportScope.FilteringKind.VISIBLE_CLASSES, "Default all under imports in $debugName (visible classes)")) + scopeChain.add(LazyImportScope(packageFragment, allUnderImportResolver, LazyImportScope.FilteringKind.VISIBLE_CLASSES, "All under imports in $debugName (visible classes)")) + + scopeChain.addAll(additionalScopes.flatMap { it.scopes(file) }) + + scopeChain.add(LazyImportScope(packageFragment, defaultAllUnderImportResolver, LazyImportScope.FilteringKind.INVISIBLE_CLASSES, "Default all under imports in $debugName (invisible classes only)")) + scopeChain.add(LazyImportScope(packageFragment, allUnderImportResolver, LazyImportScope.FilteringKind.INVISIBLE_CLASSES, "All under imports in $debugName (invisible classes only)")) + + return LazyFileScope(scopeChain, aliasImportResolver, allUnderImportResolver, packageFragment, debugName) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyFileScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyFileScope.kt index 080087ed088..74bf6bd9ac6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyFileScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyFileScope.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.resolve.lazy +import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor import org.jetbrains.kotlin.descriptors.impl.SubpackagesScope import org.jetbrains.kotlin.name.FqName @@ -24,12 +25,14 @@ import org.jetbrains.kotlin.psi.JetFile import org.jetbrains.kotlin.psi.JetImportDirective import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.NoSubpackagesInPackageScope +import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver import org.jetbrains.kotlin.resolve.scopes.ChainedScope import org.jetbrains.kotlin.resolve.scopes.JetScope +import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.utils.sure import java.util.ArrayList -class LazyFileScope private constructor( +class LazyFileScope( scopeChain: List, private val aliasImportResolver: LazyImportResolver, private val allUnderImportResolver: LazyImportResolver, @@ -50,50 +53,4 @@ class LazyFileScope private constructor( aliasImportResolver.forceResolveImportDirective(importDirective) } } - - companion object Factory { - public fun create( - resolveSession: ResolveSession, - file: JetFile, - defaultImports: Collection, - additionalScopes: List, - traceForImportResolve: BindingTrace, - traceForDefaultImportResolve: BindingTrace, - debugName: String - ): LazyFileScope { - val imports = if (file is JetCodeFragment) - file.importsAsImportList()?.getImports() ?: listOf() - else - file.getImportDirectives() - - val moduleDescriptor = resolveSession.getModuleDescriptor() - val packageView = moduleDescriptor.getPackage(file.getPackageFqName()) - val packageFragment = resolveSession.getPackageFragment(file.getPackageFqName()) - .sure { "Could not find fragment ${file.getPackageFqName()} for file ${file.getName()}" } - - val aliasImportResolver = LazyImportResolver(resolveSession, moduleDescriptor, AliasImportsIndexed(imports), traceForImportResolve) - val allUnderImportResolver = LazyImportResolver(resolveSession, moduleDescriptor, AllUnderImportsIndexed(imports), traceForImportResolve) - val defaultAliasImportResolver = LazyImportResolver(resolveSession, moduleDescriptor, AliasImportsIndexed(defaultImports), traceForDefaultImportResolve) - val defaultAllUnderImportResolver = LazyImportResolver(resolveSession, moduleDescriptor, AllUnderImportsIndexed(defaultImports), traceForDefaultImportResolve) - - val scopeChain = ArrayList() - - scopeChain.add(LazyImportScope(packageFragment, aliasImportResolver, LazyImportScope.FilteringKind.ALL, "Alias imports in $debugName")) - - scopeChain.add(NoSubpackagesInPackageScope(packageView)) //TODO: problems with visibility too - scopeChain.add(SubpackagesScope(moduleDescriptor, FqName.ROOT)) - - scopeChain.add(LazyImportScope(packageFragment, defaultAliasImportResolver, LazyImportScope.FilteringKind.ALL, "Default alias imports in $debugName")) - - scopeChain.add(LazyImportScope(packageFragment, defaultAllUnderImportResolver, LazyImportScope.FilteringKind.VISIBLE_CLASSES, "Default all under imports in $debugName (visible classes)")) - scopeChain.add(LazyImportScope(packageFragment, allUnderImportResolver, LazyImportScope.FilteringKind.VISIBLE_CLASSES, "All under imports in $debugName (visible classes)")) - - scopeChain.addAll(additionalScopes) - - scopeChain.add(LazyImportScope(packageFragment, defaultAllUnderImportResolver, LazyImportScope.FilteringKind.INVISIBLE_CLASSES, "Default all under imports in $debugName (invisible classes only)")) - scopeChain.add(LazyImportScope(packageFragment, allUnderImportResolver, LazyImportScope.FilteringKind.INVISIBLE_CLASSES, "All under imports in $debugName (invisible classes only)")) - - return LazyFileScope(scopeChain, aliasImportResolver, allUnderImportResolver, packageFragment, debugName) - } - } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index e6a157b09c8..272ee60ff50 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -25,10 +25,12 @@ import org.jetbrains.kotlin.psi.JetImportDirective import org.jetbrains.kotlin.psi.JetPsiUtil import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.PlatformTypesMappedToKotlinChecker +import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver import org.jetbrains.kotlin.resolve.QualifiedExpressionResolver.LookupMode import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer @@ -64,12 +66,14 @@ class AliasImportsIndexed(allImports: Collection) : IndexedI } class LazyImportResolver( - val resolveSession: ResolveSession, + val storageManager: StorageManager, + val qualifiedExpressionResolver: QualifiedExpressionResolver, + val fileScopeProvider: FileScopeProvider, val moduleDescriptor: ModuleDescriptor, val indexedImports: IndexedImports, private val traceForImportResolve: BindingTrace ) { - private val importedScopesProvider = resolveSession.getStorageManager().createMemoizedFunction { + private val importedScopesProvider = storageManager.createMemoizedFunction { directive: JetImportDirective -> ImportDirectiveResolveCache(directive) } @@ -87,7 +91,7 @@ class LazyImportResolver( return status.scope } - return resolveSession.getStorageManager().compute { + return storageManager.compute { val cachedStatus = importResolveStatus if (cachedStatus != null && (cachedStatus.lookupMode == mode || cachedStatus.lookupMode == LookupMode.EVERYTHING)) { cachedStatus.scope @@ -96,8 +100,7 @@ class LazyImportResolver( directiveUnderResolve = directive try { - val resolver = resolveSession.getQualifiedExpressionResolver() - val directiveImportScope = resolver.processImportReference( + val directiveImportScope = qualifiedExpressionResolver.processImportReference( directive, moduleDescriptor, traceForImportResolve, mode) val descriptors = if (directive.isAllUnder()) emptyList() else directiveImportScope.getAllDescriptors() @@ -127,7 +130,7 @@ class LazyImportResolver( val status = importedScopesProvider(importDirective).importResolveStatus if (status != null && !status.descriptors.isEmpty()) { - val fileScope = resolveSession.getFileScopeProvider().getFileScope(importDirective.getContainingJetFile()) + val fileScope = fileScopeProvider.getFileScope(importDirective.getContainingJetFile()) reportConflictingImport(importDirective, fileScope, status.descriptors, traceForImportResolve) } } @@ -181,7 +184,7 @@ class LazyImportResolver( } return target } - return resolveSession.getStorageManager().compute(::compute) + return storageManager.compute(::compute) } public fun collectFromImports( @@ -189,7 +192,7 @@ class LazyImportResolver( lookupMode: LookupMode, descriptorsSelector: (JetScope, Name) -> Collection ): Collection { - return resolveSession.getStorageManager().compute { + return storageManager.compute { var descriptors: Collection? = null for (directive in indexedImports.importsForName(name)) { if (directive == directiveUnderResolve) { @@ -264,7 +267,7 @@ class LazyImportScope( // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() - return importResolver.resolveSession.getStorageManager().compute { + return importResolver.storageManager.compute { importResolver.indexedImports.imports.flatMapTo(LinkedHashSet()) { import -> importResolver.getImportScope(import, LookupMode.EVERYTHING).getSyntheticExtensionProperties(receiverType) } @@ -277,7 +280,7 @@ class LazyImportScope( // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() - return importResolver.resolveSession.getStorageManager().compute { + return importResolver.storageManager.compute { val descriptors = LinkedHashSet() for (directive in importResolver.indexedImports.imports) { val importPath = directive.getImportPath() ?: continue From 84236992cb362220fc7dd8af5b2d6fcd5981c10c Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Fri, 17 Jul 2015 21:59:23 +0300 Subject: [PATCH 433/450] Replace Injected properties with constructor parameters when it doesn't cause cycles --- .../java/components/LazyResolveBasedCache.kt | 9 +- .../components/TraceBasedErrorReporter.kt | 17 +-- .../TraceBasedExternalSignatureResolver.java | 24 ++-- .../kotlin/psi/JetImportsFactory.java | 7 +- .../kotlin/resolve/AnnotationResolver.java | 29 ++-- .../kotlin/resolve/BodyResolver.java | 107 +++++---------- .../kotlin/resolve/ControlFlowAnalyzer.java | 6 +- .../kotlin/resolve/DeclarationResolver.kt | 24 +--- .../kotlin/resolve/DeclarationsChecker.java | 24 ++-- .../resolve/DelegatedPropertyResolver.java | 35 ++--- .../kotlin/resolve/DescriptorResolver.java | 51 +++---- .../resolve/FunctionAnalyzerExtension.java | 6 +- .../kotlin/resolve/LazyTopDownAnalyzer.kt | 128 +++++------------- .../LazyTopDownAnalyzerForTopLevel.java | 25 ++-- .../kotlin/resolve/OverloadResolver.java | 6 +- .../kotlin/resolve/OverrideResolver.java | 8 +- .../resolve/QualifiedExpressionResolver.java | 15 +- .../kotlin/resolve/ScriptBodyResolver.java | 17 +-- .../resolve/calls/ArgumentTypeResolver.java | 27 ++-- .../resolve/calls/CallExpressionResolver.java | 1 + .../kotlin/resolve/calls/CallResolver.java | 30 ++-- .../resolve/lazy/LazyDeclarationResolver.java | 14 +- .../expressions/ExpressionTypingServices.java | 13 +- .../ForLoopConventionsChecker.java | 22 ++- .../expressions/LocalClassifierAnalyzer.kt | 24 ++-- .../load/java/lazy/ModuleClassResolver.kt | 1 + .../DeserializedDescriptorResolver.java | 1 + .../DeserializedPackageFragment.kt | 1 + .../deserialization/LocalClassResolverImpl.kt | 1 + 29 files changed, 238 insertions(+), 435 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt index 4fa140afd49..2ca858a52a8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/LazyResolveBasedCache.kt @@ -22,23 +22,16 @@ import org.jetbrains.kotlin.load.java.structure.impl.* import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils import org.jetbrains.kotlin.name.FqName -import javax.inject.Inject import kotlin.properties.Delegates import org.jetbrains.kotlin.name.tail import org.jetbrains.kotlin.resolve.BindingContext.* import org.jetbrains.kotlin.resolve.BindingTrace import org.jetbrains.kotlin.resolve.BindingContextUtils -public class LazyResolveBasedCache : JavaResolverCache { - private var resolveSession by Delegates.notNull() +public class LazyResolveBasedCache(private val resolveSession: ResolveSession) : JavaResolverCache { private val trace: BindingTrace get() = resolveSession.getTrace() - Inject - public fun setSession(resolveSession: ResolveSession) { - this.resolveSession = resolveSession - } - override fun getClassResolvedFromSource(fqName: FqName): ClassDescriptor? { return trace.get(FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe()) ?: findInPackageFragments(fqName) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt index 4325c5dacaa..1fe61137776 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedErrorReporter.kt @@ -26,9 +26,7 @@ import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter import org.jetbrains.kotlin.util.slicedMap.Slices import org.jetbrains.kotlin.util.slicedMap.WritableSlice -import javax.inject.Inject - -public class TraceBasedErrorReporter : ErrorReporter { +public class TraceBasedErrorReporter(private val trace: BindingTrace) : ErrorReporter { companion object { private val LOG = Logger.getInstance(javaClass()) @@ -43,24 +41,17 @@ public class TraceBasedErrorReporter : ErrorReporter { public val classId: ClassId ) - private var trace: BindingTrace? = null - - Inject - public fun setTrace(trace: BindingTrace) { - this.trace = trace - } - override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: Int) { - trace!!.record(ABI_VERSION_ERRORS, filePath, AbiVersionErrorData(actualVersion, classId)) + trace.record(ABI_VERSION_ERRORS, filePath, AbiVersionErrorData(actualVersion, classId)) } override fun reportIncompleteHierarchy(descriptor: ClassDescriptor, unresolvedSuperClasses: List) { // TODO: MutableList is a workaround for KT-5792 Covariant types in Kotlin translated to wildcard types in Java - trace!!.record(INCOMPLETE_HIERARCHY, descriptor, unresolvedSuperClasses as MutableList) + trace.record(INCOMPLETE_HIERARCHY, descriptor, unresolvedSuperClasses as MutableList) } override fun reportCannotInferVisibility(descriptor: CallableMemberDescriptor) { - OverrideResolver.createCannotInferVisibilityReporter(trace!!).invoke(descriptor) + OverrideResolver.createCannotInferVisibilityReporter(trace).invoke(descriptor) } override fun reportLoadingError(message: String, exception: Exception?) { diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java index 9fa7cfa7d22..3cf5f75eb89 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/components/TraceBasedExternalSignatureResolver.java @@ -35,28 +35,22 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatu import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData; import org.jetbrains.kotlin.types.JetType; -import javax.inject.Inject; import java.util.Collections; import java.util.List; public class TraceBasedExternalSignatureResolver implements ExternalSignatureResolver { - private BindingTrace trace; - private ExternalAnnotationResolver externalAnnotationResolver; - private Project project; + @NotNull private final BindingTrace trace; + @NotNull private final ExternalAnnotationResolver externalAnnotationResolver; + @NotNull private final Project project; - @Inject - public void setTrace(BindingTrace trace) { - this.trace = trace; - } - - @Inject - public void setExternalAnnotationResolver(ExternalAnnotationResolver externalAnnotationResolver) { + public TraceBasedExternalSignatureResolver( + @NotNull ExternalAnnotationResolver externalAnnotationResolver, + @NotNull Project project, + @NotNull BindingTrace trace + ) { this.externalAnnotationResolver = externalAnnotationResolver; - } - - @Inject - public void setProject(Project project) { this.project = project; + this.trace = trace; } @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetImportsFactory.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetImportsFactory.java index 0155486c900..5b3e7fcb28f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetImportsFactory.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetImportsFactory.java @@ -24,20 +24,17 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.resolve.ImportPath; -import javax.inject.Inject; import java.util.Collection; import java.util.Map; import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory; public class JetImportsFactory { - private Project project; + @NotNull private final Project project; private final Map importsCache = Maps.newHashMap(); - @Inject - public void setProject(@NotNull Project project) { - importsCache.clear(); + public JetImportsFactory(@NotNull Project project) { this.project = project; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index e03f12eced9..779db10c475 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -51,32 +51,27 @@ import static org.jetbrains.kotlin.diagnostics.Errors.NOT_AN_ANNOTATION_CLASS; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class AnnotationResolver { + @NotNull private final CallResolver callResolver; + @NotNull private final StorageManager storageManager; + @NotNull private TypeResolver typeResolver; + @NotNull private final ConstantExpressionEvaluator constantExpressionEvaluator; - private CallResolver callResolver; - private StorageManager storageManager; - private TypeResolver typeResolver; - private ConstantExpressionEvaluator constantExpressionEvaluator; - - @Inject - public void setCallResolver(CallResolver callResolver) { + public AnnotationResolver( + @NotNull CallResolver callResolver, + @NotNull ConstantExpressionEvaluator constantExpressionEvaluator, + @NotNull StorageManager storageManager + ) { this.callResolver = callResolver; - } - - @Inject - public void setStorageManager(StorageManager storageManager) { + this.constantExpressionEvaluator = constantExpressionEvaluator; this.storageManager = storageManager; } + // component dependency cycle @Inject - public void setTypeResolver(TypeResolver typeResolver) { + public void setTypeResolver(@NotNull TypeResolver typeResolver) { this.typeResolver = typeResolver; } - @Inject - public void setConstantExpressionEvaluator(ConstantExpressionEvaluator constantExpressionEvaluator) { - this.constantExpressionEvaluator = constantExpressionEvaluator; - } - @NotNull public Annotations resolveAnnotationsWithoutArguments( @NotNull JetScope scope, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index 475dde783db..a8a8f85fac7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -45,7 +45,6 @@ import org.jetbrains.kotlin.util.Box; import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; -import javax.inject.Inject; import java.util.*; import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER; @@ -54,81 +53,47 @@ import static org.jetbrains.kotlin.resolve.BindingContext.*; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class BodyResolver { - private ScriptBodyResolver scriptBodyResolverResolver; - private ExpressionTypingServices expressionTypingServices; - private CallResolver callResolver; - private ObservableBindingTrace trace; - private ControlFlowAnalyzer controlFlowAnalyzer; - private DeclarationsChecker declarationsChecker; - private AnnotationResolver annotationResolver; - private DelegatedPropertyResolver delegatedPropertyResolver; - private FunctionAnalyzerExtension functionAnalyzerExtension; - private AdditionalCheckerProvider additionalCheckerProvider; - private ValueParameterResolver valueParameterResolver; - private BodyResolveCache bodyResolveCache; + @NotNull private final ScriptBodyResolver scriptBodyResolverResolver; + @NotNull private final ExpressionTypingServices expressionTypingServices; + @NotNull private final CallResolver callResolver; + @NotNull private final ObservableBindingTrace trace; + @NotNull private final ControlFlowAnalyzer controlFlowAnalyzer; + @NotNull private final DeclarationsChecker declarationsChecker; + @NotNull private final AnnotationResolver annotationResolver; + @NotNull private final DelegatedPropertyResolver delegatedPropertyResolver; + @NotNull private final FunctionAnalyzerExtension functionAnalyzerExtension; + @NotNull private final AdditionalCheckerProvider additionalCheckerProvider; + @NotNull private final ValueParameterResolver valueParameterResolver; + @NotNull private final BodyResolveCache bodyResolveCache; - // - @Inject - public void setScriptBodyResolverResolver(@NotNull ScriptBodyResolver scriptBodyResolverResolver) { - this.scriptBodyResolverResolver = scriptBodyResolverResolver; - } - - @Inject - public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { - this.expressionTypingServices = expressionTypingServices; - } - - @Inject - public void setCallResolver(@NotNull CallResolver callResolver) { - this.callResolver = callResolver; - } - - @Inject - public void setTrace(@NotNull BindingTrace trace) { - this.trace = new ObservableBindingTrace(trace); - } - - @Inject - public void setControlFlowAnalyzer(@NotNull ControlFlowAnalyzer controlFlowAnalyzer) { - this.controlFlowAnalyzer = controlFlowAnalyzer; - } - - @Inject - public void setDeclarationsChecker(@NotNull DeclarationsChecker declarationsChecker) { - this.declarationsChecker = declarationsChecker; - } - - @Inject - public void setAnnotationResolver(@NotNull AnnotationResolver annotationResolver) { - this.annotationResolver = annotationResolver; - } - - @Inject - public void setDelegatedPropertyResolver(@NotNull DelegatedPropertyResolver delegatedPropertyResolver) { - this.delegatedPropertyResolver = delegatedPropertyResolver; - } - - @Inject - public void setFunctionAnalyzerExtension(@NotNull FunctionAnalyzerExtension functionAnalyzerExtension) { - this.functionAnalyzerExtension = functionAnalyzerExtension; - } - - @Inject - public void setAdditionalCheckerProvider(AdditionalCheckerProvider additionalCheckerProvider) { + public BodyResolver( + @NotNull AdditionalCheckerProvider additionalCheckerProvider, + @NotNull AnnotationResolver annotationResolver, + @NotNull BodyResolveCache bodyResolveCache, + @NotNull CallResolver callResolver, + @NotNull ControlFlowAnalyzer controlFlowAnalyzer, + @NotNull DeclarationsChecker declarationsChecker, + @NotNull DelegatedPropertyResolver delegatedPropertyResolver, + @NotNull ExpressionTypingServices expressionTypingServices, + @NotNull FunctionAnalyzerExtension functionAnalyzerExtension, + @NotNull ScriptBodyResolver scriptBodyResolverResolver, + @NotNull BindingTrace trace, + @NotNull ValueParameterResolver valueParameterResolver + ) { this.additionalCheckerProvider = additionalCheckerProvider; - } - - @Inject - public void setValueParameterResolver(ValueParameterResolver valueParameterResolver) { + this.annotationResolver = annotationResolver; + this.bodyResolveCache = bodyResolveCache; + this.callResolver = callResolver; + this.controlFlowAnalyzer = controlFlowAnalyzer; + this.declarationsChecker = declarationsChecker; + this.delegatedPropertyResolver = delegatedPropertyResolver; + this.expressionTypingServices = expressionTypingServices; + this.functionAnalyzerExtension = functionAnalyzerExtension; + this.scriptBodyResolverResolver = scriptBodyResolverResolver; + this.trace = new ObservableBindingTrace(trace); this.valueParameterResolver = valueParameterResolver; } - @Inject - public void setBodyResolveCache(BodyResolveCache bodyResolveCache) { - this.bodyResolveCache = bodyResolveCache; - } - // - private void resolveBehaviorDeclarationBodies(@NotNull BodiesResolveContext c) { resolveDelegationSpecifierLists(c); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java index a82abdbe6a5..1ae7671d04f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java @@ -26,16 +26,14 @@ import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.types.JetType; -import javax.inject.Inject; import java.util.Map; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class ControlFlowAnalyzer { - private BindingTrace trace; + @NotNull private final BindingTrace trace; - @Inject - public void setTrace(BindingTrace trace) { + public ControlFlowAnalyzer(@NotNull BindingTrace trace) { this.trace = trace; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt index b03e082fb3b..d0b94d254ba 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt @@ -30,31 +30,19 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.lazy.TopLevelDescriptorProvider import org.jetbrains.kotlin.utils.* -import javax.inject.Inject import java.util.HashSet import org.jetbrains.kotlin.diagnostics.Errors.REDECLARATION import kotlin.properties.Delegates -public class DeclarationResolver { - private var _annotationResolver: AnnotationResolver by Delegates.notNull() - private var _trace: BindingTrace by Delegates.notNull() - - Inject - public fun setAnnotationResolver(annotationResolver: AnnotationResolver) { - this._annotationResolver = annotationResolver - } - - Inject - public fun setTrace(trace: BindingTrace) { - this._trace = trace - } +public class DeclarationResolver(private val annotationResolver: AnnotationResolver, + private val trace: BindingTrace) { public fun resolveAnnotationsOnFiles(c: TopDownAnalysisContext, scopeProvider: FileScopeProvider) { val filesToScope = c.getFiles().keysToMap { scopeProvider.getFileScope(it) } for ((file, fileScope) in filesToScope) { - _annotationResolver.resolveAnnotationsWithArguments(fileScope, file.getAnnotationEntries(), _trace) - _annotationResolver.resolveAnnotationsWithArguments(fileScope, file.getDanglingAnnotations(), _trace) + annotationResolver.resolveAnnotationsWithArguments(fileScope, file.getAnnotationEntries(), trace) + annotationResolver.resolveAnnotationsWithArguments(fileScope, file.getDanglingAnnotations(), trace) } } @@ -95,7 +83,7 @@ public class DeclarationResolver { } } for ((first, second) in redeclarations) { - _trace.report(REDECLARATION.on(first, second.asString())) + trace.report(REDECLARATION.on(first, second.asString())) } } @@ -110,7 +98,7 @@ public class DeclarationResolver { val reportAt = if (declarationOrPackageDirective is JetPackageDirective) declarationOrPackageDirective.getNameIdentifier() else declarationOrPackageDirective - _trace.report(Errors.REDECLARATION.on(reportAt, fqName.shortName().asString())) + trace.report(Errors.REDECLARATION.on(reportAt, fqName.shortName().asString())) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index b89e99b8bb5..18b9fa6b54f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -35,7 +35,6 @@ import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.checker.JetTypeChecker; -import javax.inject.Inject; import java.util.*; import static org.jetbrains.kotlin.diagnostics.Errors.*; @@ -45,23 +44,18 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.classCanHaveAbstractM import static org.jetbrains.kotlin.resolve.DescriptorUtils.classCanHaveOpenMembers; public class DeclarationsChecker { - private BindingTrace trace; - private ModifiersChecker modifiersChecker; - private DescriptorResolver descriptorResolver; + @NotNull private final BindingTrace trace; + @NotNull private final ModifiersChecker modifiersChecker; + @NotNull private final DescriptorResolver descriptorResolver; - @Inject - public void setTrace(@NotNull BindingTrace trace) { - this.trace = trace; - } - - @Inject - public void setDescriptorResolver(@NotNull DescriptorResolver descriptorResolver) { + public DeclarationsChecker( + @NotNull DescriptorResolver descriptorResolver, + @NotNull ModifiersChecker modifiersChecker, + @NotNull BindingTrace trace + ) { this.descriptorResolver = descriptorResolver; - } - - @Inject - public void setModifiersChecker(@NotNull ModifiersChecker modifiersChecker) { this.modifiersChecker = modifiersChecker; + this.trace = trace; } public void process(@NotNull BodiesResolveContext bodiesResolveContext) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java index 95365bbdf35..e33c5ad9155 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java @@ -42,7 +42,6 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; -import javax.inject.Inject; import java.util.List; import static org.jetbrains.kotlin.diagnostics.Errors.*; @@ -58,29 +57,21 @@ public class DelegatedPropertyResolver { public static final Name PROPERTY_DELEGATED_FUNCTION_NAME = Name.identifier("propertyDelegated"); - private ExpressionTypingServices expressionTypingServices; - private CallResolver callResolver; - private KotlinBuiltIns builtIns; - private AdditionalCheckerProvider additionalCheckerProvider; + @NotNull private final ExpressionTypingServices expressionTypingServices; + @NotNull private final CallResolver callResolver; + @NotNull private final KotlinBuiltIns builtIns; + @NotNull private final AdditionalCheckerProvider additionalCheckerProvider; - @Inject - public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { - this.expressionTypingServices = expressionTypingServices; - } - - @Inject - public void setCallResolver(@NotNull CallResolver callResolver) { - this.callResolver = callResolver; - } - - @Inject - public void setBuiltIns(@NotNull KotlinBuiltIns builtIns) { - this.builtIns = builtIns; - } - - @Inject - public void setAdditionalCheckerProvider(AdditionalCheckerProvider additionalCheckerProvider) { + public DelegatedPropertyResolver( + @NotNull AdditionalCheckerProvider additionalCheckerProvider, + @NotNull KotlinBuiltIns builtIns, + @NotNull CallResolver callResolver, + @NotNull ExpressionTypingServices expressionTypingServices + ) { this.additionalCheckerProvider = additionalCheckerProvider; + this.builtIns = builtIns; + this.callResolver = callResolver; + this.expressionTypingServices = expressionTypingServices; } @Nullable diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 7266aab9ce9..f24215e3e6d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -50,7 +50,6 @@ import org.jetbrains.kotlin.types.*; import org.jetbrains.kotlin.types.checker.JetTypeChecker; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; -import javax.inject.Inject; import java.util.*; import static org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER; @@ -72,41 +71,27 @@ public class DescriptorResolver { MODIFIERS_ILLEGAL_ON_PARAMETERS.remove(JetTokens.VARARG_KEYWORD); } - private TypeResolver typeResolver; - private AnnotationResolver annotationResolver; - private ExpressionTypingServices expressionTypingServices; - private DelegatedPropertyResolver delegatedPropertyResolver; - private StorageManager storageManager; - private KotlinBuiltIns builtIns; + @NotNull private final TypeResolver typeResolver; + @NotNull private final AnnotationResolver annotationResolver; + @NotNull private final ExpressionTypingServices expressionTypingServices; + @NotNull private final DelegatedPropertyResolver delegatedPropertyResolver; + @NotNull private final StorageManager storageManager; + @NotNull private final KotlinBuiltIns builtIns; - @Inject - public void setTypeResolver(@NotNull TypeResolver typeResolver) { - this.typeResolver = typeResolver; - } - - @Inject - public void setAnnotationResolver(@NotNull AnnotationResolver annotationResolver) { + public DescriptorResolver( + @NotNull AnnotationResolver annotationResolver, + @NotNull KotlinBuiltIns builtIns, + @NotNull DelegatedPropertyResolver delegatedPropertyResolver, + @NotNull ExpressionTypingServices expressionTypingServices, + @NotNull StorageManager storageManager, + @NotNull TypeResolver typeResolver + ) { this.annotationResolver = annotationResolver; - } - - @Inject - public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { - this.expressionTypingServices = expressionTypingServices; - } - - @Inject - public void setDelegatedPropertyResolver(@NotNull DelegatedPropertyResolver delegatedPropertyResolver) { - this.delegatedPropertyResolver = delegatedPropertyResolver; - } - - @Inject - public void setStorageManager(@NotNull StorageManager storageManager) { - this.storageManager = storageManager; - } - - @Inject - public void setBuiltIns(@NotNull KotlinBuiltIns builtIns) { this.builtIns = builtIns; + this.delegatedPropertyResolver = delegatedPropertyResolver; + this.expressionTypingServices = expressionTypingServices; + this.storageManager = storageManager; + this.typeResolver = typeResolver; } public List resolveSupertypes( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionAnalyzerExtension.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionAnalyzerExtension.java index 7249c7cad07..22b8b869d3e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionAnalyzerExtension.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionAnalyzerExtension.java @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.JetNamedFunction; import org.jetbrains.kotlin.resolve.inline.InlineAnalyzerExtension; import org.jetbrains.kotlin.resolve.inline.InlineUtil; -import javax.inject.Inject; import java.util.Collections; import java.util.List; import java.util.Map; @@ -34,10 +33,9 @@ public class FunctionAnalyzerExtension { void process(@NotNull FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull BindingTrace trace); } - private BindingTrace trace; + @NotNull private final BindingTrace trace; - @Inject - public void setTrace(@NotNull BindingTrace trace) { + public FunctionAnalyzerExtension(@NotNull BindingTrace trace) { this.trace = trace; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt index 01f0e39475e..75bc0790d0c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzer.kt @@ -32,78 +32,22 @@ import org.jetbrains.kotlin.resolve.lazy.* import org.jetbrains.kotlin.resolve.lazy.descriptors.LazyClassDescriptor import org.jetbrains.kotlin.resolve.varianceChecker.VarianceChecker import java.util.ArrayList -import javax.inject.Inject - -public class LazyTopDownAnalyzer { - private var trace: BindingTrace? = null - private var declarationResolver: DeclarationResolver? = null - private var overrideResolver: OverrideResolver? = null - private var overloadResolver: OverloadResolver? = null - private var varianceChecker: VarianceChecker? = null - private var moduleDescriptor: ModuleDescriptor? = null - private var lazyDeclarationResolver: LazyDeclarationResolver? = null - private var bodyResolver: BodyResolver? = null - private var topLevelDescriptorProvider: TopLevelDescriptorProvider? = null - private var fileScopeProvider: FileScopeProvider? = null - private var declarationScopeProvider: DeclarationScopeProvider? = null - - Inject - public fun setLazyDeclarationResolver(lazyDeclarationResolver: LazyDeclarationResolver) { - this.lazyDeclarationResolver = lazyDeclarationResolver - } - - Inject - public fun setTopLevelDescriptorProvider(topLevelDescriptorProvider: TopLevelDescriptorProvider) { - this.topLevelDescriptorProvider = topLevelDescriptorProvider - } - - Inject - public fun setFileScopeProvider(fileScopeProvider: FileScopeProvider) { - this.fileScopeProvider = fileScopeProvider - } - - Inject - public fun setDeclarationScopeProvider(declarationScopeProvider: DeclarationScopeProviderImpl) { - this.declarationScopeProvider = declarationScopeProvider - } - - Inject - public fun setTrace(trace: BindingTrace) { - this.trace = trace - } - - Inject - public fun setDeclarationResolver(declarationResolver: DeclarationResolver) { - this.declarationResolver = declarationResolver - } - - Inject - public fun setOverrideResolver(overrideResolver: OverrideResolver) { - this.overrideResolver = overrideResolver - } - - Inject - public fun setVarianceChecker(varianceChecker: VarianceChecker) { - this.varianceChecker = varianceChecker - } - - Inject - public fun setOverloadResolver(overloadResolver: OverloadResolver) { - this.overloadResolver = overloadResolver - } - - Inject - public fun setModuleDescriptor(moduleDescriptor: ModuleDescriptor) { - this.moduleDescriptor = moduleDescriptor - } - - Inject - public fun setBodyResolver(bodyResolver: BodyResolver) { - this.bodyResolver = bodyResolver - } +public class LazyTopDownAnalyzer( + private val trace: BindingTrace, + private val declarationResolver: DeclarationResolver, + private val overrideResolver: OverrideResolver, + private val overloadResolver: OverloadResolver, + private val varianceChecker: VarianceChecker, + private val moduleDescriptor: ModuleDescriptor, + private val lazyDeclarationResolver: LazyDeclarationResolver, + private val bodyResolver: BodyResolver, + private val topLevelDescriptorProvider: TopLevelDescriptorProvider, + private val fileScopeProvider: FileScopeProvider, + private val declarationScopeProvider: DeclarationScopeProvider +) { public fun analyzeDeclarations(topDownAnalysisMode: TopDownAnalysisMode, declarations: Collection, outerDataFlowInfo: DataFlowInfo): TopDownAnalysisContext { - val c = TopDownAnalysisContext(topDownAnalysisMode, outerDataFlowInfo, declarationScopeProvider!!) + val c = TopDownAnalysisContext(topDownAnalysisMode, outerDataFlowInfo, declarationScopeProvider) val topLevelFqNames = HashMultimap.create() @@ -127,8 +71,8 @@ public class LazyTopDownAnalyzer { if (file.isScript()) { val script = file.getScript() ?: throw AssertionError("getScript() is null for file: $file") - DescriptorResolver.registerFileInPackage(trace!!, file) - c.getScripts().put(script, topLevelDescriptorProvider!!.getScriptDescriptor(script)) + DescriptorResolver.registerFileInPackage(trace, file) + c.getScripts().put(script, topLevelDescriptorProvider.getScriptDescriptor(script)) } else { val packageDirective = file.getPackageDirective() @@ -137,7 +81,7 @@ public class LazyTopDownAnalyzer { c.addFile(file) packageDirective!!.accept(this) - DescriptorResolver.registerFileInPackage(trace!!, file) + DescriptorResolver.registerFileInPackage(trace, file) registerDeclarations(file.getDeclarations()) @@ -146,16 +90,16 @@ public class LazyTopDownAnalyzer { } override fun visitPackageDirective(directive: JetPackageDirective) { - DescriptorResolver.resolvePackageHeader(directive, moduleDescriptor!!, trace!!) + DescriptorResolver.resolvePackageHeader(directive, moduleDescriptor, trace) } override fun visitImportDirective(importDirective: JetImportDirective) { - val fileScope = fileScopeProvider!!.getFileScope(importDirective.getContainingJetFile()) as LazyFileScope + val fileScope = fileScopeProvider.getFileScope(importDirective.getContainingJetFile()) fileScope.forceResolveImport(importDirective) } override fun visitClassOrObject(classOrObject: JetClassOrObject) { - val descriptor = lazyDeclarationResolver!!.getClassDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes + val descriptor = lazyDeclarationResolver.getClassDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes c.getDeclaredClasses().put(classOrObject, descriptor) registerDeclarations(classOrObject.getDeclarations()) @@ -169,16 +113,16 @@ public class LazyTopDownAnalyzer { for (jetDeclaration in classOrObject.getDeclarations()) { if (jetDeclaration is JetObjectDeclaration && jetDeclaration.isCompanion()) { if (companionObjectAlreadyFound) { - trace!!.report(MANY_COMPANION_OBJECTS.on(jetDeclaration)) + trace.report(MANY_COMPANION_OBJECTS.on(jetDeclaration)) } companionObjectAlreadyFound = true } else if (jetDeclaration is JetSecondaryConstructor) { if (DescriptorUtils.isSingletonOrAnonymousObject(classDescriptor)) { - trace!!.report(CONSTRUCTOR_IN_OBJECT.on(jetDeclaration)) + trace.report(CONSTRUCTOR_IN_OBJECT.on(jetDeclaration)) } else if (classDescriptor.getKind() == ClassKind.INTERFACE) { - trace!!.report(CONSTRUCTOR_IN_TRAIT.on(jetDeclaration)) + trace.report(CONSTRUCTOR_IN_TRAIT.on(jetDeclaration)) } } } @@ -192,13 +136,13 @@ public class LazyTopDownAnalyzer { private fun registerPrimaryConstructorParameters(klass: JetClass) { for (jetParameter in klass.getPrimaryConstructorParameters()) { if (jetParameter.hasValOrVar()) { - c.getPrimaryConstructorParameterProperties().put(jetParameter, lazyDeclarationResolver!!.resolveToDescriptor(jetParameter) as PropertyDescriptor) + c.getPrimaryConstructorParameterProperties().put(jetParameter, lazyDeclarationResolver.resolveToDescriptor(jetParameter) as PropertyDescriptor) } } } override fun visitSecondaryConstructor(constructor: JetSecondaryConstructor) { - c.getSecondaryConstructors().put(constructor, lazyDeclarationResolver!!.resolveToDescriptor(constructor) as ConstructorDescriptor) + c.getSecondaryConstructors().put(constructor, lazyDeclarationResolver.resolveToDescriptor(constructor) as ConstructorDescriptor) } override fun visitEnumEntry(enumEntry: JetEnumEntry) { @@ -211,11 +155,11 @@ public class LazyTopDownAnalyzer { override fun visitAnonymousInitializer(initializer: JetClassInitializer) { val classOrObject = PsiTreeUtil.getParentOfType(initializer, javaClass())!! - c.getAnonymousInitializers().put(initializer, lazyDeclarationResolver!!.resolveToDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes) + c.getAnonymousInitializers().put(initializer, lazyDeclarationResolver.resolveToDescriptor(classOrObject) as ClassDescriptorWithResolutionScopes) } override fun visitTypedef(typedef: JetTypedef) { - trace!!.report(UNSUPPORTED.on(typedef, "Typedefs are not supported")) + trace.report(UNSUPPORTED.on(typedef, "Typedefs are not supported")) } override fun visitMultiDeclaration(multiDeclaration: JetMultiDeclaration) { @@ -238,18 +182,18 @@ public class LazyTopDownAnalyzer { resolveAllHeadersInClasses(c) - declarationResolver!!.checkRedeclarationsInPackages(topLevelDescriptorProvider!!, topLevelFqNames) - declarationResolver!!.checkRedeclarations(c) + declarationResolver.checkRedeclarationsInPackages(topLevelDescriptorProvider, topLevelFqNames) + declarationResolver.checkRedeclarations(c) - overrideResolver!!.check(c) + overrideResolver.check(c) - varianceChecker!!.check(c) + varianceChecker.check(c) - declarationResolver!!.resolveAnnotationsOnFiles(c, fileScopeProvider!!) + declarationResolver.resolveAnnotationsOnFiles(c, fileScopeProvider) - overloadResolver!!.process(c) + overloadResolver.process(c) - bodyResolver!!.resolveBodies(c) + bodyResolver.resolveBodies(c) return c } @@ -262,7 +206,7 @@ public class LazyTopDownAnalyzer { private fun createPropertyDescriptors(c: TopDownAnalysisContext, topLevelFqNames: Multimap, properties: List) { for (property in properties) { - val descriptor = lazyDeclarationResolver!!.resolveToDescriptor(property) as PropertyDescriptor + val descriptor = lazyDeclarationResolver.resolveToDescriptor(property) as PropertyDescriptor c.getProperties().put(property, descriptor) ForceResolveUtil.forceResolveAllContents(descriptor.getAnnotations()) @@ -272,7 +216,7 @@ public class LazyTopDownAnalyzer { private fun createFunctionDescriptors(c: TopDownAnalysisContext, functions: List) { for (function in functions) { - val simpleFunctionDescriptor = lazyDeclarationResolver!!.resolveToDescriptor(function) as SimpleFunctionDescriptor + val simpleFunctionDescriptor = lazyDeclarationResolver.resolveToDescriptor(function) as SimpleFunctionDescriptor c.getFunctions().put(function, simpleFunctionDescriptor) ForceResolveUtil.forceResolveAllContents(simpleFunctionDescriptor.getAnnotations()) for (parameterDescriptor in simpleFunctionDescriptor.getValueParameters()) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzerForTopLevel.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzerForTopLevel.java index 4f7a08dfd1b..34137d62142 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzerForTopLevel.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/LazyTopDownAnalyzerForTopLevel.java @@ -28,24 +28,21 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer; import org.jetbrains.kotlin.resolve.lazy.LazyFileScope; -import javax.inject.Inject; import java.util.Arrays; import java.util.Collection; import java.util.List; public class LazyTopDownAnalyzerForTopLevel { - private KotlinCodeAnalyzer resolveSession; - private LazyTopDownAnalyzer lazyTopDownAnalyzer; + @NotNull private final KotlinCodeAnalyzer codeAnalyzer; + @NotNull private final LazyTopDownAnalyzer lazyTopDownAnalyzer; - @Inject - public void setKotlinCodeAnalyzer(@NotNull KotlinCodeAnalyzer kotlinCodeAnalyzer) { - this.resolveSession = kotlinCodeAnalyzer; - } - - @Inject - public void setLazyTopDownAnalyzer(@NotNull LazyTopDownAnalyzer lazyTopDownAnalyzer) { + public LazyTopDownAnalyzerForTopLevel( + @NotNull LazyTopDownAnalyzer lazyTopDownAnalyzer, + @NotNull KotlinCodeAnalyzer codeAnalyzer + ) { this.lazyTopDownAnalyzer = lazyTopDownAnalyzer; + this.codeAnalyzer = codeAnalyzer; } @NotNull @@ -56,15 +53,15 @@ public class LazyTopDownAnalyzerForTopLevel { ) { PackageFragmentProvider provider; if (additionalProviders.isEmpty()) { - provider = resolveSession.getPackageFragmentProvider(); + provider = codeAnalyzer.getPackageFragmentProvider(); } else { provider = new CompositePackageFragmentProvider(KotlinPackage.plus( - Arrays.asList(resolveSession.getPackageFragmentProvider()), + Arrays.asList(codeAnalyzer.getPackageFragmentProvider()), additionalProviders)); } - ((ModuleDescriptorImpl) resolveSession.getModuleDescriptor()).initialize(provider); + ((ModuleDescriptorImpl) codeAnalyzer.getModuleDescriptor()).initialize(provider); return analyzeDeclarations(topDownAnalysisMode, files); } @@ -76,7 +73,7 @@ public class LazyTopDownAnalyzerForTopLevel { ) { TopDownAnalysisContext c = lazyTopDownAnalyzer.analyzeDeclarations(topDownAnalysisMode, elements, DataFlowInfo.EMPTY); - resolveImportsInAllFiles(c, resolveSession); + resolveImportsInAllFiles(c, codeAnalyzer); return c; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.java index cc651b6b51a..2e7bd8747cd 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.java @@ -29,7 +29,6 @@ import org.jetbrains.kotlin.psi.JetDeclaration; import org.jetbrains.kotlin.psi.JetObjectDeclaration; import org.jetbrains.kotlin.psi.JetSecondaryConstructor; -import javax.inject.Inject; import java.util.Collection; import java.util.Map; import java.util.Set; @@ -37,10 +36,9 @@ import java.util.Set; import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName; public class OverloadResolver { - private BindingTrace trace; + @NotNull private final BindingTrace trace; - @Inject - public void setTrace(BindingTrace trace) { + public OverloadResolver(@NotNull BindingTrace trace) { this.trace = trace; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java index 2d70bbd2730..487ae768abb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverrideResolver.java @@ -42,7 +42,6 @@ import org.jetbrains.kotlin.types.*; import org.jetbrains.kotlin.types.checker.JetTypeChecker; import org.jetbrains.kotlin.utils.HashSetUtil; -import javax.inject.Inject; import java.util.*; import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*; @@ -53,15 +52,12 @@ import static org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilPackage. public class OverrideResolver { - private BindingTrace trace; + @NotNull private final BindingTrace trace; - @Inject - public void setTrace(BindingTrace trace) { + public OverrideResolver(@NotNull BindingTrace trace) { this.trace = trace; } - - public void check(@NotNull TopDownAnalysisContext c) { checkVisibility(c); checkOverrides(c); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.java index e29fd460656..98f647407c3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/QualifiedExpressionResolver.java @@ -33,7 +33,6 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope; import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; -import javax.inject.Inject; import java.util.Collection; import java.util.Collections; import java.util.Set; @@ -41,18 +40,10 @@ import java.util.Set; import static org.jetbrains.kotlin.diagnostics.Errors.*; public class QualifiedExpressionResolver { - private SymbolUsageValidator symbolUsageValidator; - private final ImportDirectiveProcessor importDirectiveProcessor = new ImportDirectiveProcessor(this); + @NotNull private final SymbolUsageValidator symbolUsageValidator; + @NotNull private final ImportDirectiveProcessor importDirectiveProcessor = new ImportDirectiveProcessor(this); - /** - * @deprecated Instance of this class should be obtained from the Injector - */ - @Deprecated - public QualifiedExpressionResolver() { - } - - @Inject - public void setSymbolUsageValidator(@NotNull SymbolUsageValidator symbolUsageValidator) { + public QualifiedExpressionResolver(@NotNull SymbolUsageValidator symbolUsageValidator) { this.symbolUsageValidator = symbolUsageValidator; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java index a457e9d7e16..86e06a64666 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ScriptBodyResolver.java @@ -27,7 +27,6 @@ import org.jetbrains.kotlin.types.expressions.CoercionStrategy; import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext; import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; -import javax.inject.Inject; import java.util.Map; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; @@ -36,17 +35,15 @@ import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; // SCRIPT: resolve symbols in scripts public class ScriptBodyResolver { - private ExpressionTypingServices expressionTypingServices; - private AdditionalCheckerProvider additionalCheckerProvider; + @NotNull private final ExpressionTypingServices expressionTypingServices; + @NotNull private final AdditionalCheckerProvider additionalCheckerProvider; - @Inject - public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { - this.expressionTypingServices = expressionTypingServices; - } - - @Inject - public void setAdditionalCheckerProvider(AdditionalCheckerProvider additionalCheckerProvider) { + public ScriptBodyResolver( + @NotNull AdditionalCheckerProvider additionalCheckerProvider, + @NotNull ExpressionTypingServices expressionTypingServices + ) { this.additionalCheckerProvider = additionalCheckerProvider; + this.expressionTypingServices = expressionTypingServices; } public void resolveScriptBodies(@NotNull BodiesResolveContext c) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java index 68c09c6bad1..862d20f2903 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java @@ -46,7 +46,6 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices; import org.jetbrains.kotlin.types.expressions.JetTypeInfo; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryPackage; -import javax.inject.Inject; import java.util.Collections; import java.util.List; @@ -60,24 +59,18 @@ import static org.jetbrains.kotlin.types.TypeUtils.DONT_CARE; import static org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE; public class ArgumentTypeResolver { + @NotNull private final TypeResolver typeResolver; + @NotNull private final ExpressionTypingServices expressionTypingServices; + @NotNull private final KotlinBuiltIns builtIns; - private TypeResolver typeResolver; - private ExpressionTypingServices expressionTypingServices; - private KotlinBuiltIns builtIns; - - @Inject - public void setTypeResolver(@NotNull TypeResolver typeResolver) { - this.typeResolver = typeResolver; - } - - @Inject - public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { - this.expressionTypingServices = expressionTypingServices; - } - - @Inject - public void setBuiltIns(@NotNull KotlinBuiltIns builtIns) { + public ArgumentTypeResolver( + @NotNull KotlinBuiltIns builtIns, + @NotNull ExpressionTypingServices expressionTypingServices, + @NotNull TypeResolver typeResolver + ) { this.builtIns = builtIns; + this.expressionTypingServices = expressionTypingServices; + this.typeResolver = typeResolver; } public static boolean isSubtypeOfForArgumentType( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java index 21447bd2e64..1cb3a6cdac8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallExpressionResolver.java @@ -69,6 +69,7 @@ public class CallExpressionResolver { private ExpressionTypingServices expressionTypingServices; + // component dependency cycle @Inject public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { this.expressionTypingServices = expressionTypingServices; diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java index c3b1edc1349..11ac9867533 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolver.java @@ -23,10 +23,10 @@ import kotlin.Unit; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.name.Name; +import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.*; import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage; @@ -78,52 +78,56 @@ public class CallResolver { private ArgumentTypeResolver argumentTypeResolver; private GenericCandidateResolver genericCandidateResolver; private CallCompleter callCompleter; - private TaskPrioritizer taskPrioritizer; - private AdditionalCheckerProvider additionalCheckerProvider; + @NotNull private final TaskPrioritizer taskPrioritizer; + @NotNull private final AdditionalCheckerProvider additionalCheckerProvider; private static final PerformanceCounter callResolvePerfCounter = PerformanceCounter.Companion.create("Call resolve", ExpressionTypingVisitorDispatcher.typeInfoPerfCounter); private static final PerformanceCounter candidatePerfCounter = PerformanceCounter.Companion.create("Call resolve candidate analysis", true); + public CallResolver( + @NotNull TaskPrioritizer taskPrioritizer, + @NotNull AdditionalCheckerProvider additionalCheckerProvider + ) { + this.taskPrioritizer = taskPrioritizer; + this.additionalCheckerProvider = additionalCheckerProvider; + } + + // component dependency cycle @Inject public void setExpressionTypingServices(@NotNull ExpressionTypingServices expressionTypingServices) { this.expressionTypingServices = expressionTypingServices; } + // component dependency cycle @Inject public void setTypeResolver(@NotNull TypeResolver typeResolver) { this.typeResolver = typeResolver; } + // component dependency cycle @Inject public void setCandidateResolver(@NotNull CandidateResolver candidateResolver) { this.candidateResolver = candidateResolver; } + // component dependency cycle @Inject public void setArgumentTypeResolver(@NotNull ArgumentTypeResolver argumentTypeResolver) { this.argumentTypeResolver = argumentTypeResolver; } + // component dependency cycle @Inject public void setGenericCandidateResolver(GenericCandidateResolver genericCandidateResolver) { this.genericCandidateResolver = genericCandidateResolver; } + // component dependency cycle @Inject public void setCallCompleter(@NotNull CallCompleter callCompleter) { this.callCompleter = callCompleter; } - @Inject - public void setTaskPrioritizer(@NotNull TaskPrioritizer taskPrioritizer) { - this.taskPrioritizer = taskPrioritizer; - } - - @Inject - public void setAdditionalCheckerProvider(AdditionalCheckerProvider additionalCheckerProvider) { - this.additionalCheckerProvider = additionalCheckerProvider; - } - @NotNull public OverloadResolutionResults resolveSimpleProperty(@NotNull BasicCallResolutionContext context) { JetExpression calleeExpression = context.call.getCalleeExpression(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java index 02ed9232825..cbe952096cb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyDeclarationResolver.java @@ -38,26 +38,24 @@ import java.util.List; public class LazyDeclarationResolver { - private final BindingTrace trace; + @NotNull private final TopLevelDescriptorProvider topLevelDescriptorProvider; + @NotNull private final BindingTrace trace; protected DeclarationScopeProvider scopeProvider; - private TopLevelDescriptorProvider topLevelDescriptorProvider; + // component dependency cycle @Inject public void setDeclarationScopeProvider(@NotNull DeclarationScopeProviderImpl scopeProvider) { this.scopeProvider = scopeProvider; } - @Inject - public void setTopLevelDescriptorProvider(@NotNull TopLevelDescriptorProvider topLevelDescriptorProvider) { - this.topLevelDescriptorProvider = topLevelDescriptorProvider; - } - @Deprecated public LazyDeclarationResolver( @NotNull GlobalContext globalContext, - @NotNull BindingTrace delegationTrace + @NotNull BindingTrace delegationTrace, + @NotNull TopLevelDescriptorProvider topLevelDescriptorProvider ) { + this.topLevelDescriptorProvider = topLevelDescriptorProvider; LockBasedLazyResolveStorageManager lockBasedLazyResolveStorageManager = new LockBasedLazyResolveStorageManager(globalContext.getStorageManager()); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java index a9126f6a790..9867e0b7776 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingServices.java @@ -37,7 +37,6 @@ import org.jetbrains.kotlin.types.ErrorUtils; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.expressions.typeInfoFactory.TypeInfoFactoryPackage; -import javax.inject.Inject; import java.util.Iterator; import java.util.List; @@ -50,19 +49,15 @@ public class ExpressionTypingServices { private final ExpressionTypingFacade expressionTypingFacade; private final ExpressionTypingComponents expressionTypingComponents; - private StatementFilter statementFilter; + @NotNull private final StatementFilter statementFilter; - @Inject - public void setStatementFilter(@NotNull StatementFilter statementFilter) { - this.statementFilter = statementFilter; - } - - public ExpressionTypingServices(@NotNull ExpressionTypingComponents components) { + public ExpressionTypingServices(@NotNull ExpressionTypingComponents components, @NotNull StatementFilter statementFilter) { this.expressionTypingComponents = components; + this.statementFilter = statementFilter; this.expressionTypingFacade = ExpressionTypingVisitorDispatcher.create(components); } - public StatementFilter getStatementFilter() { + @NotNull public StatementFilter getStatementFilter() { return statementFilter; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java index d3e70365fda..b82965c9874 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ForLoopConventionsChecker.java @@ -33,7 +33,6 @@ import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.util.slicedMap.WritableSlice; -import javax.inject.Inject; import java.util.Collections; import static org.jetbrains.kotlin.diagnostics.Errors.*; @@ -41,22 +40,17 @@ import static org.jetbrains.kotlin.resolve.BindingContext.*; public class ForLoopConventionsChecker { - private KotlinBuiltIns builtIns; - private SymbolUsageValidator symbolUsageValidator; - private FakeCallResolver fakeCallResolver; + @NotNull private final KotlinBuiltIns builtIns; + @NotNull private final SymbolUsageValidator symbolUsageValidator; + @NotNull private final FakeCallResolver fakeCallResolver; - @Inject - public void setBuiltIns(@NotNull KotlinBuiltIns builtIns) { + public ForLoopConventionsChecker( + @NotNull KotlinBuiltIns builtIns, + @NotNull FakeCallResolver fakeCallResolver, + @NotNull SymbolUsageValidator symbolUsageValidator + ) { this.builtIns = builtIns; - } - - @Inject - public void setFakeCallResolver(@NotNull FakeCallResolver fakeCallResolver) { this.fakeCallResolver = fakeCallResolver; - } - - @Inject - public void setSymbolUsageValidator(SymbolUsageValidator symbolUsageValidator) { this.symbolUsageValidator = symbolUsageValidator; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt index ac2cc72943e..7ec7c4cf7e2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/LocalClassifierAnalyzer.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types.expressions import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil +import org.jetbrains.annotations.NotNull import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.GlobalContext import org.jetbrains.kotlin.context.withModule @@ -45,14 +46,14 @@ import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.DynamicTypesSettings public class LocalClassifierAnalyzer( - val globalContext: GlobalContext, - val storageManager: StorageManager, - val descriptorResolver: DescriptorResolver, - val funcionDescriptorResolver: FunctionDescriptorResolver, - val typeResolver: TypeResolver, - val annotationResolver: AnnotationResolver, - val additionalCheckerProvider: AdditionalCheckerProvider, - val dynamicTypesSettings: DynamicTypesSettings + private val globalContext: GlobalContext, + private val storageManager: StorageManager, + private val descriptorResolver: DescriptorResolver, + private val funcionDescriptorResolver: FunctionDescriptorResolver, + private val typeResolver: TypeResolver, + private val annotationResolver: AnnotationResolver, + private val additionalCheckerProvider: AdditionalCheckerProvider, + private val dynamicTypesSettings: DynamicTypesSettings ) { fun processClassOrObject( scope: WritableScope?, @@ -151,8 +152,9 @@ class LocalClassDescriptorHolder( class LocalLazyDeclarationResolver( globalContext: GlobalContext, trace: BindingTrace, - val localClassDescriptorManager: LocalClassDescriptorHolder -) : LazyDeclarationResolver(globalContext, trace) { + private val localClassDescriptorManager: LocalClassDescriptorHolder, + topLevelDescriptorProvider : TopLevelDescriptorProvider +) : LazyDeclarationResolver(globalContext, trace, topLevelDescriptorProvider) { override fun getClassDescriptor(classOrObject: JetClassOrObject): ClassDescriptor { if (localClassDescriptorManager.isMyClass(classOrObject)) { @@ -166,7 +168,7 @@ class LocalLazyDeclarationResolver( class DeclarationScopeProviderForLocalClassifierAnalyzer( lazyDeclarationResolver: LazyDeclarationResolver, fileScopeProvider: FileScopeProvider, - val localClassDescriptorManager: LocalClassDescriptorHolder + private val localClassDescriptorManager: LocalClassDescriptorHolder ) : DeclarationScopeProviderImpl(lazyDeclarationResolver, fileScopeProvider) { override fun getResolutionScopeForDeclaration(elementOfDeclaration: PsiElement): JetScope { if (localClassDescriptorManager.isMyClass(elementOfDeclaration)) { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt index cba15f0dfba..3d1653726aa 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/ModuleClassResolver.kt @@ -32,6 +32,7 @@ public class SingleModuleClassResolver() : ModuleClassResolver { return resolver!!.resolveClass(javaClass) } + // component dependency cycle var resolver: JavaDescriptorResolver? = null @Inject set } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.java index 1738a9a12ea..29cfa72a0f9 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/DeserializedDescriptorResolver.java @@ -45,6 +45,7 @@ public final class DeserializedDescriptorResolver { this.errorReporter = errorReporter; } + // component dependency cycle @Inject public void setComponents(@NotNull DeserializationComponentsForJava context) { this.components = context.getComponents(); diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt index 765947f6dfa..52f955cfcf6 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedPackageFragment.kt @@ -44,6 +44,7 @@ public abstract class DeserializedPackageFragment( protected var components: DeserializationComponents by Delegates.notNull() + // component dependency cycle Inject public fun setDeserializationComponents(components: DeserializationComponents) { this.components = components diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt index bb6d55f5200..33b8f54d1ef 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/LocalClassResolverImpl.kt @@ -24,6 +24,7 @@ import kotlin.properties.Delegates public class LocalClassResolverImpl : LocalClassResolver { public var components: DeserializationComponents by Delegates.notNull() + // component dependency cycle Inject public fun setDeserializationComponents(components: DeserializationComponents) { this.components = components From eb97005cb5718e90a1b2c8bd2e81fbc9459686fd Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Mon, 20 Jul 2015 16:03:17 +0300 Subject: [PATCH 434/450] Avoid creating SimpleResolutionContext in ConstantExpressionEvaluator to updateNumberType --- .../resolve/calls/ArgumentTypeResolver.java | 21 ++++++++++--------- .../kotlin/resolve/calls/CallCompleter.kt | 2 +- .../resolve/calls/GenericCandidateResolver.kt | 2 +- .../evaluate/ConstantExpressionEvaluator.kt | 8 +------ .../expressions/ExpressionTypingUtils.java | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java index 862d20f2903..87ef35c94e9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/ArgumentTypeResolver.java @@ -151,7 +151,7 @@ public class ArgumentTypeResolver { private static JetFunction getFunctionLiteralArgumentIfAny( @NotNull JetExpression expression, @NotNull ResolutionContext context ) { - JetExpression deparenthesizedExpression = getLastElementDeparenthesized(expression, context); + JetExpression deparenthesizedExpression = getLastElementDeparenthesized(expression, context.statementFilter); if (deparenthesizedExpression instanceof JetFunctionLiteralExpression) { return ((JetFunctionLiteralExpression) deparenthesizedExpression).getFunctionLiteral(); } @@ -164,7 +164,7 @@ public class ArgumentTypeResolver { @Nullable public static JetExpression getLastElementDeparenthesized( @Nullable JetExpression expression, - @NotNull ResolutionContext context + @NotNull StatementFilter statementFilter ) { JetExpression deparenthesizedExpression = JetPsiUtil.deparenthesize(expression, false); if (deparenthesizedExpression instanceof JetBlockExpression) { @@ -173,9 +173,9 @@ public class ArgumentTypeResolver { // This case is a temporary hack for 'if' branches. // The right way to implement this logic is to interpret 'if' branches as function literals with explicitly-typed signatures // (no arguments and no receiver) and therefore analyze them straight away (not in the 'complete' phase). - JetExpression lastStatementInABlock = ResolvePackage.getLastStatementInABlock(context.statementFilter, blockExpression); + JetExpression lastStatementInABlock = ResolvePackage.getLastStatementInABlock(statementFilter, blockExpression); if (lastStatementInABlock != null) { - return getLastElementDeparenthesized(lastStatementInABlock, context); + return getLastElementDeparenthesized(lastStatementInABlock, statementFilter); } } return deparenthesizedExpression; @@ -303,7 +303,7 @@ public class ArgumentTypeResolver { if (type.getConstructor() instanceof IntegerValueTypeConstructor) { IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor(); JetType primitiveType = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType); - updateNumberType(primitiveType, expression, context); + updateNumberType(primitiveType, expression, context.statementFilter, context.trace); return primitiveType; } } @@ -313,19 +313,20 @@ public class ArgumentTypeResolver { public static void updateNumberType( @NotNull JetType numberType, @Nullable JetExpression expression, - @NotNull ResolutionContext context + @NotNull StatementFilter statementFilter, + @NotNull BindingTrace trace ) { if (expression == null) return; - BindingContextUtils.updateRecordedType(numberType, expression, context.trace, false); + BindingContextUtils.updateRecordedType(numberType, expression, trace, false); if (!(expression instanceof JetConstantExpression)) { - JetExpression deparenthesized = getLastElementDeparenthesized(expression, context); + JetExpression deparenthesized = getLastElementDeparenthesized(expression, statementFilter); if (deparenthesized != expression) { - updateNumberType(numberType, deparenthesized, context); + updateNumberType(numberType, deparenthesized, statementFilter, trace); } return; } - ConstantExpressionEvaluator.evaluate(expression, context.trace, numberType); + ConstantExpressionEvaluator.evaluate(expression, trace, numberType); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 91023046e3f..b5cf244d821 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -226,7 +226,7 @@ public class CallCompleter( if (valueArgument.isExternal()) return val expression = valueArgument.getArgumentExpression() ?: return - val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context) ?: return + val deparenthesized = ArgumentTypeResolver.getLastElementDeparenthesized(expression, context.statementFilter) ?: return val recordedType = expression.let { context.trace.getType(it) } var updatedType: JetType? = recordedType diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index 721629325d0..129d4d252c9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -185,7 +185,7 @@ class GenericCandidateResolver( argumentExpression: JetExpression?, context: ResolutionContext<*> ): JetType? { - val deparenthesizedArgument = getLastElementDeparenthesized(argumentExpression, context) + val deparenthesizedArgument = getLastElementDeparenthesized(argumentExpression, context.statementFilter) if (deparenthesizedArgument == null || type == null) return type val dataFlowValue = DataFlowValueFactory.createDataFlowValue(deparenthesizedArgument, type, context) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 63b80d5aa04..a7240b3f284 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -170,13 +170,7 @@ public class ConstantExpressionEvaluator( val constant = ConstantExpressionEvaluator.evaluate(argumentExpression, trace, expectedType) if (constant is IntegerValueTypeConstant) { val defaultType = constant.getType(expectedType) - val context = SimpleResolutionContext(trace, JetScope.Empty, TypeUtils.NO_EXPECTED_TYPE, DataFlowInfo.EMPTY, - ContextDependency.INDEPENDENT, - CompositeChecker(emptyList()), - SymbolUsageValidator.Empty, - AdditionalTypeChecker.Composite(emptyList()), - StatementFilter.NONE) - ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, context) + ArgumentTypeResolver.updateNumberType(defaultType, argumentExpression, StatementFilter.NONE, trace) } if (constant != null) { constants.add(constant) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java index 58e9ba815af..92932bd142e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingUtils.java @@ -253,7 +253,7 @@ public class ExpressionTypingUtils { IntegerValueTypeConstant integerValueTypeConstant = (IntegerValueTypeConstant) value; if (context.contextDependency == INDEPENDENT) { expressionType = integerValueTypeConstant.getType(context.expectedType); - ArgumentTypeResolver.updateNumberType(expressionType, expression, context); + ArgumentTypeResolver.updateNumberType(expressionType, expression, context.statementFilter, context.trace); } else { expressionType = integerValueTypeConstant.getUnknownIntegerType(); From 08ac0ae7a0bd309591b2e708cc6ebf4ddf668ef7 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 13:10:32 +0300 Subject: [PATCH 435/450] Renamed classes --- .../kotlin/codegen/ExpressionCodegen.java | 8 ++++---- ...onsScope.kt => JavaSyntheticExtensionsScope.kt} | 14 +++++++------- .../idea/codeInsight/ReferenceVariantsHelper.kt | 4 ++-- .../SyntheticPropertyAccessorReference.kt | 10 +++++----- .../kotlin/idea/completion/LookupElementFactory.kt | 4 ++-- .../intentions/UsePropertyAccessSyntaxIntention.kt | 6 +++--- .../KotlinPropertyAccessorsReferenceSearcher.kt | 8 ++++---- 7 files changed, 27 insertions(+), 27 deletions(-) rename compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/{JavaBeansExtensionsScope.kt => JavaSyntheticExtensionsScope.kt} (94%) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index d52b296ad68..45023e2870e 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -76,7 +76,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature; import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature; import org.jetbrains.kotlin.resolve.scopes.receivers.*; -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor; +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor; import org.jetbrains.kotlin.types.JetType; import org.jetbrains.kotlin.types.TypeProjection; import org.jetbrains.kotlin.types.TypeUtils; @@ -2145,8 +2145,8 @@ public class ExpressionCodegen extends JetVisitor implem @NotNull MethodKind methodKind, StackValue receiver ) { - if (propertyDescriptor instanceof SyntheticJavaBeansPropertyDescriptor) { - return intermediateValueForSyntheticExtensionProperty((SyntheticJavaBeansPropertyDescriptor) propertyDescriptor, receiver); + if (propertyDescriptor instanceof SyntheticJavaPropertyDescriptor) { + return intermediateValueForSyntheticExtensionProperty((SyntheticJavaPropertyDescriptor) propertyDescriptor, receiver); } DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration(); @@ -2242,7 +2242,7 @@ public class ExpressionCodegen extends JetVisitor implem } @NotNull - private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaBeansPropertyDescriptor propertyDescriptor, StackValue receiver) { + private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaPropertyDescriptor propertyDescriptor, StackValue receiver) { Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType()); CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context); FunctionDescriptor setMethod = propertyDescriptor.getSetMethod(); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt similarity index 94% rename from compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt rename to compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index c5deca72822..b406d7d6647 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaBeansExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -38,12 +38,12 @@ import org.jetbrains.kotlin.utils.addIfNotNull import java.beans.Introspector import java.util.ArrayList -interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { +interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor val setMethod: FunctionDescriptor? companion object { - fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { + fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? { val name = getterOrSetter.getName() if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization @@ -51,7 +51,7 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { if (owner !is JavaClassDescriptor) return null return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) - .filterIsInstance() + .filterIsInstance() .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } } @@ -73,12 +73,12 @@ interface SyntheticJavaBeansPropertyDescriptor : PropertyDescriptor { } class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager) : FileScopeProvider.AdditionalScopes { - private val scope = JavaBeansExtensionsScope(storageManager) + private val scope = JavaSyntheticExtensionsScope(storageManager) override fun scopes(file: JetFile) = listOf(scope) } -class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { +class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { triple -> syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third) } @@ -158,7 +158,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet if (classifier is JavaClassDescriptor) { for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { - val propertyName = SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue + val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) } } @@ -192,7 +192,7 @@ class JavaBeansExtensionsScope(storageManager: StorageManager) : JetScope by Jet name: Name, type: JetType, receiverType: JetType - ) : SyntheticJavaBeansPropertyDescriptor, PropertyDescriptorImpl( + ) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl( DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, null, Annotations.EMPTY, diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index b877da621df..2ec2d2d549b 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.JetTypeChecker @@ -75,7 +75,7 @@ public class ReferenceVariantsHelper( if (filterOutJavaGettersAndSetters) { val accessorMethodsToRemove = HashSet() for (variant in variants) { - if (variant is SyntheticJavaBeansPropertyDescriptor) { + if (variant is SyntheticJavaPropertyDescriptor) { accessorMethodsToRemove.add(variant.getMethod) accessorMethodsToRemove.addIfNotNull(variant.setMethod) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 703f46f7f51..d689db4a800 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -26,17 +26,17 @@ import org.jetbrains.kotlin.psi.JetNameReferenceExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.utils.addIfNotNull sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference(expression) { override fun getTargetDescriptors(context: BindingContext): Collection { val descriptors = super.getTargetDescriptors(context) - if (descriptors.none { it is SyntheticJavaBeansPropertyDescriptor }) return emptyList() + if (descriptors.none { it is SyntheticJavaPropertyDescriptor }) return emptyList() val result = SmartList() for (descriptor in descriptors) { - if (descriptor is SyntheticJavaBeansPropertyDescriptor) { + if (descriptor is SyntheticJavaPropertyDescriptor) { if (getter) { result.add(descriptor.getMethod) } @@ -57,9 +57,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr val newNameAsName = Name.identifier(newElementName) val newName = if (getter) - SyntheticJavaBeansPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) + SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) else - SyntheticJavaBeansPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) + SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 09f2be940a9..043a16c6709 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.renderer.DescriptorRenderer import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import javax.swing.Icon @@ -254,7 +254,7 @@ public class LookupElementFactory( if (descriptor is CallableDescriptor) { when { - descriptor is SyntheticJavaBeansPropertyDescriptor -> { + descriptor is SyntheticJavaPropertyDescriptor -> { var from = descriptor.getMethod.getName().asString() + "()" descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" } element = element.appendTailText(" (from $from)", true) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index 273c8a0ddc3..fc931f06252 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -37,7 +37,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor class UsePropertyAccessSyntaxInspection : IntentionBasedInspection(UsePropertyAccessSyntaxIntention()) @@ -87,8 +87,8 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent return property } - private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaBeansPropertyDescriptor? { - SyntheticJavaBeansPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } + private fun findSyntheticProperty(function: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? { + SyntheticJavaPropertyDescriptor.findByGetterOrSetter(function, resolutionScope)?.let { return it } for (overridden in function.getOverriddenDescriptors()) { findSyntheticProperty(overridden, resolutionScope)?.let { return it } diff --git a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt index 3ea9e34c1cd..5af77fff1c2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/search/ideaExtensions/KotlinPropertyAccessorsReferenceSearcher.kt @@ -29,8 +29,8 @@ import org.jetbrains.kotlin.idea.JetFileType import org.jetbrains.kotlin.idea.caches.resolve.getJavaMethodDescriptor import org.jetbrains.kotlin.psi.JetProperty import org.jetbrains.kotlin.storage.LockBasedStorageManager -import org.jetbrains.kotlin.synthetic.SyntheticJavaBeansPropertyDescriptor -import org.jetbrains.kotlin.synthetic.JavaBeansExtensionsScope +import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor +import org.jetbrains.kotlin.synthetic.JavaSyntheticExtensionsScope public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase(true) { override fun processQuery(queryParameters: MethodReferencesSearch.SearchParameters, consumer: Processor) { @@ -54,8 +54,8 @@ public class KotlinPropertyAccessorsReferenceSearcher() : QueryExecutorBase Date: Fri, 17 Jul 2015 14:06:19 +0300 Subject: [PATCH 436/450] Fixed wrong test data --- .../rename/syntheticPropertyUsages2/before/Usages.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt index d850719ed2e..97a3bb2eda3 100644 --- a/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages2/before/Usages.kt @@ -1,6 +1,6 @@ import testing.JavaClass fun usages(javaClass: JavaClass) { - javaClass.somethingNew = javaClass.something + 1 - javaClass.somethingNew++ + javaClass.something = javaClass.something + 1 + javaClass.something++ } \ No newline at end of file From b6027a0efe686ceef6d08c23484ec5b0241f016a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 14:28:21 +0300 Subject: [PATCH 437/450] Changed synthetic properties naming for getters starting with "is" --- .../synthetic/JavaSyntheticExtensionsScope.kt | 41 ++++++++++++++----- .../tests/syntheticExtensions/IsNaming.kt | 25 +++++++++-- .../tests/syntheticExtensions/IsNaming.txt | 2 + .../SyntheticPropertyAccessorReference.kt | 13 ++++-- .../common/extensions/SyntheticExtensions2.kt | 4 +- .../usePropertyAccessSyntax/isGet.kt | 4 ++ .../usePropertyAccessSyntax/isGet.kt.after | 4 ++ .../usePropertyAccessSyntax/isSet.kt | 4 ++ .../usePropertyAccessSyntax/isSet.kt.after | 4 ++ .../syntheticPropertyUsages3/after/Usages.kt | 5 +++ .../after/testing/JavaClass.java | 6 +++ .../syntheticPropertyUsages3/before/Usages.kt | 5 +++ .../before/testing/JavaClass.java | 6 +++ .../renameSetMethod.test | 6 +++ .../intentions/IntentionTestGenerated.java | 12 ++++++ .../rename/RenameTestGenerated.java | 6 +++ 16 files changed, 127 insertions(+), 20 deletions(-) create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/isGet.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/isGet.kt.after create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/isSet.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/isSet.kt.after create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages3/after/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages3/after/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages3/before/Usages.kt create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages3/before/testing/JavaClass.java create mode 100644 idea/testData/refactoring/rename/syntheticPropertyUsages3/renameSetMethod.test diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index b406d7d6647..2b44ac22772 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -45,7 +45,9 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { companion object { fun findByGetterOrSetter(getterOrSetter: FunctionDescriptor, resolutionScope: JetScope): SyntheticJavaPropertyDescriptor? { val name = getterOrSetter.getName() - if (propertyNameByGetMethodName(name) == null && propertyNameBySetMethodName(name) == null) return null // optimization + if (name.isSpecial()) return null + val identifier = name.getIdentifier() + if (!identifier.startsWith("get") && !identifier.startsWith("is") && !identifier.startsWith("set")) return null // optimization val owner = getterOrSetter.getContainingDeclaration() if (owner !is JavaClassDescriptor) return null @@ -56,15 +58,22 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { } fun propertyNameByGetMethodName(methodName: Name): Name? - = propertyNameFromAccessorMethodName(methodName, "get") ?: propertyNameFromAccessorMethodName(methodName, "is") + = propertyNameFromAccessorMethodName(methodName, "get") ?: propertyNameFromAccessorMethodName(methodName, "is", removePrefix = false) - fun propertyNameBySetMethodName(methodName: Name): Name? - = propertyNameFromAccessorMethodName(methodName, "set") + fun propertyNameBySetMethodName(methodName: Name, withIsPrefix: Boolean): Name? + = propertyNameFromAccessorMethodName(methodName, "set", addPrefix = if (withIsPrefix) "is" else null) - private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String): Name? { + private fun propertyNameFromAccessorMethodName(methodName: Name, prefix: String, removePrefix: Boolean = true, addPrefix: String? = null): Name? { if (methodName.isSpecial()) return null val identifier = methodName.getIdentifier() if (!identifier.startsWith(prefix)) return null + + if (addPrefix != null) { + assert(removePrefix) + return Name.identifier(addPrefix + identifier.removePrefix(prefix)) + } + + if (!removePrefix) return methodName val name = Introspector.decapitalize(identifier.removePrefix(prefix)) if (!Name.isValidIdentifier(name)) return null return Name.identifier(name) @@ -103,7 +112,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by .singleOrNull { isGoodGetMethod(it) } ?: return null val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(possibleSetMethodName(name)).singleOrNull { isGoodSetMethod(it, propertyType) } + val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())).singleOrNull { isGoodSetMethod(it, propertyType) } return MyPropertyDescriptor(javaClass, getMethod, setMethod, name, propertyType, type) } @@ -177,12 +186,24 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by //TODO: reuse code with generation? private fun possibleGetMethodNames(propertyName: Name): Collection { - val capitalized = propertyName.getIdentifier().capitalize() - return listOf(Name.identifier("get" + capitalized), Name.identifier("is" + capitalized)) + val identifier = propertyName.getIdentifier() + val getPrefixName = Name.identifier("get" + identifier.capitalize()) + if (identifier.startsWith("is")) { + return listOf(propertyName, getPrefixName) + } + else { + return listOf(getPrefixName) + } } - private fun possibleSetMethodName(propertyName: Name): Name { - return Name.identifier("set" + propertyName.getIdentifier().capitalize()) + private fun setMethodName(getMethodName: Name): Name { + val identifier = getMethodName.getIdentifier() + val prefix = when { + identifier.startsWith("get") -> "get" + identifier.startsWith("is") -> "is" + else -> throw IllegalArgumentException() + } + return Name.identifier("set" + identifier.removePrefix(prefix).capitalize()) } private class MyPropertyDescriptor( diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt index c4883eddbf2..45eb42ecf0a 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.kt @@ -1,13 +1,30 @@ // FILE: KotlinFile.kt fun foo(javaClass: JavaClass) { - javaClass.something = !javaClass.something + javaClass.isSomething = !javaClass.isSomething + javaClass.isSomething2 = !javaClass.isSomething2 + javaClass.something + javaClass.isSomethingWrong javaClass.somethingWrong } // FILE: JavaClass.java public class JavaClass { - public boolean isSomething() { return true; } - public void setSomething(boolean value) { } - public int isSomethingWrong() { return 1; } + public boolean isSomething() { + return true; + } + + public void setSomething(boolean value) { + } + + public boolean getIsSomething2() { + return true; + } + + public void setIsSomething2(boolean value) { + } + + public int isSomethingWrong() { + return 1; + } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt index f80114acd07..93bde185b5b 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/IsNaming.txt @@ -5,9 +5,11 @@ internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit public open class JavaClass { public constructor JavaClass() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getIsSomething2(): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open fun isSomething(): kotlin.Boolean public open fun isSomethingWrong(): kotlin.Int + public open fun setIsSomething2(/*0*/ value: kotlin.Boolean): kotlin.Unit public open fun setSomething(/*0*/ value: kotlin.Boolean): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index d689db4a800..d0c873128ff 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -21,11 +21,12 @@ import com.intellij.psi.PsiElement import com.intellij.util.SmartList import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.JetNameReferenceExpression import org.jetbrains.kotlin.psi.JetPsiFactory -import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor import org.jetbrains.kotlin.utils.addIfNotNull @@ -56,10 +57,14 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr if (!Name.isValidIdentifier(newElementName!!)) return expression val newNameAsName = Name.identifier(newElementName) - val newName = if (getter) + val newName = if (getter) { SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) - else - SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName) + } + else { + val propertyDescriptor = super.getTargetDescriptors(expression.analyze(BodyResolveMode.PARTIAL)) + .singleOrNull { it is SyntheticJavaPropertyDescriptor } ?: return expression + SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = propertyDescriptor.getName().asString().startsWith("is")) + } if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method val nameIdentifier = JetPsiFactory(expression).createNameIdentifier(newName.getIdentifier()) diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index cc74e6dfe9b..98c55ba5476 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -5,10 +5,10 @@ fun Thread.foo(urlConnection: java.net.URLConnection) { } // EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " (from getPriority()/setPriority())", typeText: "Int" } -// EXIST_JAVA_ONLY: { lookupString: "daemon", itemText: "daemon", tailText: " (from isDaemon()/setDaemon())", typeText: "Boolean" } +// EXIST_JAVA_ONLY: { lookupString: "isDaemon", itemText: "isDaemon", tailText: " (from isDaemon()/setDaemon())", typeText: "Boolean" } // EXIST_JAVA_ONLY: { lookupString: "URL", itemText: "URL", tailText: " (from getURL())", typeText: "URL!" } // ABSENT: getPriority // ABSENT: setPriority -// ABSENT: isDaemon +// ABSENT: { itemText: "isDaemon", tailText: "()" } // ABSENT: setDaemon // ABSENT: getURL diff --git a/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt b/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt new file mode 100644 index 00000000000..4226c66661d --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.isDaemon() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt.after new file mode 100644 index 00000000000..2d219caa3cd --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/isGet.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.isDaemon +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt b/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt new file mode 100644 index 00000000000..d85a6bc74a5 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.setDaemon(true) +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt.after new file mode 100644 index 00000000000..51f85fe5da9 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/isSet.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(thread: Thread) { + thread.isDaemon = true +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/Usages.kt new file mode 100644 index 00000000000..2d1769e76d3 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/Usages.kt @@ -0,0 +1,5 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.isSomethingNew = !javaClass.isSomething +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/testing/JavaClass.java new file mode 100644 index 00000000000..c1d68acf1af --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages3/after/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public boolean isSomething() { return true; } + public void setSomethingNew(boolean value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/Usages.kt b/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/Usages.kt new file mode 100644 index 00000000000..686f44b4a3e --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/Usages.kt @@ -0,0 +1,5 @@ +import testing.JavaClass + +fun usages(javaClass: JavaClass) { + javaClass.isSomething = !javaClass.isSomething +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/testing/JavaClass.java b/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/testing/JavaClass.java new file mode 100644 index 00000000000..330068bb7d8 --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages3/before/testing/JavaClass.java @@ -0,0 +1,6 @@ +package testing; + +public class JavaClass { + public boolean isSomething() { return true; } + public void setSomething(boolean value) {} +} \ No newline at end of file diff --git a/idea/testData/refactoring/rename/syntheticPropertyUsages3/renameSetMethod.test b/idea/testData/refactoring/rename/syntheticPropertyUsages3/renameSetMethod.test new file mode 100644 index 00000000000..cfbc1f7d38a --- /dev/null +++ b/idea/testData/refactoring/rename/syntheticPropertyUsages3/renameSetMethod.test @@ -0,0 +1,6 @@ +{ + "type": "JAVA_METHOD", + "classId": "testing/JavaClass", + "methodSignature": "void setSomething(boolean value)", + "newName": "setSomethingNew" +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 67130b4b574..05e05dc3277 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -7433,6 +7433,18 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("isGet.kt") + public void testIsGet() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/isGet.kt"); + doTest(fileName); + } + + @TestMetadata("isSet.kt") + public void testIsSet() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/isSet.kt"); + doTest(fileName); + } + @TestMetadata("set.kt") public void testSet() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/set.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java index 22b18c54325..05d62c0d780 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/rename/RenameTestGenerated.java @@ -382,4 +382,10 @@ public class RenameTestGenerated extends AbstractRenameTest { String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/syntheticPropertyUsages2/renameSetMethod.test"); doTest(fileName); } + + @TestMetadata("syntheticPropertyUsages3/renameSetMethod.test") + public void testSyntheticPropertyUsages3_RenameSetMethod() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/rename/syntheticPropertyUsages3/renameSetMethod.test"); + doTest(fileName); + } } From 23cfe88b7175efbf41ab25e3917be3920f99c9d0 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 15:13:39 +0300 Subject: [PATCH 438/450] KT-8530 Synthetic properties doesn't work with smart casts #KT-8530 Fixed --- .../synthetic/JavaSyntheticExtensionsScope.kt | 36 ++++++++++----- .../kotlin/resolve/AllUnderImportsScope.kt | 8 ++-- .../tasks/CallableDescriptorCollectors.kt | 16 +++---- .../resolve/calls/tasks/TaskPrioritizer.kt | 45 ++++++++++++------- .../resolve/calls/tasks/dynamicCalls.kt | 4 +- .../kotlin/resolve/lazy/LazyImportScope.kt | 8 ++-- .../tests/syntheticExtensions/SmartCast.kt | 28 ++++++++++++ .../tests/syntheticExtensions/SmartCast.txt | 37 +++++++++++++++ .../SmartCastImplicitReceiver.kt | 23 ++++++++++ .../SmartCastImplicitReceiver.txt | 29 ++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 12 +++++ .../resolve/scopes/AbstractScopeAdapter.kt | 8 ++-- .../kotlin/resolve/scopes/ChainedScope.kt | 8 ++-- .../kotlin/resolve/scopes/FilteringScope.kt | 4 +- .../kotlin/resolve/scopes/JetScope.kt | 4 +- .../kotlin/resolve/scopes/JetScopeImpl.kt | 4 +- .../resolve/scopes/SubstitutingScope.kt | 4 +- .../jetbrains/kotlin/types/ErrorUtils.java | 8 ++-- .../codeInsight/ReferenceVariantsHelper.kt | 14 +++--- 19 files changed, 229 insertions(+), 71 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 2b44ac22772..695dcfca9af 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -36,7 +36,7 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.utils.addIfNotNull import java.beans.Introspector -import java.util.ArrayList +import java.util.* interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor @@ -52,7 +52,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val owner = getterOrSetter.getContainingDeclaration() if (owner !is JavaClassDescriptor) return null - return resolutionScope.getSyntheticExtensionProperties(owner.getDefaultType()) + return resolutionScope.getSyntheticExtensionProperties(listOf(owner.getDefaultType())) .filterIsInstance() .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } } @@ -136,11 +136,22 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by && descriptor.getVisibility() == Visibilities.PUBLIC } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { - return collectSyntheticPropertiesByName(null, receiverType.makeNotNullable(), name) ?: emptyList() + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { + var result: SmartList? = null + val processedTypes: MutableSet? = if (receiverTypes.size() > 1) HashSet() else null + receiverTypes.forEach { + result = collectSyntheticPropertiesByName(result, it.makeNotNullable(), name, processedTypes) + } + return when { + result == null -> emptyList() + result!!.size() > 1 -> result!!.toSet() + else -> result!! + } } - private fun collectSyntheticPropertiesByName(result: SmartList?, type: JetType, name: Name): SmartList? { + private fun collectSyntheticPropertiesByName(result: SmartList?, type: JetType, name: Name, processedTypes: MutableSet?): SmartList? { + if (processedTypes != null && !processedTypes.add(type)) return result + @suppress("NAME_SHADOWING") var result = result @@ -150,18 +161,23 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by result = result.add(syntheticPropertyInClass(Triple(classifier, type, name))) } - typeConstructor.getSupertypes().forEach { result = collectSyntheticPropertiesByName(result, it, name) } + typeConstructor.getSupertypes().forEach { result = collectSyntheticPropertiesByName(result, it, name, processedTypes) } return result } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { val result = ArrayList() - result.collectSyntheticProperties(receiverType.makeNotNullable()) + val processedTypes = HashSet() + receiverTypes.forEach { + result.collectSyntheticProperties(it.makeNotNullable(), processedTypes) + } return result } - private fun MutableList.collectSyntheticProperties(type: JetType) { + private fun MutableList.collectSyntheticProperties(type: JetType, processedTypes: MutableSet) { + if (!processedTypes.add(type)) return + val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() if (classifier is JavaClassDescriptor) { @@ -173,7 +189,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by } } - typeConstructor.getSupertypes().forEach { collectSyntheticProperties(it) } + typeConstructor.getSupertypes().forEach { collectSyntheticProperties(it, processedTypes) } } private fun SmartList?.add(property: PropertyDescriptor?): SmartList? { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt index f4218d6fc5c..f80c038a654 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AllUnderImportsScope.kt @@ -53,12 +53,12 @@ class AllUnderImportsScope : JetScope { return scopes.flatMap { it.getFunctions(name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { - return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType, name) } + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { + return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { - return scopes.flatMap { it.getSyntheticExtensionProperties(receiverType) } + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) } } override fun getPackage(name: Name): PackageViewDescriptor? = null // packages are not imported by all under imports diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt index 32555451aa8..2625c5d35de 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/CallableDescriptorCollectors.kt @@ -39,7 +39,7 @@ public trait CallableDescriptorCollector { public fun getStaticMembersByName(receiver: JetType, name: Name, bindingTrace: BindingTrace): Collection - public fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection + public fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection } private fun CallableDescriptorCollector.withDefaultFilter() = filtered { !LibrarySourceHacks.shouldSkip(it) } @@ -97,7 +97,7 @@ private object FunctionCollector : CallableDescriptorCollector { + override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection { val functions = scope.getFunctions(name) val (extensions, nonExtensions) = functions.partition { it.getExtensionReceiverParameter() != null } @@ -151,9 +151,9 @@ private object VariableCollector : CallableDescriptorCollector { + override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection { // property may have an extension function type, we check the applicability later to avoid an early computing of deferred types - return (listOf(scope.getLocalVariable(name)) + scope.getProperties(name) + scope.getSyntheticExtensionProperties(receiver, name)).filterNotNull() + return (listOf(scope.getLocalVariable(name)) + scope.getProperties(name) + scope.getSyntheticExtensionProperties(receiverTypes, name)).filterNotNull() } override fun toString() = "VARIABLES" @@ -175,8 +175,8 @@ private object PropertyCollector : CallableDescriptorCollector { - return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, receiver, bindingTrace)) + override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection { + return filterProperties(VARIABLES_COLLECTOR.getExtensionsByName(scope, name, receiverTypes, bindingTrace)) } override fun toString() = "PROPERTIES" @@ -197,8 +197,8 @@ private fun CallableDescriptorCollector.filtered(fil return delegate.getStaticMembersByName(receiver, name, bindingTrace).filter(filter) } - override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { - return delegate.getExtensionsByName(scope, name, receiver, bindingTrace).filter(filter) + override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection { + return delegate.getExtensionsByName(scope, name, receiverTypes, bindingTrace).filter(filter) } override fun toString(): String { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index e6b8ead5a3c..41ea2fbd7a8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -18,9 +18,9 @@ package org.jetbrains.kotlin.resolve.calls.tasks import com.google.common.collect.Lists import com.google.common.collect.Sets -import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus import org.jetbrains.kotlin.psi.Call import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.ErrorUtils +import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.checker.JetTypeChecker import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import org.jetbrains.kotlin.types.isDynamic @@ -119,8 +120,9 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { } val implicitReceivers = Sets.newLinkedHashSet(JetScopeUtils.getImplicitReceiversHierarchyValues(c.scope)) if (receiver.exists()) { - addCandidatesForExplicitReceiver(receiver, implicitReceivers, c, isExplicit = true) - addMembers(receiver, c, staticMembers = true, isExplicit = true) + val receiverTypes = SmartCastUtils.getSmartCastVariants(receiver, c.context) + addCandidatesForExplicitReceiver(receiver, receiverTypes, implicitReceivers, c, isExplicit = true) + addMembers(receiver, receiverTypes, c, staticMembers = true, isExplicit = true) return } addCandidatesForNoReceiver(implicitReceivers, c) @@ -128,22 +130,24 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun addCandidatesForExplicitReceiver( explicitReceiver: ReceiverValue, + explicitReceiverTypes: Collection, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean ) { - addMembers(explicitReceiver, c, staticMembers = false, isExplicit = isExplicit) + addMembers(explicitReceiver, explicitReceiverTypes, c, staticMembers = false, isExplicit = isExplicit) if (explicitReceiver.getType().isDynamic()) { - addCandidatesForDynamicReceiver(explicitReceiver, implicitReceivers, c, isExplicit) + addCandidatesForDynamicReceiver(explicitReceiver, explicitReceiverTypes, implicitReceivers, c, isExplicit) } else { - addExtensionCandidates(explicitReceiver, implicitReceivers, c, isExplicit) + addExtensionCandidates(explicitReceiver, explicitReceiverTypes, implicitReceivers, c, isExplicit) } } private fun addExtensionCandidates( explicitReceiver: ReceiverValue, + explicitReceiverTypes: Collection, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean @@ -154,6 +158,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { addMemberExtensionCandidates( implicitReceiver, explicitReceiver, + explicitReceiverTypes, callableDescriptorCollector, c, createKind(EXTENSION_RECEIVER, isExplicit) @@ -164,7 +169,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { convertWithImpliedThis( c.scope, explicitReceiver, - callableDescriptorCollector.getExtensionsByName(c.scope, c.name, explicitReceiver.getType(), c.context.trace), + callableDescriptorCollector.getExtensionsByName(c.scope, c.name, explicitReceiverTypes, c.context.trace), createKind(EXTENSION_RECEIVER, isExplicit), c.context.call ) @@ -174,15 +179,15 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun addMembers( explicitReceiver: ReceiverValue, + explicitReceiverTypes: Collection, c: TaskPrioritizerContext, staticMembers: Boolean, isExplicit: Boolean ) { for (callableDescriptorCollector in c.callableDescriptorCollectors) { c.result.addCandidates { - val variantsForExplicitReceiver = SmartCastUtils.getSmartCastVariants(explicitReceiver, c.context) val members = Lists.newArrayList>() - for (type in variantsForExplicitReceiver) { + for (type in explicitReceiverTypes) { val membersForThisVariant = if (staticMembers) { callableDescriptorCollector.getStaticMembersByName(type, c.name, c.context.trace) } @@ -205,12 +210,13 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun addCandidatesForDynamicReceiver( explicitReceiver: ReceiverValue, + explicitReceiverTypes: Collection, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean ) { val onlyDynamicReceivers = c.replaceCollectors(c.callableDescriptorCollectors.onlyDynamicReceivers()) - addExtensionCandidates(explicitReceiver, implicitReceivers, onlyDynamicReceivers, isExplicit) + addExtensionCandidates(explicitReceiver, explicitReceiverTypes, implicitReceivers, onlyDynamicReceivers, isExplicit) c.result.addCandidates { val dynamicScope = DynamicCallableDescriptors.createDynamicDescriptorScope(c.context.call, c.scope.getContainingDeclaration()) @@ -231,13 +237,14 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun addMemberExtensionCandidates( dispatchReceiver: ReceiverValue, receiverParameter: ReceiverValue, + receiverParameterTypes: Collection, callableDescriptorCollector: CallableDescriptorCollector, c: TaskPrioritizerContext, receiverKind: ExplicitReceiverKind ) { c.result.addCandidates { val memberExtensions = - callableDescriptorCollector.getExtensionsByName(dispatchReceiver.getType().getMemberScope(), c.name, receiverParameter.getType(), c.context.trace) + callableDescriptorCollector.getExtensionsByName(dispatchReceiver.getType().getMemberScope(), c.name, receiverParameterTypes, c.context.trace) convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter, receiverKind, c.context.call) } } @@ -269,17 +276,19 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { //locals c.result.addCandidates(localsList) + val implicitReceiversWithTypes = implicitReceivers.map { it to SmartCastUtils.getSmartCastVariants(it, c.context) } + //try all implicit receivers as explicit - for (implicitReceiver in implicitReceivers) { - addCandidatesForExplicitReceiver(implicitReceiver, implicitReceivers, c, isExplicit = false) + for ((implicitReceiver, implicitReceiverTypes) in implicitReceiversWithTypes) { + addCandidatesForExplicitReceiver(implicitReceiver, implicitReceiverTypes, implicitReceivers, c, isExplicit = false) } //nonlocals c.result.addCandidates(nonlocalsList) //static (only for better error reporting) - for (implicitReceiver in implicitReceivers) { - addMembers(implicitReceiver, c, staticMembers = true, isExplicit = false) + for ((implicitReceiver, implicitReceiverTypes) in implicitReceiversWithTypes) { + addMembers(implicitReceiver, implicitReceiverTypes, c, staticMembers = true, isExplicit = false) } } @@ -297,7 +306,8 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { // (1) a.foo + foo.invoke() if (!explicitReceiver.exists()) { - addCandidatesForExplicitReceiver(variableReceiver, implicitReceivers, c, isExplicit = true) + val variableReceiverTypes = SmartCastUtils.getSmartCastVariants(variableReceiver, c.context) + addCandidatesForExplicitReceiver(variableReceiver, variableReceiverTypes, implicitReceivers, c, isExplicit = true) } // (2) foo + a.invoke() @@ -323,8 +333,9 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { c: TaskPrioritizerContext, receiverKind: ExplicitReceiverKind ) { + val receiverParameterTypes = SmartCastUtils.getSmartCastVariants(receiverParameter, c.context) for (callableDescriptorCollector in c.callableDescriptorCollectors) { - addMemberExtensionCandidates(dispatchReceiver, receiverParameter, callableDescriptorCollector, c, receiverKind) + addMemberExtensionCandidates(dispatchReceiver, receiverParameter, receiverParameterTypes, callableDescriptorCollector, c, receiverKind) } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt index eb376226710..528cdb6eed2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/dynamicCalls.kt @@ -223,8 +223,8 @@ public fun DeclarationDescriptor.isDynamic(): Boolean { } class CollectorForDynamicReceivers(val delegate: CallableDescriptorCollector) : CallableDescriptorCollector by delegate { - override fun getExtensionsByName(scope: JetScope, name: Name, receiver: JetType, bindingTrace: BindingTrace): Collection { - return delegate.getExtensionsByName(scope, name, receiver, bindingTrace).filter { + override fun getExtensionsByName(scope: JetScope, name: Name, receiverTypes: Collection, bindingTrace: BindingTrace): Collection { + return delegate.getExtensionsByName(scope, name, receiverTypes, bindingTrace).filter { it.getExtensionReceiverParameter()?.getType()?.isDynamic() ?: false } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt index 272ee60ff50..8b2d59de4f0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/LazyImportScope.kt @@ -258,18 +258,18 @@ class LazyImportScope( return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() - return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverType, name) } + return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name) } } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { // we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf() return importResolver.storageManager.compute { importResolver.indexedImports.imports.flatMapTo(LinkedHashSet()) { import -> - importResolver.getImportScope(import, LookupMode.EVERYTHING).getSyntheticExtensionProperties(receiverType) + importResolver.getImportScope(import, LookupMode.EVERYTHING).getSyntheticExtensionProperties(receiverTypes) } } } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.kt new file mode 100644 index 00000000000..6dff2b630a1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.kt @@ -0,0 +1,28 @@ +// FILE: KotlinFile.kt +fun foo(o: JavaInterface2): Int { + if (o is JavaClass) { + o.something++ + return o.x + o.something2 + } + return 0 +} + +// FILE: JavaClass.java +public abstract class JavaClass extends BaseClass implements JavaInterface { + public int getSomething() { return 1; } + public void setSomething(int value) { } +} + +// FILE: BaseClass.java +public abstract class BaseClass implements JavaInterface { +} + +// FILE: JavaInterface.java +public interface JavaInterface { + int getX(); +} + +// FILE: JavaInterface2.java +public interface JavaInterface2 { + int getSomething2(); +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.txt new file mode 100644 index 00000000000..7100c3e7725 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.txt @@ -0,0 +1,37 @@ +package + +public /*synthesized*/ fun JavaInterface(/*0*/ function: () -> kotlin.Int): JavaInterface +public /*synthesized*/ fun JavaInterface2(/*0*/ function: () -> kotlin.Int): JavaInterface2 +internal fun foo(/*0*/ o: JavaInterface2): kotlin.Int + +public abstract class BaseClass : JavaInterface { + public constructor BaseClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public abstract class JavaClass : BaseClass, JavaInterface { + public constructor JavaClass() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Int + public abstract override /*2*/ /*fake_override*/ fun getX(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething2(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt new file mode 100644 index 00000000000..7da8bd686ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt @@ -0,0 +1,23 @@ +// FILE: KotlinFile.kt +fun Any.foo(): Int { + if (this is JavaClass) { + something++ + return x + } + return 0 +} + +// FILE: JavaClass.java +public abstract class JavaClass extends BaseClass implements JavaInterface { + public int getSomething() { return 1; } + public void setSomething(int value) { } +} + +// FILE: BaseClass.java +public abstract class BaseClass implements JavaInterface { +} + +// FILE: JavaInterface.java +public interface JavaInterface { + int getX(); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.txt new file mode 100644 index 00000000000..fb712c02c73 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.txt @@ -0,0 +1,29 @@ +package + +public /*synthesized*/ fun JavaInterface(/*0*/ function: () -> kotlin.Int): JavaInterface +internal fun kotlin.Any.foo(): kotlin.Int + +public abstract class BaseClass : JavaInterface { + public constructor BaseClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public abstract class JavaClass : BaseClass, JavaInterface { + public constructor JavaClass() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Int + public abstract override /*2*/ /*fake_override*/ fun getX(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getX(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 1563eeaba42..4de00ef2cf9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14093,6 +14093,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt"); doTest(fileName); } + + @TestMetadata("SmartCast.kt") + public void testSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SmartCast.kt"); + doTest(fileName); + } + + @TestMetadata("SmartCastImplicitReceiver.kt") + public void testSmartCastImplicitReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper") diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt index bd2484fe4fe..91712ae2867 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/AbstractScopeAdapter.kt @@ -47,12 +47,12 @@ public abstract class AbstractScopeAdapter : JetScope { return workerScope.getProperties(name) } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection { - return workerScope.getSyntheticExtensionProperties(receiverType, name) + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { + return workerScope.getSyntheticExtensionProperties(receiverTypes, name) } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection { - return workerScope.getSyntheticExtensionProperties(receiverType) + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { + return workerScope.getSyntheticExtensionProperties(receiverTypes) } override fun getLocalVariable(name: Name): VariableDescriptor? { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt index 7ba44c9658b..276e6e68e57 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/ChainedScope.kt @@ -65,11 +65,11 @@ public open class ChainedScope( override fun getFunctions(name: Name): Collection = getFromAllScopes { it.getFunctions(name) } - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection - = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType, name) } + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection + = getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name) } - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection - = getFromAllScopes { it.getSyntheticExtensionProperties(receiverType) } + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection + = getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes) } override fun getImplicitReceiversHierarchy(): List { if (implicitReceiverHierarchy == null) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt index 5dc3782cee5..9bfe6e2b90f 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/FilteringScope.kt @@ -37,9 +37,9 @@ public class FilteringScope(private val workerScope: JetScope, private val predi override fun getProperties(name: Name) = workerScope.getProperties(name).filter(predicate) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = workerScope.getSyntheticExtensionProperties(receiverType, name).filter(predicate) + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection = workerScope.getSyntheticExtensionProperties(receiverTypes, name).filter(predicate) - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = workerScope.getSyntheticExtensionProperties(receiverType).filter(predicate) + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate) override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name)) diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt index 6e117e28ff2..6735a8f95e0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScope.kt @@ -35,9 +35,9 @@ public trait JetScope { public fun getFunctions(name: Name): Collection - public fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection - public fun getSyntheticExtensionProperties(receiverType: JetType): Collection + public fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection public fun getContainingDeclaration(): DeclarationDescriptor diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt index e55a691dffc..bb5905a005d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/JetScopeImpl.kt @@ -32,9 +32,9 @@ public abstract class JetScopeImpl : JetScope { override fun getFunctions(name: Name): Collection = setOf() - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = listOf() + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection = listOf() - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = listOf() + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = listOf() override fun getDeclarationsByLabel(labelName: Name): Collection = listOf() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt index d1533271a52..25d9e79d4bb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/scopes/SubstitutingScope.kt @@ -70,9 +70,9 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su override fun getFunctions(name: Name) = substitute(workerScope.getFunctions(name)) - override fun getSyntheticExtensionProperties(receiverType: JetType, name: Name): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverType, name)) + override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name)) - override fun getSyntheticExtensionProperties(receiverType: JetType): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverType)) + override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes)) override fun getPackage(name: Name) = workerScope.getPackage(name) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java index 4c1299be7ec..86fc5e0d1f2 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/ErrorUtils.java @@ -94,14 +94,14 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionProperties( - @NotNull JetType receiverType, @NotNull Name name + @NotNull Collection receiverTypes, @NotNull Name name ) { return ERROR_PROPERTY_GROUP; } @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { return ERROR_PROPERTY_GROUP; } @@ -210,14 +210,14 @@ public class ErrorUtils { @NotNull @Override public Collection getSyntheticExtensionProperties( - @NotNull JetType receiverType, @NotNull Name name + @NotNull Collection receiverTypes, @NotNull Name name ) { throw new IllegalStateException(); } @NotNull @Override - public Collection getSyntheticExtensionProperties(@NotNull JetType receiverType) { + public Collection getSyntheticExtensionProperties(@NotNull Collection receiverTypes) { throw new IllegalStateException(); } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index 2ec2d2d549b..f07eaa5c5b3 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -167,7 +167,9 @@ public class ReferenceVariantsHelper( val memberFilter = kindFilter exclude DescriptorKindExclude.Extensions val containingDeclaration = resolutionScope.getContainingDeclaration() - for (receiverType in SmartCastUtils.getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo)) { + val receiverTypes = SmartCastUtils.getSmartCastVariantsWithLessSpecificExcluded(receiverValue, context, containingDeclaration, dataFlowInfo) + + for (receiverType in receiverTypes) { val members = receiverType.getMemberScope().getDescriptorsFiltered(DescriptorKindFilter.ALL, nameFilter) // filter by kind later because of constructors for (member in members) { if (member is ClassDescriptor) { @@ -179,12 +181,12 @@ public class ReferenceVariantsHelper( this.add(member) } } + } - if (!kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) { - for (extension in resolutionScope.getSyntheticExtensionProperties(receiverType)) { - if (nameFilter(extension.getName()) && kindFilter.accepts(extension)) { - addAll(extension.substituteExtensionIfCallable(receiverValue, callType, context, dataFlowInfo, containingDeclaration)) - } + if (!kindFilter.excludes.contains(DescriptorKindExclude.Extensions)) { + for (extension in resolutionScope.getSyntheticExtensionProperties(receiverTypes)) { + if (nameFilter(extension.getName()) && kindFilter.accepts(extension)) { + addAll(extension.substituteExtensionIfCallable(receiverValue, callType, context, dataFlowInfo, containingDeclaration)) } } } From 0ac990e1a0e2bfe4e7bf0cba1afbb0e06c95d0c5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 15:22:46 +0300 Subject: [PATCH 439/450] More tests for smart casts --- .../extensions/SyntheticExtensionsSmartCast.kt | 10 ++++++++++ .../extensions/SyntheticExtensionsSmartCast2.kt | 10 ++++++++++ .../test/JSBasicCompletionTestGenerated.java | 12 ++++++++++++ .../test/JvmBasicCompletionTestGenerated.java | 12 ++++++++++++ .../intentions/usePropertyAccessSyntax/smartCast.kt | 8 ++++++++ .../usePropertyAccessSyntax/smartCast.kt.after | 8 ++++++++ .../idea/intentions/IntentionTestGenerated.java | 6 ++++++ 7 files changed, 66 insertions(+) create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt.after diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt new file mode 100644 index 00000000000..f45fcd3870f --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt @@ -0,0 +1,10 @@ +import java.io.File + +fun foo(o: Any) { + if (o is File) { + o. + } +} + +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " (from getAbsolutePath())", typeText: "String!" } +// ABSENT: getAbsolutePath diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt new file mode 100644 index 00000000000..807fe0eb505 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt @@ -0,0 +1,10 @@ +import java.io.File + +fun Any.foo() { + if (this is File) { + + } +} + +// EXIST_JAVA_ONLY: { lookupString: "absolutePath", itemText: "absolutePath", tailText: " (from getAbsolutePath())", typeText: "String!" } +// ABSENT: getAbsolutePath diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 4873ed301ac..c87ef238e8c 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1251,6 +1251,18 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("SyntheticExtensionsSmartCast.kt") + public void testSyntheticExtensionsSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt"); + doTest(fileName); + } + + @TestMetadata("SyntheticExtensionsSmartCast2.kt") + public void testSyntheticExtensionsSmartCast2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 2d1a2a7d9af..747bcd68b61 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1251,6 +1251,18 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("SyntheticExtensionsSmartCast.kt") + public void testSyntheticExtensionsSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast.kt"); + doTest(fileName); + } + + @TestMetadata("SyntheticExtensionsSmartCast2.kt") + public void testSyntheticExtensionsSmartCast2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSmartCast2.kt"); + doTest(fileName); + } + @TestMetadata("WrongExplicitReceiver.kt") public void testWrongExplicitReceiver() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/WrongExplicitReceiver.kt"); diff --git a/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt b/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt new file mode 100644 index 00000000000..e30d98f8d03 --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(o: Any) { + if (o is File) { + o.getAbsolutePath() + } +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt.after new file mode 100644 index 00000000000..a69bc4b844c --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt.after @@ -0,0 +1,8 @@ +// WITH_RUNTIME +import java.io.File + +fun foo(o: Any) { + if (o is File) { + o.absolutePath + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 05e05dc3277..f215c2d4b1e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -7463,6 +7463,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("smartCast.kt") + public void testSmartCast() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/smartCast.kt"); + doTest(fileName); + } + @TestMetadata("superCall.kt") public void testSuperCall() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/superCall.kt"); From 4a8adacedd3d8a3dcc59e68e44771294ff8d7b44 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 16:45:10 +0300 Subject: [PATCH 440/450] Changed policy for properties from methods like "getURL()"" --- .../synthetic/JavaSyntheticExtensionsScope.kt | 45 ++++++++++-------- .../kotlin/util/capitalizeDecapitalize.kt | 46 +++++++++++++++++++ .../syntheticExtensions/AbbreviationName.kt | 11 ++++- .../syntheticExtensions/AbbreviationName.txt | 2 + .../common/extensions/SyntheticExtensions2.kt | 2 +- .../parameterNameAndType/URLConnection.kt | 6 +++ .../test/JSBasicCompletionTestGenerated.java | 6 +++ .../test/JvmBasicCompletionTestGenerated.java | 6 +++ .../kotlin/idea/core/KotlinNameSuggester.kt | 26 ++--------- 9 files changed, 104 insertions(+), 46 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/kotlin/util/capitalizeDecapitalize.kt create mode 100644 idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 695dcfca9af..ddf56b84a74 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -34,6 +34,8 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable +import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord +import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import org.jetbrains.kotlin.utils.addIfNotNull import java.beans.Introspector import java.util.* @@ -74,7 +76,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { } if (!removePrefix) return methodName - val name = Introspector.decapitalize(identifier.removePrefix(prefix)) + val name = identifier.removePrefix(prefix).decapitalizeSmart() if (!Name.isValidIdentifier(name)) return null return Name.identifier(name) } @@ -94,16 +96,10 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { if (name.isSpecial()) return null - val identifier = name.getIdentifier() + val identifier = name.identifier if (identifier.isEmpty()) return null val firstChar = identifier[0] - if (!firstChar.isJavaIdentifierStart()) return null - if (identifier.length() > 1) { - if (firstChar.isUpperCase() != identifier[1].isUpperCase()) return null - } - else { - if (firstChar.isUpperCase()) return null - } + if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null val memberScope = javaClass.getMemberScope(type.getArguments()) val getMethod = possibleGetMethodNames(name) @@ -111,6 +107,9 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by .flatMap { memberScope.getFunctions(it).asSequence() } .singleOrNull { isGoodGetMethod(it) } ?: return null + // don't accept "uRL" for "getURL" etc + if (SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(getMethod.name) != name) return null + val propertyType = getMethod.getReturnType() ?: return null val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())).singleOrNull { isGoodSetMethod(it, propertyType) } @@ -139,13 +138,13 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { var result: SmartList? = null val processedTypes: MutableSet? = if (receiverTypes.size() > 1) HashSet() else null - receiverTypes.forEach { - result = collectSyntheticPropertiesByName(result, it.makeNotNullable(), name, processedTypes) + for (type in receiverTypes) { + result = collectSyntheticPropertiesByName(result, type.makeNotNullable(), name, processedTypes) } return when { result == null -> emptyList() - result!!.size() > 1 -> result!!.toSet() - else -> result!! + result.size() > 1 -> result.toSet() + else -> result } } @@ -202,24 +201,30 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by //TODO: reuse code with generation? private fun possibleGetMethodNames(propertyName: Name): Collection { - val identifier = propertyName.getIdentifier() - val getPrefixName = Name.identifier("get" + identifier.capitalize()) + val result = ArrayList(3) + val identifier = propertyName.identifier + if (identifier.startsWith("is")) { - return listOf(propertyName, getPrefixName) + result.add(propertyName) } - else { - return listOf(getPrefixName) + + val capitalize1 = identifier.capitalize() + val capitalize2 = identifier.capitalizeFirstWord() + result.add(Name.identifier("get" + capitalize1)) + if (capitalize2 != capitalize1) { + result.add(Name.identifier("get" + capitalize2)) } + return result } private fun setMethodName(getMethodName: Name): Name { - val identifier = getMethodName.getIdentifier() + val identifier = getMethodName.identifier val prefix = when { identifier.startsWith("get") -> "get" identifier.startsWith("is") -> "is" else -> throw IllegalArgumentException() } - return Name.identifier("set" + identifier.removePrefix(prefix).capitalize()) + return Name.identifier("set" + identifier.removePrefix(prefix)) } private class MyPropertyDescriptor( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/util/capitalizeDecapitalize.kt b/compiler/frontend/src/org/jetbrains/kotlin/util/capitalizeDecapitalize.kt new file mode 100644 index 00000000000..76aafb5ba58 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/util/capitalizeDecapitalize.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.util.capitalizeDecapitalize + +/** + * "FooBar" -> "fooBar" + * "FOOBar" -> "fooBar" + * "FOO" -> "foo" + */ +public fun String.decapitalizeSmart(): String { + if (isEmpty() || !charAt(0).isUpperCase()) return this + + if (length() == 1 || !charAt(1).isUpperCase()) { + return decapitalize() + } + + val secondWordStart = (indices.firstOrNull { !charAt(it).isUpperCase() } + ?: return toLowerCase()) - 1 + return substring(0, secondWordStart).toLowerCase() + substring(secondWordStart) +} + +/** + * "fooBar" -> "FOOBar" + * "FooBar" -> "FOOBar" + * "foo" -> "FOO" + */ +public fun String.capitalizeFirstWord(): String { + val secondWordStart = indices.drop(1).firstOrNull { !charAt(it).isLowerCase() } + ?: return toUpperCase() + return substring(0, secondWordStart).toUpperCase() + substring(secondWordStart) +} + diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt index b1b397fe5f9..2c812f9d52b 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.kt @@ -1,13 +1,20 @@ // FILE: KotlinFile.kt fun foo(javaClass: JavaClass) { - javaClass.URL = javaClass.URL + "/" + javaClass.url = javaClass.url + "/" + javaClass.htmlFile += "1" - javaClass.url + javaClass.URL javaClass.uRL + javaClass.HTMLFile + javaClass.hTMLFile + javaClass.htmlfile } // FILE: JavaClass.java public class JavaClass { public String getURL() { return true; } public void setURL(String value) { } + + public String getHTMLFile() { return true; } + public void setHTMLFile(String value) { } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt index c2731564e6d..6d50ee24342 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/AbbreviationName.txt @@ -5,8 +5,10 @@ internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit public open class JavaClass { public constructor JavaClass() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getHTMLFile(): kotlin.String! public open fun getURL(): kotlin.String! public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setHTMLFile(/*0*/ value: kotlin.String!): kotlin.Unit public open fun setURL(/*0*/ value: kotlin.String!): kotlin.Unit public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt index 98c55ba5476..5c1e4726cba 100644 --- a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions2.kt @@ -6,7 +6,7 @@ fun Thread.foo(urlConnection: java.net.URLConnection) { // EXIST_JAVA_ONLY: { lookupString: "priority", itemText: "priority", tailText: " (from getPriority()/setPriority())", typeText: "Int" } // EXIST_JAVA_ONLY: { lookupString: "isDaemon", itemText: "isDaemon", tailText: " (from isDaemon()/setDaemon())", typeText: "Boolean" } -// EXIST_JAVA_ONLY: { lookupString: "URL", itemText: "URL", tailText: " (from getURL())", typeText: "URL!" } +// EXIST_JAVA_ONLY: { lookupString: "url", itemText: "url", tailText: " (from getURL())", typeText: "URL!" } // ABSENT: getPriority // ABSENT: setPriority // ABSENT: { itemText: "isDaemon", tailText: "()" } diff --git a/idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt b/idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt new file mode 100644 index 00000000000..b746eca68f9 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt @@ -0,0 +1,6 @@ +import java.net.URLConnection + +fun foo(url){} + +// EXIST_JAVA_ONLY: { lookupString: "urlConnection", itemText: "urlConnection: URLConnection", tailText: " (java.net)" } +// ABSENT: urlconnection diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index c87ef238e8c..41f8b46f755 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1617,6 +1617,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("URLConnection.kt") + public void testURLConnection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt"); + doTest(fileName); + } + @TestMetadata("UserPrefix1.kt") public void testUserPrefix1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/parameterNameAndType/UserPrefix1.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 747bcd68b61..56d3bd490c4 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1617,6 +1617,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("URLConnection.kt") + public void testURLConnection() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/parameterNameAndType/URLConnection.kt"); + doTest(fileName); + } + @TestMetadata("UserPrefix1.kt") public void testUserPrefix1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/parameterNameAndType/UserPrefix1.kt"); diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt index f3e064b0f12..0c184a5fe8e 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/KotlinNameSuggester.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.checker.JetTypeChecker +import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import java.util.* import java.util.regex.Pattern @@ -240,12 +241,12 @@ public object KotlinNameSuggester { val upperCaseLetter = Character.isUpperCase(c) if (i == 0) { - addName(if (startLowerCase) decapitalize(s) else s, validator) + addName(if (startLowerCase) s.decapitalizeSmart() else s, validator) } else { if (upperCaseLetter && !upperCaseLetterBefore) { val substring = s.substring(i) - addName(if (startLowerCase) decapitalize(substring) else substring, validator) + addName(if (startLowerCase) substring.decapitalizeSmart() else substring, validator) } } @@ -253,27 +254,6 @@ public object KotlinNameSuggester { } } - private fun decapitalize(s: String): String { - var c = s.charAt(0) - if (!Character.isUpperCase(c)) return s - - val builder = StringBuilder(s.length()) - var decapitalize = true - for (i in 0..s.length() - 1) { - c = s.charAt(i) - if (decapitalize) { - if (Character.isUpperCase(c)) { - c = Character.toLowerCase(c) - } - else { - decapitalize = false - } - } - builder.append(c) - } - return builder.toString() - } - private fun deleteNonLetterFromString(s: String): String { val pattern = Pattern.compile("[^a-zA-Z]") val matcher = pattern.matcher(s) From d2fb7381ce4b1855bb76f3da783371626b49bb9a Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 16:50:19 +0300 Subject: [PATCH 441/450] Tested one more case --- .../diagnostics/tests/syntheticExtensions/FalseGetters.kt | 3 +++ .../diagnostics/tests/syntheticExtensions/FalseGetters.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt index f0733cc1564..859abe3f688 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.kt @@ -4,6 +4,7 @@ fun foo(javaClass: JavaClass) { javaClass.something2 javaClass.somethingStatic javaClass.somethingVoid + javaClass.ter } // FILE: JavaClass.java @@ -15,4 +16,6 @@ public class JavaClass { public static int getSomethingStatic() { return 1; } public void getSomethingVoid() { } + + public int getter() { return 1; } } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt index 0b48f1f6f53..808b3d6d7a4 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FalseGetters.txt @@ -8,6 +8,7 @@ public open class JavaClass { public open fun getSomething1(/*0*/ p: kotlin.Int): kotlin.Int public open fun getSomething2(): T! public open fun getSomethingVoid(): kotlin.Unit + public open fun getter(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String From e0e70440323677fe7f9540cdb42f47f2f72679ff Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 19:57:01 +0300 Subject: [PATCH 442/450] Synthetic properties: fixed completion and inspection for generic class + fixed KT-8539 No completion of generic extension function for <*> type arguments #KT-8539 Fixed --- .../synthetic/JavaSyntheticExtensionsScope.kt | 37 ++++++++++++------- .../impl/PropertyDescriptorImpl.java | 5 ++- .../kotlin/types/DescriptorSubstitutor.java | 3 +- .../codeInsight/ReferenceVariantsHelper.kt | 9 +++-- .../jetbrains/kotlin/idea/util/FuzzyType.kt | 4 +- .../SyntheticPropertyAccessorReference.kt | 11 +++--- .../idea/completion/LookupElementFactory.kt | 7 ++-- .../basic/common/extensions/StarTypeArg.kt | 9 +++++ .../SyntheticExtensionsInGenericClass.kt | 10 +++++ .../test/JSBasicCompletionTestGenerated.java | 12 ++++++ .../test/JvmBasicCompletionTestGenerated.java | 12 ++++++ .../UsePropertyAccessSyntaxIntention.kt | 1 + .../genericClassMethod.kt | 4 ++ .../genericClassMethod.kt.after | 4 ++ .../intentions/IntentionTestGenerated.java | 6 +++ 15 files changed, 103 insertions(+), 31 deletions(-) create mode 100644 idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt create mode 100644 idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt create mode 100644 idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt.after diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index ddf56b84a74..eb097c037e3 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -30,15 +30,18 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager +import org.jetbrains.kotlin.types.DescriptorSubstitutor import org.jetbrains.kotlin.types.JetType +import org.jetbrains.kotlin.types.TypeSubstitutor +import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord import org.jetbrains.kotlin.util.capitalizeDecapitalize.decapitalizeSmart import org.jetbrains.kotlin.utils.addIfNotNull -import java.beans.Introspector -import java.util.* +import java.util.ArrayList +import java.util.HashSet interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val getMethod: FunctionDescriptor @@ -54,9 +57,10 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val owner = getterOrSetter.getContainingDeclaration() if (owner !is JavaClassDescriptor) return null + val originalGetterOrSetter = getterOrSetter.original return resolutionScope.getSyntheticExtensionProperties(listOf(owner.getDefaultType())) .filterIsInstance() - .firstOrNull { getterOrSetter == it.getMethod || getterOrSetter == it.setMethod } + .firstOrNull { originalGetterOrSetter == it.getMethod || originalGetterOrSetter == it.setMethod } } fun propertyNameByGetMethodName(methodName: Name): Name? @@ -90,18 +94,18 @@ class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager } class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { - private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { triple -> - syntheticPropertyInClassNotCached(triple.first, triple.second, triple.third) + private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { pair -> + syntheticPropertyInClassNotCached(pair.first, pair.second) } - private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, type: JetType, name: Name): PropertyDescriptor? { + private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, name: Name): PropertyDescriptor? { if (name.isSpecial()) return null val identifier = name.identifier if (identifier.isEmpty()) return null val firstChar = identifier[0] if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null - val memberScope = javaClass.getMemberScope(type.getArguments()) + val memberScope = javaClass.getUnsubstitutedMemberScope() val getMethod = possibleGetMethodNames(name) .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } @@ -113,7 +117,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val propertyType = getMethod.getReturnType() ?: return null val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())).singleOrNull { isGoodSetMethod(it, propertyType) } - return MyPropertyDescriptor(javaClass, getMethod, setMethod, name, propertyType, type) + return MyPropertyDescriptor(javaClass, getMethod.original, setMethod?.original, name, propertyType) } private fun isGoodGetMethod(descriptor: FunctionDescriptor): Boolean { @@ -157,7 +161,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() if (classifier is JavaClassDescriptor) { - result = result.add(syntheticPropertyInClass(Triple(classifier, type, name))) + result = result.add(syntheticPropertyInClass(Pair(classifier, name))) } typeConstructor.getSupertypes().forEach { result = collectSyntheticPropertiesByName(result, it, name, processedTypes) } @@ -180,10 +184,10 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() if (classifier is JavaClassDescriptor) { - for (descriptor in classifier.getMemberScope(type.getArguments()).getDescriptors(DescriptorKindFilter.FUNCTIONS)) { + for (descriptor in classifier.getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue - addIfNotNull(syntheticPropertyInClass(Triple(classifier, type, propertyName))) + addIfNotNull(syntheticPropertyInClass(Pair(classifier, propertyName))) } } } @@ -232,8 +236,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by override val getMethod: FunctionDescriptor, override val setMethod: FunctionDescriptor?, name: Name, - type: JetType, - receiverType: JetType + type: JetType ) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl( DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, null, @@ -246,7 +249,13 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by SourceElement.NO_SOURCE/*TODO?*/ ) { init { - setType(type, emptyList(), null, receiverType) + val classTypeParams = javaClass.typeConstructor.parameters + val typeParameters = ArrayList(classTypeParams.size()) + val typeSubstitutor = DescriptorSubstitutor.substituteTypeParameters(classTypeParams, TypeSubstitutor.EMPTY, this, typeParameters) + + val propertyType = typeSubstitutor.safeSubstitute(type, Variance.INVARIANT) + val receiverType = typeSubstitutor.safeSubstitute(javaClass.defaultType, Variance.INVARIANT) + setType(propertyType, typeParameters, null, receiverType) val getter = PropertyGetterDescriptorImpl(this, Annotations.EMPTY, diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java index 546b9a39ef7..cd3c802a72d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/PropertyDescriptorImpl.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.name.Name; @@ -82,7 +83,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr public void setType( @NotNull JetType outType, - @NotNull List typeParameters, + @ReadOnly @NotNull List typeParameters, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @Nullable JetType receiverType ) { @@ -92,7 +93,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr public void setType( @NotNull JetType outType, - @NotNull List typeParameters, + @ReadOnly @NotNull List typeParameters, @Nullable ReceiverParameterDescriptor dispatchReceiverParameter, @Nullable ReceiverParameterDescriptor extensionReceiverParameter ) { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java index 8e2f40e0d58..d8f90e6c230 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/DescriptorSubstitutor.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types; import org.jetbrains.annotations.Mutable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ReadOnly; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.SourceElement; import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor; @@ -33,7 +34,7 @@ public class DescriptorSubstitutor { @NotNull public static TypeSubstitutor substituteTypeParameters( - @NotNull List typeParameters, + @ReadOnly @NotNull List typeParameters, @NotNull final TypeSubstitutor originalSubstitutor, @NotNull DeclarationDescriptor newContainingDeclaration, @NotNull @Mutable List result diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index f07eaa5c5b3..9cc005276f6 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -75,13 +75,14 @@ public class ReferenceVariantsHelper( if (filterOutJavaGettersAndSetters) { val accessorMethodsToRemove = HashSet() for (variant in variants) { - if (variant is SyntheticJavaPropertyDescriptor) { - accessorMethodsToRemove.add(variant.getMethod) - accessorMethodsToRemove.addIfNotNull(variant.setMethod) + val original = variant.original + if (original is SyntheticJavaPropertyDescriptor) { + accessorMethodsToRemove.add(original.getMethod) + accessorMethodsToRemove.addIfNotNull(original.setMethod) } } - variants = variants.filter { it !in accessorMethodsToRemove } + variants = variants.filter { it.original !in accessorMethodsToRemove } } return variants diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index ff568c938f1..62d3065ebcd 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -108,8 +108,8 @@ class FuzzyType( constraintSystem.registerTypeVariables(freeParameters, { Variance.INVARIANT }) when (matchKind) { - MatchKind.IS_SUBTYPE -> constraintSystem.addSubtypeConstraint(type, otherType, ConstraintPositionKind.SPECIAL.position()) - MatchKind.IS_SUPERTYPE -> constraintSystem.addSubtypeConstraint(otherType, type, ConstraintPositionKind.SPECIAL.position()) + MatchKind.IS_SUBTYPE -> constraintSystem.addSubtypeConstraint(type, otherType, ConstraintPositionKind.RECEIVER_POSITION.position()) + MatchKind.IS_SUPERTYPE -> constraintSystem.addSubtypeConstraint(otherType, type, ConstraintPositionKind.RECEIVER_POSITION.position()) } constraintSystem.fixVariables() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index d0c873128ff..8faea2f7412 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -33,16 +33,17 @@ import org.jetbrains.kotlin.utils.addIfNotNull sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpression, private val getter: Boolean) : JetSimpleReference(expression) { override fun getTargetDescriptors(context: BindingContext): Collection { val descriptors = super.getTargetDescriptors(context) - if (descriptors.none { it is SyntheticJavaPropertyDescriptor }) return emptyList() + if (descriptors.none { it.original is SyntheticJavaPropertyDescriptor }) return emptyList() val result = SmartList() for (descriptor in descriptors) { - if (descriptor is SyntheticJavaPropertyDescriptor) { + val original = descriptor.original + if (original is SyntheticJavaPropertyDescriptor) { if (getter) { - result.add(descriptor.getMethod) + result.add(original.getMethod) } else { - result.addIfNotNull(descriptor.setMethod) + result.addIfNotNull(original.setMethod) } } } @@ -62,7 +63,7 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr } else { val propertyDescriptor = super.getTargetDescriptors(expression.analyze(BodyResolveMode.PARTIAL)) - .singleOrNull { it is SyntheticJavaPropertyDescriptor } ?: return expression + .singleOrNull { it.original is SyntheticJavaPropertyDescriptor } ?: return expression SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = propertyDescriptor.getName().asString().startsWith("is")) } if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 043a16c6709..2f4bb767736 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -253,10 +253,11 @@ public class LookupElementFactory( } if (descriptor is CallableDescriptor) { + val original = descriptor.original when { - descriptor is SyntheticJavaPropertyDescriptor -> { - var from = descriptor.getMethod.getName().asString() + "()" - descriptor.setMethod?.let { from += "/" + it.getName().asString() + "()" } + original is SyntheticJavaPropertyDescriptor -> { + var from = original.getMethod.getName().asString() + "()" + original.setMethod?.let { from += "/" + it.getName().asString() + "()" } element = element.appendTailText(" (from $from)", true) } diff --git a/idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt b/idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt new file mode 100644 index 00000000000..56632edad6b --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt @@ -0,0 +1,9 @@ +class MyClass + +fun MyClass.ext() = "" + +fun foo(t: MyClass<*>) { + t. +} + +// EXIST: ext diff --git a/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt new file mode 100644 index 00000000000..92a33673845 --- /dev/null +++ b/idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt @@ -0,0 +1,10 @@ +fun foo(klass: Class<*>) { + klass. +} + +// EXIST_JAVA_ONLY: simpleName +// ABSENT: getSimpleName +// EXIST_JAVA_ONLY: enclosingClass +// ABSENT: getEnclosingClass +// EXIST_JAVA_ONLY: annotations +// ABSENT: getAnnotations diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java index 41f8b46f755..7774d5abeec 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JSBasicCompletionTestGenerated.java @@ -1233,6 +1233,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("StarTypeArg.kt") + public void testStarTypeArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensions1.kt") public void testSyntheticExtensions1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); @@ -1245,6 +1251,12 @@ public class JSBasicCompletionTestGenerated extends AbstractJSBasicCompletionTes doTest(fileName); } + @TestMetadata("SyntheticExtensionsInGenericClass.kt") + public void testSyntheticExtensionsInGenericClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensionsSafeCall.kt") public void testSyntheticExtensionsSafeCall() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt"); diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java index 56d3bd490c4..6f4be44d652 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmBasicCompletionTestGenerated.java @@ -1233,6 +1233,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("StarTypeArg.kt") + public void testStarTypeArg() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/StarTypeArg.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensions1.kt") public void testSyntheticExtensions1() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensions1.kt"); @@ -1245,6 +1251,12 @@ public class JvmBasicCompletionTestGenerated extends AbstractJvmBasicCompletionT doTest(fileName); } + @TestMetadata("SyntheticExtensionsInGenericClass.kt") + public void testSyntheticExtensionsInGenericClass() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsInGenericClass.kt"); + doTest(fileName); + } + @TestMetadata("SyntheticExtensionsSafeCall.kt") public void testSyntheticExtensionsSafeCall() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/idea-completion/testData/basic/common/extensions/SyntheticExtensionsSafeCall.kt"); diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt index fc931f06252..f162840b7f2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/UsePropertyAccessSyntaxIntention.kt @@ -82,6 +82,7 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent val referenceVariantsHelper = ReferenceVariantsHelper(bindingContext, moduleDescriptor, callExpression.getProject(), ::isVisible) val propertyName = property.getName() val accessibleVariables = referenceVariantsHelper.getReferenceVariants(callee, DescriptorKindFilter.VARIABLES, { it == propertyName }) + .map { it.original } if (property !in accessibleVariables) return null // shadowed by something else return property diff --git a/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt b/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt new file mode 100644 index 00000000000..7d1bf9a0f2d --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(klass: Class<*>) { + klass.getEnclosingClass() +} \ No newline at end of file diff --git a/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt.after b/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt.after new file mode 100644 index 00000000000..733e44dba2c --- /dev/null +++ b/idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt.after @@ -0,0 +1,4 @@ +// WITH_RUNTIME +fun foo(klass: Class<*>) { + klass.enclosingClass +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index f215c2d4b1e..9d155e4f9a2 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -7415,6 +7415,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest { doTest(fileName); } + @TestMetadata("genericClassMethod.kt") + public void testGenericClassMethod() throws Exception { + String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/genericClassMethod.kt"); + doTest(fileName); + } + @TestMetadata("get.kt") public void testGet() throws Exception { String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/usePropertyAccessSyntax/get.kt"); From 367e2944523dfeda35b03e11ff304a9fd242e720 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 20:33:03 +0300 Subject: [PATCH 443/450] No synthetic properties in java class for methods inherited from Kotlin --- .../kotlin/synthetic/JavaSyntheticExtensionsScope.kt | 5 +++-- .../diagnostics/tests/syntheticExtensions/Bases.kt | 4 ++-- .../diagnostics/tests/syntheticExtensions/Bases.txt | 8 ++++---- .../diagnostics/tests/syntheticExtensions/Getter.kt | 2 +- .../diagnostics/tests/syntheticExtensions/Getter.txt | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index eb097c037e3..1f756442c03 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -109,13 +109,14 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val getMethod = possibleGetMethodNames(name) .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } - .singleOrNull { isGoodGetMethod(it) } ?: return null + .singleOrNull { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodGetMethod(it) } ?: return null // don't accept "uRL" for "getURL" etc if (SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(getMethod.name) != name) return null val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())).singleOrNull { isGoodSetMethod(it, propertyType) } + val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())) + .singleOrNull { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodSetMethod(it, propertyType) } return MyPropertyDescriptor(javaClass, getMethod.original, setMethod?.original, name, propertyType) } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt index 1b924922c87..2ea41e308b1 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.kt @@ -1,10 +1,10 @@ // FILE: KotlinFile.kt open class KotlinClass1 : JavaClass1() { - fun getSomethingKotlin1(): Int = 1 + public fun getSomethingKotlin1(): Int = 1 } class KotlinClass2 : JavaClass2() { - fun getSomethingKotlin2(): Int = 1 + public fun getSomethingKotlin2(): Int = 1 } fun foo(k: KotlinClass2) { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt index 51a80c0f2d6..2681c9cc870 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Bases.txt @@ -16,7 +16,7 @@ public open class JavaClass2 : KotlinClass1 { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int public open fun getSomething2(): kotlin.Int - internal final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -25,7 +25,7 @@ internal open class KotlinClass1 : JavaClass1 { public constructor KotlinClass1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int - internal final fun getSomethingKotlin1(): kotlin.Int + public final fun getSomethingKotlin1(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } @@ -35,8 +35,8 @@ internal final class KotlinClass2 : JavaClass2 { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun getSomething1(): kotlin.Int public open override /*1*/ /*fake_override*/ fun getSomething2(): kotlin.Int - internal final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int - internal final fun getSomethingKotlin2(): kotlin.Int + public final override /*1*/ /*fake_override*/ fun getSomethingKotlin1(): kotlin.Int + public final fun getSomethingKotlin2(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt index 27eb7ad4cb2..314f895def1 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.kt @@ -1,6 +1,6 @@ // FILE: KotlinFile.kt class KotlinClass { - fun getSomething(): Int = 1 + public fun getSomething(): Int = 1 } fun foo(javaClass: JavaClass, kotlinClass: KotlinClass) { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt index 73feaeb7466..f82412dce00 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/Getter.txt @@ -14,7 +14,7 @@ public open class JavaClass { internal final class KotlinClass { public constructor KotlinClass() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - internal final fun getSomething(): kotlin.Int + public final fun getSomething(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } From 612c009f6b01c35ad99be6ae06bc2d51675e4a8f Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 17 Jul 2015 23:25:14 +0300 Subject: [PATCH 444/450] Synthetic properties: correct behaviour for method hierarchies --- .../synthetic/JavaSyntheticExtensionsScope.kt | 82 ++++++++++++------- .../overrideOnlyGetter.java | 10 +++ .../syntheticExtensions/overrideOnlyGetter.kt | 5 ++ .../JavaOverridesKotlin.kt | 29 +++++++ .../JavaOverridesKotlin.txt | 31 +++++++ .../KotlinOverridesJava.kt | 52 ++++++++++++ .../KotlinOverridesJava.txt | 47 +++++++++++ .../KotlinOverridesJava2.kt | 25 ++++++ .../KotlinOverridesJava2.txt | 29 +++++++ .../KotlinOverridesJava3.kt | 25 ++++++ .../KotlinOverridesJava3.txt | 29 +++++++ .../KotlinOverridesJava4.kt | 28 +++++++ .../KotlinOverridesJava4.txt | 37 +++++++++ .../KotlinOverridesJava5.kt | 29 +++++++ .../KotlinOverridesJava5.txt | 37 +++++++++ .../syntheticExtensions/OverrideGetterOnly.kt | 22 +++++ .../OverrideGetterOnly.txt | 22 +++++ .../checkers/JetDiagnosticsTestGenerated.java | 42 ++++++++++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 6 ++ 19 files changed, 559 insertions(+), 28 deletions(-) create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.txt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 1f756442c03..8d3c153763b 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.types.JetType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isBoolean +import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeFirstWord @@ -54,8 +55,7 @@ interface SyntheticJavaPropertyDescriptor : PropertyDescriptor { val identifier = name.getIdentifier() if (!identifier.startsWith("get") && !identifier.startsWith("is") && !identifier.startsWith("set")) return null // optimization - val owner = getterOrSetter.getContainingDeclaration() - if (owner !is JavaClassDescriptor) return null + val owner = getterOrSetter.getContainingDeclaration() as? ClassDescriptor ?: return null val originalGetterOrSetter = getterOrSetter.original return resolutionScope.getSyntheticExtensionProperties(listOf(owner.getDefaultType())) @@ -94,50 +94,76 @@ class AdditionalScopesWithJavaSyntheticExtensions(storageManager: StorageManager } class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by JetScope.Empty { - private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { pair -> + private val syntheticPropertyInClass = storageManager.createMemoizedFunctionWithNullableValues, PropertyDescriptor> { pair -> syntheticPropertyInClassNotCached(pair.first, pair.second) } - private fun syntheticPropertyInClassNotCached(javaClass: JavaClassDescriptor, name: Name): PropertyDescriptor? { + private fun syntheticPropertyInClassNotCached(ownerClass: ClassDescriptor, name: Name): PropertyDescriptor? { if (name.isSpecial()) return null val identifier = name.identifier if (identifier.isEmpty()) return null val firstChar = identifier[0] if (!firstChar.isJavaIdentifierStart() || firstChar.isUpperCase()) return null - val memberScope = javaClass.getUnsubstitutedMemberScope() + val memberScope = ownerClass.unsubstitutedMemberScope val getMethod = possibleGetMethodNames(name) .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } - .singleOrNull { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodGetMethod(it) } ?: return null + .singleOrNull { + it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() + } ?: return null // don't accept "uRL" for "getURL" etc if (SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(getMethod.name) != name) return null - val propertyType = getMethod.getReturnType() ?: return null - val setMethod = memberScope.getFunctions(setMethodName(getMethod.getName())) - .singleOrNull { it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodSetMethod(it, propertyType) } + val setMethod = memberScope.getFunctions(setMethodName(getMethod.name)) + .singleOrNull { isGoodSetMethod(it, getMethod) } - return MyPropertyDescriptor(javaClass, getMethod.original, setMethod?.original, name, propertyType) + val propertyType = getMethod.returnType ?: return null + return MyPropertyDescriptor(ownerClass, getMethod.original, setMethod?.original, name, propertyType) + } + + private fun FunctionDescriptor.hasJavaOriginInHierarchy(): Boolean { + return if (overriddenDescriptors.isEmpty()) + containingDeclaration is JavaClassDescriptor + else + overriddenDescriptors.any { it.hasJavaOriginInHierarchy() } } private fun isGoodGetMethod(descriptor: FunctionDescriptor): Boolean { - val returnType = descriptor.getReturnType() ?: return false + val returnType = descriptor.returnType ?: return false if (returnType.isUnit()) return false - if (descriptor.getName().asString().startsWith("is") && !returnType.isBoolean()) return false + if (descriptor.name.asString().startsWith("is") && !returnType.isBoolean()) return false - return descriptor.getValueParameters().isEmpty() - && descriptor.getTypeParameters().isEmpty() - && descriptor.getVisibility() == Visibilities.PUBLIC //TODO: what about protected and package-local? + return descriptor.valueParameters.isEmpty() + && descriptor.typeParameters.isEmpty() + && descriptor.visibility == Visibilities.PUBLIC //TODO: what about protected and package-local? } - private fun isGoodSetMethod(descriptor: FunctionDescriptor, propertyType: JetType): Boolean { - val parameter = descriptor.getValueParameters().singleOrNull() ?: return false - return parameter.getType() == propertyType - && parameter.getVarargElementType() == null - && descriptor.getTypeParameters().isEmpty() - && descriptor.getReturnType()?.let { it.isUnit() } ?: false - && descriptor.getVisibility() == Visibilities.PUBLIC + private fun isGoodSetMethod(descriptor: FunctionDescriptor, getMethod: FunctionDescriptor): Boolean { + val propertyType = getMethod.returnType ?: return false + val parameter = descriptor.valueParameters.singleOrNull() ?: return false + if (parameter.type != propertyType) { + if (descriptor.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return false // real setter must exactly match getter's type + if (!propertyType.isSubtypeOf(parameter.type)) return false + if (descriptor.findOverridden { + val baseProperty = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(it, this) + baseProperty?.getMethod?.name == getMethod.name + } == null) return false + } + + return parameter.varargElementType == null + && descriptor.typeParameters.isEmpty() + && descriptor.returnType?.let { it.isUnit() } ?: false + && descriptor.visibility == Visibilities.PUBLIC + } + + private fun FunctionDescriptor.findOverridden(condition: (FunctionDescriptor) -> Boolean): FunctionDescriptor? { + for (descriptor in overriddenDescriptors) { + if (condition(descriptor)) return descriptor + descriptor.findOverridden(condition)?.let { return it } + } + return null } override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { @@ -161,7 +187,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() - if (classifier is JavaClassDescriptor) { + if (classifier is ClassDescriptor) { result = result.add(syntheticPropertyInClass(Pair(classifier, name))) } @@ -184,7 +210,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val typeConstructor = type.getConstructor() val classifier = typeConstructor.getDeclarationDescriptor() - if (classifier is JavaClassDescriptor) { + if (classifier is ClassDescriptor) { for (descriptor in classifier.getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { val propertyName = SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(descriptor.getName()) ?: continue @@ -233,13 +259,13 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by } private class MyPropertyDescriptor( - javaClass: JavaClassDescriptor, + ownerClass: ClassDescriptor, override val getMethod: FunctionDescriptor, override val setMethod: FunctionDescriptor?, name: Name, type: JetType ) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl( - DescriptorUtils.getContainingModule(javaClass)/* TODO:is it ok? */, + DescriptorUtils.getContainingModule(ownerClass)/* TODO:is it ok? */, null, Annotations.EMPTY, Modality.FINAL, @@ -250,12 +276,12 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by SourceElement.NO_SOURCE/*TODO?*/ ) { init { - val classTypeParams = javaClass.typeConstructor.parameters + val classTypeParams = ownerClass.typeConstructor.parameters val typeParameters = ArrayList(classTypeParams.size()) val typeSubstitutor = DescriptorSubstitutor.substituteTypeParameters(classTypeParams, TypeSubstitutor.EMPTY, this, typeParameters) val propertyType = typeSubstitutor.safeSubstitute(type, Variance.INVARIANT) - val receiverType = typeSubstitutor.safeSubstitute(javaClass.defaultType, Variance.INVARIANT) + val receiverType = typeSubstitutor.safeSubstitute(ownerClass.defaultType, Variance.INVARIANT) setType(propertyType, typeParameters, null, receiverType) val getter = PropertyGetterDescriptorImpl(this, diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.java new file mode 100644 index 00000000000..4a7ab421bc5 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.java @@ -0,0 +1,10 @@ +class JavaClass1 { + protected Object value = null; + + public Object getSomething() { return null; } + public void setSomething(Object value) { this.value = value; } +} + +class JavaClass2 extends JavaClass1 { + public String getSomething() { return (String)value; } +} diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.kt new file mode 100644 index 00000000000..cd8d6552080 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.kt @@ -0,0 +1,5 @@ +fun box(): String { + val javaClass = JavaClass2() + javaClass.something = "OK" + return javaClass.something +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.kt new file mode 100644 index 00000000000..ca18c9b15bc --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.kt @@ -0,0 +1,29 @@ +// FILE: KotlinFile.kt +open class KotlinClass { + public open fun getSomething1(): Int = 1 + + public open fun setSomething2(value: Int) {} +} + +fun foo(javaClass: JavaClass) { + useInt(javaClass.getSomething1()) + useInt(javaClass.something1) + + javaClass.setSomething2(javaClass.getSomething2() + 1) + javaClass.something2 = javaClass.something2 + 1 +} + +fun useInt(i: Int) {} + +// FILE: JavaClass.java +public class JavaClass extends KotlinClass implements JavaInterface { + public int getSomething1() { return 1; } + + public int getSomething2() { return 1; } + public void setSomething2(int value) {} +} + +// FILE: JavaInterface.java +public class JavaInterface { + int getSomething2(); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.txt new file mode 100644 index 00000000000..85484900fc5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.txt @@ -0,0 +1,31 @@ +package + +internal fun foo(/*0*/ javaClass: JavaClass): kotlin.Unit +internal fun useInt(/*0*/ i: kotlin.Int): kotlin.Unit + +public open class JavaClass : KotlinClass, JavaInterface { + public constructor JavaClass() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething1(): kotlin.Int + public open override /*1*/ fun getSomething2(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ fun setSomething2(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class JavaInterface { + public constructor JavaInterface() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun getSomething2(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal open class KotlinClass { + public constructor KotlinClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething2(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.kt new file mode 100644 index 00000000000..bbebad6f852 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.kt @@ -0,0 +1,52 @@ +// FILE: KotlinFile.kt +abstract class KotlinClass : JavaClass(), KotlinInterface, JavaInterface { + override fun getSomething1(): Int = 1 + override fun getSomething3(): String = "" + override fun setSomething4(value: String) {} + override fun getSomething5(): String = "" +} + +interface KotlinInterface { + public fun getSomething1(): Int + public fun getSomething4(): String +} + +fun foo(k: KotlinClass) { + useInt(k.getSomething1()) + useInt(k.something1) + + useInt(k.getSomething2()) + useInt(k.something2) + + useString(k.getSomething3()) + useString(k.something3) + + k.setSomething4("") + k.something4 += "" + k.setSomething4(null) + k.something4 = null + + useString(k.getSomething5()) + useString(k.something5) + k.setSomething5(1) + k.something5 = 1 +} + +fun useInt(i: Int) {} +fun useString(i: String) {} + +// FILE: JavaClass.java +public class JavaClass { + public int getSomething1() { return 1; } + public int getSomething2() { return 1; } + public Object getSomething3() { return null; } +} + +// FILE: JavaInterface.java +public interface JavaInterface { + String getSomething4(); + void setSomething4(String value); + + Object getSomething5(); + void setSomething5(Object value); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.txt new file mode 100644 index 00000000000..a48f3c46a49 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.txt @@ -0,0 +1,47 @@ +package + +internal fun foo(/*0*/ k: KotlinClass): kotlin.Unit +internal fun useInt(/*0*/ i: kotlin.Int): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething1(): kotlin.Int + public open fun getSomething2(): kotlin.Int + public open fun getSomething3(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething4(): kotlin.String! + public abstract fun getSomething5(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething4(/*0*/ value: kotlin.String!): kotlin.Unit + public abstract fun setSomething5(/*0*/ value: kotlin.Any!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal abstract class KotlinClass : JavaClass, KotlinInterface, JavaInterface { + public constructor KotlinClass() + public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun getSomething1(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun getSomething2(): kotlin.Int + public open override /*1*/ fun getSomething3(): kotlin.String + public abstract override /*2*/ /*fake_override*/ fun getSomething4(): kotlin.String! + public open override /*1*/ fun getSomething5(): kotlin.String + public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ fun setSomething4(/*0*/ value: kotlin.String): kotlin.Unit + public abstract override /*1*/ /*fake_override*/ fun setSomething5(/*0*/ value: kotlin.Any!): kotlin.Unit + public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface KotlinInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething1(): kotlin.Int + public abstract fun getSomething4(): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.kt new file mode 100644 index 00000000000..fadda63cd94 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.kt @@ -0,0 +1,25 @@ +// FILE: KotlinFile.kt +abstract class KotlinClass : JavaInterface1, JavaInterface2 { + override fun getSomething(): String = "" +} + +fun foo(k: KotlinClass) { + useString(k.getSomething()) + useString(k.something) + if (k.something == null) return + + k.setSomething(1) + k.something = 1 +} + +fun useString(i: String) {} + +// FILE: JavaInterface1.java +public interface JavaInterface1 { + String getSomething(); +} + +// FILE: JavaInterface2.java +public interface JavaInterface2 { + void setSomething(int value); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.txt new file mode 100644 index 00000000000..50f76abf47e --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.txt @@ -0,0 +1,29 @@ +package + +public /*synthesized*/ fun JavaInterface1(/*0*/ function: () -> kotlin.String!): JavaInterface1 +public /*synthesized*/ fun JavaInterface2(/*0*/ function: (kotlin.Int) -> kotlin.Unit): JavaInterface2 +internal fun foo(/*0*/ k: KotlinClass): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public interface JavaInterface1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal abstract class KotlinClass : JavaInterface1, JavaInterface2 { + public constructor KotlinClass() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething(): kotlin.String + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt new file mode 100644 index 00000000000..7af74313db4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt @@ -0,0 +1,25 @@ +// FILE: KotlinFile.kt +abstract class KotlinClass : JavaInterface1, JavaInterface2 { + override fun getSomething(): String = "" +} + +fun foo(k: KotlinClass) { + useString(k.getSomething()) + useString(k.something) + if (k.something == null) return + + k.setSomething("") + k.something = "" +} + +fun useString(i: String) {} + +// FILE: JavaInterface1.java +public interface JavaInterface1 { + String getSomething(); +} + +// FILE: JavaInterface2.java +public interface JavaInterface2 { + void setSomething(String value); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.txt new file mode 100644 index 00000000000..dab991a8dcf --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.txt @@ -0,0 +1,29 @@ +package + +public /*synthesized*/ fun JavaInterface1(/*0*/ function: () -> kotlin.String!): JavaInterface1 +public /*synthesized*/ fun JavaInterface2(/*0*/ function: (kotlin.String!) -> kotlin.Unit): JavaInterface2 +internal fun foo(/*0*/ k: KotlinClass): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public interface JavaInterface1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal abstract class KotlinClass : JavaInterface1, JavaInterface2 { + public constructor KotlinClass() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething(): kotlin.String + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt new file mode 100644 index 00000000000..a53a67f5084 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt @@ -0,0 +1,28 @@ +// FILE: KotlinFile.kt +abstract class KotlinClass : JavaInterface3 { + override fun getSomething(): String = "" +} + +fun foo(k: KotlinClass) { + useString(k.getSomething()) + useString(k.something) + if (k.something == null) return + + k.setSomething("") + k.something = "" +} + +fun useString(i: String) {} + +// FILE: JavaInterface1.java +public interface JavaInterface1 { + String getSomething(); +} + +// FILE: JavaInterface2.java +public interface JavaInterface2 { + void setSomething(String value); +} + +// FILE: JavaInterface3.java +public interface JavaInterface3 extends JavaInterface1, JavaInterface2 {} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.txt new file mode 100644 index 00000000000..4d1dff211de --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.txt @@ -0,0 +1,37 @@ +package + +public /*synthesized*/ fun JavaInterface1(/*0*/ function: () -> kotlin.String!): JavaInterface1 +public /*synthesized*/ fun JavaInterface2(/*0*/ function: (kotlin.String!) -> kotlin.Unit): JavaInterface2 +internal fun foo(/*0*/ k: KotlinClass): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public interface JavaInterface1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface3 : JavaInterface1, JavaInterface2 { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun getSomething(): kotlin.String! + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal abstract class KotlinClass : JavaInterface3 { + public constructor KotlinClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething(): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.kt new file mode 100644 index 00000000000..69e516b4abc --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.kt @@ -0,0 +1,29 @@ +// FILE: KotlinFile.kt +abstract class KotlinClass : JavaInterface3 { + override fun getSomething(): String = "" +} + +fun foo(k: KotlinClass) { + useString(k.getSomething()) + useString(k.something) + if (k.something == null) return + + k.setSomething("") + k.something = "" +} + +fun useString(i: String) {} + +// FILE: JavaInterface1.java +public interface JavaInterface1 { + String getSomething(); +} + +// FILE: JavaInterface2.java +public interface JavaInterface2 { + String getSomething(); + void setSomething(String value); +} + +// FILE: JavaInterface3.java +public interface JavaInterface3 extends JavaInterface1, JavaInterface2 {} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.txt new file mode 100644 index 00000000000..7f113511b9c --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.txt @@ -0,0 +1,37 @@ +package + +public /*synthesized*/ fun JavaInterface1(/*0*/ function: () -> kotlin.String!): JavaInterface1 +internal fun foo(/*0*/ k: KotlinClass): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public interface JavaInterface1 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface JavaInterface3 : JavaInterface1, JavaInterface2 { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*2*/ /*fake_override*/ fun getSomething(): kotlin.String! + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal abstract class KotlinClass : JavaInterface3 { + public constructor KotlinClass() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething(): kotlin.String + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.String!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.kt new file mode 100644 index 00000000000..c8e14d5333b --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.kt @@ -0,0 +1,22 @@ +// FILE: KotlinFile.kt + +fun foo(o: JavaClass2) { + useString(o.something) + o.something = "" + o.setSomething(1) + o.something = 1 // we generate extension property for JavaClass2 with more specific type + o.something += "1" +} + +fun useString(i: String) {} + +// FILE: JavaClass1.java +public class JavaClass1 { + public Object getSomething() { return null; } + public void setSomething(Object value) { } +} + +// FILE: JavaClass2.java +public class JavaClass2 extends JavaClass1 { + public String getSomething() { return ""; } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.txt new file mode 100644 index 00000000000..d49adc526da --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.txt @@ -0,0 +1,22 @@ +package + +internal fun foo(/*0*/ o: JavaClass2): kotlin.Unit +internal fun useString(/*0*/ i: kotlin.String): kotlin.Unit + +public open class JavaClass1 { + public constructor JavaClass1() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getSomething(): kotlin.Any! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setSomething(/*0*/ value: kotlin.Any!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class JavaClass2 : JavaClass1 { + public constructor JavaClass2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun getSomething(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.Any!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 4de00ef2cf9..9609029d56a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14082,12 +14082,54 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("JavaOverridesKotlin.kt") + public void testJavaOverridesKotlin() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/JavaOverridesKotlin.kt"); + doTest(fileName); + } + + @TestMetadata("KotlinOverridesJava.kt") + public void testKotlinOverridesJava() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava.kt"); + doTest(fileName); + } + + @TestMetadata("KotlinOverridesJava2.kt") + public void testKotlinOverridesJava2() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava2.kt"); + doTest(fileName); + } + + @TestMetadata("KotlinOverridesJava3.kt") + public void testKotlinOverridesJava3() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt"); + doTest(fileName); + } + + @TestMetadata("KotlinOverridesJava4.kt") + public void testKotlinOverridesJava4() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt"); + doTest(fileName); + } + + @TestMetadata("KotlinOverridesJava5.kt") + public void testKotlinOverridesJava5() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava5.kt"); + doTest(fileName); + } + @TestMetadata("OnlyPublic.kt") public void testOnlyPublic() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/OnlyPublic.kt"); doTest(fileName); } + @TestMetadata("OverrideGetterOnly.kt") + public void testOverrideGetterOnly() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/OverrideGetterOnly.kt"); + doTest(fileName); + } + @TestMetadata("SetterOnly.kt") public void testSetterOnly() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SetterOnly.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java index 040a22f3ef9..86f18641a95 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -847,6 +847,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod doTestAgainstJava(fileName); } + @TestMetadata("overrideOnlyGetter.kt") + public void testOverrideOnlyGetter() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/overrideOnlyGetter.kt"); + doTestAgainstJava(fileName); + } + @TestMetadata("plusPlus.kt") public void testPlusPlus() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/plusPlus.kt"); From 1c52f8a5245ee21ff69d806dba1bb780333b80b3 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sat, 18 Jul 2015 11:30:07 +0300 Subject: [PATCH 445/450] Fixed synthetic properties for method inherited from two bases --- .../synthetic/JavaSyntheticExtensionsScope.kt | 3 +-- .../syntheticExtensions/fromTwoBases.java | 14 ++++++++++ .../syntheticExtensions/fromTwoBases.kt | 5 ++++ .../tests/syntheticExtensions/FromTwoBases.kt | 19 +++++++++++++ .../syntheticExtensions/FromTwoBases.txt | 27 +++++++++++++++++++ .../KotlinOverridesJava4.kt | 2 +- .../checkers/JetDiagnosticsTestGenerated.java | 6 +++++ ...ackBoxAgainstJavaCodegenTestGenerated.java | 6 +++++ 8 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.java create mode 100644 compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 8d3c153763b..b0867f93d40 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -110,7 +110,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } .singleOrNull { - it.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE && isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() + isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() } ?: return null // don't accept "uRL" for "getURL" etc @@ -144,7 +144,6 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val propertyType = getMethod.returnType ?: return false val parameter = descriptor.valueParameters.singleOrNull() ?: return false if (parameter.type != propertyType) { - if (descriptor.kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) return false // real setter must exactly match getter's type if (!propertyType.isSubtypeOf(parameter.type)) return false if (descriptor.findOverridden { val baseProperty = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(it, this) diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.java b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.java new file mode 100644 index 00000000000..43794724a9c --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.java @@ -0,0 +1,14 @@ +interface A { + String getOk(); +} + +interface B { + String getOk(); +} + +interface C extends A, B { +} + +class JavaClass implements C { + public String getOk() { return "OK"; } +} diff --git a/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt new file mode 100644 index 00000000000..ca57a4e6155 --- /dev/null +++ b/compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt @@ -0,0 +1,5 @@ +fun box(): String { + return f(JavaClass()) +} + +fun f(c: C) = c.ok diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt new file mode 100644 index 00000000000..d329ecc0d80 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt @@ -0,0 +1,19 @@ +// FILE: KotlinFile.kt + +interface C : A, B + +fun foo(c: C) { + c.setSomething(c.getSomething() + 1) + c.something++ +} + +// FILE: A.java +public interface A { + int getSomething(); +} + +// FILE: B.java +public interface B { + int getSomething(); + void setSomething(int value); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.txt new file mode 100644 index 00000000000..658ddecc2a3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.txt @@ -0,0 +1,27 @@ +package + +public /*synthesized*/ fun A(/*0*/ function: () -> kotlin.Int): A +internal fun foo(/*0*/ c: C): kotlin.Unit + +public interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface B { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal interface C : A, B { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*2*/ /*fake_override*/ fun getSomething(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract override /*1*/ /*fake_override*/ fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt index a53a67f5084..ef65896c7cb 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava4.kt @@ -9,7 +9,7 @@ fun foo(k: KotlinClass) { if (k.something == null) return k.setSomething("") - k.something = "" + k.something = "" } fun useString(i: String) {} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 9609029d56a..f566d4292aa 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14052,6 +14052,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("FromTwoBases.kt") + public void testFromTwoBases() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/FromTwoBases.kt"); + doTest(fileName); + } + @TestMetadata("GenericClass.kt") public void testGenericClass() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/GenericClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java index 86f18641a95..b623aa01867 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -835,6 +835,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCod JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxAgainstJava/syntheticExtensions"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("fromTwoBases.kt") + public void testFromTwoBases() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/fromTwoBases.kt"); + doTestAgainstJava(fileName); + } + @TestMetadata("getter.kt") public void testGetter() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/syntheticExtensions/getter.kt"); From 31b7c33fa83120b4714aba4571990587d4d4ab0d Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sat, 18 Jul 2015 11:52:40 +0300 Subject: [PATCH 446/450] No need to scan base classes --- .../synthetic/JavaSyntheticExtensionsScope.kt | 35 ++++++++----------- .../TypeParameterReceiver.kt | 16 +++++++++ .../TypeParameterReceiver.txt | 19 ++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++ 4 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.kt create mode 100644 compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index b0867f93d40..913ea8b4a4a 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -30,10 +30,7 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.storage.StorageManager -import org.jetbrains.kotlin.types.DescriptorSubstitutor -import org.jetbrains.kotlin.types.JetType -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.typeUtil.isBoolean import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.types.typeUtil.isUnit @@ -167,9 +164,9 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by override fun getSyntheticExtensionProperties(receiverTypes: Collection, name: Name): Collection { var result: SmartList? = null - val processedTypes: MutableSet? = if (receiverTypes.size() > 1) HashSet() else null + val processedTypes: MutableSet? = if (receiverTypes.size() > 1) HashSet() else null for (type in receiverTypes) { - result = collectSyntheticPropertiesByName(result, type.makeNotNullable(), name, processedTypes) + result = collectSyntheticPropertiesByName(result, type.constructor, name, processedTypes) } return when { result == null -> emptyList() @@ -178,37 +175,34 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by } } - private fun collectSyntheticPropertiesByName(result: SmartList?, type: JetType, name: Name, processedTypes: MutableSet?): SmartList? { + private fun collectSyntheticPropertiesByName(result: SmartList?, type: TypeConstructor, name: Name, processedTypes: MutableSet?): SmartList? { if (processedTypes != null && !processedTypes.add(type)) return result @suppress("NAME_SHADOWING") var result = result - val typeConstructor = type.getConstructor() - val classifier = typeConstructor.getDeclarationDescriptor() + val classifier = type.declarationDescriptor if (classifier is ClassDescriptor) { result = result.add(syntheticPropertyInClass(Pair(classifier, name))) } - - typeConstructor.getSupertypes().forEach { result = collectSyntheticPropertiesByName(result, it, name, processedTypes) } + else { + type.supertypes.forEach { result = collectSyntheticPropertiesByName(result, it.constructor, name, processedTypes) } + } return result } override fun getSyntheticExtensionProperties(receiverTypes: Collection): Collection { val result = ArrayList() - val processedTypes = HashSet() - receiverTypes.forEach { - result.collectSyntheticProperties(it.makeNotNullable(), processedTypes) - } + val processedTypes = HashSet() + receiverTypes.forEach { result.collectSyntheticProperties(it.constructor, processedTypes) } return result } - private fun MutableList.collectSyntheticProperties(type: JetType, processedTypes: MutableSet) { + private fun MutableList.collectSyntheticProperties(type: TypeConstructor, processedTypes: MutableSet) { if (!processedTypes.add(type)) return - val typeConstructor = type.getConstructor() - val classifier = typeConstructor.getDeclarationDescriptor() + val classifier = type.declarationDescriptor if (classifier is ClassDescriptor) { for (descriptor in classifier.getUnsubstitutedMemberScope().getDescriptors(DescriptorKindFilter.FUNCTIONS)) { if (descriptor is FunctionDescriptor) { @@ -217,8 +211,9 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by } } } - - typeConstructor.getSupertypes().forEach { collectSyntheticProperties(it, processedTypes) } + else { + type.supertypes.forEach { collectSyntheticProperties(it.constructor, processedTypes) } + } } private fun SmartList?.add(property: PropertyDescriptor?): SmartList? { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.kt new file mode 100644 index 00000000000..c106a07c6da --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.kt @@ -0,0 +1,16 @@ +// FILE: KotlinFile.kt + +fun foo(t: T) { + t.setSomething(t.getSomething() + 1) + t.something++ +} + +// FILE: A.java +public interface A { + int getSomething(); +} + +// FILE: B.java +public interface B extends A { + void setSomething(int value); +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.txt new file mode 100644 index 00000000000..f2de8f0142f --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.txt @@ -0,0 +1,19 @@ +package + +public /*synthesized*/ fun A(/*0*/ function: () -> kotlin.Int): A +internal fun foo(/*0*/ t: T): kotlin.Unit + +public interface A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface B : A { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun getSomething(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public abstract fun setSomething(/*0*/ value: kotlin.Int): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index f566d4292aa..649dfdeb967 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -14153,6 +14153,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/SmartCastImplicitReceiver.kt"); doTest(fileName); } + + @TestMetadata("TypeParameterReceiver.kt") + public void testTypeParameterReceiver() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/TypeParameterReceiver.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/thisAndSuper") From 2ab8f9de8b9326a03b92f26410d4c1a9cf47d913 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Sun, 19 Jul 2015 18:04:42 +0300 Subject: [PATCH 447/450] Fixed compilation --- .../introduceParameter/KotlinIntroduceParameterDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt index cbe75dba431..4757952c6ce 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceParameter/KotlinIntroduceParameterDialog.kt @@ -323,7 +323,7 @@ public class KotlinIntroduceParameterDialog private constructor( override fun createUsageViewDescriptor(usages: Array) = BaseUsageViewDescriptor() - override fun getCommandName() = commandName + override fun getCommandName(): String = commandName } ) } From 4ec26de2a895be4474a3f0a6f79a08ff9f3b7f0e Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 20 Jul 2015 19:20:23 +0300 Subject: [PATCH 448/450] Changes on code review --- .../kotlin/synthetic/JavaSyntheticExtensionsScope.kt | 11 +++++------ .../tests/syntheticExtensions/KotlinOverridesJava3.kt | 2 +- .../references/SyntheticPropertyAccessorReference.kt | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt index 913ea8b4a4a..91cc5e7d961 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticExtensionsScope.kt @@ -104,14 +104,11 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by val memberScope = ownerClass.unsubstitutedMemberScope val getMethod = possibleGetMethodNames(name) - .asSequence() .flatMap { memberScope.getFunctions(it).asSequence() } .singleOrNull { isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() } ?: return null - // don't accept "uRL" for "getURL" etc - if (SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(getMethod.name) != name) return null val setMethod = memberScope.getFunctions(setMethodName(getMethod.name)) .singleOrNull { isGoodSetMethod(it, getMethod) } @@ -140,7 +137,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by private fun isGoodSetMethod(descriptor: FunctionDescriptor, getMethod: FunctionDescriptor): Boolean { val propertyType = getMethod.returnType ?: return false val parameter = descriptor.valueParameters.singleOrNull() ?: return false - if (parameter.type != propertyType) { + if (!TypeUtils.equalTypes(parameter.type, propertyType)) { if (!propertyType.isSubtypeOf(parameter.type)) return false if (descriptor.findOverridden { val baseProperty = SyntheticJavaPropertyDescriptor.findByGetterOrSetter(it, this) @@ -225,7 +222,7 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by //TODO: reuse code with generation? - private fun possibleGetMethodNames(propertyName: Name): Collection { + private fun possibleGetMethodNames(propertyName: Name): Sequence { val result = ArrayList(3) val identifier = propertyName.identifier @@ -239,7 +236,9 @@ class JavaSyntheticExtensionsScope(storageManager: StorageManager) : JetScope by if (capitalize2 != capitalize1) { result.add(Name.identifier("get" + capitalize2)) } - return result + + return result.asSequence() + .filter { SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(it) == propertyName } // don't accept "uRL" for "getURL" etc } private fun setMethodName(getMethodName: Name): Name { diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt index 7af74313db4..568078acfd3 100644 --- a/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/KotlinOverridesJava3.kt @@ -9,7 +9,7 @@ fun foo(k: KotlinClass) { if (k.something == null) return k.setSomething("") - k.something = "" + k.something = "" } fun useString(i: String) {} diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt index 8faea2f7412..da13e967668 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/references/SyntheticPropertyAccessorReference.kt @@ -62,9 +62,9 @@ sealed class SyntheticPropertyAccessorReference(expression: JetNameReferenceExpr SyntheticJavaPropertyDescriptor.propertyNameByGetMethodName(newNameAsName) } else { - val propertyDescriptor = super.getTargetDescriptors(expression.analyze(BodyResolveMode.PARTIAL)) - .singleOrNull { it.original is SyntheticJavaPropertyDescriptor } ?: return expression - SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = propertyDescriptor.getName().asString().startsWith("is")) + //TODO: it's not correct + //TODO: setIsY -> setIsIsY bug + SyntheticJavaPropertyDescriptor.propertyNameBySetMethodName(newNameAsName, withIsPrefix = expression.getReferencedNameAsName().asString().startsWith("is")) } if (newName == null) return expression //TODO: handle the case when get/set becomes ordinary method From fac55b60fa5df92d7cd47b570b64d808f1161895 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 20 Jul 2015 19:39:16 +0300 Subject: [PATCH 449/450] Lazy computation of smart cast types for receivers in call resolve --- .../resolve/calls/tasks/TaskPrioritizer.kt | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt index 41ea2fbd7a8..702e18c17bc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tasks/TaskPrioritizer.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.psi.Call import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isOrOverridesSynthesized import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext +import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastUtils import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.BOTH_RECEIVERS import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind.DISPATCH_RECEIVER @@ -113,41 +114,46 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun doComputeTasks(receiver: ReceiverValue, c: TaskPrioritizerContext) { ProgressIndicatorAndCompilationCanceledStatus.checkCanceled() + val receiverWithTypes = ReceiverWithTypes(receiver, c.context) + val resolveInvoke = c.context.call.getDispatchReceiver().exists() if (resolveInvoke) { - addCandidatesForInvoke(receiver, c) + addCandidatesForInvoke(receiverWithTypes, c) return } val implicitReceivers = Sets.newLinkedHashSet(JetScopeUtils.getImplicitReceiversHierarchyValues(c.scope)) if (receiver.exists()) { - val receiverTypes = SmartCastUtils.getSmartCastVariants(receiver, c.context) - addCandidatesForExplicitReceiver(receiver, receiverTypes, implicitReceivers, c, isExplicit = true) - addMembers(receiver, receiverTypes, c, staticMembers = true, isExplicit = true) + addCandidatesForExplicitReceiver(receiverWithTypes, implicitReceivers, c, isExplicit = true) + addMembers(receiverWithTypes, c, staticMembers = true, isExplicit = true) return } addCandidatesForNoReceiver(implicitReceivers, c) } + private class ReceiverWithTypes( + val value: ReceiverValue, + private val context: ResolutionContext<*>) { + val types: Collection by lazy { SmartCastUtils.getSmartCastVariants(value, context) } + } + private fun addCandidatesForExplicitReceiver( - explicitReceiver: ReceiverValue, - explicitReceiverTypes: Collection, + explicitReceiver: ReceiverWithTypes, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean ) { - addMembers(explicitReceiver, explicitReceiverTypes, c, staticMembers = false, isExplicit = isExplicit) + addMembers(explicitReceiver, c, staticMembers = false, isExplicit = isExplicit) - if (explicitReceiver.getType().isDynamic()) { - addCandidatesForDynamicReceiver(explicitReceiver, explicitReceiverTypes, implicitReceivers, c, isExplicit) + if (explicitReceiver.value.type.isDynamic()) { + addCandidatesForDynamicReceiver(explicitReceiver, implicitReceivers, c, isExplicit) } else { - addExtensionCandidates(explicitReceiver, explicitReceiverTypes, implicitReceivers, c, isExplicit) + addExtensionCandidates(explicitReceiver, implicitReceivers, c, isExplicit) } } private fun addExtensionCandidates( - explicitReceiver: ReceiverValue, - explicitReceiverTypes: Collection, + explicitReceiver: ReceiverWithTypes, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean @@ -158,7 +164,6 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { addMemberExtensionCandidates( implicitReceiver, explicitReceiver, - explicitReceiverTypes, callableDescriptorCollector, c, createKind(EXTENSION_RECEIVER, isExplicit) @@ -168,8 +173,8 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { c.result.addCandidates { convertWithImpliedThis( c.scope, - explicitReceiver, - callableDescriptorCollector.getExtensionsByName(c.scope, c.name, explicitReceiverTypes, c.context.trace), + explicitReceiver.value, + callableDescriptorCollector.getExtensionsByName(c.scope, c.name, explicitReceiver.types, c.context.trace), createKind(EXTENSION_RECEIVER, isExplicit), c.context.call ) @@ -178,8 +183,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { } private fun addMembers( - explicitReceiver: ReceiverValue, - explicitReceiverTypes: Collection, + explicitReceiver: ReceiverWithTypes, c: TaskPrioritizerContext, staticMembers: Boolean, isExplicit: Boolean @@ -187,7 +191,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { for (callableDescriptorCollector in c.callableDescriptorCollectors) { c.result.addCandidates { val members = Lists.newArrayList>() - for (type in explicitReceiverTypes) { + for (type in explicitReceiver.types) { val membersForThisVariant = if (staticMembers) { callableDescriptorCollector.getStaticMembersByName(type, c.name, c.context.trace) } @@ -196,7 +200,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { } convertWithReceivers( membersForThisVariant, - explicitReceiver, + explicitReceiver.value, NO_RECEIVER, members, createKind(DISPATCH_RECEIVER, isExplicit), @@ -209,14 +213,13 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { } private fun addCandidatesForDynamicReceiver( - explicitReceiver: ReceiverValue, - explicitReceiverTypes: Collection, + explicitReceiver: ReceiverWithTypes, implicitReceivers: Collection, c: TaskPrioritizerContext, isExplicit: Boolean ) { val onlyDynamicReceivers = c.replaceCollectors(c.callableDescriptorCollectors.onlyDynamicReceivers()) - addExtensionCandidates(explicitReceiver, explicitReceiverTypes, implicitReceivers, onlyDynamicReceivers, isExplicit) + addExtensionCandidates(explicitReceiver, implicitReceivers, onlyDynamicReceivers, isExplicit) c.result.addCandidates { val dynamicScope = DynamicCallableDescriptors.createDynamicDescriptorScope(c.context.call, c.scope.getContainingDeclaration()) @@ -225,7 +228,7 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { it.getNonExtensionsByName(dynamicScope, c.name, c.context.trace) } - convertWithReceivers(dynamicDescriptors, explicitReceiver, NO_RECEIVER, createKind(DISPATCH_RECEIVER, isExplicit), c.context.call) + convertWithReceivers(dynamicDescriptors, explicitReceiver.value, NO_RECEIVER, createKind(DISPATCH_RECEIVER, isExplicit), c.context.call) } } @@ -236,16 +239,15 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { private fun addMemberExtensionCandidates( dispatchReceiver: ReceiverValue, - receiverParameter: ReceiverValue, - receiverParameterTypes: Collection, + receiverParameter: ReceiverWithTypes, callableDescriptorCollector: CallableDescriptorCollector, c: TaskPrioritizerContext, receiverKind: ExplicitReceiverKind ) { c.result.addCandidates { val memberExtensions = - callableDescriptorCollector.getExtensionsByName(dispatchReceiver.getType().getMemberScope(), c.name, receiverParameterTypes, c.context.trace) - convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter, receiverKind, c.context.call) + callableDescriptorCollector.getExtensionsByName(dispatchReceiver.type.memberScope, c.name, receiverParameter.types, c.context.trace) + convertWithReceivers(memberExtensions, dispatchReceiver, receiverParameter.value, receiverKind, c.context.call) } } @@ -276,23 +278,23 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { //locals c.result.addCandidates(localsList) - val implicitReceiversWithTypes = implicitReceivers.map { it to SmartCastUtils.getSmartCastVariants(it, c.context) } + val implicitReceiversWithTypes = implicitReceivers.map { ReceiverWithTypes(it, c.context) } //try all implicit receivers as explicit - for ((implicitReceiver, implicitReceiverTypes) in implicitReceiversWithTypes) { - addCandidatesForExplicitReceiver(implicitReceiver, implicitReceiverTypes, implicitReceivers, c, isExplicit = false) + for (implicitReceiver in implicitReceiversWithTypes) { + addCandidatesForExplicitReceiver(implicitReceiver, implicitReceivers, c, isExplicit = false) } //nonlocals c.result.addCandidates(nonlocalsList) //static (only for better error reporting) - for ((implicitReceiver, implicitReceiverTypes) in implicitReceiversWithTypes) { - addMembers(implicitReceiver, implicitReceiverTypes, c, staticMembers = true, isExplicit = false) + for (implicitReceiver in implicitReceiversWithTypes) { + addMembers(implicitReceiver, c, staticMembers = true, isExplicit = false) } } - private fun addCandidatesForInvoke(explicitReceiver: ReceiverValue, c: TaskPrioritizerContext) { + private fun addCandidatesForInvoke(explicitReceiver: ReceiverWithTypes, c: TaskPrioritizerContext) { val implicitReceivers = JetScopeUtils.getImplicitReceiversHierarchyValues(c.scope) // For 'a.foo()' where foo has function type, @@ -305,9 +307,8 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { // or for 'invoke' function. // (1) a.foo + foo.invoke() - if (!explicitReceiver.exists()) { - val variableReceiverTypes = SmartCastUtils.getSmartCastVariants(variableReceiver, c.context) - addCandidatesForExplicitReceiver(variableReceiver, variableReceiverTypes, implicitReceivers, c, isExplicit = true) + if (!explicitReceiver.value.exists()) { + addCandidatesForExplicitReceiver(ReceiverWithTypes(variableReceiver, c.context), implicitReceivers, c, isExplicit = true) } // (2) foo + a.invoke() @@ -316,26 +317,25 @@ public class TaskPrioritizer(private val storageManager: StorageManager) { //trait A //trait Foo { fun A.invoke() } - if (explicitReceiver.exists()) { + if (explicitReceiver.value.exists()) { //a.foo() addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(variableReceiver, explicitReceiver, c, BOTH_RECEIVERS) return } // with (a) { foo() } for (implicitReceiver in implicitReceivers) { - addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(variableReceiver, implicitReceiver, c, DISPATCH_RECEIVER) + addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver(variableReceiver, ReceiverWithTypes(implicitReceiver, c.context), c, DISPATCH_RECEIVER) } } private fun addCandidatesWhenInvokeIsMemberAndExtensionToExplicitReceiver( dispatchReceiver: ReceiverValue, - receiverParameter: ReceiverValue, + receiverParameter: ReceiverWithTypes, c: TaskPrioritizerContext, receiverKind: ExplicitReceiverKind ) { - val receiverParameterTypes = SmartCastUtils.getSmartCastVariants(receiverParameter, c.context) for (callableDescriptorCollector in c.callableDescriptorCollectors) { - addMemberExtensionCandidates(dispatchReceiver, receiverParameter, receiverParameterTypes, callableDescriptorCollector, c, receiverKind) + addMemberExtensionCandidates(dispatchReceiver, receiverParameter, callableDescriptorCollector, c, receiverKind) } } From 0d09c55bac76dde190a16ddc9b40de3800455f14 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 16 Jul 2015 14:02:55 +0300 Subject: [PATCH 450/450] JetPackageDirective made not JetExpression --- .../src/org/jetbrains/kotlin/psi/JetPackageDirective.java | 2 +- compiler/frontend/src/org/jetbrains/kotlin/psi/JetVisitor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java index d745d9e0f49..5caa6c0e827 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPackageDirective.java @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.psi.stubs.elements.JetStubElementTypes; import java.util.Collections; import java.util.List; -public class JetPackageDirective extends JetModifierListOwnerStub> implements JetExpression { +public class JetPackageDirective extends JetModifierListOwnerStub> { private String qualifiedNameCache = null; public JetPackageDirective(@NotNull ASTNode node) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetVisitor.java index 249a00b8caa..ff7e98bc42d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetVisitor.java @@ -439,6 +439,6 @@ public class JetVisitor extends PsiElementVisitor { } public R visitPackageDirective(@NotNull JetPackageDirective directive, D data) { - return visitExpression(directive, data); + return visitJetElement(directive, data); } }